Skip to content

Commit 61c6f10

Browse files
committed
Proposed fix for force_return errors.
We do not need to look up an address in the address book map just to check the type of the key in the map, as the type must be exactly the same as the provided destination. But if we don't find the destination in the map, we get back `end()` which is not a valid value and may have a `which_` field in the `boost::variant` that can trigger the assert.
1 parent 5d431f3 commit 61c6f10

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/wallet/rpcwallet.cpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -2200,11 +2200,8 @@ static void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const
22002200
entry.pushKV("account", account);
22012201
if (IsValidDestination(r.destination))
22022202
{
2203-
auto item = pwallet->mapAddressBook.find(r.destination);
2204-
if (item->first.type() == typeid(CKeyID))
2205-
entry.pushKV("address", EncodeDestination(r.destination, false));
2206-
else
2207-
entry.pushKV("address", EncodeDestination(r.destination));
2203+
entry.pushKV("address", EncodeDestination(
2204+
r.destination, r.destination.type() != typeid(CKeyID)));
22082205
}
22092206
if (wtx.IsCoinBase())
22102207
{
@@ -2517,11 +2514,8 @@ static void ExportTransactions(CWallet* const pwallet, const CWalletTx& wtx, con
25172514
csvRecord[TRANSACTION_CSV_FIELD_ACCOUNT] = account;
25182515
if ( IsValidDestination(r->destination) )
25192516
{
2520-
auto item = pwallet->mapAddressBook.find(r->destination);
2521-
if (item->first.type() == typeid(CKeyID))
2522-
csvRecord[TRANSACTION_CSV_FIELD_ADDRESS] = EncodeDestination(r->destination, false);
2523-
else
2524-
csvRecord[TRANSACTION_CSV_FIELD_ADDRESS] = EncodeDestination(r->destination);
2517+
csvRecord[TRANSACTION_CSV_FIELD_ADDRESS] = EncodeDestination(
2518+
r->destination, r->destination.type() != typeid(CKeyID));
25252519
}
25262520
if (wtx.IsCoinBase())
25272521
{

0 commit comments

Comments
 (0)