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

Function listtransactions

src/wallet/rpc/transactions.cpp:485–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483}
484
485RPCHelpMan listtransactions()
486{
487 return RPCHelpMan{"listtransactions",
488 "\nIf a label name is provided, this will return only incoming transactions paying to addresses with the specified label.\n"
489 "\nReturns up to 'count' most recent transactions skipping the first 'from' transactions.\n",
490 {
491 {"label|dummy", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "If set, should be a valid label name to return only incoming transactions\n"
492 "with the specified label, or \"*\" to disable filtering and return all transactions."},
493 {"count", RPCArg::Type::NUM, RPCArg::Default{10}, "The number of transactions to return"},
494 {"skip", RPCArg::Type::NUM, RPCArg::Default{0}, "The number of transactions to skip"},
495 {"include_watchonly", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true for watch-only wallets, otherwise false"}, "Include transactions to watch-only addresses (see 'importaddress')"},
496 },
497 RPCResult{
498 RPCResult::Type::ARR, "", "",
499 {
500 {RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult>>(
501 {
502 {RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction."},
503 {RPCResult::Type::STR, "address", "The bitcoin address of the transaction."},
504 {RPCResult::Type::STR, "category", "The transaction category.\n"
505 "\"send\" Transactions sent.\n"
506 "\"receive\" Non-coinbase transactions received.\n"
507 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
508 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
509 "\"orphan\" Orphaned coinbase transactions received."},
510 {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n"
511 "for all other categories"},
512 {RPCResult::Type::STR, "label", /*optional=*/true, "A comment for the address/transaction, if any"},
513 {RPCResult::Type::NUM, "vout", "the vout value"},
514 {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the\n"
515 "'send' category of transactions."},
516 },
517 TransactionDescriptionString()),
518 {
519 {RPCResult::Type::BOOL, "abandoned", /*optional=*/true, "'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
520 "'send' category of transactions."},
521 })},
522 }
523 },
524 RPCExamples{
525 "\nList the most recent 10 transactions in the systems\n"
526 + HelpExampleCli("listtransactions", "") +
527 "\nList transactions 100 to 120\n"
528 + HelpExampleCli("listtransactions", "\"*\" 20 100") +
529 "\nAs a JSON-RPC call\n"
530 + HelpExampleRpc("listtransactions", "\"*\", 20, 100")
531 },
532 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
533{
534 const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
535 if (!pwallet) return NullUniValue;
536
537 // Make sure the results are valid at least up to the most recent block
538 // the user could have gotten from another RPC command prior to now
539 pwallet->BlockUntilSyncedToCurrentChain();
540
541 const std::string* filter_label = nullptr;
542 if (!request.params[0].isNull() && request.params[0].get_str() != "*") {

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
ParseIncludeWatchonlyFunction · 0.85
get_intMethod · 0.80
rbeginMethod · 0.80
rendMethod · 0.80
push_backVMethod · 0.80
CatFunction · 0.50

Tested by

no test coverage detected