From e8941f064a96a584583b4d4c02af57441a5c12db Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 22 Mar 2022 11:49:58 +0100 Subject: [PATCH] rpc: Exclude descriptor when address is excluded Github-Pull: bitcoin#24636 Rebased-From: faf37c2 --- src/core_write.cpp | 8 +++++--- src/rpc/rawtransaction.cpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core_write.cpp b/src/core_write.cpp index d61b89900f..2192b41c9b 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -192,9 +192,11 @@ static void SidechainScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& o const std::string prefix = is_parent_chain ? "pegout_" : ""; CTxDestination address; - out.pushKV(prefix + "asm", ScriptToAsmStr(scriptPubKey)); - out.pushKV(prefix + "desc", InferDescriptor(scriptPubKey, DUMMY_SIGNING_PROVIDER)->ToString()); - if (include_hex) out.pushKV(prefix + "hex", HexStr(scriptPubKey)); + out.pushKV("asm", ScriptToAsmStr(scriptPubKey)); + if (include_addresses) { + out.pushKV("desc", InferDescriptor(scriptPubKey, DUMMY_SIGNING_PROVIDER)->ToString()); + } + if (include_hex) out.pushKV("hex", HexStr(scriptPubKey)); std::vector> solns; const TxoutType type{Solver(scriptPubKey, solns)}; diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index dd61387cc4..d1497c19c1 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1202,6 +1202,7 @@ static RPCHelpMan decodepsbt() {RPCResult::Type::OBJ, "scriptPubKey", "", { {RPCResult::Type::STR, "asm", "The asm"}, + {RPCResult::Type::STR, "desc", "Inferred descriptor for the output"}, {RPCResult::Type::STR_HEX, "hex", "The hex"}, {RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"}, {RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"},