Skip to content

Commit 86c3f8d

Browse files
committed
Remove createwitnessaddress
This RPC command is unsafe as it will return an address even if the script is invalid.
1 parent 2a0836f commit 86c3f8d

File tree

1 file changed

+0
-38
lines changed

1 file changed

+0
-38
lines changed

src/rpc/misc.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -321,43 +321,6 @@ UniValue createmultisig(const UniValue& params, bool fHelp)
321321
return result;
322322
}
323323

324-
UniValue createwitnessaddress(const UniValue& params, bool fHelp)
325-
{
326-
if (fHelp || params.size() < 1 || params.size() > 1)
327-
{
328-
string msg = "createwitnessaddress \"script\"\n"
329-
"\nCreates a witness address for a particular script.\n"
330-
"It returns a json object with the address and witness script.\n"
331-
332-
"\nArguments:\n"
333-
"1. \"script\" (string, required) A hex encoded script\n"
334-
335-
"\nResult:\n"
336-
"{\n"
337-
" \"address\":\"multisigaddress\", (string) The value of the new address (P2SH of witness script).\n"
338-
" \"witnessScript\":\"script\" (string) The string value of the hex-encoded witness script.\n"
339-
"}\n"
340-
;
341-
throw runtime_error(msg);
342-
}
343-
344-
if (!IsHex(params[0].get_str())) {
345-
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Script must be hex-encoded");
346-
}
347-
348-
std::vector<unsigned char> code = ParseHex(params[0].get_str());
349-
CScript script(code.begin(), code.end());
350-
CScript witscript = GetScriptForWitness(script);
351-
CScriptID witscriptid(witscript);
352-
CBitcoinAddress address(witscriptid);
353-
354-
UniValue result(UniValue::VOBJ);
355-
result.push_back(Pair("address", address.ToString()));
356-
result.push_back(Pair("witnessScript", HexStr(witscript.begin(), witscript.end())));
357-
358-
return result;
359-
}
360-
361324
UniValue verifymessage(const UniValue& params, bool fHelp)
362325
{
363326
if (fHelp || params.size() != 3)
@@ -493,7 +456,6 @@ static const CRPCCommand commands[] =
493456
{ "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */
494457
{ "util", "validateaddress", &validateaddress, true }, /* uses wallet if enabled */
495458
{ "util", "createmultisig", &createmultisig, true },
496-
{ "util", "createwitnessaddress", &createwitnessaddress, true },
497459
{ "util", "verifymessage", &verifymessage, true },
498460
{ "util", "signmessagewithprivkey", &signmessagewithprivkey, true },
499461

0 commit comments

Comments
 (0)