@@ -576,18 +576,16 @@ static RPCHelpMan decodescript()
576
576
}
577
577
ScriptPubKeyToUniv (script, r, /* include_hex */ false );
578
578
579
- UniValue type ;
580
- type = find_value (r, " type " ) ;
579
+ std::vector<std::vector< unsigned char >> solutions_data ;
580
+ const TxoutType which_type{ Solver (script, solutions_data)} ;
581
581
582
- if (type. isStr () && type. get_str () != " scripthash " ) {
582
+ if (which_type != TxoutType::SCRIPTHASH ) {
583
583
// P2SH cannot be wrapped in a P2SH. If this script is already a P2SH,
584
584
// don't return the address for a P2SH of the P2SH.
585
585
r.pushKV (" p2sh" , EncodeDestination (ScriptHash (script)));
586
586
// P2SH and witness programs cannot be wrapped in P2WSH, if this script
587
587
// is a witness program, don't return addresses for a segwit programs.
588
- if (type.get_str () == " pubkey" || type.get_str () == " pubkeyhash" || type.get_str () == " multisig" || type.get_str () == " nonstandard" ) {
589
- std::vector<std::vector<unsigned char >> solutions_data;
590
- TxoutType which_type = Solver (script, solutions_data);
588
+ if (which_type == TxoutType::PUBKEY || which_type == TxoutType::PUBKEYHASH || which_type == TxoutType::MULTISIG || which_type == TxoutType::NONSTANDARD) {
591
589
// Uncompressed pubkeys cannot be used with segwit checksigs.
592
590
// If the script contains an uncompressed pubkey, skip encoding of a segwit program.
593
591
if ((which_type == TxoutType::PUBKEY) || (which_type == TxoutType::MULTISIG)) {
0 commit comments