Skip to content

Commit 3382028

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 f0c222d commit 3382028

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

wallet/wallet.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,15 +2607,24 @@ func (w *Wallet) GetTransaction(txHash chainhash.Hash) (*GetTransactionResult,
26072607

26082608
res = GetTransactionResult{
26092609
Summary: makeTxSummary(dbtx, w, txDetail),
2610-
Timestamp: txDetail.Block.Time.Unix(),
2611-
Confirmations: txDetail.Block.Height,
2610+
BlockHash: nil,
2611+
Height: -1,
2612+
Confirmations: 0,
2613+
Timestamp: 0,
26122614
}
26132615

26142616
// If it is a confirmed transaction we set the corresponding
2615-
// block height and hash.
2617+
// block height, timestamp, and hash.
26162618
if txDetail.Block.Height != -1 {
2619+
res.Timestamp = txDetail.Block.Time.Unix()
26172620
res.Height = txDetail.Block.Height
26182621
res.BlockHash = &txDetail.Block.Hash
2622+
2623+
bestBlock := w.SyncedTo()
2624+
blockHeight := txDetail.Block.Height
2625+
res.Confirmations = calcConf(
2626+
blockHeight, bestBlock.Height,
2627+
)
26192628
}
26202629

26212630
return nil

0 commit comments

Comments
 (0)