Skip to content

Commit 4daad19

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 7ea9f09 commit 4daad19

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
@@ -2601,14 +2601,20 @@ func (w *Wallet) GetTransaction(txHash chainhash.Hash) (*GetTransactionResult,
26012601
res = GetTransactionResult{
26022602
Summary: makeTxSummary(dbtx, w, txDetail),
26032603
Timestamp: txDetail.Block.Time.Unix(),
2604-
Confirmations: txDetail.Block.Height,
2604+
Confirmations: 0,
26052605
}
26062606

26072607
// If it is a confirmed transaction we set the corresponding
26082608
// block height and hash.
26092609
if txDetail.Block.Height != -1 {
26102610
res.Height = txDetail.Block.Height
26112611
res.BlockHash = &txDetail.Block.Hash
2612+
2613+
bestBlock := w.SyncedTo()
2614+
blockHeight := txDetail.Block.Height
2615+
res.Confirmations = calculateConfirmations(
2616+
blockHeight, bestBlock.Height,
2617+
)
26122618
}
26132619

26142620
return nil

0 commit comments

Comments
 (0)