mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 17:03:46 +00:00
Add method getBalanceFromJs for work with address as bytes
This commit is contained in:
parent
3680cd5926
commit
58bc91afcf
1 changed files with 6 additions and 0 deletions
|
|
@ -134,6 +134,11 @@ func (dw *dbWrapper) getBalance(addr common.Address) *big.Int {
|
|||
return dw.db.GetBalance(addr)
|
||||
}
|
||||
|
||||
// getBalance retrieves an account's balance
|
||||
func (dw *dbWrapper) getBalanceFromJs(addr []byte) *big.Int {
|
||||
return dw.db.GetBalance(common.BytesToAddress(addr))
|
||||
}
|
||||
|
||||
// getNonce retrieves an account's nonce
|
||||
func (dw *dbWrapper) getNonce(addr common.Address) uint64 {
|
||||
return dw.db.GetNonce(addr)
|
||||
|
|
@ -159,6 +164,7 @@ func (dw *dbWrapper) toValue(vm *otto.Otto) otto.Value {
|
|||
value, _ := vm.ToValue(dw)
|
||||
obj := value.Object()
|
||||
obj.Set("getBalance", dw.getBalance)
|
||||
obj.Set("getBalanceFromJs", dw.getBalanceFromJs)
|
||||
obj.Set("getNonce", dw.getNonce)
|
||||
obj.Set("getCode", dw.getCode)
|
||||
obj.Set("getState", dw.getState)
|
||||
|
|
|
|||
Loading…
Reference in a new issue