Skip to content

Commit 5aa3816

Browse files
author
Antoine Riard
committed
Comment better get_height_timer logic.
Height timer as an important component of a more-secure, fee-sensitive claiming of time-constrained LN outputs, therefore document assumptions.
1 parent 90cd9f4 commit 5aa3816

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/ln/onchaintx.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ impl OnchainTxHandler {
315315
tx_weight
316316
}
317317

318+
/// In LN, output claimed are time-sensitive, which means we have to spend them before reaching some timelock expiration. At in-channel
319+
/// output detection, we generate a first version of a claim tx and associate to it a height timer. A height timer is an absolute block
320+
/// height than once reached we should generate a new bumped "version" of the claim tx to be sure than we safely claim outputs before
321+
/// than our counterparty can do it too. If timelock expires soon, height timer is going to be scale down in consequence to increase
322+
/// frequency of the bump and so increase our bets of success.
318323
fn get_height_timer(current_height: u32, timelock_expiration: u32) -> u32 {
319324
if timelock_expiration <= current_height + 3 {
320325
return current_height + 1
@@ -387,6 +392,8 @@ impl OnchainTxHandler {
387392
}
388393
}
389394

395+
// Compute new height timer to decide when we need to regenerate a new bumped version of the claim tx (if we
396+
// didn't receive confirmation of it before, or not enough reorg-safe depth on top of it).
390397
let new_timer = Self::get_height_timer(height, cached_claim_datas.soonest_timelock);
391398
let mut inputs_witnesses_weight = 0;
392399
let mut total_amount = 0;

0 commit comments

Comments
 (0)