Skip to content

Commit 7866394

Browse files
authored
Merge pull request #1841 from ariard/2022-11-revoked-balance-non-aggregable
Post-anchor: do not aggregate claim of revoked output
2 parents 5c89d01 + 5e968ed commit 7866394

File tree

3 files changed

+93
-107
lines changed

3 files changed

+93
-107
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
24312431
let commitment_package = PackageTemplate::build_package(
24322432
self.funding_info.0.txid.clone(), self.funding_info.0.index as u32,
24332433
PackageSolvingData::HolderFundingOutput(funding_output),
2434-
best_block_height, false, best_block_height,
2434+
best_block_height, best_block_height
24352435
);
24362436
self.onchain_tx_handler.update_claims_view_from_requests(
24372437
vec![commitment_package], best_block_height, best_block_height,
@@ -2614,8 +2614,8 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
26142614
// First, process non-htlc outputs (to_holder & to_counterparty)
26152615
for (idx, outp) in tx.output.iter().enumerate() {
26162616
if outp.script_pubkey == revokeable_p2wsh {
2617-
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);
2618-
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, true, height);
2617+
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.opt_anchors());
2618+
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);
26192619
claimable_outpoints.push(justice_package);
26202620
to_counterparty_output_info =
26212621
Some((idx.try_into().expect("Txn can't have more than 2^32 outputs"), outp.value));
@@ -2633,7 +2633,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
26332633
to_counterparty_output_info);
26342634
}
26352635
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.opt_anchors.is_some());
2636-
let justice_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, PackageSolvingData::RevokedHTLCOutput(revk_htlc_outp), htlc.cltv_expiry, true, height);
2636+
let justice_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, PackageSolvingData::RevokedHTLCOutput(revk_htlc_outp), htlc.cltv_expiry, height);
26372637
claimable_outpoints.push(justice_package);
26382638
}
26392639
}
@@ -2758,8 +2758,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
27582758
self.counterparty_commitment_params.counterparty_htlc_base_key,
27592759
htlc.clone(), self.onchain_tx_handler.opt_anchors()))
27602760
};
2761-
let aggregation = if !htlc.offered { false } else { true };
2762-
let counterparty_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc.cltv_expiry,aggregation, 0);
2761+
let counterparty_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc.cltv_expiry, 0);
27632762
claimable_outpoints.push(counterparty_package);
27642763
}
27652764
}
@@ -2798,11 +2797,12 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
27982797
let revk_outp = RevokedOutput::build(
27992798
per_commitment_point, self.counterparty_commitment_params.counterparty_delayed_payment_base_key,
28002799
self.counterparty_commitment_params.counterparty_htlc_base_key, per_commitment_key,
2801-
tx.output[idx].value, self.counterparty_commitment_params.on_counterparty_tx_csv
2800+
tx.output[idx].value, self.counterparty_commitment_params.on_counterparty_tx_csv,
2801+
false
28022802
);
28032803
let justice_package = PackageTemplate::build_package(
28042804
htlc_txid, idx as u32, PackageSolvingData::RevokedOutput(revk_outp),
2805-
height + self.counterparty_commitment_params.on_counterparty_tx_csv as u32, true, height
2805+
height + self.counterparty_commitment_params.on_counterparty_tx_csv as u32, height
28062806
);
28072807
claimable_outpoints.push(justice_package);
28082808
if outputs_to_watch.is_none() {
@@ -2825,11 +2825,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
28252825

28262826
for &(ref htlc, _, _) in holder_tx.htlc_outputs.iter() {
28272827
if let Some(transaction_output_index) = htlc.transaction_output_index {
2828-
let (htlc_output, aggregable) = if htlc.offered {
2828+
let htlc_output = if htlc.offered {
28292829
let htlc_output = HolderHTLCOutput::build_offered(
28302830
htlc.amount_msat, htlc.cltv_expiry, self.onchain_tx_handler.opt_anchors()
28312831
);
2832-
(htlc_output, false)
2832+
htlc_output
28332833
} else {
28342834
let payment_preimage = if let Some(preimage) = self.payment_preimages.get(&htlc.payment_hash) {
28352835
preimage.clone()
@@ -2840,12 +2840,12 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
28402840
let htlc_output = HolderHTLCOutput::build_accepted(
28412841
payment_preimage, htlc.amount_msat, self.onchain_tx_handler.opt_anchors()
28422842
);
2843-
(htlc_output, self.onchain_tx_handler.opt_anchors())
2843+
htlc_output
28442844
};
28452845
let htlc_package = PackageTemplate::build_package(
28462846
holder_tx.txid, transaction_output_index,
28472847
PackageSolvingData::HolderHTLCOutput(htlc_output),
2848-
htlc.cltv_expiry, aggregable, conf_height
2848+
htlc.cltv_expiry, conf_height
28492849
);
28502850
claim_requests.push(htlc_package);
28512851
}
@@ -3185,7 +3185,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
31853185
let should_broadcast = self.should_broadcast_holder_commitment_txn(logger);
31863186
if should_broadcast {
31873187
let funding_outp = HolderFundingOutput::build(self.funding_redeemscript.clone(), self.channel_value_satoshis, self.onchain_tx_handler.opt_anchors());
3188-
let commitment_package = PackageTemplate::build_package(self.funding_info.0.txid.clone(), self.funding_info.0.index as u32, PackageSolvingData::HolderFundingOutput(funding_outp), self.best_block.height(), false, self.best_block.height());
3188+
let commitment_package = PackageTemplate::build_package(self.funding_info.0.txid.clone(), self.funding_info.0.index as u32, PackageSolvingData::HolderFundingOutput(funding_outp), self.best_block.height(), self.best_block.height());
31893189
claimable_outpoints.push(commitment_package);
31903190
self.pending_monitor_events.push(MonitorEvent::CommitmentTxConfirmed(self.funding_info.0));
31913191
let commitment_tx = self.onchain_tx_handler.get_fully_signed_holder_tx(&self.funding_redeemscript);

0 commit comments

Comments
 (0)