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

Function createblindedaddress

src/rpc/misc.cpp:1044–1087  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1042
1043
1044static RPCHelpMan createblindedaddress()
1045{
1046 return RPCHelpMan{"createblindedaddress",
1047 "\nCreates a blinded address using the provided blinding key.\n",
1048 {
1049 {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The unblinded address to be blinded."},
1050 {"blinding_key", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The blinding public key. This can be obtained for a given address using `getaddressinfo` (`confidential_key` field)."},
1051 },
1052 RPCResult{
1053 RPCResult::Type::STR, "blinded_address", "The blinded address"
1054 },
1055 RPCExamples{
1056 "\nCreate a blinded address\n"
1057 + HelpExampleCli("createblindedaddress", "HEZk3iQi1jC49bxUriTtynnXgWWWdAYx16 ec09811118b6febfa5ebe68642e5091c418fbace07e655da26b4a845a691fc2d") +
1058 "\nAs a json rpc call\n"
1059 + HelpExampleRpc("createblindedaddress", "HEZk3iQi1jC49bxUriTtynnXgWWWdAYx16, ec09811118b6febfa5ebe68642e5091c418fbace07e655da26b4a845a691fc2d")
1060 },
1061 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1062{
1063 CTxDestination address = DecodeDestination(request.params[0].get_str());
1064 if (!IsValidDestination(address)) {
1065 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address or script");
1066 }
1067 if (IsBlindDestination(address)) {
1068 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Not an unblinded address");
1069 }
1070
1071 if (!IsHex(request.params[1].get_str())) {
1072 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid hexadecimal for key");
1073 }
1074 std::vector<unsigned char> keydata = ParseHex(request.params[1].get_str());
1075 if (keydata.size() != 33) {
1076 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid hexadecimal key length, must be length 66.");
1077 }
1078
1079 CPubKey key;
1080 key.Set(keydata.begin(), keydata.end());
1081
1082 // Append blinding key and return
1083 std::visit(BlindingPubkeyAdderVisitor(key), address);
1084 return EncodeDestination(address);
1085},
1086 };
1087}
1088
1089
1090// END ELEMENTS CALLS

Callers

nothing calls this directly

Calls 14

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
JSONRPCErrorFunction · 0.85
IsBlindDestinationFunction · 0.85
IsHexFunction · 0.85
ParseHexFunction · 0.85
EncodeDestinationFunction · 0.85
sizeMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected