| 246 | } |
| 247 | |
| 248 | Value dropprivkey(const Array& params, bool fHelp) { |
| 249 | if (fHelp || params.size() != 1) { |
| 250 | throw runtime_error( |
| 251 | "dropprivkey \"address\"\n" |
| 252 | "\ndrop keys for the given address.\n" |
| 253 | "\nResult:\n" |
| 254 | "\nExamples:\n" + |
| 255 | HelpExampleCli("dropprivkey", "\"wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4\"") + "\nAs a json rpc call\n" + |
| 256 | HelpExampleRpc("dropprivkey", "\"wLKf2NqwtHk3BfzK5wMDfbKYN1SC3weyR4\"")); |
| 257 | } |
| 258 | |
| 259 | EnsureWalletIsUnlocked(); |
| 260 | |
| 261 | CKeyID keyid = RPC_PARAM::GetKeyId(params[0]); |
| 262 | |
| 263 | CKey key; |
| 264 | if (!pWalletMain->GetKey(keyid, key)) |
| 265 | throw JSONRPCError(RPC_WALLET_ERROR, "Failed to acquire CKey from address."); |
| 266 | |
| 267 | if (!pWalletMain->RemoveKey(key)) |
| 268 | throw JSONRPCError(RPC_WALLET_ERROR, "Failed to drop privkey from wallet."); |
| 269 | |
| 270 | Object ret; |
| 271 | ret.push_back(Pair("info", "privkey was dropped.")); |
| 272 | |
| 273 | return ret; |
| 274 | } |
nothing calls this directly
no test coverage detected