Skip to content

Commit 94d73d3

Browse files
committed
scantxoutset: support legacy P2PK script type
1 parent 892de1d commit 94d73d3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/rpc/blockchain.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
20362036
" { \"pubkey\" : (object, optional) Public key\n"
20372037
" {\n"
20382038
" \"pubkey\" : \"<pubkey\">, (string, required) HEX encoded public key\n"
2039-
" \"script_types\" : [ ... ], (array, optional) Array of script-types to derive from the pubkey (possible values: \"P2PKH\", \"P2SH-P2WPKH\", \"P2WPKH\")\n"
2039+
" \"script_types\" : [ ... ], (array, optional) Array of script-types to derive from the pubkey (possible values: \"P2PK\", \"P2PKH\", \"P2SH-P2WPKH\", \"P2WPKH\")\n"
20402040
" }\n"
20412041
" },\n"
20422042
" ]\n"
@@ -2142,8 +2142,13 @@ UniValue scantxoutset(const JSONRPCRequest& request)
21422142
for (const UniValue& script_type_uni : script_types_uni.get_array().getValues()) {
21432143
OutputScriptType script_type = GetOutputScriptTypeFromString(script_type_uni.get_str());
21442144
if (script_type == OutputScriptType::UNKNOWN) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid script type");
2145-
2146-
CScript script = GetScriptForDestination(GetDestinationForKey(pubkey, script_type));
2145+
CScript script;
2146+
if (script_type == OutputScriptType::P2PK) {
2147+
// support legacy P2PK scripts
2148+
script << ToByteVector(pubkey) << OP_CHECKSIG;
2149+
} else {
2150+
script = GetScriptForDestination(GetDestinationForKey(pubkey, script_type));
2151+
}
21472152
assert(!script.empty());
21482153
needles.insert(script);
21492154
}

0 commit comments

Comments
 (0)