]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Provide missing derivation parameters to OnchainTxHandler
authorWilmer Paulino <wilmer@wilmerpaulino.com>
Fri, 13 Oct 2023 20:47:45 +0000 (13:47 -0700)
committerWilmer Paulino <wilmer@wilmerpaulino.com>
Fri, 20 Oct 2023 18:03:02 +0000 (11:03 -0700)
`OnchainTxHandler` will need to construct `HTLCDescriptor`s for holder
HTLCs, but it did not have access to all of the derivation parameters
that need to be provided.

lightning/src/chain/channelmonitor.rs
lightning/src/chain/onchaintx.rs

index acb735e151e672e579c09d095676f9cf643aed0a..aa53e6fd5d9e79847c374adae4e6e06b5f312e78 100644 (file)
@@ -1172,9 +1172,10 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                        (holder_commitment_tx, trusted_tx.commitment_number())
                };
 
-               let onchain_tx_handler =
-                       OnchainTxHandler::new(destination_script.clone(), keys,
-                       channel_parameters.clone(), initial_holder_commitment_tx, secp_ctx);
+               let onchain_tx_handler = OnchainTxHandler::new(
+                       channel_value_satoshis, channel_keys_id, destination_script.clone(), keys,
+                       channel_parameters.clone(), initial_holder_commitment_tx, secp_ctx
+               );
 
                let mut outputs_to_watch = HashMap::new();
                outputs_to_watch.insert(funding_info.0.txid, vec![(funding_info.0.index as u32, funding_info.1.clone())]);
index 5daa2463de99ec0d129bd3e28f0cf6a11b161e9c..857b6b9a6b0801cc20f625097d66731f45159ed8 100644 (file)
@@ -215,6 +215,8 @@ pub(crate) enum OnchainClaim {
 /// do RBF bumping if possible.
 #[derive(Clone)]
 pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
+       channel_value_satoshis: u64,
+       channel_keys_id: [u8; 32],
        destination_script: Script,
        holder_commitment: HolderCommitmentTransaction,
        // holder_htlc_sigs and prev_holder_htlc_sigs are in the order as they appear in the commitment
@@ -276,7 +278,9 @@ pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
 impl<ChannelSigner: WriteableEcdsaChannelSigner> PartialEq for OnchainTxHandler<ChannelSigner> {
        fn eq(&self, other: &Self) -> bool {
                // `signer`, `secp_ctx`, and `pending_claim_events` are excluded on purpose.
-               self.destination_script == other.destination_script &&
+               self.channel_value_satoshis == other.channel_value_satoshis &&
+                       self.channel_keys_id == other.channel_keys_id &&
+                       self.destination_script == other.destination_script &&
                        self.holder_commitment == other.holder_commitment &&
                        self.holder_htlc_sigs == other.holder_htlc_sigs &&
                        self.prev_holder_commitment == other.prev_holder_commitment &&
@@ -418,6 +422,8 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
                secp_ctx.seeded_randomize(&entropy_source.get_secure_random_bytes());
 
                Ok(OnchainTxHandler {
+                       channel_value_satoshis,
+                       channel_keys_id,
                        destination_script,
                        holder_commitment,
                        holder_htlc_sigs,
@@ -436,8 +442,14 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
 }
 
 impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
-       pub(crate) fn new(destination_script: Script, signer: ChannelSigner, channel_parameters: ChannelTransactionParameters, holder_commitment: HolderCommitmentTransaction, secp_ctx: Secp256k1<secp256k1::All>) -> Self {
+       pub(crate) fn new(
+               channel_value_satoshis: u64, channel_keys_id: [u8; 32], destination_script: Script,
+               signer: ChannelSigner, channel_parameters: ChannelTransactionParameters,
+               holder_commitment: HolderCommitmentTransaction, secp_ctx: Secp256k1<secp256k1::All>
+       ) -> Self {
                OnchainTxHandler {
+                       channel_value_satoshis,
+                       channel_keys_id,
                        destination_script,
                        holder_commitment,
                        holder_htlc_sigs: None,