@@ -576,18 +576,16 @@ static RPCHelpMan decodescript()
576576 }
577577 ScriptPubKeyToUniv (script, r, /* include_hex */ false );
578578
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)} ;
581581
582- if (type. isStr () && type. get_str () != " scripthash " ) {
582+ if (which_type != TxoutType::SCRIPTHASH ) {
583583 // P2SH cannot be wrapped in a P2SH. If this script is already a P2SH,
584584 // don't return the address for a P2SH of the P2SH.
585585 r.pushKV (" p2sh" , EncodeDestination (ScriptHash (script)));
586586 // P2SH and witness programs cannot be wrapped in P2WSH, if this script
587587 // 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) {
591589 // Uncompressed pubkeys cannot be used with segwit checksigs.
592590 // If the script contains an uncompressed pubkey, skip encoding of a segwit program.
593591 if ((which_type == TxoutType::PUBKEY) || (which_type == TxoutType::MULTISIG)) {
0 commit comments