X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Fln%2Fmsgs.rs;h=2557454b4623567302f4f7f380cee305c04e05ec;hb=1016e1f605ff03ed14ed875e7cd4f567ae15c96a;hp=38c832564c4b88df8f8a26727bd1668f970f0ec8;hpb=64a800720e63c17910a524ab72dd9dedc05d3345;p=rust-lightning diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 38c83256..2557454b 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -267,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, + #[cfg(taproot)] + /// Next nonce the channel acceptor should use to finalize the funding output signature + pub next_local_nonce: Option } /// A [`funding_signed`] message to be sent to or received from a peer. @@ -278,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, } /// A [`channel_ready`] message to be sent to or received from a peer. @@ -417,6 +426,9 @@ pub struct CommitmentSigned { pub signature: Signature, /// Signatures on the HTLC transactions pub htlc_signatures: Vec, + #[cfg(taproot)] + /// The partial Taproot signature on the commitment transaction + pub partial_signature_with_nonce: Option, } /// A [`revoke_and_ack`] message to be sent to or received from a peer. @@ -430,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 } /// An [`update_fee`] message to be sent to or received from a peer @@ -1393,30 +1408,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, @@ -1476,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 @@ -2501,6 +2556,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(); @@ -2515,6 +2574,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(); @@ -2678,6 +2739,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(); @@ -2703,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();