parent
d0b942d414
commit
0b371b09e8
1 changed files with 39 additions and 1 deletions
40
cmdmgr.go
40
cmdmgr.go
|
@ -37,6 +37,7 @@ var rpcHandlers = map[string]cmdHandler{
|
|||
"getaccountaddress": GetAccountAddress,
|
||||
"getaddressesbyaccount": GetAddressesByAccount,
|
||||
"getbalance": GetBalance,
|
||||
"getinfo": GetInfo,
|
||||
"getnewaddress": GetNewAddress,
|
||||
"importprivkey": ImportPrivKey,
|
||||
"keypoolrefill": KeypoolRefill,
|
||||
|
@ -56,7 +57,6 @@ var rpcHandlers = map[string]cmdHandler{
|
|||
"createmultisig": Unimplemented,
|
||||
"dumpwallet": Unimplemented,
|
||||
"getblocktemplate": Unimplemented,
|
||||
"getinfo": Unimplemented,
|
||||
"getrawchangeaddress": Unimplemented,
|
||||
"getreceivedbyaccount": Unimplemented,
|
||||
"getreceivedbyaddress": Unimplemented,
|
||||
|
@ -335,6 +335,44 @@ func GetBalance(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
|||
return balance, nil
|
||||
}
|
||||
|
||||
// GetInfo handles a getinfo request by returning the a structure containing
|
||||
// information about the current state of btcwallet.
|
||||
// exist.
|
||||
func GetInfo(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||
|
||||
// Call down to btcd for all of the information in this command known
|
||||
// by them. This call can not realistically ever fail.
|
||||
gicmd, _ := btcjson.NewGetInfoCmd(<-NewJSONID)
|
||||
response := <-(CurrentRPCConn().SendRequest(NewRPCRequest(gicmd,
|
||||
make(map[string]interface{}))))
|
||||
if response.Err != nil {
|
||||
return nil, response.Err
|
||||
}
|
||||
ret := response.Result.(map[string]interface{})
|
||||
|
||||
balance := float64(0.0)
|
||||
accounts := accountstore.ListAccounts(1)
|
||||
for _, v := range accounts {
|
||||
balance += v
|
||||
}
|
||||
ret["walletversion"] = wallet.VersCurrent.Uint32()
|
||||
ret["balance"] = balance
|
||||
// Keypool times are not tracked. set to current time.
|
||||
ret["keypoololdest"] = time.Now().Unix()
|
||||
ret["keypoolsize"] = cfg.KeypoolSize
|
||||
TxFeeIncrement.Lock()
|
||||
ret["paytxfee"] = TxFeeIncrement.i
|
||||
TxFeeIncrement.Unlock()
|
||||
/*
|
||||
* We don't set the following since they don't make much sense in the
|
||||
* wallet architecture:
|
||||
* ret["unlocked_until"]
|
||||
* ret["errors"]
|
||||
*/
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// GetAccount handles a getaccount request by returning the account name
|
||||
// associated with a single address.
|
||||
func GetAccount(icmd btcjson.Cmd) (interface{}, *btcjson.Error) {
|
||||
|
|
Loading…
Reference in a new issue