diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2534,8 +2534,8 @@ "progress report (in %) of the current scan"}, {"scanobjects", RPCArg::Type::ARR, - RPCArg::Optional::NO, - "Array of scan objects\n" + RPCArg::Optional::OMITTED, + "Array of scan objects. Required for \"start\" action\n" " Every scan object is either a " "string descriptor or an object:", { @@ -2628,6 +2628,13 @@ RPC_INVALID_PARAMETER, "Scan already in progress, use action \"abort\" or \"status\""); } + + if (request.params.size() < 2) { + throw JSONRPCError( + RPC_MISC_ERROR, + "scanobjects argument is required for the start action"); + } + std::set needles; std::map descriptors; Amount total_in = Amount::zero(); diff --git a/test/functional/rpc_scantxoutset.py b/test/functional/rpc_scantxoutset.py --- a/test/functional/rpc_scantxoutset.py +++ b/test/functional/rpc_scantxoutset.py @@ -216,6 +216,16 @@ 'pkh([0c5f9a1e/1/1/1500]03832901c250025da2aebae2bfb38d5c703a57ab66ad477f9c578bfbcd78abca6f)#vchwd07g', 'pkh([0c5f9a1e/1/1/1]030d820fc9e8211c4169be8530efbc632775d8286167afd178caaf1089b77daba7)#z2t3ypsa']) + # Check that status and abort don't need second arg + assert_equal(self.nodes[0].scantxoutset("status"), None) + assert_equal(self.nodes[0].scantxoutset("abort"), False) + + # Check that second arg is needed for start + assert_raises_rpc_error(-1, + "scanobjects argument is required for the start action", + self.nodes[0].scantxoutset, + "start") + if __name__ == '__main__': ScantxoutsetTest().main()