Skip to content

Commit 29da917

Browse files
committed
f Revert "Use real on-chain value where possible in get_claimable_balance"
Note that the test utility will become a fixup on a later commit, the assertion change will move...somewhere, or maybe be its own commit
1 parent a91b4a3 commit 29da917

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,20 +1435,16 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
14351435
let mut delayed_output_pending = None;
14361436
for event in us.onchain_events_awaiting_threshold_conf.iter() {
14371437
match event.event {
1438-
OnchainEvent::HTLCUpdate {
1439-
commitment_tx_output_idx, onchain_value_satoshis, htlc_value_satoshis, .. }
1438+
OnchainEvent::HTLCUpdate { commitment_tx_output_idx, htlc_value_satoshis, .. }
14401439
if commitment_tx_output_idx == Some(htlc_commitment_tx_output_idx) => {
14411440
debug_assert!(htlc_update_pending.is_none());
1442-
htlc_update_pending = Some((
1443-
onchain_value_satoshis.unwrap_or(htlc_value_satoshis.unwrap()),
1444-
event.confirmation_threshold()));
1441+
debug_assert_eq!(htlc_value_satoshis.unwrap(), htlc.amount_msat / 1000);
1442+
htlc_update_pending = Some(event.confirmation_threshold());
14451443
},
1446-
OnchainEvent::HTLCSpendConfirmation {
1447-
commitment_tx_output_idx, preimage, onchain_value_satoshis, .. }
1444+
OnchainEvent::HTLCSpendConfirmation { commitment_tx_output_idx, preimage, .. }
14481445
if commitment_tx_output_idx == htlc_commitment_tx_output_idx => {
14491446
debug_assert!(htlc_spend_pending.is_none());
1450-
htlc_spend_pending = Some((event.confirmation_threshold(),
1451-
preimage.is_some(), onchain_value_satoshis));
1447+
htlc_spend_pending = Some((event.confirmation_threshold(), preimage.is_some()));
14521448
},
14531449
OnchainEvent::MaturingOutput {
14541450
descriptor: SpendableOutputDescriptor::DelayedPaymentOutput(ref descriptor) }
@@ -1481,9 +1477,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
14811477
// If the payment was outbound, check if there's an HTLCUpdate
14821478
// indicating we have spent this HTLC with a timeout, claiming it back
14831479
// and awaiting confirmations on it.
1484-
if let Some((value, conf_thresh)) = htlc_update_pending {
1480+
if let Some(conf_thresh) = htlc_update_pending {
14851481
res.push(Balance::ClaimableAwaitingConfirmations {
1486-
claimable_amount_satoshis: value,
1482+
claimable_amount_satoshis: htlc.amount_msat / 1000,
14871483
confirmation_height: conf_thresh,
14881484
});
14891485
} else {
@@ -1499,9 +1495,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
14991495
// preimage, we lost funds to our counterparty! We will then continue
15001496
// to show it as ContentiousClaimable until ANTI_REORG_DELAY.
15011497
debug_assert!(htlc_update_pending.is_none());
1502-
if let Some((conf_thresh, true, value)) = htlc_spend_pending {
1498+
if let Some((conf_thresh, true)) = htlc_spend_pending {
15031499
res.push(Balance::ClaimableAwaitingConfirmations {
1504-
claimable_amount_satoshis: value.unwrap_or(htlc.amount_msat / 1000),
1500+
claimable_amount_satoshis: htlc.amount_msat / 1000,
15051501
confirmation_height: conf_thresh,
15061502
});
15071503
} else {

lightning/src/ln/monitor_tests.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,11 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) {
512512
let node_b_htlc_claimable = nodes[1].best_block_info().1 + BREAKDOWN_TIMEOUT as u32;
513513
mine_transaction(&nodes[1], &b_broadcast_txn[0]);
514514

515-
fuzzy_assert_eq(b_broadcast_txn[0].output[0].value,
516-
3_000 - chan_feerate * b_broadcast_txn[0].weight() as u64 / 1_000);
517-
518515
assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations {
519516
claimable_amount_satoshis: 1_000,
520517
confirmation_height: node_b_commitment_claimable,
521518
}, Balance::ClaimableAwaitingConfirmations {
522-
claimable_amount_satoshis: b_broadcast_txn[0].output[0].value,
519+
claimable_amount_satoshis: 3_000,
523520
confirmation_height: node_b_htlc_claimable,
524521
}, Balance::ContentiousClaimable {
525522
claimable_amount_satoshis: 4_000,
@@ -533,7 +530,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) {
533530
test_spendable_output(&nodes[1], &remote_txn[0]);
534531

535532
assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations {
536-
claimable_amount_satoshis: b_broadcast_txn[0].output[0].value,
533+
claimable_amount_satoshis: 3_000,
537534
confirmation_height: node_b_htlc_claimable,
538535
}, Balance::ContentiousClaimable {
539536
claimable_amount_satoshis: 4_000,

0 commit comments

Comments
 (0)