Merge pull request #2219 from benthecarman/custom-closing-address
[rust-lightning] / lightning / src / ln / msgs.rs
index 6e49a46f08a02a25065652e28cf3895afc031fe8..df6a2aba3b9df821f742421aa90feca5f4a31069 100644 (file)
@@ -40,17 +40,22 @@ use core::fmt::Debug;
 use crate::io::{self, Read};
 use crate::io_extras::read_to_end;
 
-use crate::util::events::{MessageSendEventsProvider, OnionMessageProvider};
+use crate::events::{MessageSendEventsProvider, OnionMessageProvider};
 use crate::util::logger;
-use crate::util::ser::{LengthReadable, Readable, ReadableArgs, Writeable, Writer, FixedLengthReader, HighZeroBytesDroppedBigSize, Hostname};
+use crate::util::ser::{LengthReadable, Readable, ReadableArgs, Writeable, Writer, WithoutLength, FixedLengthReader, HighZeroBytesDroppedBigSize, Hostname};
 
 use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
 
-use crate::routing::gossip::NodeId;
+use crate::routing::gossip::{NodeAlias, NodeId};
 
 /// 21 million * 10^8 * 1000
 pub(crate) const MAX_VALUE_MSAT: u64 = 21_000_000_0000_0000_000;
 
+#[cfg(taproot)]
+/// A partial signature that also contains the Musig2 nonce its signer used
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct PartialSignatureWithNonce(pub musig2::types::PartialSignature, pub musig2::types::PublicNonce);
+
 /// An error in decoding a message or struct.
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub enum DecodeError {
@@ -194,8 +199,8 @@ pub struct OpenChannel {
        pub first_per_commitment_point: PublicKey,
        /// The channel flags to be used
        pub channel_flags: u8,
-       /// Optionally, a request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
-       pub shutdown_scriptpubkey: OptionalField<Script>,
+       /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
+       pub shutdown_scriptpubkey: Option<Script>,
        /// The channel type that this channel will represent
        ///
        /// If this is `None`, we derive the channel type from the intersection of our
@@ -236,14 +241,17 @@ pub struct AcceptChannel {
        pub htlc_basepoint: PublicKey,
        /// The first to-be-broadcast-by-sender transaction's per commitment point
        pub first_per_commitment_point: PublicKey,
-       /// Optionally, a request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
-       pub shutdown_scriptpubkey: OptionalField<Script>,
+       /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
+       pub shutdown_scriptpubkey: Option<Script>,
        /// The channel type that this channel will represent.
        ///
        /// If this is `None`, we derive the channel type from the intersection of
        /// 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.
@@ -259,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<PartialSignatureWithNonce>,
+       #[cfg(taproot)]
+       /// Next nonce the channel acceptor should use to finalize the funding output signature
+       pub next_local_nonce: Option<musig2::types::PublicNonce>
 }
 
 /// A [`funding_signed`] message to be sent to or received from a peer.
@@ -270,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.
@@ -409,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.
@@ -422,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
@@ -435,20 +458,6 @@ pub struct UpdateFee {
        pub feerate_per_kw: u32,
 }
 
-#[derive(Clone, Debug, PartialEq, Eq)]
-/// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
-///
-/// This is used to convince the recipient that the channel is at a certain commitment
-/// number even if they lost that data due to a local failure. Of course, the peer may lie
-/// and even later commitments may have been revoked.
-pub struct DataLossProtect {
-       /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
-       /// belonging to the recipient
-       pub your_last_per_commitment_secret: [u8; 32],
-       /// The sender's per-commitment point for their current commitment transaction
-       pub my_current_per_commitment_point: PublicKey,
-}
-
 /// A [`channel_reestablish`] message to be sent to or received from a peer.
 ///
 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
@@ -460,8 +469,11 @@ pub struct ChannelReestablish {
        pub next_local_commitment_number: u64,
        /// The next commitment number for the recipient
        pub next_remote_commitment_number: u64,
-       /// Optionally, a field proving that next_remote_commitment_number-1 has been revoked
-       pub data_loss_protect: OptionalField<DataLossProtect>,
+       /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
+       /// belonging to the recipient
+       pub your_last_per_commitment_secret: [u8; 32],
+       /// The sender's per-commitment point for their current commitment transaction
+       pub my_current_per_commitment_point: PublicKey,
 }
 
 /// An [`announcement_signatures`] message to be sent to or received from a peer.
@@ -671,7 +683,7 @@ pub struct UnsignedNodeAnnouncement {
        /// An alias, for UI purposes.
        ///
        /// This should be sanitized before use. There is no guarantee of uniqueness.
-       pub alias: [u8; 32],
+       pub alias: NodeAlias,
        /// List of addresses on which this node is reachable
        pub addresses: Vec<NetAddress>,
        pub(crate) excess_address_data: Vec<u8>,
@@ -934,20 +946,6 @@ pub struct CommitmentUpdate {
        pub commitment_signed: CommitmentSigned,
 }
 
-/// Messages could have optional fields to use with extended features
-/// As we wish to serialize these differently from `Option<T>`s (`Options` get a tag byte, but
-/// [`OptionalField`] simply gets `Present` if there are enough bytes to read into it), we have a
-/// separate enum type for them.
-///
-/// (C-not exported) due to a free generic in `T`
-#[derive(Clone, Debug, PartialEq, Eq)]
-pub enum OptionalField<T> {
-       /// Optional field is included in message
-       Present(T),
-       /// Optional field is absent in message
-       Absent
-}
-
 /// A trait to describe an object which can receive channel messages.
 ///
 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
@@ -1145,6 +1143,7 @@ mod fuzzy_internal_msgs {
                },
                FinalNode {
                        payment_data: Option<FinalOnionHopData>,
+                       payment_metadata: Option<Vec<u8>>,
                        keysend_preimage: Option<PaymentPreimage>,
                },
        }
@@ -1242,53 +1241,28 @@ impl From<io::Error> for DecodeError {
        }
 }
 
-impl Writeable for OptionalField<Script> {
-       fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
-               match *self {
-                       OptionalField::Present(ref script) => {
-                               // Note that Writeable for script includes the 16-bit length tag for us
-                               script.write(w)?;
-                       },
-                       OptionalField::Absent => {}
-               }
-               Ok(())
-       }
-}
-
-impl Readable for OptionalField<Script> {
-       fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
-               match <u16 as Readable>::read(r) {
-                       Ok(len) => {
-                               let mut buf = vec![0; len as usize];
-                               r.read_exact(&mut buf)?;
-                               Ok(OptionalField::Present(Script::from(buf)))
-                       },
-                       Err(DecodeError::ShortRead) => Ok(OptionalField::Absent),
-                       Err(e) => Err(e)
-               }
-       }
-}
-
-impl Writeable for OptionalField<u64> {
-       fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
-               match *self {
-                       OptionalField::Present(ref value) => {
-                               value.write(w)?;
-                       },
-                       OptionalField::Absent => {}
-               }
-               Ok(())
-       }
-}
-
-impl Readable for OptionalField<u64> {
-       fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
-               let value: u64 = Readable::read(r)?;
-               Ok(OptionalField::Present(value))
-       }
-}
-
+#[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,
+}, {
+       (0, shutdown_scriptpubkey, (option, encoding: (Script, WithoutLength))), // Don't encode length twice.
+       (1, channel_type, option),
+});
 
