mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge bitcoin/bitcoin#23642: refactor: Call type-solver earlier in decodescript
33330702081f67cb05fd86e00b252f6355249513 refactor: Call type-solver earlier in decodescript (MarcoFalke) fab0d998f4bf0f3f09afa51845d91408dd484408 style: Remove whitespace (MarcoFalke) Pull request description: The current logic is a bit confusing. First creating the `UniValue` return dict, then parsing it again to get the type as `std::string`. Clean this up by using a strong type `TxoutType`. Also, remove whitespace. ACKs for top commit: shaavan: ACK 33330702081f67cb05fd86e00b252f6355249513 theStack: Code-review ACK 33330702081f67cb05fd86e00b252f6355249513 Tree-SHA512: 49db7bc614d2491cd3ec0177d21ad1e9924dbece1eb5635290cd7fd18cb30adf4711b891daf522e7c4f6baab3033b66393bbfcd1d4726f24f90a433124f925d6
This commit is contained in:
parent
1e55310232
commit
61a0140362
@ -869,7 +869,8 @@ static RPCHelpMan decoderawtransaction()
|
|||||||
|
|
||||||
static RPCHelpMan decodescript()
|
static RPCHelpMan decodescript()
|
||||||
{
|
{
|
||||||
return RPCHelpMan{"decodescript",
|
return RPCHelpMan{
|
||||||
|
"decodescript",
|
||||||
"\nDecode a hex-encoded script.\n",
|
"\nDecode a hex-encoded script.\n",
|
||||||
{
|
{
|
||||||
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded script"},
|
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded script"},
|
||||||
@ -886,7 +887,7 @@ static RPCHelpMan decodescript()
|
|||||||
{RPCResult::Type::STR, "address", "Dash address"},
|
{RPCResult::Type::STR, "address", "Dash address"},
|
||||||
}},
|
}},
|
||||||
{RPCResult::Type::STR, "p2sh", "address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH)"},
|
{RPCResult::Type::STR, "p2sh", "address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH)"},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
RPCExamples{
|
RPCExamples{
|
||||||
HelpExampleCli("decodescript", "\"hexstring\"")
|
HelpExampleCli("decodescript", "\"hexstring\"")
|
||||||
@ -906,11 +907,10 @@ static RPCHelpMan decodescript()
|
|||||||
}
|
}
|
||||||
ScriptPubKeyToUniv(script, r, /* fIncludeHex */ false);
|
ScriptPubKeyToUniv(script, r, /* fIncludeHex */ false);
|
||||||
|
|
||||||
UniValue type;
|
std::vector<std::vector<unsigned char>> solutions_data;
|
||||||
|
const TxoutType which_type{Solver(script, solutions_data)};
|
||||||
|
|
||||||
type = find_value(r, "type");
|
if (which_type != TxoutType::SCRIPTHASH) {
|
||||||
|
|
||||||
if (type.isStr() && type.get_str() != "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)));
|
||||||
|
Loading…
Reference in New Issue
Block a user