Skip to content

Commit 1668dbe

Browse files
committed
Stop passing current height to PackageTemplate::build_package
Now that we don't store the confirmation height of the inputs being spent, passing the current height to `PackageTemplate::build_package` is useless - we only use it to set the height at which we should next bump the fee, but we just want it to be "next block", so we might as well use `0` and avoid the extra argument. Further, in one case we were already passing `0`, so passing the argument is just confusing as we can't rely on it being set.
1 parent 3ea6449 commit 1668dbe

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
30183018
let commitment_package = PackageTemplate::build_package(
30193019
self.funding_info.0.txid.clone(), self.funding_info.0.index as u32,
30203020
PackageSolvingData::HolderFundingOutput(funding_outp),
3021-
self.best_block.height, self.best_block.height
3021+
self.best_block.height,
30223022
);
30233023
let mut claimable_outpoints = vec![commitment_package];
30243024
let event = MonitorEvent::HolderForceClosedWithInfo {
@@ -3459,7 +3459,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
34593459
for (idx, outp) in tx.output.iter().enumerate() {
34603460
if outp.script_pubkey == revokeable_p2wsh {
34613461
let revk_outp = RevokedOutput::build(per_commitment_point, self.counterparty_commitment_params.counterparty_delayed_payment_base_key, self.counterparty_commitment_params.counterparty_htlc_base_key, per_commitment_key, outp.value, self.counterparty_commitment_params.on_counterparty_tx_csv, self.onchain_tx_handler.channel_type_features().supports_anchors_zero_fee_htlc_tx());
3462-
let justice_package = PackageTemplate::build_package(commitment_txid, idx as u32, PackageSolvingData::RevokedOutput(revk_outp), height + self.counterparty_commitment_params.on_counterparty_tx_csv as u32, height);
3462+
let justice_package = PackageTemplate::build_package(
3463+
commitment_txid, idx as u32,
3464+
PackageSolvingData::RevokedOutput(revk_outp),
3465+
height + self.counterparty_commitment_params.on_counterparty_tx_csv as u32,
3466+
);
34633467
claimable_outpoints.push(justice_package);
34643468
to_counterparty_output_info =
34653469
Some((idx.try_into().expect("Txn can't have more than 2^32 outputs"), outp.value));
@@ -3476,7 +3480,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
34763480
return (claimable_outpoints, to_counterparty_output_info);
34773481
}
34783482
let revk_htlc_outp = RevokedHTLCOutput::build(per_commitment_point, self.counterparty_commitment_params.counterparty_delayed_payment_base_key, self.counterparty_commitment_params.counterparty_htlc_base_key, per_commitment_key, htlc.amount_msat / 1000, htlc.clone(), &self.onchain_tx_handler.channel_transaction_parameters.channel_type_features);
3479-
let justice_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, PackageSolvingData::RevokedHTLCOutput(revk_htlc_outp), htlc.cltv_expiry, height);
3483+
let justice_package = PackageTemplate::build_package(
3484+
commitment_txid,
3485+
transaction_output_index,
3486+
PackageSolvingData::RevokedHTLCOutput(revk_htlc_outp),
3487+
htlc.cltv_expiry,
3488+
);
34803489
claimable_outpoints.push(justice_package);
34813490
}
34823491
}
@@ -3598,7 +3607,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35983607
self.counterparty_commitment_params.counterparty_htlc_base_key,
35993608
htlc.clone(), self.onchain_tx_handler.channel_type_features().clone()))
36003609
};
3601-
let counterparty_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc.cltv_expiry, 0);
3610+
let counterparty_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc.cltv_expiry);
36023611
claimable_outpoints.push(counterparty_package);
36033612
}
36043613
}
@@ -3642,7 +3651,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36423651
);
36433652
let justice_package = PackageTemplate::build_package(
36443653
htlc_txid, idx as u32, PackageSolvingData::RevokedOutput(revk_outp),
3645-
height + self.counterparty_commitment_params.on_counterparty_tx_csv as u32, height
3654+
height + self.counterparty_commitment_params.on_counterparty_tx_csv as u32,
36463655
);
36473656
claimable_outpoints.push(justice_package);
36483657
if outputs_to_watch.is_none() {
@@ -3685,7 +3694,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36853694
let htlc_package = PackageTemplate::build_package(
36863695
holder_tx.txid, transaction_output_index,
36873696
PackageSolvingData::HolderHTLCOutput(htlc_output),
3688-
htlc.cltv_expiry, conf_height
3697+
htlc.cltv_expiry,
36893698
);
36903699
claim_requests.push(htlc_package);
36913700
}

lightning/src/chain/package.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ impl PackageTemplate {
10291029
}).is_some()
10301030
}
10311031

1032-
pub (crate) fn build_package(txid: Txid, vout: u32, input_solving_data: PackageSolvingData, soonest_conf_deadline: u32, first_bump: u32) -> Self {
1032+
pub (crate) fn build_package(txid: Txid, vout: u32, input_solving_data: PackageSolvingData, soonest_conf_deadline: u32) -> Self {
10331033
let (malleability, aggregable) = PackageSolvingData::map_output_type_flags(&input_solving_data);
10341034
let inputs = vec![(BitcoinOutPoint { txid, vout }, input_solving_data)];
10351035
PackageTemplate {
@@ -1038,7 +1038,7 @@ impl PackageTemplate {
10381038
soonest_conf_deadline,
10391039
aggregable,
10401040
feerate_previous: 0,
1041-
height_timer: first_bump,
1041+
height_timer: 0,
10421042
}
10431043
}
10441044
}

0 commit comments

Comments
 (0)