Skip to content

Commit

Permalink
Bugfix: Don't return the address of a P2SH of a P2SH
Browse files Browse the repository at this point in the history
Github-Pull: bitcoin#8845
Rebased-From: cef66cbca48fa969c9fb3374f2892202a4fe31ac
  • Loading branch information
jnewbery authored and luke-jr committed Oct 5, 2016
1 parent 41cced2 commit 103c724
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/rpcrawtransaction.cpp
Expand Up @@ -461,7 +461,7 @@ Value decodescript(const Array& 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\"")
Expand All @@ -480,7 +480,15 @@ Value decodescript(const Array& 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;
}

Expand Down

0 comments on commit 103c724

Please sign in to comment.