Skip to content

Commit e8c3d22

Browse files
committed
f Move height check call into top request loop
1 parent 46f5b3d commit e8c3d22

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lightning/src/chain/onchaintx.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,15 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
415415
}
416416
}
417417

418+
if req.package_timelock() > height + 1 {
419+
log_debug!(logger, "Delaying claim of package until its timelock at {} (current height {}), the following outpoints are spent:", req.package_timelock(), height);
420+
for outpoint in req.outpoints() {
421+
log_debug!(logger, " Outpoint {}", outpoint);
422+
}
423+
self.locktimed_packages.entry(req.package_timelock()).or_insert(Vec::new()).push(req);
424+
continue 'req_walk;
425+
}
426+
418427
log_trace!(logger, "Test if outpoint can be aggregated with expiration {} against {}", req.timelock(), height + CLTV_SHARED_CLAIM_BUFFER);
419428
if req.timelock() <= height + CLTV_SHARED_CLAIM_BUFFER || !req.aggregable() {
420429
// Don't aggregate if outpoint package timelock is soon or marked as non-aggregable
@@ -443,13 +452,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
443452
// Generate claim transactions and track them to bump if necessary at
444453
// height timer expiration (i.e in how many blocks we're going to take action).
445454
for mut req in preprocessed_requests {
446-
if req.package_timelock() > height + 1 {
447-
log_debug!(logger, "Delaying claim of package until its timelock at {} (current height {}), the following outpoints are spent:", req.package_timelock(), height);
448-
for outpoint in req.outpoints() {
449-
log_debug!(logger, " Outpoint {}", outpoint);
450-
}
451-
self.locktimed_packages.entry(req.package_timelock()).or_insert(Vec::new()).push(req);
452-
} else if let Some((new_timer, new_feerate, tx)) = self.generate_claim_tx(height, &req, &*fee_estimator, &*logger) {
455+
if let Some((new_timer, new_feerate, tx)) = self.generate_claim_tx(height, &req, &*fee_estimator, &*logger) {
453456
req.set_timer(new_timer);
454457
req.set_feerate(new_feerate);
455458
let txid = tx.txid();

0 commit comments

Comments
 (0)