Update the `AcceptChannel` message for Taproot support.
authorArik Sosman <git@arik.io>
Tue, 28 Mar 2023 21:59:20 +0000 (14:59 -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 f1c5cae25ae8bbfbc84b85640c3367de18aa56c1..efb7da4152141464f6dba8b6770265c72041c26c 100644 (file)
@@ -5332,6 +5332,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
                                None => Builder::new().into_script(),
                        }),
                        channel_type: Some(self.channel_type.clone()),
+                       #[cfg(taproot)]
+                       next_local_nonce: None,
                }
        }
 
index e7d6c27f58a0803ed638f4e04fb531969fda599b..38c832564c4b88df8f8a26727bd1668f970f0ec8 100644 (file)
@@ -249,6 +249,9 @@ pub struct AcceptChannel {
        /// our feature bits with our counterparty's feature bits from the [`Init`] message.
        /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
        pub channel_type: Option<ChannelTypeFeatures>,
+       #[cfg(taproot)]
+       /// Next nonce the channel initiator should use to create a funding output signature against
+       pub next_local_nonce: Option<musig2::types::PublicNonce>,
 }
 
 /// A [`funding_created`] message to be sent to or received from a peer.
@@ -1293,7 +1296,28 @@ impl Readable for OptionalField<u64> {
        }
 }
 
+#[cfg(not(taproot))]
+impl_writeable_msg!(AcceptChannel, {
+       temporary_channel_id,
+       dust_limit_satoshis,
+       max_htlc_value_in_flight_msat,
+       channel_reserve_satoshis,
+       htlc_minimum_msat,
+       minimum_depth,
+       to_self_delay,
+       max_accepted_htlcs,
+       funding_pubkey,
+       revocation_basepoint,
+       payment_point,
+       delayed_payment_basepoint,
+       htlc_basepoint,
+       first_per_commitment_point,
+       shutdown_scriptpubkey
+}, {
+       (1, channel_type, option),
+});
 
+#[cfg(taproot)]
 impl_writeable_msg!(AcceptChannel, {
        temporary_channel_id,
        dust_limit_satoshis,
@@ -1312,6 +1336,7 @@ impl_writeable_msg!(AcceptChannel, {
        shutdown_scriptpubkey
 }, {
        (1, channel_type, option),
+       (4, next_local_nonce, option),
 });
 
 impl_writeable_msg!(AnnouncementSignatures, {
@@ -2449,6 +2474,8 @@ mod tests {
                        first_per_commitment_point: pubkey_6,
                        shutdown_scriptpubkey: if shutdown { OptionalField::Present(Address::p2pkh(&::bitcoin::PublicKey{compressed: true, inner: pubkey_1}, Network::Testnet).script_pubkey()) } else { OptionalField::Absent },
                        channel_type: None,
+                       #[cfg(taproot)]
+                       next_local_nonce: None,
                };
                let encoded_value = accept_channel.encode();
                let mut target_value = hex::decode("020202020202020202020202020202020202020202020202020202020202020212345678901234562334032891223698321446687011447600083a840000034d000c89d4c0bcc0bc031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d076602531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe33703462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f703f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a").unwrap();