Update the `FundingSigned` message for Taproot support.
authorArik Sosman <git@arik.io>
Wed, 29 Mar 2023 22:02:34 +0000 (15:02 -0700)
committerArik Sosman <git@arik.io>
Mon, 3 Apr 2023 20:17:12 +0000 (13:17 -0700)
lightning/src/ln/channel.rs
lightning/src/ln/msgs.rs

index e413ab6416c629b5dcbaedc4b8918f4c3d1be344..43604c1912c3785fbba7b119a2a40647dea91110 100644 (file)
@@ -2352,7 +2352,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
 
                Ok((msgs::FundingSigned {
                        channel_id: self.channel_id,
-                       signature
+                       signature,
+                       #[cfg(taproot)]
+                       partial_signature_with_nonce: None,
                }, channel_monitor))
        }
 
index fa6c84f1834501f0ff330f4eefd925aa6f2f37c1..5e51fc0a9f42569132ca1cd96e94b45092b5cafe 100644 (file)
@@ -284,6 +284,9 @@ pub struct FundingSigned {
        pub channel_id: [u8; 32],
        /// The signature of the channel acceptor (fundee) on the initial commitment transaction
        pub signature: Signature,
+       #[cfg(taproot)]
+       /// The partial signature of the channel acceptor (fundee)
+       pub partial_signature_with_nonce: Option<PartialSignatureWithNonce>,
 }
 
 /// A [`channel_ready`] message to be sent to or received from a peer.
@@ -1429,11 +1432,20 @@ impl_writeable_msg!(FundingCreated, {
        (4, next_local_nonce, option)
 });
 
+#[cfg(not(taproot))]
 impl_writeable_msg!(FundingSigned, {
        channel_id,
        signature
 }, {});
 
+#[cfg(taproot)]
+impl_writeable_msg!(FundingSigned, {
+       channel_id,
+       signature
+}, {
+       (2, partial_signature_with_nonce, option)
+});
+
 impl_writeable_msg!(ChannelReady, {
        channel_id,
        next_per_commitment_point,
@@ -2536,6 +2548,8 @@ mod tests {
                let funding_signed = msgs::FundingSigned {
                        channel_id: [2; 32],
                        signature: sig_1,
+                       #[cfg(taproot)]
+                       partial_signature_with_nonce: None,
                };
                let encoded_value = funding_signed.encode();
                let target_value = hex::decode("0202020202020202020202020202020202020202020202020202020202020202d977cb9b53d93a6ff64bb5f1e158b4094b66e798fb12911168a3ccdf80a83096340a6a95da0ae8d9f776528eecdbb747eb6b545495a4319ed5378e35b21e073a").unwrap();