bolt: implement tx_add_input message codec#23
bolt: implement tx_add_input message codec#23harsh04044 wants to merge 1 commit intomorehouse:masterfrom
Conversation
|
@morehouse picked up tx_add_input since the embedded prevtx field made it the most involved of the interactive-tx codecs. Would love a review when you get a chance. |
2b8012d to
c0af643
Compare
c0af643 to
1058cc3
Compare
morehouse
left a comment
There was a problem hiding this comment.
Thanks for tackling this. Main feedback:
- let's avoid depending on the
bitcoincrate for now - let's add support for the
tlvsfield - please structure the tests similarly to the other codecs (
open_channelis a good example)
smite/src/bolt/tx_add_input.rs
Outdated
| /// Previous transaction being spent (consensus-encoded on the wire). | ||
| pub prevtx: Transaction, |
There was a problem hiding this comment.
The dependency on bitcoin pulls a lot of new crates in.
At this point in the project I'd like to avoid that dependency -- let's make prevtx a Vec<u8> instead. Later on, when we are working on the interactive-tx flow, we can revisit whether it makes sense to take this dependency or implement our own minimal Transaction functionality.
| pub prevtx_vout: u32, | ||
| /// The sequence number for this input. | ||
| pub sequence: u32, | ||
| } |
There was a problem hiding this comment.
We also should support the tlvs field.
smite/src/bolt/tx_add_input.rs
Outdated
| } | ||
|
|
||
| #[test] | ||
| fn truncated_decode_returns_error() { |
There was a problem hiding this comment.
Ideally we should test truncation at every field (one test per field) like we do with other codecs.
1058cc3 to
600f6da
Compare
|
Updated: dropped the bitcoin crate dependency (prevtx is now Vec), added TxAddInputTlvs following the open_channel pattern, and restructured tests to match the other codecs with one test per truncated field. |
Implements the
tx_add_inputmessage codec (type 0x0042) for BOLT 2 interactive transaction construction.The
prevtxfield carries a full consensus-encoded Bitcoin transaction, decoded usingbitcoin::consensus::deserializeand length-prefixed on the wire via theWireFormattrait.Includes encode/decode,
Messageenum integration, and tests covering roundtrip, truncation, and trailing bytes.Part of #5