@@ -300,6 +300,7 @@ static RPCHelpMan getrawtransactionmulti() {
300300 {" verbose" , RPCArg::Type::BOOL, RPCArg::Default{false },
301301 " If false, return a string, otherwise return a json object" },
302302 },
303+ // TODO: replace RPCResults to proper annotation
303304 RPCResults{},
304305 RPCExamples{
305306 HelpExampleCli (" getrawtransactionmulti" ,
@@ -366,6 +367,101 @@ static RPCHelpMan getrawtransactionmulti() {
366367 };
367368}
368369
370+ static RPCHelpMan getislocks ()
371+ {
372+ return RPCHelpMan{" getislocks" ,
373+ " \n Returns the raw InstantSend lock data for each txids. Returns Null if there is no known IS yet." ,
374+ {
375+ {" txids" , RPCArg::Type::ARR, RPCArg::Optional::NO, " The transaction ids (no more than 100)" ,
376+ {
377+ {" txid" , RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, " A transaction hash" },
378+ },
379+ },
380+ {" verbose" , RPCArg::Type::NUM, RPCArg::Default{1 }, " 0 for hex-encoded data, 1 for a json object" },
381+ },
382+ RPCResult{
383+ RPCResult::Type::ARR, " " , " Response is an array with the same size as the input txids" ,
384+ {
385+ RPCResult{" for verbose = 0 if InstantSend Lock is known for specified txid" ,
386+ RPCResult::Type::STR, " data" , " The serialized, hex-encoded data for 'txid'"
387+ },
388+ RPCResult{" for verbose = 1 if InstantSend Lock is known for specified txid" ,
389+ RPCResult::Type::OBJ, " " , " " ,
390+ {
391+ {RPCResult::Type::STR_HEX, " txid" , " The transaction id" },
392+ {RPCResult::Type::ARR, " inputs" , " The inputs" ,
393+ {
394+ {RPCResult::Type::OBJ, " " , " " ,
395+ {
396+ {RPCResult::Type::STR_HEX, " txid" , " The transaction id" },
397+ {RPCResult::Type::NUM, " vout" , " The output number" },
398+ },
399+ },
400+ }},
401+ {RPCResult::Type::STR_HEX, " cycleHash" , " The Cycle Hash" },
402+ {RPCResult::Type::STR_HEX, " signature" , " The InstantSend's BLS signature" },
403+ }},
404+ RPCResult{" if no InstantSend Lock is known for specified txid" ,
405+ RPCResult::Type::STR, " data" , " Just 'None' string"
406+ },
407+ }},
408+ RPCExamples{
409+ HelpExampleCli (" getislocks" , " '[\" txid\" ,...]'" )
410+ + HelpExampleRpc (" getislocks" , " '[\" txid\" ,...]'" )
411+ },
412+ [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
413+ {
414+ const NodeContext& node = EnsureAnyNodeContext (request.context );
415+
416+ UniValue result_arr (UniValue::VARR);
417+ UniValue txids = request.params [0 ].get_array ();
418+ if (txids.size () > 100 ) {
419+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Up to 100 txids only" );
420+ }
421+
422+ int verbose = 1 ;
423+ if (!request.params [1 ].isNull ()) {
424+ if (request.params [1 ].isBool ()) {
425+ verbose = request.params [1 ].get_bool () ? 1 : 0 ;
426+ } else {
427+ verbose = request.params [1 ].get_int ();
428+ }
429+ }
430+
431+ const LLMQContext& llmq_ctx = EnsureLLMQContext (node);
432+ for (const auto idx : irange::range (txids.size ())) {
433+ const uint256 txid (ParseHashV (txids[idx], " txid" ));
434+
435+ if (const llmq::CInstantSendLockPtr islock = llmq_ctx.isman ->GetInstantSendLockByTxid (txid); islock != nullptr ) {
436+ if (verbose == 1 ) {
437+ UniValue objIS (UniValue::VOBJ);
438+ objIS.pushKV (" txid" , islock->txid .ToString ());
439+ UniValue inputs (UniValue::VARR);
440+ for (const auto out : islock->inputs ) {
441+ UniValue outpoint (UniValue::VOBJ);
442+ outpoint.pushKV (" txid" , out.hash .ToString ());
443+ outpoint.pushKV (" vout" , static_cast <int64_t >(out.n ));
444+ inputs.push_back (outpoint);
445+ }
446+ objIS.pushKV (" inputs" , inputs);
447+ objIS.pushKV (" cycleHash" , islock->cycleHash .ToString ());
448+ objIS.pushKV (" sig" , islock->sig .ToString ());
449+ result_arr.push_back (objIS);
450+ } else {
451+ CDataStream ssTx (SER_NETWORK, PROTOCOL_VERSION);
452+ ssTx << *islock;
453+ result_arr.push_back (HexStr (ssTx));
454+ }
455+ } else {
456+ result_arr.push_back (" None" );
457+ }
458+ }
459+ return result_arr;
460+
461+ },
462+ };
463+ }
464+
369465static RPCHelpMan gettxchainlocks ()
370466{
371467 return RPCHelpMan{
@@ -2088,6 +2184,7 @@ static const CRPCCommand commands[] =
20882184 { " rawtransactions" , &getassetunlockstatuses, },
20892185 { " rawtransactions" , &getrawtransaction, },
20902186 { " rawtransactions" , &getrawtransactionmulti, },
2187+ { " rawtransactions" , &getislocks, },
20912188 { " rawtransactions" , &gettxchainlocks, },
20922189 { " rawtransactions" , &createrawtransaction, },
20932190 { " rawtransactions" , &decoderawtransaction, },
0 commit comments