Skip to content

Commit

Permalink
fix(ln-dlc-node): Compute confirmations correctly
Browse files Browse the repository at this point in the history
The original logic was flawed because it would correctly show 1
confirmation when the transaction was included in a block, but it
would subsequently deduct 1 confirmation after the second
confirmation.

We were already doing this correctly for the `Blockchain` struct, so
there is nothing to fix there.
  • Loading branch information
luckysori committed Mar 25, 2024
1 parent 55753a3 commit 8b7564d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/ln-dlc-node/src/on_chain_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ impl<D> OnChainWallet<D> {

let tip = self.get_tip();
let n_confirmations = match tip.checked_sub(confirmation_height) {
Some(diff) => NonZeroU32::new(diff).unwrap_or({
// Being included in a block counts as a confirmation!
NonZeroU32::new(1).expect("non-zero value")
}),
// Being included in a block counts as a confirmation!
Some(diff) => NonZeroU32::new(diff + 1).expect("non-zero"),
None => {
// The transaction shouldn't be ahead of the tip!
debug_assert!(false);
Expand Down

0 comments on commit 8b7564d

Please sign in to comment.