MCPcopy Create free account
hub / github.com/ElementsProject/elements / importmasterblindingkey

Function importmasterblindingkey

src/wallet/rpc/backup.cpp:2103–2143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2101}
2102
2103RPCHelpMan importmasterblindingkey()
2104{
2105 return RPCHelpMan{"importmasterblindingkey",
2106 "\nImports a master private blinding key in hex for the wallet."
2107 "\nNote: wallets can only have one master blinding key at a time. Funds could be permanently lost if user doesn't know what they are doing. Recommended use is only for wallet recovery using this in conjunction with `sethdseed`.\n",
2108 {
2109 {"hexkey", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The blinding key in hex"},
2110 },
2111 RPCResult{RPCResult::Type::NONE, "", ""},
2112 RPCExamples{
2113 HelpExampleCli("importmasterblindingkey", "<hexkey>")
2114 },
2115 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
2116{
2117 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
2118 if (!wallet) return NullUniValue;
2119 CWallet* const pwallet = wallet.get();
2120
2121 LOCK(pwallet->cs_wallet);
2122
2123 if (!IsHex(request.params[0].get_str())) {
2124 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid hexadecimal for key");
2125 }
2126 std::vector<unsigned char> keydata = ParseHex(request.params[0].get_str());
2127 if (keydata.size() != 32) {
2128 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid hexadecimal key length");
2129 }
2130
2131 uint256 keyval;
2132 memcpy(keyval.begin(), &keydata[0], 32);
2133
2134 if (!pwallet->SetMasterBlindingKey(keyval)) {
2135 throw JSONRPCError(RPC_WALLET_ERROR, "Failed to import master blinding key");
2136 }
2137
2138 pwallet->MarkDirty();
2139
2140 return NullUniValue;
2141},
2142 };
2143}
2144
2145RPCHelpMan importissuanceblindingkey()
2146{

Callers

nothing calls this directly

Calls 10

HelpExampleCliFunction · 0.85
IsHexFunction · 0.85
JSONRPCErrorFunction · 0.85
ParseHexFunction · 0.85
SetMasterBlindingKeyMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
MarkDirtyMethod · 0.45

Tested by

no test coverage detected