mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
refactor: Call type-solver earlier in decodescript
Also, remove std::string type.
This commit is contained in:
parent
fab0d998f4
commit
3333070208
1 changed files with 4 additions and 6 deletions
|
@ -576,18 +576,16 @@ static RPCHelpMan decodescript()
|
||||||
}
|
}
|
||||||
ScriptPubKeyToUniv(script, r, /* include_hex */ false);
|
ScriptPubKeyToUniv(script, r, /* include_hex */ false);
|
||||||
|
|
||||||
UniValue type;
|
std::vector<std::vector<unsigned char>> solutions_data;
|
||||||
type = find_value(r, "type");
|
const TxoutType which_type{Solver(script, solutions_data)};
|
||||||
|
|
||||||
if (type.isStr() && type.get_str() != "scripthash") {
|
if (which_type != TxoutType::SCRIPTHASH) {
|
||||||
// P2SH cannot be wrapped in a P2SH. If this script is already a P2SH,
|
// 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.
|
// don't return the address for a P2SH of the P2SH.
|
||||||
r.pushKV("p2sh", EncodeDestination(ScriptHash(script)));
|
r.pushKV("p2sh", EncodeDestination(ScriptHash(script)));
|
||||||
// P2SH and witness programs cannot be wrapped in P2WSH, if this script
|
// P2SH and witness programs cannot be wrapped in P2WSH, if this script
|
||||||
// is a witness program, don't return addresses for a segwit programs.
|
// is a witness program, don't return addresses for a segwit programs.
|
||||||
if (type.get_str() == "pubkey" || type.get_str() == "pubkeyhash" || type.get_str() == "multisig" || type.get_str() == "nonstandard") {
|
if (which_type == TxoutType::PUBKEY || which_type == TxoutType::PUBKEYHASH || which_type == TxoutType::MULTISIG || which_type == TxoutType::NONSTANDARD) {
|
||||||
std::vector<std::vector<unsigned char>> solutions_data;
|
|
||||||
TxoutType which_type = Solver(script, solutions_data);
|
|
||||||
// Uncompressed pubkeys cannot be used with segwit checksigs.
|
// Uncompressed pubkeys cannot be used with segwit checksigs.
|
||||||
// If the script contains an uncompressed pubkey, skip encoding of a segwit program.
|
// If the script contains an uncompressed pubkey, skip encoding of a segwit program.
|
||||||
if ((which_type == TxoutType::PUBKEY) || (which_type == TxoutType::MULTISIG)) {
|
if ((which_type == TxoutType::PUBKEY) || (which_type == TxoutType::MULTISIG)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue