aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-08-09 09:46:25 -0400
committerAndrew Chow <github@achow101.com>2023-09-12 12:14:31 -0400
commit07d3bdf4ebc06825ea24ab6f7c87aef6a22238c6 (patch)
tree11a23667794fcd9b4052230f9cfac00e9cb6b00d /src/rpc
parent1a98a51c666e9ae77364115775ec2e0ba984e8e0 (diff)
downloadbitcoin-07d3bdf4ebc06825ea24ab6f7c87aef6a22238c6.tar.xz
Add PubKeyDestination for P2PK scripts
P2PK scripts are not PKHash destinations, they should have their own type. This also results in no longer showing a p2pkh address for p2pk outputs. However for backwards compatibility, ListCoinst will still do this conversion.
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/output_script.cpp5
-rw-r--r--src/rpc/util.cpp5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/rpc/output_script.cpp b/src/rpc/output_script.cpp
index 4dd424fa14..f9343f48a8 100644
--- a/src/rpc/output_script.cpp
+++ b/src/rpc/output_script.cpp
@@ -280,6 +280,11 @@ static RPCHelpMan deriveaddresses()
for (const CScript& script : scripts) {
CTxDestination dest;
if (!ExtractDestination(script, dest)) {
+ // ExtractDestination no longer returns true for P2PK since it doesn't have a corresponding address
+ // However combo will output P2PK and should just ignore that script
+ if (scripts.size() > 1 && std::get_if<PubKeyDestination>(&dest)) {
+ continue;
+ }
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Descriptor does not have a corresponding address");
}
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index e5ee6d7496..9a941be181 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -253,6 +253,11 @@ public:
return UniValue(UniValue::VOBJ);
}
+ UniValue operator()(const PubKeyDestination& dest) const
+ {
+ return UniValue(UniValue::VOBJ);
+ }
+
UniValue operator()(const PKHash& keyID) const
{
UniValue obj(UniValue::VOBJ);