Skip to content

Commit f5a1a3d

Browse files
committed
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.
1 parent 83676f7 commit f5a1a3d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lightning/src/chain/channelmonitor.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1172,9 +1172,10 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
11721172
(holder_commitment_tx, trusted_tx.commitment_number())
11731173
};
11741174

1175-
let onchain_tx_handler =
1176-
OnchainTxHandler::new(destination_script.clone(), keys,
1177-
channel_parameters.clone(), initial_holder_commitment_tx, secp_ctx);
1175+
let onchain_tx_handler = OnchainTxHandler::new(
1176+
channel_value_satoshis, channel_keys_id, destination_script.clone(), keys,
1177+
channel_parameters.clone(), initial_holder_commitment_tx, secp_ctx
1178+
);
11781179

11791180
let mut outputs_to_watch = HashMap::new();
11801181
outputs_to_watch.insert(funding_info.0.txid, vec![(funding_info.0.index as u32, funding_info.1.clone())]);

lightning/src/chain/onchaintx.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ pub(crate) enum OnchainClaim {
215215
/// do RBF bumping if possible.
216216
#[derive(Clone)]
217217
pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
218+
channel_value_satoshis: u64,
219+
channel_keys_id: [u8; 32],
218220
destination_script: Script,
219221
holder_commitment: HolderCommitmentTransaction,
220222
// 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> {
276278
impl<ChannelSigner: WriteableEcdsaChannelSigner> PartialEq for OnchainTxHandler<ChannelSigner> {
277279
fn eq(&self, other: &Self) -> bool {
278280
// `signer`, `secp_ctx`, and `pending_claim_events` are excluded on purpose.
279-
self.destination_script == other.destination_script &&
281+
self.channel_value_satoshis == other.channel_value_satoshis &&
282+
self.channel_keys_id == other.channel_keys_id &&
283+
self.destination_script == other.destination_script &&
280284
self.holder_commitment == other.holder_commitment &&
281285
self.holder_htlc_sigs == other.holder_htlc_sigs &&
282286
self.prev_holder_commitment == other.prev_holder_commitment &&
@@ -418,6 +422,8 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
418422
secp_ctx.seeded_randomize(&entropy_source.get_secure_random_bytes());
419423

420424
Ok(OnchainTxHandler {
425+
channel_value_satoshis,
426+
channel_keys_id,
421427
destination_script,
422428
holder_commitment,
423429
holder_htlc_sigs,
@@ -436,8 +442,14 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
436442
}
437443

438444
impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
439-
pub(crate) fn new(destination_script: Script, signer: ChannelSigner, channel_parameters: ChannelTransactionParameters, holder_commitment: HolderCommitmentTransaction, secp_ctx: Secp256k1<secp256k1::All>) -> Self {
445+
pub(crate) fn new(
446+
channel_value_satoshis: u64, channel_keys_id: [u8; 32], destination_script: Script,
447+
signer: ChannelSigner, channel_parameters: ChannelTransactionParameters,
448+
holder_commitment: HolderCommitmentTransaction, secp_ctx: Secp256k1<secp256k1::All>
449+
) -> Self {
440450
OnchainTxHandler {
451+
channel_value_satoshis,
452+
channel_keys_id,
441453
destination_script,
442454
holder_commitment,
443455
holder_htlc_sigs: None,

0 commit comments

Comments
 (0)