From 8be51e37cf5b4572303e98485867619d9f57e763 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Mon, 30 Dec 2013 12:44:51 -0500 Subject: [PATCH] Add handlers to unimplemented RPC requests. Fixes #29. --- cmdmgr.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/cmdmgr.go b/cmdmgr.go index c944c24..d4c5963 100644 --- a/cmdmgr.go +++ b/cmdmgr.go @@ -41,7 +41,7 @@ var ( type cmdHandler func(chan []byte, btcjson.Cmd) var rpcHandlers = map[string]cmdHandler{ - // Standard bitcoind methods + // Standard bitcoind methods (implemented) "dumpprivkey": DumpPrivKey, "getaddressesbyaccount": GetAddressesByAccount, "getbalance": GetBalance, @@ -55,6 +55,40 @@ var rpcHandlers = map[string]cmdHandler{ "walletlock": WalletLock, "walletpassphrase": WalletPassphrase, + // Standard bitcoind methods (currently unimplemented) + "addmultisigaddress": Unimplemented, + "backupwallet": Unimplemented, + "createmultisig": Unimplemented, + "dumpwallet": Unimplemented, + "getaccount": Unimplemented, + "getaccountaddress": Unimplemented, + "getrawchangeaddress": Unimplemented, + "getreceivedbyaccount": Unimplemented, + "getreceivedbyaddress": Unimplemented, + "gettransaction": Unimplemented, + "gettxout": Unimplemented, + "gettxoutsetinfo": Unimplemented, + "importwallet": Unimplemented, + "keypoolrefill": Unimplemented, + "listaddressgroupings": Unimplemented, + "listlockunspent": Unimplemented, + "listreceivedbyaccount": Unimplemented, + "listreceivedbyaddress": Unimplemented, + "listsinceblock": Unimplemented, + "listunspent": Unimplemented, + "lockunspent": Unimplemented, + "move": Unimplemented, + "sendtoaddress": Unimplemented, + "setaccount": Unimplemented, + "signmessage": Unimplemented, + "signrawtransaction": Unimplemented, + "validateaddress": Unimplemented, + "verifymessage": Unimplemented, + "walletpassphrasechange": Unimplemented, + + // Standard bitcoind methods which won't be implemented by btcwallet. + "encryptwallet": Unsupported, + // Extensions not exclusive to websocket connections. "createencryptedwallet": CreateEncryptedWallet, } @@ -171,6 +205,22 @@ func ReplySuccess(frontend chan []byte, id interface{}, result interface{}) { } } +// Unimplemented responds to an unimplemented RPC request with the +// appropiate error. +func Unimplemented(frontend chan []byte, icmd btcjson.Cmd) { + ReplyError(frontend, icmd.Id(), &btcjson.ErrUnimplemented) +} + +// Unsupported responds to an standard bitcoind RPC request which is +// unsupported by btcwallet due to design differences. +func Unsupported(frontend chan []byte, icmd btcjson.Cmd) { + e := &btcjson.Error{ + Code: -1, + Message: "Command unsupported by btcwallet", + } + ReplyError(frontend, icmd.Id(), e) +} + // DumpPrivKey replies to a dumpprivkey request with the private // key for a single address, or an appropiate error if the wallet // is locked.