From: Wilmer Paulino Date: Fri, 13 Oct 2023 20:47:45 +0000 (-0700) Subject: Provide missing derivation parameters to OnchainTxHandler X-Git-Tag: v0.0.118~3^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=5958604ea67b01ce69e4502bf2c35254838abab9;p=rust-lightning Provide missing derivation parameters to OnchainTxHandler `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. --- diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index acb735e15..aa53e6fd5 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -1172,9 +1172,10 @@ impl ChannelMonitor { (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())]); diff --git a/lightning/src/chain/onchaintx.rs b/lightning/src/chain/onchaintx.rs index 5daa2463d..857b6b9a6 100644 --- a/lightning/src/chain/onchaintx.rs +++ b/lightning/src/chain/onchaintx.rs @@ -215,6 +215,8 @@ pub(crate) enum OnchainClaim { /// do RBF bumping if possible. #[derive(Clone)] pub struct OnchainTxHandler { + 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 { impl PartialEq for OnchainTxHandler { 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 OnchainTxHandler { - pub(crate) fn new(destination_script: Script, signer: ChannelSigner, channel_parameters: ChannelTransactionParameters, holder_commitment: HolderCommitmentTransaction, secp_ctx: Secp256k1) -> 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 + ) -> Self { OnchainTxHandler { + channel_value_satoshis, + channel_keys_id, destination_script, holder_commitment, holder_htlc_sigs: None,