Skip to content

Commit 9d74fff

Browse files
committed
Dont RBF a tx twice if it hits RBF timer when one input is spent
1 parent 91ad422 commit 9d74fff

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,7 +2330,7 @@ impl ChannelMonitor {
23302330
let mut watch_outputs = Vec::new();
23312331
let mut spendable_outputs = Vec::new();
23322332
let mut htlc_updated = Vec::new();
2333-
let mut bump_candidates = Vec::new();
2333+
let mut bump_candidates = HashMap::new();
23342334
for tx in txn_matched {
23352335
if tx.input.len() == 1 {
23362336
// Assuming our keys were not leaked (in which case we're screwed no matter what),
@@ -2435,7 +2435,7 @@ impl ChannelMonitor {
24352435
}
24362436
}
24372437
//TODO: recompute soonest_timelock to avoid wasting a bit on fees
2438-
bump_candidates.push((ancestor_claimable_txid.0.clone(), claim_material.clone()));
2438+
bump_candidates.insert(ancestor_claimable_txid.0.clone(), claim_material.clone());
24392439
}
24402440
break; //No need to iterate further, either tx is our or their
24412441
} else {
@@ -2511,17 +2511,19 @@ impl ChannelMonitor {
25112511
}
25122512
for (ancestor_claim_txid, ref mut cached_claim_datas) in self.pending_claim_requests.iter_mut() {
25132513
if cached_claim_datas.height_timer == height {
2514-
bump_candidates.push((ancestor_claim_txid.clone(), cached_claim_datas.clone()));
2514+
if let hash_map::Entry::Vacant(entry) = bump_candidates.entry(ancestor_claim_txid.clone()) {
2515+
entry.insert(cached_claim_datas.clone());
2516+
}
25152517
}
25162518
}
2517-
for &mut (_, ref mut cached_claim_datas) in bump_candidates.iter_mut() {
2519+
for ref mut cached_claim_datas in bump_candidates.values_mut() {
25182520
if let Some((new_timer, new_feerate, bump_tx)) = self.bump_claim_tx(height, &cached_claim_datas, fee_estimator) {
25192521
cached_claim_datas.height_timer = new_timer;
25202522
cached_claim_datas.feerate_previous = new_feerate;
25212523
broadcaster.broadcast_transaction(&bump_tx);
25222524
}
25232525
}
2524-
for (ancestor_claim_txid, cached_claim_datas) in bump_candidates.drain(..) {
2526+
for (ancestor_claim_txid, cached_claim_datas) in bump_candidates.drain() {
25252527
self.pending_claim_requests.insert(ancestor_claim_txid, cached_claim_datas);
25262528
}
25272529
self.last_block_hash = block_hash.clone();

0 commit comments

Comments
 (0)