bolt: implement tx_add_output message codec#26
bolt: implement tx_add_output message codec#26harsh04044 wants to merge 1 commit intomorehouse:masterfrom
Conversation
kushagra0902
left a comment
There was a problem hiding this comment.
The PR looks good to me with everything handled properly
ecec0ed to
eb6d3d4
Compare
Good catch. The bitcoin crate was added as part of the tx_add_input PR (#23) which hasn't merged yet. Added it directly to this branch -- should compile now. |
I was working at something else and had the package already that bypassed the error, good catch @Vineet1101 |
smite/src/bolt/tx_add_output.rs
Outdated
| /// The value of this output in satoshis. | ||
| pub sats: u64, | ||
| /// The scriptPubKey for this output. | ||
| pub script: ScriptBuf, |
There was a problem hiding this comment.
Let's use script: Vec<u8> for now to avoid the bitcoin dependency. We can add it later if necessary.
| impl TxAddOutput { | ||
| /// Encodes to wire format (without message type prefix). | ||
| #[must_use] | ||
| pub fn encode(&self) -> Vec<u8> { |
There was a problem hiding this comment.
We should assert that script.len() <= u16::MAX here since Vec<u8>::write assumes this.
| }) | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
We should also test the cases where the script length is truncated or the script itself is truncated.
eb6d3d4 to
643d73c
Compare
|
Done, script is now Vec, added the assert on script.len() in encode(), and split out truncation tests for the script length and script data fields. |


Implements the
tx_add_outputcodec (type 67) for BOLT 2 interactive-tx.The script field is a variable-length scriptPubKey, length-prefixed via the WireFormat trait. Tests cover roundtrip, empty script, trailing bytes, and truncation at each field boundary.
Part of #5.