Skip to content

Adds Txid to lighting-block-sync::convert #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2021

Conversation

sr-gi
Copy link
Contributor

@sr-gi sr-gi commented Aug 6, 2021

Adds TryInto<Txid> for JsonResponse.

Related to lightningdevkit/ldk-sample#28 (see lightningdevkit/ldk-sample#28 (comment)).

@sr-gi sr-gi force-pushed the add-txid-convert branch from 1435eb2 to 1224597 Compare August 6, 2021 14:29
@codecov
Copy link

codecov bot commented Aug 6, 2021

Codecov Report

Merging #1037 (f65d05c) into main (8530078) will increase coverage by 0.01%.
The diff coverage is 95.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1037      +/-   ##
==========================================
+ Coverage   90.80%   90.81%   +0.01%     
==========================================
  Files          61       65       +4     
  Lines       31582    32843    +1261     
==========================================
+ Hits        28678    29828    +1150     
- Misses       2904     3015     +111     
Impacted Files Coverage Δ
lightning-block-sync/src/convert.rs 93.12% <95.23%> (+0.31%) ⬆️
lightning/src/util/ser_macros.rs 87.90% <0.00%> (-8.42%) ⬇️
lightning/src/util/errors.rs 67.30% <0.00%> (-4.13%) ⬇️
lightning-background-processor/src/lib.rs 93.93% <0.00%> (-1.65%) ⬇️
lightning/src/ln/channel.rs 88.70% <0.00%> (-0.54%) ⬇️
lightning-net-tokio/src/lib.rs 76.98% <0.00%> (-0.38%) ⬇️
lightning/src/util/test_utils.rs 82.29% <0.00%> (-0.26%) ⬇️
lightning/src/ln/peer_handler.rs 45.75% <0.00%> (-0.23%) ⬇️
lightning/src/ln/functional_test_utils.rs 95.13% <0.00%> (-0.06%) ⬇️
lightning/src/chain/onchaintx.rs 94.18% <0.00%> (-0.01%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8530078...f65d05c. Read the comment docs.

Comment on lines 159 to 182
impl TryInto<Txid> for JsonResponse {
type Error = std::io::Error;
fn try_into(self) -> std::io::Result<Txid> {
match self.0.as_str() {
None => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"expected JSON string",
)),
Some(hex_data) => match Vec::<u8>::from_hex(hex_data) {
Err(_) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"invalid hex data",
)),
Ok(txid_data) => match encode::deserialize(&txid_data) {
Err(_) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"invalid txid",
)),
Ok(txid) => Ok(txid),
},
},
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you need tabs not spaces. Likewise in the tests.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ACK this PR mod the tabs-to-spaces Jeff pointed out

@sr-gi sr-gi force-pushed the add-txid-convert branch from 1224597 to f65d05c Compare August 24, 2021 08:52
@sr-gi
Copy link
Contributor Author

sr-gi commented Aug 24, 2021

@jkczyz @valentinewallace should be good now.

@TheBlueMatt TheBlueMatt merged commit d523b6e into lightningdevkit:main Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants