File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -535,7 +535,7 @@ UniValue decodescript(const UniValue& params, bool fHelp)
535
535
" \" address\" (string) bitcoin address\n "
536
536
" ,...\n "
537
537
" ],\n "
538
- " \" p2sh\" ,\" address\" (string) script address \n "
538
+ " \" p2sh\" ,\" address\" (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH). \n "
539
539
" }\n "
540
540
" \n Examples:\n "
541
541
+ HelpExampleCli (" decodescript" , " \" hexstring\" " )
@@ -554,7 +554,15 @@ UniValue decodescript(const UniValue& params, bool fHelp)
554
554
}
555
555
ScriptPubKeyToJSON (script, r, false );
556
556
557
- r.push_back (Pair (" p2sh" , CBitcoinAddress (CScriptID (script)).ToString ()));
557
+ UniValue type;
558
+ type = find_value (r, " type" );
559
+
560
+ if (type.isStr () && type.get_str () != " scripthash" ) {
561
+ // P2SH cannot be wrapped in a P2SH. If this script is already a P2SH,
562
+ // don't return the address for a P2SH of the P2SH.
563
+ r.push_back (Pair (" p2sh" , CBitcoinAddress (CScriptID (script)).ToString ()));
564
+ }
565
+
558
566
return r;
559
567
}
560
568
You can’t perform that action at this time.
0 commit comments