diff --git a/api/worker.go b/api/worker.go index 3c29f6c0..05720374 100644 --- a/api/worker.go +++ b/api/worker.go @@ -678,18 +678,21 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option GetA for _, txid := range txm { tx, err := w.GetTransaction(txid, false, false) // mempool transaction may fail - if err != nil { - glog.Error("GetTransaction in mempool ", tx, ": ", err) + if err != nil || tx == nil { + glog.Warning("GetTransaction in mempool: ", err) } else { - uBalSat.Add(&uBalSat, tx.getAddrVoutValue(addrDesc)) - uBalSat.Sub(&uBalSat, tx.getAddrVinValue(addrDesc)) - if page == 0 { - if option == TxidHistory { - txids[txi] = tx.Txid - } else { - txs[txi] = tx + // skip already confirmed txs, mempool may be out of sync + if tx.Confirmations == 0 { + uBalSat.Add(&uBalSat, tx.getAddrVoutValue(addrDesc)) + uBalSat.Sub(&uBalSat, tx.getAddrVinValue(addrDesc)) + if page == 0 { + if option == TxidHistory { + txids[txi] = tx.Txid + } else { + txs[txi] = tx + } + txi++ } - txi++ } } } diff --git a/bchain/coins/eth/ethrpc.go b/bchain/coins/eth/ethrpc.go index 6f1cd31b..e33f2ab2 100644 --- a/bchain/coins/eth/ethrpc.go +++ b/bchain/coins/eth/ethrpc.go @@ -519,7 +519,7 @@ func (b *EthereumRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error) { // It could be optimized for mempool, i.e. without block time and confirmations func (b *EthereumRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) { tx, err := b.GetTransaction(txid) - // it there is an error getting the tx or the tx is confirmed, remove it from pending transactions + // if there is an error getting the tx or the tx is confirmed, remove it from pending transactions if err == bchain.ErrTxNotFound || (tx != nil && tx.Confirmations > 0) { b.pendingTransactionsLock.Lock() delete(b.pendingTransactions, txid)