Creates a new ons pay_type for show_transfers

The displaying of ONS transactions in show_transfers and
export_transfers previously showed the dummy destination address which
contained zero bytes and converted to a nonsense address. Created a new
ONS type for the display functions and removed the displaying of the destination
address.

In addition refactored how we determine that a transaction was either a
staking, ons or output transaction as we were previously parsing the
tx_extra where the data was already in the
cryptonote::transaction::type.

Finally renamed the wording for staking rewards. Previously "miner" now
"reward"
This commit is contained in:
Sean Darcy 2021-04-21 15:37:55 +10:00
parent 6d189d2ab0
commit 411af23b4b
5 changed files with 24 additions and 12 deletions

View File

@ -8548,6 +8548,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
case wallet::pay_type::miner: color = epee::console_color_cyan; break;
case wallet::pay_type::governance: color = epee::console_color_cyan; break;
case wallet::pay_type::stake: color = epee::console_color_blue; break;
case wallet::pay_type::ons: color = epee::console_color_blue; break;
case wallet::pay_type::service_node: color = epee::console_color_cyan; break;
default: color = epee::console_color_magenta; break;
}
@ -8568,6 +8569,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
if (transfer.pay_type == wallet::pay_type::in ||
transfer.pay_type == wallet::pay_type::governance ||
transfer.pay_type == wallet::pay_type::service_node ||
transfer.pay_type == wallet::pay_type::ons ||
transfer.pay_type == wallet::pay_type::miner)
destinations += output.address.substr(0, 6);
else

View File

@ -32,6 +32,7 @@
#include <string>
#include <vector>
#include "cryptonote_basic/subaddress_index.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "transfer_destination.h"
#include "crypto/hash.h"
@ -45,7 +46,8 @@ enum struct pay_type
stake,
miner,
service_node,
governance
governance,
ons
};
inline const char *pay_type_string(pay_type type)
@ -56,13 +58,24 @@ inline const char *pay_type_string(pay_type type)
case pay_type::in: return "in";
case pay_type::out: return "out";
case pay_type::stake: return "stake";
case pay_type::miner: return "miner";
case pay_type::ons: return "ons";
case pay_type::miner: return "reward";
case pay_type::service_node: return "snode";
case pay_type::governance: return "gov";
default: assert(false); return "xxxxx";
}
}
inline pay_type pay_type_from_tx(const cryptonote::transaction tx)
{
switch(tx.type)
{
case cryptonote::txtype::stake: return wallet::pay_type::stake;
case cryptonote::txtype::oxen_name_system: return wallet::pay_type::ons;
default: return wallet::pay_type::out;
}
}
OXEN_RPC_DOC_INTROSPECT
struct transfer_view
{

View File

@ -2546,10 +2546,6 @@ void wallet2::process_unconfirmed(const crypto::hash &txid, const cryptonote::tr
if(unconf_it != m_unconfirmed_txs.end()) {
if (store_tx_info()) {
try {
// TODO(doyle): ONS introduces tx type stake, we can use this to quickly determine if a transaction is staking
// transaction without having to parse tx_extra.
bool stake = service_nodes::tx_get_staking_components(tx, nullptr /*stake*/);
wallet::pay_type pay_type = stake ? wallet::pay_type::stake : wallet::pay_type::out;
m_confirmed_txs.insert(std::make_pair(txid, confirmed_transfer_details(unconf_it->second, height)));
}
catch (...) {
@ -2587,9 +2583,7 @@ void wallet2::process_outgoing(const crypto::hash &txid, const cryptonote::trans
}
entry.first->second.m_subaddr_account = subaddr_account;
entry.first->second.m_subaddr_indices = subaddr_indices;
bool stake = service_nodes::tx_get_staking_components(tx, nullptr /*stake*/);
entry.first->second.m_pay_type = stake ? wallet::pay_type::stake : wallet::pay_type::out;
entry.first->second.m_pay_type = wallet::pay_type_from_tx(tx);
}
entry.first->second.m_rings.clear();
@ -6330,6 +6324,8 @@ void wallet2::get_transfers(get_transfers_args_t args, std::vector<wallet::trans
bool add_entry = true;
if (args.stake && args_count == 1)
add_entry = o.second.m_pay_type == wallet::pay_type::stake;
if (args.ons && args_count == 1)
add_entry = o.second.m_pay_type == wallet::pay_type::ons;
if (add_entry)
transfers.push_back(make_transfer_view(o.first, o.second));
@ -6407,6 +6403,7 @@ std::string wallet2::transfers_to_csv(const std::vector<wallet::transfer_view>&
running_balance += transfer.amount;
break;
case wallet::pay_type::stake:
case wallet::pay_type::ons:
running_balance -= transfer.fee;
break;
case wallet::pay_type::out:
@ -6912,8 +6909,7 @@ void wallet2::add_unconfirmed_tx(const cryptonote::transaction& tx, uint64_t amo
utd.m_timestamp = time(NULL);
utd.m_subaddr_account = subaddr_account;
utd.m_subaddr_indices = subaddr_indices;
bool stake = service_nodes::tx_get_staking_components(tx, nullptr /*stake*/);
utd.m_pay_type = stake ? wallet::pay_type::stake : wallet::pay_type::out;
utd.m_pay_type = wallet::pay_type_from_tx(tx);
for (const auto &in: tx.vin)
{
if (!std::holds_alternative<cryptonote::txin_to_key>(in))

View File

@ -787,6 +787,7 @@ private:
bool in = false;
bool out = false;
bool stake = false;
bool ons = false;
bool pending = false;
bool failed = false;
bool pool = false;

View File

@ -2017,7 +2017,7 @@ namespace tools
{
res.in.push_back(std::move(entry));
}
else if (entry.pay_type == wallet::pay_type::out || entry.pay_type == wallet::pay_type::stake)
else if (entry.pay_type == wallet::pay_type::out || entry.pay_type == wallet::pay_type::stake || entry.pay_type == wallet::pay_type::ons)
{
res.out.push_back(std::move(entry));
}