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

Function dumpblindingkey

src/wallet/rpc/backup.cpp:2219–2259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2217}
2218
2219RPCHelpMan dumpblindingkey()
2220{
2221 return RPCHelpMan{"dumpblindingkey",
2222 "\nDumps the private blinding key for a CT address in hex."
2223 "\nNote: If the address is not a CT address, looks for blinding key corresponding to this non-CT address.",
2224 {
2225 {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The CT address"},
2226 },
2227 RPCResult{
2228 RPCResult::Type::STR, "blindingkey", "the blinding key",
2229 },
2230 RPCExamples{
2231 HelpExampleCli("dumpblindingkey", "\"my address\"")
2232 },
2233 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
2234{
2235 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
2236 if (!wallet) return NullUniValue;
2237 CWallet* const pwallet = wallet.get();
2238
2239 LOCK(pwallet->cs_wallet);
2240
2241 CTxDestination dest = DecodeDestination(request.params[0].get_str());
2242 if (!IsValidDestination(dest)) {
2243 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
2244 }
2245 CScript script = GetScriptForDestination(dest);
2246 CKey key;
2247 key = pwallet->GetBlindingKey(&script);
2248 if (key.IsValid()) {
2249 CPubKey pubkey(key.GetPubKey());
2250 if (IsBlindDestination(dest) && pubkey != GetDestinationBlindingKey(dest)) {
2251 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "CT address blinding key does not match the blinding key in wallet");
2252 }
2253 return HexStr(Span<const unsigned char>(key.begin(), key.size()));
2254 }
2255
2256 throw JSONRPCError(RPC_WALLET_ERROR, "Blinding key for address is unknown");
2257},
2258 };
2259}
2260
2261RPCHelpMan dumpmasterblindingkey()
2262{

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
JSONRPCErrorFunction · 0.85
GetScriptForDestinationFunction · 0.85
IsBlindDestinationFunction · 0.85
GetBlindingKeyMethod · 0.80
HexStrFunction · 0.50
getMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected