]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Update the `CommitmentSigned` message for Taproot support.
authorArik Sosman <git@arik.io>
Wed, 29 Mar 2023 22:21:30 +0000 (15:21 -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/functional_tests.rs
lightning/src/ln/msgs.rs

index 43604c1912c3785fbba7b119a2a40647dea91110..e2b3fb0665f4d3f45d43c41a1b7aa2d0ec74ed90 100644 (file)
@@ -5923,6 +5923,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
                        channel_id: self.channel_id,
                        signature,
                        htlc_signatures,
+                       #[cfg(taproot)]
+                       partial_signature_with_nonce: None,
                }, (counterparty_commitment_txid, commitment_stats.htlcs_included)))
        }
 
index 56586b0a29c569be57700a316e109e1bb76edb24..af547b3af084ef5f73f0f49080b837624f3f070c 100644 (file)
@@ -735,7 +735,9 @@ fn test_update_fee_that_funder_cannot_afford() {
        let commit_signed_msg = msgs::CommitmentSigned {
                channel_id: chan.2,
                signature: res.0,
-               htlc_signatures: res.1
+               htlc_signatures: res.1,
+               #[cfg(taproot)]
+               partial_signature_with_nonce: None,
        };
 
        let update_fee = msgs::UpdateFee {
@@ -1455,7 +1457,9 @@ fn test_fee_spike_violation_fails_htlc() {
        let commit_signed_msg = msgs::CommitmentSigned {
                channel_id: chan.2,
                signature: res.0,
-               htlc_signatures: res.1
+               htlc_signatures: res.1,
+               #[cfg(taproot)]
+               partial_signature_with_nonce: None,
        };
 
        // Send the commitment_signed message to the nodes[1].
index 5e51fc0a9f42569132ca1cd96e94b45092b5cafe..61e18648a58878877596649d17b7f52450a90d70 100644 (file)
@@ -426,6 +426,9 @@ pub struct CommitmentSigned {
        pub signature: Signature,
        /// Signatures on the HTLC transactions
        pub htlc_signatures: Vec<Signature>,
+       #[cfg(taproot)]
+       /// The partial Taproot signature on the commitment transaction
+       pub partial_signature_with_nonce: Option<PartialSignatureWithNonce>,
 }
 
 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
@@ -1402,12 +1405,22 @@ impl_writeable!(ClosingSignedFeeRange, {
        max_fee_satoshis
 });
 
+#[cfg(not(taproot))]
 impl_writeable_msg!(CommitmentSigned, {
        channel_id,
        signature,
        htlc_signatures
 }, {});
 
+#[cfg(taproot)]
+impl_writeable_msg!(CommitmentSigned, {
+       channel_id,
+       signature,
+       htlc_signatures
+}, {
+       (2, partial_signature_with_nonce, option)
+});
+
 impl_writeable!(DecodedOnionErrorPacket, {
        hmac,
        failuremsg,
@@ -2713,6 +2726,8 @@ mod tests {
                        channel_id: [2; 32],
                        signature: sig_1,
                        htlc_signatures: if htlcs { vec![sig_2, sig_3, sig_4] } else { Vec::new() },
+                       #[cfg(taproot)]
+                       partial_signature_with_nonce: None,
                };
                let encoded_value = commitment_signed.encode();
                let mut target_value = hex::decode("0202020202020202020202020202020202020202020202020202020202020202d977cb9b53d93a6ff64bb5f1e158b4094b66e798fb12911168a3ccdf80a83096340a6a95da0ae8d9f776528eecdbb747eb6b545495a4319ed5378e35b21e073a").unwrap();