Correctly count unconfirmed txs in api GetAddress and GetXpub
parent
3d10d9c2c5
commit
3df1cc81ed
|
@ -657,6 +657,7 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco
|
|||
uBalSat big.Int
|
||||
totalReceived, totalSent *big.Int
|
||||
nonce string
|
||||
unconfirmedTxs int
|
||||
nonTokenTxs int
|
||||
totalResults int
|
||||
)
|
||||
|
@ -705,6 +706,7 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco
|
|||
} else {
|
||||
// skip already confirmed txs, mempool may be out of sync
|
||||
if tx.Confirmations == 0 {
|
||||
unconfirmedTxs++
|
||||
uBalSat.Add(&uBalSat, tx.getAddrVoutValue(addrDesc))
|
||||
uBalSat.Sub(&uBalSat, tx.getAddrVinValue(addrDesc))
|
||||
if page == 0 {
|
||||
|
@ -763,7 +765,7 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco
|
|||
Txs: int(ba.Txs),
|
||||
NonTokenTxs: nonTokenTxs,
|
||||
UnconfirmedBalanceSat: (*Amount)(&uBalSat),
|
||||
UnconfirmedTxs: len(txm),
|
||||
UnconfirmedTxs: unconfirmedTxs,
|
||||
Transactions: txs,
|
||||
Txids: txids,
|
||||
Tokens: tokens,
|
||||
|
|
22
api/xpub.go
22
api/xpub.go
|
@ -367,15 +367,16 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Acc
|
|||
inputOutput byte
|
||||
}
|
||||
var (
|
||||
txc xpubTxids
|
||||
txmMap map[string]*Tx
|
||||
txCount int
|
||||
txs []*Tx
|
||||
txids []string
|
||||
pg Paging
|
||||
filtered bool
|
||||
err error
|
||||
uBalSat big.Int
|
||||
txc xpubTxids
|
||||
txmMap map[string]*Tx
|
||||
txCount int
|
||||
txs []*Tx
|
||||
txids []string
|
||||
pg Paging
|
||||
filtered bool
|
||||
err error
|
||||
uBalSat big.Int
|
||||
unconfirmedTxs int
|
||||
)
|
||||
data, bestheight, err := w.getXpubData(xpub, page, txsOnPage, option, filter, gap)
|
||||
if err != nil {
|
||||
|
@ -426,6 +427,7 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Acc
|
|||
}
|
||||
// skip already confirmed txs, mempool may be out of sync
|
||||
if tx.Confirmations == 0 {
|
||||
unconfirmedTxs++
|
||||
uBalSat.Add(&uBalSat, tx.getAddrVoutValue(ad.addrDesc))
|
||||
uBalSat.Sub(&uBalSat, tx.getAddrVinValue(ad.addrDesc))
|
||||
if page == 0 && !foundTx && (useTxids == nil || useTxids(&txid, ad)) {
|
||||
|
@ -529,7 +531,7 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Acc
|
|||
TotalSentSat: (*Amount)(&data.sentSat),
|
||||
Txs: txCount,
|
||||
UnconfirmedBalanceSat: (*Amount)(&uBalSat),
|
||||
UnconfirmedTxs: len(txmMap),
|
||||
UnconfirmedTxs: unconfirmedTxs,
|
||||
Transactions: txs,
|
||||
Txids: txids,
|
||||
TotalTokens: totalTokens,
|
||||
|
|
Loading…
Reference in New Issue