diff options
author | Determinant <[email protected]> | 2020-09-19 14:33:17 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2020-09-19 14:33:17 -0400 |
commit | eda06da4c762be9944fdc1dbb3c7786fc4719960 (patch) | |
tree | 751095c84c9a878647c96dc5a3c7f752a34c3332 /internal/ethapi | |
parent | bf037f27122dcc96849b4dd3d9f9f76c9bb26292 (diff) |
...
Diffstat (limited to 'internal/ethapi')
-rw-r--r-- | internal/ethapi/api.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9915ad4..9e50f64 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -555,6 +555,17 @@ func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Add return (*hexutil.Big)(state.GetBalance(address)), state.Error() } +// GetBalanceMultiCoin returns the amount of wei for the given address in the state of the +// given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta +// block numbers are also allowed. +func (s *PublicBlockChainAPI) GetBalanceMultiCoin(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash, coinID common.Hash) (*hexutil.Big, error) { + state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash) + if state == nil || err != nil { + return nil, err + } + return (*hexutil.Big)(state.GetBalanceMultiCoin(address, coinID)), state.Error() +} + // Result structs for GetProof type AccountResult struct { Address common.Address `json:"address"` |