Skip to content

Commit 5b56413

Browse files
wallet: properly calculate confirmations in GetTransaction
Fix bug where GetTransaction was setting confirmations to the block height instead of calculating them correctly.
1 parent b23e283 commit 5b56413

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

wallet/wallet.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2607,14 +2607,20 @@ func (w *Wallet) GetTransaction(txHash chainhash.Hash) (*GetTransactionResult,
26072607
res = GetTransactionResult{
26082608
Summary: makeTxSummary(dbtx, w, txDetail),
26092609
Timestamp: txDetail.Block.Time.Unix(),
2610-
Confirmations: txDetail.Block.Height,
2610+
Confirmations: 0,
26112611
}
26122612

26132613
// If it is a confirmed transaction we set the corresponding
26142614
// block height and hash.
26152615
if txDetail.Block.Height != -1 {
26162616
res.Height = txDetail.Block.Height
26172617
res.BlockHash = &txDetail.Block.Hash
2618+
2619+
bestBlock := w.SyncedTo()
2620+
blockHeight := txDetail.Block.Height
2621+
res.Confirmations = calculateConfirmations(
2622+
blockHeight, bestBlock.Height,
2623+
)
26182624
}
26192625

26202626
return nil

0 commit comments

Comments
 (0)