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
Add a consensus::deserialize_hex
function
#2039
Add a consensus::deserialize_hex
function
#2039
Conversation
Will need #2036 |
392e863
to
1d7e3b6
Compare
Upgrade the `bitcoin` dependency to the soon-to-be-released version. Doing this patch lead to: - rust-bitcoin/rust-bitcoin#2038 - rust-bitcoin/rust-bitcoin#2039 Once they merge and we release then this PR can come off WIP.
f68da07
to
f71d250
Compare
f71d250
to
a202c98
Compare
I'm now not sure this is correct because it does not have the same behaviour in regards to erroring if all data is not consumed. However doing so needs a refactor which implies I have to change the error handling because I've used the "new" style. I'm inclined to put this to draft and do it after the release ... |
Drafting sounds good to me. |
Cool, thanks. |
Yes I have wanted this SO MUCH for SO LONG :) :) |
I took it from you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, had these comments here pending in the review thing in github, not sure they're still relevant.
bitcoin/src/consensus/mod.rs
Outdated
#[derive(Debug)] | ||
pub enum DecodeHexError { | ||
/// Hex decoding error. | ||
Decode(HexToBytesError), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hex
/HexFormat
?
bitcoin/src/consensus/mod.rs
Outdated
/// Hex decoding error. | ||
Decode(HexToBytesError), | ||
/// Consensus deserialization error. | ||
Deser(encode::Error), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm that short code isn't super helpful. Formatting
/Serialization
/Encoding
or something.
Vaguely remember something like "we don't know how to deal with errors when it comes to hex and don't want to think about it". Which I agreed with at the time, we didn't do much hex other than hash types in the hashes::hex module and converting to hex never gives errors while parsing it can. But glad it's making it in. Tbh on principle we should have neither of them and users should just use a hex crate to do hex, but well, it's so common in Bitcoin to represent txs as a very specific type of hex (non-prefixed lowercase) that we can get away with it IMO. |
Cool, thanks for looking. I'll come back to this once v0.31.0 is out. |
Yeah, I would even consider |
a202c98
to
8067cbf
Compare
Needs EDIT: Turns out I was wrong, PR now uses a custom iterator (originally from |
Ah, interesting, so IO is actually useful in hex. |
Damn, I was using this method just now and then realized it doesn't exist yet.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core2
was removed so this can proceed.
8067cbf
to
f516c7a
Compare
This is WIP but showcases that we only need |
805aa5c
to
a6323f4
Compare
Pull Request Test Coverage Report for Build 8272603794Details
💛 - Coveralls |
a6323f4
to
38ecfa8
Compare
Needs #2512 |
38ecfa8
to
495a105
Compare
Might need #2573 |
495a105
to
abd2e8f
Compare
We have `serialize_hex` and `deserialize` but no `deserialize_hex`, add it. Move the `IterReader` out of `consensus::serde` to the `consensus` module. Add some additional logic to the `DecodeError`, I'm not sure why this wasn't there before? Use the `HexSliceToBytesIter` by way of the `IterReader` to deserialize an arbitrary hex string. Add unit tests to check that we consume all bytes when deserializing a fixed size object (a transaction).
abd2e8f
to
16a8137
Compare
Rebased for good measure to pick up #2573, there are no acks anyways. No other changes. |
Labels were stale. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 16a8137
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 16a8137
We have
serialize_hex
anddeserialize
but nodeserialize_hex
, add it.Move the
IterReader
out ofconsensus::serde
to theconsensus
module.Add some additional logic to the
DecodeError
, I'm not sure why this wasn't there before?Use the
HexSliceToBytesIter
by way of theIterReader
to deserialize an arbitrary hex string. Add unit tests to check that we consume all bytes when deserializing a fixed size object (a transaction).