| 432 | } |
| 433 | |
| 434 | RPCHelpMan 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 | |
| 487 | RPCHelpMan getbalances() |
| 488 | { |
nothing calls this directly
no test coverage detected