@@ -339,6 +339,48 @@ UniValue createmultisig(const UniValue& params, bool fHelp)
339
339
return result;
340
340
}
341
341
342
+ UniValue createblindedaddress (const UniValue& params, bool fHelp )
343
+ {
344
+ if (fHelp || params.size () != 2 )
345
+ {
346
+ string msg = " createblindedaddress address blinding_key\n "
347
+ " \n Creates a blinded address using the provided blinding key.\n "
348
+ " \n Arguments:\n "
349
+ " 1. \" address\" (string, required) The unblinded address to be blinded.\n "
350
+ " 2. \" key\" (string, required) The blinding private key.\n "
351
+ " \n Result:\n "
352
+ " \" blinded_address\" (string) The blinded address.\n "
353
+ " \n Examples:\n "
354
+ " \n Create a multisig address from 2 addresses\n "
355
+ + HelpExampleCli (" createblindedaddress" , " HEZk3iQi1jC49bxUriTtynnXgWWWdAYx16 ec09811118b6febfa5ebe68642e5091c418fbace07e655da26b4a845a691fc2d" ) +
356
+ " \n As a json rpc call\n "
357
+ + HelpExampleRpc (" createblindedaddress" , " HEZk3iQi1jC49bxUriTtynnXgWWWdAYx16, ec09811118b6febfa5ebe68642e5091c418fbace07e655da26b4a845a691fc2d" )
358
+ ;
359
+ throw runtime_error (msg);
360
+ }
361
+
362
+ CBitcoinAddress address (params[0 ].get_str ());
363
+ if (!address.IsValid ()) {
364
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Invalid Bitcoin address or script" );
365
+ }
366
+ if (address.IsBlinded ()) {
367
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Not an unblinded address" );
368
+ }
369
+
370
+ if (!IsHex (params[1 ].get_str ())) {
371
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Invalid hexadecimal for key" );
372
+ }
373
+ std::vector<unsigned char > keydata = ParseHex (params[1 ].get_str ());
374
+ if (keydata.size () != 32 ) {
375
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Invalid hexadecimal key length, must be 32 bytes long." );
376
+ }
377
+
378
+ CKey key;
379
+ key.Set (keydata.begin (), keydata.end (), true );
380
+
381
+ return address.AddBlindingKey (key.GetPubKey ()).ToString ();
382
+ }
383
+
342
384
UniValue verifymessage (const UniValue& params, bool fHelp )
343
385
{
344
386
if (fHelp || params.size () != 3 )
@@ -472,6 +514,7 @@ static const CRPCCommand commands[] =
472
514
{ " control" , " getinfo" , &getinfo, true }, /* uses wallet if enabled */
473
515
{ " util" , " validateaddress" , &validateaddress, true }, /* uses wallet if enabled */
474
516
{ " util" , " createmultisig" , &createmultisig, true },
517
+ { " util" , " createblindedaddress" , &createblindedaddress, true },
475
518
{ " util" , " verifymessage" , &verifymessage, true },
476
519
{ " util" , " signmessagewithprivkey" , &signmessagewithprivkey, true },
477
520
0 commit comments