+#[cfg(taproot)]
 impl_writeable_msg!(AcceptChannel, {
        temporary_channel_id,
        dust_limit_satoshis,
@@ -1304,9 +1278,10 @@ impl_writeable_msg!(AcceptChannel, {
        delayed_payment_basepoint,
        htlc_basepoint,
        first_per_commitment_point,
-       shutdown_scriptpubkey
 }, {
+       (0, shutdown_scriptpubkey, (option, encoding: (Script, WithoutLength))), // Don't encode length twice.
        (1, channel_type, option),
+       (4, next_local_nonce, option),
 });
 
 impl_writeable_msg!(AnnouncementSignatures, {
@@ -1316,42 +1291,13 @@ impl_writeable_msg!(AnnouncementSignatures, {
        bitcoin_signature
 }, {});
 
-impl Writeable for ChannelReestablish {
-       fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
-               self.channel_id.write(w)?;
-               self.next_local_commitment_number.write(w)?;
-               self.next_remote_commitment_number.write(w)?;
-               match self.data_loss_protect {
-                       OptionalField::Present(ref data_loss_protect) => {
-                               (*data_loss_protect).your_last_per_commitment_secret.write(w)?;
-                               (*data_loss_protect).my_current_per_commitment_point.write(w)?;
-                       },
-                       OptionalField::Absent => {}
-               }
-               Ok(())
-       }
-}
-
-impl Readable for ChannelReestablish{
-       fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
-               Ok(Self {
-                       channel_id: Readable::read(r)?,
-                       next_local_commitment_number: Readable::read(r)?,
-                       next_remote_commitment_number: Readable::read(r)?,
-                       data_loss_protect: {
-                               match <[u8; 32] as Readable>::read(r) {
-                                       Ok(your_last_per_commitment_secret) =>
-                                               OptionalField::Present(DataLossProtect {
-                                                       your_last_per_commitment_secret,
-                                                       my_current_per_commitment_point: Readable::read(r)?,
-                                               }),
-                                       Err(DecodeError::ShortRead) => OptionalField::Absent,
-                                       Err(e) => return Err(e)
-                               }
-                       }
-               })
-       }
-}
+impl_writeable_msg!(ChannelReestablish, {
+       channel_id,
+       next_local_commitment_number,
+       next_remote_commitment_number,
+       your_last_per_commitment_secret,
+       my_current_per_commitment_point,
+}, {});
 
 impl_writeable_msg!(ClosingSigned,
        { channel_id, fee_satoshis, signature },
@@ -1363,30 +1309,60 @@ 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,
        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)
+});
 
