MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / dropprivkey

Function dropprivkey

src/rpc/rpcdump.cpp:248–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248Value 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}

Callers

nothing calls this directly

Calls 10

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
EnsureWalletIsUnlockedFunction · 0.85
GetKeyIdFunction · 0.85
JSONRPCErrorFunction · 0.85
PairClass · 0.85
RemoveKeyMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45
GetKeyMethod · 0.45

Tested by

no test coverage detected