Skip to content

Commit 0354b87

Browse files
Merge #995: Proposed fix for (one type of) force_return errors.
61c6f10 Proposed fix for force_return errors. (Zannick) Pull request description: ## Issue When dealing with some orphan transactions[^1], some addresses aren't in the address map, and so when we look them up we get an invalid return value to indicate we didn't find it. However, we don't check for the sentinel value and instead try to look up its type (it's a `boost::variant`) which can assert with forced_return if the `which_` field is outside the valid range. [^1]: This only happened for me for months-old orphan blocks, and I can't tell if the address never existed or if it got corrupted at some point. ## Fix We don't need to look up an address in the map when all we're going to do is use the key (which must be the same type per `boost::variant`). ## Tested Windows 10 mainnet wallet. Tree-SHA512: ad16474dfdc4c0ca21fb1b36b34b38836e9769f0f4fef47468edb23ccc271e6903dec97e9e5bb602fa6d1ea123c315f17a0a1bd8264a98df4146728a096a0ecd
2 parents ab85642 + 61c6f10 commit 0354b87

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)