Skip to content

bolt: implement tx_add_input message codec#23

Merged
morehouse merged 1 commit intomorehouse:masterfrom
harsh04044:bolt/tx-add-input
Apr 30, 2026
Merged

bolt: implement tx_add_input message codec#23
morehouse merged 1 commit intomorehouse:masterfrom
harsh04044:bolt/tx-add-input

Conversation

@harsh04044
Copy link
Copy Markdown
Contributor

Implements the tx_add_input message codec (type 0x0042) for BOLT 2 interactive transaction construction.

The prevtx field carries a full consensus-encoded Bitcoin transaction, decoded using bitcoin::consensus::deserialize and length-prefixed on the wire via the WireFormat trait.

Includes encode/decode, Message enum integration, and tests covering roundtrip, truncation, and trailing bytes.

Part of #5

@harsh04044
Copy link
Copy Markdown
Contributor Author

@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.

Comment thread Cargo.toml Outdated
Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt.rs Outdated
Comment thread smite/src/bolt.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs
Comment thread smite/src/bolt/tx_add_input.rs
Copy link
Copy Markdown
Owner

@morehouse morehouse left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this. Main feedback:

  • let's avoid depending on the bitcoin crate for now
  • let's add support for the tlvs field
  • please structure the tests similarly to the other codecs (open_channel is a good example)

Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs
Comment thread smite/src/bolt/tx_add_input.rs Outdated
@harsh04044
Copy link
Copy Markdown
Contributor Author

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.

@morehouse

@harsh04044 harsh04044 requested a review from morehouse April 7, 2026 10:32
Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt.rs Outdated
}

#[test]
fn message_tx_add_input_roundtrip() {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Tests should be ordered by the message type number.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs
Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs
@harsh04044 harsh04044 force-pushed the bolt/tx-add-input branch 3 times, most recently from 7470f73 to e2d30df Compare April 15, 2026 23:53
@harsh04044 harsh04044 requested a review from morehouse April 15, 2026 23:53
Copy link
Copy Markdown
Owner

@morehouse morehouse left a comment

Choose a reason for hiding this comment

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

Looks good once these comments are addressed.

Comment thread smite/src/bolt/tx_add_input.rs
Comment thread smite/src/bolt.rs Outdated
}

/// Valid `TxAddInput` message for testing.
fn sample_tx_add_input() -> TxAddInput {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Let's move this helper function to directly before message_tx_add_input_roundtrip, for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to directly before message_tx_add_input_roundtrip.

Comment thread smite/src/bolt/tx_add_input.rs Outdated
Comment thread smite/src/bolt/tx_add_input.rs Outdated
@harsh04044 harsh04044 force-pushed the bolt/tx-add-input branch 2 times, most recently from 6498f66 to 39aa70d Compare April 29, 2026 10:35
Copy link
Copy Markdown
Owner

@morehouse morehouse left a comment

Choose a reason for hiding this comment

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

LGTM

@morehouse morehouse merged commit 5ea5211 into morehouse:master Apr 30, 2026
1 check passed
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.

3 participants