Skip to content

Commit

Permalink
client/dcr: Fix negative swap confs (decred#3009)
Browse files Browse the repository at this point in the history
There is an unsafe subtraction when checking the number of confirmations
on a DCR transaction.
  • Loading branch information
martonp authored and buck54321 committed Oct 17, 2024
1 parent 4e224d2 commit fec815b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/asset/dcr/spv.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,11 @@ func (w *spvWallet) GetTransaction(ctx context.Context, txHash *chainhash.Hash)

if txd.Block.Height != -1 {
ret.BlockHash = txd.Block.Hash.String()
ret.Confirmations = int64(tipHeight - txd.Block.Height + 1)
if tipHeight >= txd.Block.Height {
ret.Confirmations = int64(tipHeight - txd.Block.Height + 1)
} else {
ret.Confirmations = 1
}
}

details, err := w.ListTransactionDetails(ctx, txHash)
Expand Down

0 comments on commit fec815b

Please sign in to comment.