+#[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,
@@ -1441,17 +1417,27 @@ impl_writeable_msg!(OpenChannel, {
        htlc_basepoint,
        first_per_commitment_point,
        channel_flags,
-       shutdown_scriptpubkey
 }, {
+       (0, shutdown_scriptpubkey, (option, encoding: (Script, WithoutLength))), // Don't encode length twice.
        (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
@@ -1576,11 +1562,12 @@ impl Writeable for OnionHopData {
                                        (6, short_channel_id, required)
                                });
                        },
-                       OnionHopDataFormat::FinalNode { ref payment_data, ref keysend_preimage } => {
+                       OnionHopDataFormat::FinalNode { ref payment_data, ref payment_metadata, ref keysend_preimage } => {
                                _encode_varint_length_prefixed_tlv!(w, {
                                        (2, HighZeroBytesDroppedBigSize(self.amt_to_forward), required),
                                        (4, HighZeroBytesDroppedBigSize(self.outgoing_cltv_value), required),
                                        (8, payment_data, option),
+                                       (16, payment_metadata.as_ref().map(|m| WithoutLength(m)), option),
                                        (5482373484, keysend_preimage, option)
                                });
                        },
@@ -1595,29 +1582,33 @@ impl Readable for OnionHopData {
                let mut cltv_value = HighZeroBytesDroppedBigSize(0u32);
                let mut short_id: Option<u64> = None;
                let mut payment_data: Option<FinalOnionHopData> = None;
+               let mut payment_metadata: Option<WithoutLength<Vec<u8>>> = None;
                let mut keysend_preimage: Option<PaymentPreimage> = None;
                read_tlv_fields!(r, {
                        (2, amt, required),
                        (4, cltv_value, required),
                        (6, short_id, option),
                        (8, payment_data, option),
+                       (16, payment_metadata, option),
                        // See https://github.com/lightning/blips/blob/master/blip-0003.md
                        (5482373484, keysend_preimage, option)
                });
 
                let format = if let Some(short_channel_id) = short_id {
                        if payment_data.is_some() { return Err(DecodeError::InvalidValue); }
+                       if payment_metadata.is_some() { return Err(DecodeError::InvalidValue); }
                        OnionHopDataFormat::NonFinalNode {
                                short_channel_id,
                        }
                } else {
-                       if let &Some(ref data) = &payment_data {
+                       if let Some(data) = &payment_data {
                                if data.total_msat > MAX_VALUE_MSAT {
                                        return Err(DecodeError::InvalidValue);
                                }
                        }
                        OnionHopDataFormat::FinalNode {
                                payment_data,
+                               payment_metadata: payment_metadata.map(|w| w.0),
                                keysend_preimage,
                        }
                };
@@ -1846,7 +1837,7 @@ impl Readable for UnsignedNodeAnnouncement {
                let node_id: NodeId = Readable::read(r)?;
                let mut rgb = [0; 3];
                r.read_exact(&mut rgb)?;
-               let alias: [u8; 32] = Readable::read(r)?;
+               let alias: NodeAlias = Readable::read(r)?;
 
                let addr_len: u16 = Readable::read(r)?;
                let mut addresses: Vec<NetAddress> = Vec::new();
@@ -2052,8 +2043,8 @@ mod tests {
        use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
        use crate::ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
        use crate::ln::msgs;
-       use crate::ln::msgs::{FinalOnionHopData, OptionalField, OnionErrorPacket, OnionHopDataFormat};
-       use crate::routing::gossip::NodeId;
+       use crate::ln::msgs::{FinalOnionHopData, OnionErrorPacket, OnionHopDataFormat};
+       use crate::routing::gossip::{NodeAlias, NodeId};
        use crate::util::ser::{Writeable, Readable, Hostname};
 
        use bitcoin::hashes::hex::FromHex;
@@ -2071,23 +2062,7 @@ mod tests {
        use core::convert::TryFrom;
 
        #[test]
-       fn encoding_channel_reestablish_no_secret() {
-               let cr = msgs::ChannelReestablish {
-                       channel_id: [4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0],
-                       next_local_commitment_number: 3,
-                       next_remote_commitment_number: 4,
-                       data_loss_protect: OptionalField::Absent,
-               };
-
-               let encoded_value = cr.encode();
-               assert_eq!(
-                       encoded_value,
-                       vec![4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4]
-               );
-       }
-
-       #[test]
-       fn encoding_channel_reestablish_with_secret() {
+       fn encoding_channel_reestablish() {
                let public_key = {
                        let secp_ctx = Secp256k1::new();
                        PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0101010101010101010101010101010101010101010101010101010101010101").unwrap()[..]).unwrap())
@@ -2097,7 +2072,8 @@ mod tests {
                        channel_id: [4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0],
                        next_local_commitment_number: 3,
                        next_remote_commitment_number: 4,
-                       data_loss_protect: OptionalField::Present(msgs::DataLossProtect { your_last_per_commitment_secret: [9;32], my_current_per_commitment_point: public_key}),
+                       your_last_per_commitment_secret: [9;32],
+                       my_current_per_commitment_point: public_key,
                };
 
                let encoded_value = cr.encode();
@@ -2248,7 +2224,7 @@ mod tests {
                        timestamp: 20190119,
                        node_id: NodeId::from_pubkey(&pubkey_1),
                        rgb: [32; 3],
-                       alias: [16;32],
+                       alias: NodeAlias([16;32]),
                        addresses,
                        excess_address_data: if excess_address_data { vec![33, 108, 40, 11, 83, 149, 162, 84, 110, 126, 75, 38, 99, 224, 79, 129, 22, 34, 241, 90, 79, 146, 232, 58, 162, 233, 43, 162, 165, 115, 193, 57, 20, 44, 84, 174, 99, 7, 42, 30, 193, 238, 125, 192, 192, 75, 222, 92, 132, 120, 6, 23, 42, 160, 92, 146, 194, 42, 232, 227, 8, 209, 210, 105] } else { Vec::new() },
                        excess_data: if excess_data { vec![59, 18, 204, 25, 92, 224, 162, 209, 189, 166, 168, 139, 239, 161, 159, 160, 127, 81, 202, 167, 92, 232, 56, 55, 242, 137, 101, 96, 11, 138, 172, 171, 8, 85, 255, 176, 231, 65, 236, 95, 124, 65, 66, 30, 152, 41, 169, 212, 134, 17, 200, 200, 49, 247, 27, 229, 234, 115, 230, 101, 148, 151, 127, 253] } else { Vec::new() },
@@ -2386,7 +2362,7 @@ mod tests {
                        htlc_basepoint: pubkey_5,
                        first_per_commitment_point: pubkey_6,
                        channel_flags: if random_bit { 1 << 5 } else { 0 },
-                       shutdown_scriptpubkey: if shutdown { OptionalField::Present(Address::p2pkh(&::bitcoin::PublicKey{compressed: true, inner: pubkey_1}, Network::Testnet).script_pubkey()) } else { OptionalField::Absent },
+                       shutdown_scriptpubkey: if shutdown { Some(Address::p2pkh(&::bitcoin::PublicKey{compressed: true, inner: pubkey_1}, Network::Testnet).script_pubkey()) } else { None },
                        channel_type: if incl_chan_type { Some(ChannelTypeFeatures::empty()) } else { None },
                };
                let encoded_value = open_channel.encode();
@@ -2442,8 +2418,10 @@ mod tests {
                        delayed_payment_basepoint: pubkey_4,
                        htlc_basepoint: pubkey_5,
                        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 },
+                       shutdown_scriptpubkey: if shutdown { Some(Address::p2pkh(&::bitcoin::PublicKey{compressed: true, inner: pubkey_1}, Network::Testnet).script_pubkey()) } else { None },
                        channel_type: None,
+                       #[cfg(taproot)]
+                       next_local_nonce: None,
                };
                let encoded_value = accept_channel.encode();
                let mut target_value = hex::decode("020202020202020202020202020202020202020202020202020202020202020212345678901234562334032891223698321446687011447600083a840000034d000c89d4c0bcc0bc031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d076602531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe33703462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f703f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a").unwrap();
@@ -2469,6 +2447,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();
@@ -2483,6 +2465,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();
@@ -2646,6 +2630,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();
@@ -2671,6 +2657,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();
@@ -2783,6 +2771,7 @@ mod tests {
                let mut msg = msgs::OnionHopData {
                        format: OnionHopDataFormat::FinalNode {
                                payment_data: None,
+                               payment_metadata: None,
                                keysend_preimage: None,
                        },
                        amt_to_forward: 0x0badf00d01020304,
@@ -2806,6 +2795,7 @@ mod tests {
                                        payment_secret: expected_payment_secret,
                                        total_msat: 0x1badca1f
                                }),
+                               payment_metadata: None,
                                keysend_preimage: None,
                        },
                        amt_to_forward: 0x0badf00d01020304,
@@ -2820,6 +2810,7 @@ mod tests {
                                payment_secret,
                                total_msat: 0x1badca1f
                        }),
+                       payment_metadata: None,
                        keysend_preimage: None,
                } = msg.format {
                        assert_eq!(payment_secret, expected_payment_secret);