Skip to content

Commit 722e9a4

Browse files
committed
wallet, rpc: add label to listsinceblock
1 parent 852891f commit 722e9a4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/wallet/rpc/transactions.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ RPCHelpMan listsinceblock()
552552
{"include_removed", RPCArg::Type::BOOL, RPCArg::Default{true}, "Show transactions that were removed due to a reorg in the \"removed\" array\n"
553553
"(not guaranteed to work on pruned nodes)"},
554554
{"include_change", RPCArg::Type::BOOL, RPCArg::Default{false}, "Also add entries for change outputs.\n"},
555+
{"label", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Return only incoming transactions paying to addresses with the specified label.\n"},
555556
},
556557
RPCResult{
557558
RPCResult::Type::OBJ, "", "",
@@ -634,6 +635,11 @@ RPCHelpMan listsinceblock()
634635
bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
635636
bool include_change = (!request.params[4].isNull() && request.params[4].get_bool());
636637

638+
std::optional<std::string> filter_label;
639+
if (!request.params[5].isNull()) {
640+
filter_label = request.params[5].get_str();
641+
}
642+
637643
int depth = height ? wallet.GetLastBlockHeight() + 1 - *height : -1;
638644

639645
UniValue transactions(UniValue::VARR);
@@ -642,7 +648,7 @@ RPCHelpMan listsinceblock()
642648
const CWalletTx& tx = pairWtx.second;
643649

644650
if (depth == -1 || abs(wallet.GetTxDepthInMainChain(tx)) < depth) {
645-
ListTransactions(wallet, tx, 0, true, transactions, filter, std::nullopt/* filter_label */, /*include_change=*/include_change);
651+
ListTransactions(wallet, tx, 0, true, transactions, filter, filter_label, include_change);
646652
}
647653
}
648654

@@ -659,7 +665,7 @@ RPCHelpMan listsinceblock()
659665
if (it != wallet.mapWallet.end()) {
660666
// We want all transactions regardless of confirmation count to appear here,
661667
// even negative confirmation ones, hence the big negative.
662-
ListTransactions(wallet, it->second, -100000000, true, removed, filter, std::nullopt/* filter_label */, /*include_change=*/include_change);
668+
ListTransactions(wallet, it->second, -100000000, true, removed, filter, filter_label, include_change);
663669
}
664670
}
665671
blockId = block.hashPrevBlock;
@@ -777,7 +783,7 @@ RPCHelpMan gettransaction()
777783
WalletTxToJSON(*pwallet, wtx, entry);
778784

779785
UniValue details(UniValue::VARR);
780-
ListTransactions(*pwallet, wtx, 0, false, details, filter, std::nullopt /* filter_label */);
786+
ListTransactions(*pwallet, wtx, 0, false, details, filter, /*filter_label=*/std::nullopt);
781787
entry.pushKV("details", details);
782788

783789
std::string strHex = EncodeHexTx(*wtx.tx, pwallet->chain().rpcSerializationFlags());

0 commit comments

Comments
 (0)