Load ETH account balance also for accounts without any transactions #125

This commit is contained in:
Martin Boehm 2019-02-19 20:14:04 +01:00
parent d41adf0a4e
commit 347e1d5967

View File

@ -493,15 +493,14 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto
if err != nil {
return nil, nil, nil, 0, 0, 0, NewAPIError(fmt.Sprintf("Address not found, %v", err), true)
}
b, err := w.chain.EthereumTypeGetBalance(addrDesc)
if err != nil {
return nil, nil, nil, 0, 0, 0, errors.Annotatef(err, "EthereumTypeGetBalance %v", addrDesc)
}
if ca != nil {
ba = &db.AddrBalance{
Txs: uint32(ca.TotalTxs),
}
var b *big.Int
b, err = w.chain.EthereumTypeGetBalance(addrDesc)
if err != nil {
return nil, nil, nil, 0, 0, 0, errors.Annotatef(err, "EthereumTypeGetBalance %v", addrDesc)
}
if b != nil {
ba.BalanceSat = *b
}
@ -578,6 +577,13 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto
}
}
nonContractTxs = int(ca.NonContractTxs)
} else {
// addresses without any normal transactions can have internal transactions and therefore balance
if b != nil {
ba = &db.AddrBalance{
BalanceSat: *b,
}
}
}
return ba, tokens, ci, n, nonContractTxs, totalResults, nil
}