Browse Source

Merge #8845: Don't return the address of a P2SH of a P2SH

d51f182 Don't return the address of a P2SH of a P2SH. (jnewbery)
0.14
Wladimir J. van der Laan 8 years ago
parent
commit
6e094e54f7
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 12
      src/rpc/rawtransaction.cpp

12
src/rpc/rawtransaction.cpp

@ -535,7 +535,7 @@ UniValue decodescript(const UniValue& params, bool fHelp) @@ -535,7 +535,7 @@ UniValue decodescript(const UniValue& params, bool fHelp)
" \"address\" (string) bitcoin address\n"
" ,...\n"
" ],\n"
" \"p2sh\",\"address\" (string) script address\n"
" \"p2sh\",\"address\" (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("decodescript", "\"hexstring\"")
@ -554,7 +554,15 @@ UniValue decodescript(const UniValue& params, bool fHelp) @@ -554,7 +554,15 @@ UniValue decodescript(const UniValue& params, bool fHelp)
}
ScriptPubKeyToJSON(script, r, false);
r.push_back(Pair("p2sh", CBitcoinAddress(CScriptID(script)).ToString()));
UniValue type;
type = find_value(r, "type");
if (type.isStr() && type.get_str() != "scripthash") {
// P2SH cannot be wrapped in a P2SH. If this script is already a P2SH,
// don't return the address for a P2SH of the P2SH.
r.push_back(Pair("p2sh", CBitcoinAddress(CScriptID(script)).ToString()));
}
return r;
}

Loading…
Cancel
Save