From 0219a8def0ff422b77f7fe4024aa5862435fe23a Mon Sep 17 00:00:00 2001 From: Arik Sosman Date: Tue, 28 Mar 2023 17:33:45 -0700 Subject: [PATCH] Update the `FundingCreated` message for Taproot support. --- lightning/src/ln/channel.rs | 6 +++++- lightning/src/ln/msgs.rs | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index efb7da415..e413ab641 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -5398,7 +5398,11 @@ impl Channel { temporary_channel_id, funding_txid: funding_txo.txid, funding_output_index: funding_txo.index, - signature + signature, + #[cfg(taproot)] + partial_signature_with_nonce: None, + #[cfg(taproot)] + next_local_nonce: None, }) } diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 38c832564..fa6c84f18 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -267,6 +267,12 @@ pub struct FundingCreated { pub funding_output_index: u16, /// The signature of the channel initiator (funder) on the initial commitment transaction pub signature: Signature, + #[cfg(taproot)] + /// The partial signature of the channel initiator (funder) + pub partial_signature_with_nonce: Option, + #[cfg(taproot)] + /// Next nonce the channel acceptor should use to finalize the funding output signature + pub next_local_nonce: Option } /// A [`funding_signed`] message to be sent to or received from a peer. @@ -1405,12 +1411,23 @@ impl_writeable!(DecodedOnionErrorPacket, { pad }); +#[cfg(not(taproot))] impl_writeable_msg!(FundingCreated, { temporary_channel_id, funding_txid, funding_output_index, signature }, {}); +#[cfg(taproot)] +impl_writeable_msg!(FundingCreated, { + temporary_channel_id, + funding_txid, + funding_output_index, + signature +}, { + (2, partial_signature_with_nonce, option), + (4, next_local_nonce, option) +}); impl_writeable_msg!(FundingSigned, { channel_id, @@ -2501,6 +2518,10 @@ mod tests { funding_txid: Txid::from_hex("c2d4449afa8d26140898dd54d3390b057ba2a5afcf03ba29d7dc0d8b9ffe966e").unwrap(), funding_output_index: 255, signature: sig_1, + #[cfg(taproot)] + partial_signature_with_nonce: None, + #[cfg(taproot)] + next_local_nonce: None, }; let encoded_value = funding_created.encode(); let target_value = hex::decode("02020202020202020202020202020202020202020202020202020202020202026e96fe9f8b0ddcd729ba03cfafa5a27b050b39d354dd980814268dfa9a44d4c200ffd977cb9b53d93a6ff64bb5f1e158b4094b66e798fb12911168a3ccdf80a83096340a6a95da0ae8d9f776528eecdbb747eb6b545495a4319ed5378e35b21e073a").unwrap(); -- 2.39.5