Fix cli wallet showing wrong Owner value for backup owner

When doing a lookup by owner in simplewallet (`ons_by_owner`) the wallet
was always writing "Owner: ..." for whatever owner row was requested,
*not* the actual Owner row returned.

In particular, when we get back a record where WalletX is the backup
owner and WalletA is the primary owner then when looking up ons records
by owner for WalletX it would print:

Owner: WalletX
BackupOwner: WalletX

Instead of properly showing the record owner details of:

Owner: WalletA
BackupOwner: WalletX

This fixes it.
This commit is contained in:
Jason Rhinelander 2021-06-10 12:01:36 -03:00
parent 7fbe15e96b
commit 5b1ca27e2e
1 changed files with 1 additions and 12 deletions

View File

@ -7068,17 +7068,6 @@ bool simple_wallet::ons_by_owner(const std::vector<std::string>& args)
auto const &rpc = rpc_results[i];
for (auto const &entry : rpc)
{
std::string const *owner = nullptr;
try
{
owner = &requests[i].entries.at(entry.request_index);
}
catch (std::exception const &e)
{
fail_msg_writer() << "Daemon returned an invalid owner index = " << entry.request_index << " skipping mapping";
continue;
}
std::string_view name;
std::string value;
if (auto got = cache.find(entry.name_hash); got != cache.end())
@ -7100,7 +7089,7 @@ bool simple_wallet::ons_by_owner(const std::vector<std::string>& args)
if (!value.empty()) writer
<< "\n Value: " << value;
writer
<< "\n Owner: " << *owner;
<< "\n Owner: " << entry.owner;
if (entry.backup_owner) writer
<< "\n Backup owner: " << *entry.backup_owner;
writer