]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Update the `RevokeAndACK` message for Taproot support.
authorArik Sosman <git@arik.io>
Wed, 29 Mar 2023 23:35:05 +0000 (16:35 -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 e2b3fb0665f4d3f45d43c41a1b7aa2d0ec74ed90..39e07bed8c49ed022d667b10b4ddfcb74d39334b 100644 (file)
@@ -3910,6 +3910,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
                        channel_id: self.channel_id,
                        per_commitment_secret,
                        next_per_commitment_point,
+                       #[cfg(taproot)]
+                       next_local_nonce: None,
                }
        }
 
index af547b3af084ef5f73f0f49080b837624f3f070c..c77195cfac38fc0aed7df9979e16000c9e40af5c 100644 (file)
@@ -1470,7 +1470,9 @@ fn test_fee_spike_violation_fails_htlc() {
        let raa_msg = msgs::RevokeAndACK {
                channel_id: chan.2,
                per_commitment_secret: local_secret,
-               next_per_commitment_point: next_local_point
+               next_per_commitment_point: next_local_point,
+               #[cfg(taproot)]
+               next_local_nonce: None,
        };
        nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa_msg);
 
@@ -7498,7 +7500,13 @@ fn test_counterparty_raa_skip_no_crash() {
        }
 
        nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(),
-               &msgs::RevokeAndACK { channel_id, per_commitment_secret, next_per_commitment_point });
+               &msgs::RevokeAndACK {
+                       channel_id,
+                       per_commitment_secret,
+                       next_per_commitment_point,
+                       #[cfg(taproot)]
+                       next_local_nonce: None,
+               });
        assert_eq!(check_closed_broadcast!(nodes[1], true).unwrap().data, "Received an unexpected revoke_and_ack");
        check_added_monitors!(nodes[1], 1);
        check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: "Received an unexpected revoke_and_ack".to_string() });
index 61e18648a58878877596649d17b7f52450a90d70..2557454b4623567302f4f7f380cee305c04e05ec 100644 (file)
@@ -442,6 +442,9 @@ pub struct RevokeAndACK {
        pub per_commitment_secret: [u8; 32],
        /// The next sender-broadcast commitment transaction's per-commitment point
        pub next_per_commitment_point: PublicKey,
+       #[cfg(taproot)]
+       /// Musig nonce the recipient should use in their next commitment signature message
+       pub next_local_nonce: Option<musig2::types::PublicNonce>
 }
 
 /// An [`update_fee`] message to be sent to or received from a peer
@@ -1518,12 +1521,22 @@ impl_writeable_msg!(OpenChannel, {
        (1, channel_type, option),
 });
 
+#[cfg(not(taproot))]
 impl_writeable_msg!(RevokeAndACK, {
        channel_id,
        per_commitment_secret,
        next_per_commitment_point
 }, {});
 
+#[cfg(taproot)]
+impl_writeable_msg!(RevokeAndACK, {
+       channel_id,
+       per_commitment_secret,
+       next_per_commitment_point
+}, {
+       (4, next_local_nonce, option)
+});
+
 impl_writeable_msg!(Shutdown, {
        channel_id,
        scriptpubkey
@@ -2753,6 +2766,8 @@ mod tests {
                        channel_id: [2; 32],
                        per_commitment_secret: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                        next_per_commitment_point: pubkey_1,
+                       #[cfg(taproot)]
+                       next_local_nonce: None,
                };
                let encoded_value = raa.encode();
                let target_value = hex::decode("02020202020202020202020202020202020202020202020202020202020202020101010101010101010101010101010101010101010101010101010101010101031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f").unwrap();