Skip to content

Commit 6771222

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 6183dbb commit 6771222

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
@@ -2610,14 +2610,20 @@ func (w *Wallet) GetTransaction(txHash chainhash.Hash) (*GetTransactionResult,
26102610
res = GetTransactionResult{
26112611
Summary: makeTxSummary(dbtx, w, txDetail),
26122612
Timestamp: txDetail.Block.Time.Unix(),
2613-
Confirmations: txDetail.Block.Height,
2613+
Confirmations: 0,
26142614
}
26152615

26162616
// If it is a confirmed transaction we set the corresponding
26172617
// block height and hash.
26182618
if txDetail.Block.Height != -1 {
26192619
res.Height = txDetail.Block.Height
26202620
res.BlockHash = &txDetail.Block.Hash
2621+
2622+
bestBlock := w.SyncedTo()
2623+
blockHeight := txDetail.Block.Height
2624+
res.Confirmations = calculateConfirmations(
2625+
blockHeight, bestBlock.Height,
2626+
)
26212627
}
26222628

26232629
return nil

0 commit comments

Comments
 (0)