mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
add account balance to rpc
This commit is contained in:
parent
5875394cab
commit
ef66beb5cc
2 changed files with 13 additions and 0 deletions
|
|
@ -698,6 +698,10 @@ const Account_JS = `
|
||||||
web3._extend({
|
web3._extend({
|
||||||
property: 'account',
|
property: 'account',
|
||||||
methods: [
|
methods: [
|
||||||
|
new web3._extend.Property({
|
||||||
|
name: 'balance',
|
||||||
|
getter: 'account_balance'
|
||||||
|
}),
|
||||||
new web3._extend.Property({
|
new web3._extend.Property({
|
||||||
name: 'balanceCredit',
|
name: 'balanceCredit',
|
||||||
getter: 'account_balanceCredit'
|
getter: 'account_balanceCredit'
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,15 @@ func NewAccountingApi(m *AccountingMetrics) *AccountingApi {
|
||||||
return &AccountingApi{m}
|
return &AccountingApi{m}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Balance returns local node balance (units credited - units debited)
|
||||||
|
func (self *AccountingApi) Balance() (int64, error) {
|
||||||
|
if self.metrics == nil {
|
||||||
|
return 0, errNoAccountingMetrics
|
||||||
|
}
|
||||||
|
balance := mBalanceCredit.Count() - mBalanceDebit.Count()
|
||||||
|
return balance, nil
|
||||||
|
}
|
||||||
|
|
||||||
// BalanceCredit returns total amount of units credited by local node
|
// BalanceCredit returns total amount of units credited by local node
|
||||||
func (self *AccountingApi) BalanceCredit() (int64, error) {
|
func (self *AccountingApi) BalanceCredit() (int64, error) {
|
||||||
if self.metrics == nil {
|
if self.metrics == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue