bolt: implement accept_channel2 message codec#37
bolt: implement accept_channel2 message codec#37harsh04044 wants to merge 1 commit intomorehouse:masterfrom
Conversation
ekzyis
left a comment
There was a problem hiding this comment.
The CI didn't run for this yet, but it would fail because of formatting. Please make sure to run cargo fmt --all (or configure format on save).
8567b9a to
ee7e288
Compare
ee7e288 to
dedc305
Compare
Done, addressed all suggestions. |
|
|
||
| /// TLV extensions for the `accept_channel2` message. | ||
| #[derive(Debug, Clone, Default, PartialEq, Eq)] | ||
| pub struct AcceptChannel2Tlvs; |
There was a problem hiding this comment.
A no-op TLV struct is not helpful. We need to implement the TLVs described in the spec.
| // 32 (channel_id) + 8*4 (u64 fields) + 4 (u32) + 2*2 (u16 fields) + 33*7 (pubkeys) = 303 | ||
| let mut out = Vec::with_capacity(303); |
There was a problem hiding this comment.
Nit: currently no other codecs preallocate Vec. For consistency I'd prefer to drop this for now. In the future, if we determine this is a worthwhile optimization, we can do it for all codecs at once.
| /// to_self_delay(2) + max_accepted_htlcs(2) = 72 bytes. | ||
| const FIRST_PUBKEY_OFFSET: usize = 72; | ||
|
|
||
| fn sample_accept_channel2() -> AcceptChannel2 { |
There was a problem hiding this comment.
We should allow TLVs to specified as a parameter, following the pattern of other codecs.
Implements the
accept_channel2codec (type 65) for BOLT 2 dual-funded channel establishment.accept_channel2 introduces a second per-commitment point compared to accept_channel, required for the v2 channel open flow. Tests cover roundtrip, trailing bytes, truncation at each scalar field boundary, and invalid public key detection for both the first and last key fields.
Part of #5.