@@ -2032,6 +2032,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2032
2032
" 2. \" scanobjects\" (array, optional) Array of scan objects (only one object type per scan object allowed)\n "
2033
2033
" [\n "
2034
2034
" { \" address\" : \" <address>\" }, (string, optional) Bitcoin address\n "
2035
+ " { \" script\" : \" <scriptPubKey>\" }, (string, optional) HEX encoded script (scriptPubKey)\n "
2035
2036
" { \" pubkey\" : (object, optional) Public key\n "
2036
2037
" {\n "
2037
2038
" \" pubkey\" : \" <pubkey\" >, (string, required) HEX encoded public key\n "
@@ -2089,14 +2090,17 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2089
2090
}
2090
2091
UniValue address_uni = find_value (scanobject, " address" );
2091
2092
UniValue pubkey_uni = find_value (scanobject, " pubkey" );
2093
+ UniValue script_uni = find_value (scanobject, " script" );
2092
2094
2093
2095
// make sure only one object type is present
2094
- if (1 != !address_uni.isNull () + !pubkey_uni.isNull ()) {
2096
+ if (1 != !address_uni.isNull () + !pubkey_uni.isNull () + !script_uni. isNull () ) {
2095
2097
throw JSONRPCError (RPC_INVALID_PARAMETER, " Only one object type is allowed per scan object" );
2096
2098
} else if (!address_uni.isNull () && !address_uni.isStr ()) {
2097
2099
throw JSONRPCError (RPC_INVALID_PARAMETER, " Scanobject \" address\" must contain a single string as value" );
2098
2100
} else if (!pubkey_uni.isNull () && !pubkey_uni.isObject ()) {
2099
2101
throw JSONRPCError (RPC_INVALID_PARAMETER, " Scanobject \" pubkey\" must contain an object as value" );
2102
+ } else if (!script_uni.isNull () && !script_uni.isStr ()) {
2103
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Scanobject \" script\" must contain a single string as value" );
2100
2104
} else if (address_uni.isStr ()) {
2101
2105
// type: address
2102
2106
// decode destination and derive the scriptPubKey
@@ -2117,8 +2121,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2117
2121
// check the script types and use the default if not provided
2118
2122
if (!script_types_uni.isNull () && !script_types_uni.isArray ()) {
2119
2123
throw JSONRPCError (RPC_INVALID_PARAMETER, " script_types must be an array" );
2120
- }
2121
- else if (script_types_uni.isNull ()) {
2124
+ } else if (script_types_uni.isNull ()) {
2122
2125
// use the default script types
2123
2126
script_types_uni = UniValue (UniValue::VARR);
2124
2127
for (const char *t : g_default_scantxoutset_script_types) {
@@ -2144,6 +2147,12 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2144
2147
assert (!script.empty ());
2145
2148
needles.insert (script);
2146
2149
}
2150
+ } else if (script_uni.isStr ()) {
2151
+ // type: script
2152
+ // check and add the script to the scan containers (needles array)
2153
+ CScript script (ParseHexV (script_uni, " script" ));
2154
+ // TODO: check script: max length, has OP, is unspenable etc.
2155
+ needles.insert (script);
2147
2156
}
2148
2157
}
2149
2158
0 commit comments