MCPcopy Create free account
hub / github.com/ElementsProject/elements / listlockunspent

Function listlockunspent

src/wallet/rpc/coins.cpp:434–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434RPCHelpMan listlockunspent()
435{
436 return RPCHelpMan{"listlockunspent",
437 "\nReturns list of temporarily unspendable outputs.\n"
438 "See the lockunspent call to lock and unlock transactions for spending.\n",
439 {},
440 RPCResult{
441 RPCResult::Type::ARR, "", "",
442 {
443 {RPCResult::Type::OBJ, "", "",
444 {
445 {RPCResult::Type::STR_HEX, "txid", "The transaction id locked"},
446 {RPCResult::Type::NUM, "vout", "The vout value"},
447 }},
448 }
449 },
450 RPCExamples{
451 "\nList the unspent transactions\n"
452 + HelpExampleCli("listunspent", "") +
453 "\nLock an unspent transaction\n"
454 + HelpExampleCli("lockunspent", "false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
455 "\nList the locked transactions\n"
456 + HelpExampleCli("listlockunspent", "") +
457 "\nUnlock the transaction again\n"
458 + HelpExampleCli("lockunspent", "true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
459 "\nAs a JSON-RPC call\n"
460 + HelpExampleRpc("listlockunspent", "")
461 },
462 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
463{
464 const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
465 if (!pwallet) return NullUniValue;
466
467 LOCK(pwallet->cs_wallet);
468
469 std::vector<COutPoint> vOutpts;
470 pwallet->ListLockedCoins(vOutpts);
471
472 UniValue ret(UniValue::VARR);
473
474 for (const COutPoint& outpt : vOutpts) {
475 UniValue o(UniValue::VOBJ);
476
477 o.pushKV("txid", outpt.hash.GetHex());
478 o.pushKV("vout", (int)outpt.n);
479 ret.push_back(o);
480 }
481
482 return ret;
483},
484 };
485}
486
487RPCHelpMan getbalances()
488{

Callers

nothing calls this directly

Calls 7

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
ListLockedCoinsMethod · 0.80
pushKVMethod · 0.45
GetHexMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected