@@ -316,7 +316,7 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
316
316
*/
317
317
template <class Vec >
318
318
static void ListTransactions (const CWallet& wallet, const CWalletTx& wtx, int nMinDepth, bool fLong ,
319
- Vec& ret, const isminefilter& filter_ismine, const std::string* filter_label,
319
+ Vec& ret, const isminefilter& filter_ismine, const std::optional<std:: string>& filter_label,
320
320
bool include_change = false )
321
321
EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
322
322
{
@@ -329,7 +329,7 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM
329
329
bool involvesWatchonly = CachedTxIsFromMe (wallet, wtx, ISMINE_WATCH_ONLY);
330
330
331
331
// Sent
332
- if (!filter_label)
332
+ if (!filter_label. has_value () )
333
333
{
334
334
for (const COutputEntry& s : listSent)
335
335
{
@@ -362,7 +362,7 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM
362
362
if (address_book_entry) {
363
363
label = address_book_entry->GetLabel ();
364
364
}
365
- if (filter_label && label != * filter_label) {
365
+ if (filter_label. has_value () && label != filter_label. value () ) {
366
366
continue ;
367
367
}
368
368
UniValue entry (UniValue::VOBJ);
@@ -485,10 +485,10 @@ RPCHelpMan listtransactions()
485
485
// the user could have gotten from another RPC command prior to now
486
486
pwallet->BlockUntilSyncedToCurrentChain ();
487
487
488
- const std::string* filter_label = nullptr ;
488
+ std::optional<std:: string> filter_label;
489
489
if (!request.params [0 ].isNull () && request.params [0 ].get_str () != " *" ) {
490
- filter_label = & request.params [0 ].get_str ();
491
- if (filter_label-> empty ()) {
490
+ filter_label = request.params [0 ].get_str ();
491
+ if (filter_label. value (). empty ()) {
492
492
throw JSONRPCError (RPC_INVALID_PARAMETER, " Label argument must be a valid label name or \" *\" ." );
493
493
}
494
494
}
@@ -642,7 +642,7 @@ RPCHelpMan listsinceblock()
642
642
const CWalletTx& tx = pairWtx.second ;
643
643
644
644
if (depth == -1 || abs (wallet.GetTxDepthInMainChain (tx)) < depth) {
645
- ListTransactions (wallet, tx, 0 , true , transactions, filter, /* filter_label= */ nullptr , /* include_change=*/ include_change);
645
+ ListTransactions (wallet, tx, 0 , true , transactions, filter, std::nullopt /* filter_label */ , /* include_change=*/ include_change);
646
646
}
647
647
}
648
648
@@ -659,7 +659,7 @@ RPCHelpMan listsinceblock()
659
659
if (it != wallet.mapWallet .end ()) {
660
660
// We want all transactions regardless of confirmation count to appear here,
661
661
// even negative confirmation ones, hence the big negative.
662
- ListTransactions (wallet, it->second , -100000000 , true , removed, filter, /* filter_label= */ nullptr , /* include_change=*/ include_change);
662
+ ListTransactions (wallet, it->second , -100000000 , true , removed, filter, std::nullopt /* filter_label */ , /* include_change=*/ include_change);
663
663
}
664
664
}
665
665
blockId = block.hashPrevBlock ;
@@ -777,7 +777,7 @@ RPCHelpMan gettransaction()
777
777
WalletTxToJSON (*pwallet, wtx, entry);
778
778
779
779
UniValue details (UniValue::VARR);
780
- ListTransactions (*pwallet, wtx, 0 , false , details, filter, /* filter_label= */ nullptr );
780
+ ListTransactions (*pwallet, wtx, 0 , false , details, filter, std::nullopt /* filter_label */ );
781
781
entry.pushKV (" details" , details);
782
782
783
783
std::string strHex = EncodeHexTx (*wtx.tx , pwallet->chain ().rpcSerializationFlags ());
0 commit comments