fixes to the CLI wallet output of staking and protocol_tx outputs
This commit is contained in:
@@ -5742,20 +5742,49 @@ void simple_wallet::on_new_block(uint64_t height, const cryptonote::block& block
|
||||
m_refresh_progress_reporter.update(height, false);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const std::string& asset_type, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time)
|
||||
void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const std::string& asset_type, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time, const uint64_t& origin_td_idx)
|
||||
{
|
||||
if (m_locked)
|
||||
return;
|
||||
std::stringstream burn;
|
||||
if (burnt != 0) {
|
||||
burn << " (" << print_money(amount) << " yet " << print_money(burnt) << " was burnt)";
|
||||
}
|
||||
message_writer(asset_type == "SAL" ? console_color_green : console_color_yellow, false) << "\r" <<
|
||||
tr("Height ") << height << ", " <<
|
||||
tr("txid ") << txid << ", " <<
|
||||
print_money(amount - burnt) << burn.str() << " " << asset_type << ", " <<
|
||||
tr("idx ") << subaddr_index;
|
||||
|
||||
// Check for an origin TX
|
||||
if (tx.type == cryptonote::transaction_type::PROTOCOL) {
|
||||
|
||||
if (origin_td_idx != ((uint64_t)-1)) {
|
||||
// Should not happen - report error
|
||||
}
|
||||
|
||||
// Retrieve the TD from the wallet
|
||||
tools::wallet2::transfer_details td_origin = m_wallet->get_transfer_details(origin_td_idx);
|
||||
|
||||
if (td_origin.m_tx.type == cryptonote::transaction_type::BURN) {
|
||||
message_writer(console_color_red) << "\r" << "*** BURN ***";
|
||||
} else if (td_origin.m_tx.type == cryptonote::transaction_type::CONVERT) {
|
||||
message_writer(console_color_red) << "\r" << "*** CONVERT ***";
|
||||
} else if (td_origin.m_tx.type == cryptonote::transaction_type::YIELD) {
|
||||
message_writer(asset_type == "SAL" ? console_color_green : console_color_yellow, false) << "\r" <<
|
||||
tr("Height ") << height << ", " <<
|
||||
tr("txid ") << txid << ", " <<
|
||||
tr("stake returned ") << print_money(td_origin.m_tx.amount_burnt) << " " << td_origin.asset_type << " from height " << td_origin.m_block_height << ", " <<
|
||||
tr("idx ") << subaddr_index;
|
||||
|
||||
message_writer(asset_type == "SAL" ? console_color_green : console_color_yellow, false) << "\r" <<
|
||||
tr("Height ") << height << ", " <<
|
||||
tr("txid ") << txid << ", " <<
|
||||
tr("yield earned ") << print_money(amount - td_origin.m_tx.amount_burnt) << " " << asset_type << ", " <<
|
||||
tr("idx ") << subaddr_index;
|
||||
} else {
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
message_writer(asset_type == "SAL" ? console_color_green : console_color_yellow, false) << "\r" <<
|
||||
tr("Height ") << height << ", " <<
|
||||
tr("txid ") << txid << ", " <<
|
||||
print_money(amount) << " " << asset_type << ", " <<
|
||||
tr("idx ") << subaddr_index;
|
||||
}
|
||||
|
||||
const uint64_t warn_height = m_wallet->nettype() == TESTNET ? 1000000 : m_wallet->nettype() == STAGENET ? 50000 : 1650000;
|
||||
if (height >= warn_height && !is_change)
|
||||
{
|
||||
@@ -5787,6 +5816,7 @@ void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid,
|
||||
}
|
||||
if (unlock_time && !cryptonote::is_coinbase(tx))
|
||||
message_writer() << tr("NOTE: This transaction is locked, see details with: show_transfer ") + epee::string_tools::pod_to_hex(txid);
|
||||
|
||||
if (m_auto_refresh_refreshing)
|
||||
m_cmd_binder.print_prompt();
|
||||
else
|
||||
@@ -5809,6 +5839,24 @@ void simple_wallet::on_money_spent(uint64_t height, const crypto::hash &txid, co
|
||||
tr("txid ") << txid << ", " <<
|
||||
tr("spent ") << print_money(amount) << " " << asset_type << ", " <<
|
||||
tr("idx ") << subaddr_index;
|
||||
std::stringstream burn;
|
||||
if (in_tx.type == cryptonote::transaction_type::BURN) {
|
||||
message_writer(console_color_red, false) << "\r" <<
|
||||
tr("Height ") << height << ", " <<
|
||||
tr("txid ") << txid << ", " <<
|
||||
tr("burnt ") << print_money(in_tx.amount_burnt) << " " << asset_type;
|
||||
} else if (in_tx.type == cryptonote::transaction_type::CONVERT) {
|
||||
message_writer(console_color_yellow, false) << "\r" <<
|
||||
tr("Height ") << height << ", " <<
|
||||
tr("txid ") << txid << ", " <<
|
||||
tr("converting ") << print_money(in_tx.amount_burnt) << " " << asset_type;
|
||||
} else if (in_tx.type == cryptonote::transaction_type::YIELD) {
|
||||
message_writer(console_color_red, false) << "\r" <<
|
||||
tr("Height ") << height << ", " <<
|
||||
tr("txid ") << txid << ", " <<
|
||||
tr("staked ") << print_money(in_tx.amount_burnt) << " " << asset_type;
|
||||
} else {
|
||||
}
|
||||
if (m_auto_refresh_refreshing)
|
||||
m_cmd_binder.print_prompt();
|
||||
else
|
||||
|
||||
@@ -353,7 +353,7 @@ namespace cryptonote
|
||||
|
||||
//----------------- i_wallet2_callback ---------------------
|
||||
virtual void on_new_block(uint64_t height, const cryptonote::block& block);
|
||||
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const std::string& asset_type, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time);
|
||||
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const std::string& asset_type, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time, const uint64_t& origin_td_idx);
|
||||
virtual void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index);
|
||||
virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& in_tx, uint64_t amount, const std::string& asset_type, const cryptonote::transaction& spend_tx, const cryptonote::subaddress_index& subaddr_index);
|
||||
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define DEF_SALVIUM_VERSION_TAG "7f6b8da"
|
||||
#define DEF_SALVIUM_VERSION "0.0.4"
|
||||
#define DEF_SALVIUM_VERSION "0.0.5"
|
||||
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
|
||||
#define DEF_MONERO_VERSION "0.18.2.2"
|
||||
#define DEF_MONERO_RELEASE_NAME "Zero"
|
||||
|
||||
@@ -154,20 +154,20 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback
|
||||
}
|
||||
}
|
||||
|
||||
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time)
|
||||
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time, const uint64_t& tx_origin_idx)
|
||||
{
|
||||
|
||||
std::string tx_hash = epee::string_tools::pod_to_hex(txid);
|
||||
|
||||
LOG_PRINT_L3(__FUNCTION__ << ": money received. height: " << height
|
||||
<< ", tx: " << tx_hash
|
||||
<< ", amount: " << print_money(amount - burnt)
|
||||
<< ", burnt: " << print_money(burnt)
|
||||
<< ", raw_output_value: " << print_money(amount)
|
||||
<< ", amount: " << print_money(amount)
|
||||
<< ", burnt: " << print_money(tx.amount_burnt)
|
||||
<< ", raw_output_value: " << print_money(amount - tx.amount_burnt)
|
||||
<< ", idx: " << subaddr_index);
|
||||
// do not signal on received tx if wallet is not syncronized completely
|
||||
if (m_listener && m_wallet->synchronized()) {
|
||||
m_listener->moneyReceived(tx_hash, amount - burnt);
|
||||
m_listener->moneyReceived(tx_hash, amount - tx.amount_burnt);
|
||||
m_listener->updated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2101,6 +2101,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
std::vector<tx_scan_info_t> tx_scan_info(tx.vout.size());
|
||||
std::deque<bool> output_found(tx.vout.size(), false);
|
||||
uint64_t total_received_1 = 0;
|
||||
uint64_t origin_td_idx = ((uint64_t)-1);
|
||||
while (!tx.vout.empty())
|
||||
{
|
||||
std::vector<size_t> outs;
|
||||
@@ -2252,6 +2253,9 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
error::wallet_internal_error,
|
||||
"Failed to calculate uniqueness from origin TX");
|
||||
|
||||
// At this point, we know that we are receiving something - store the origin TD index
|
||||
origin_td_idx = idx;
|
||||
|
||||
// At this point, we need to clear the "locked coins" count, because otherwise we will be counting yield stakes twice in our balance
|
||||
|
||||
// Get the output key for the change entry
|
||||
@@ -2331,6 +2335,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
td.m_txid = txid;
|
||||
td.m_asset_type_output_index = asset_type_output_indices[o];
|
||||
td.asset_type = asset_type;
|
||||
td.m_origin_td_idx = origin_td_idx;
|
||||
td.m_key_image = tx_scan_info[o].ki;
|
||||
td.m_key_image_known = !m_watch_only && !m_multisig;
|
||||
if (!td.m_key_image_known)
|
||||
@@ -2389,7 +2394,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
}
|
||||
LOG_PRINT_L0("Received money: " << print_money(td.amount()) << ", with tx: " << txid);
|
||||
if (0 != m_callback)
|
||||
m_callback->on_money_received(height, txid, tx, td.m_amount, 0, td.asset_type, td.m_subaddr_index, spends_one_of_ours(tx), td.m_tx.unlock_time);
|
||||
m_callback->on_money_received(height, txid, tx, td.m_amount, td.asset_type, td.m_subaddr_index, spends_one_of_ours(tx), td.m_tx.unlock_time, td.m_origin_td_idx);
|
||||
}
|
||||
total_received_1 += amount;
|
||||
notify = true;
|
||||
@@ -2459,6 +2464,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
THROW_WALLET_EXCEPTION_IF(!cryptonote::get_output_asset_type(tx.vout[o], asset_type), error::wallet_internal_error, "failed to get output_asset_type");
|
||||
td.m_asset_type_output_index = asset_type_output_indices[o];
|
||||
td.asset_type = asset_type;
|
||||
td.m_origin_td_idx = origin_td_idx;
|
||||
td.m_amount = amount;
|
||||
td.m_pk_index = pk_index - 1;
|
||||
td.m_subaddr_index = tx_scan_info[o].received->index;
|
||||
@@ -2493,7 +2499,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
|
||||
LOG_PRINT_L0("Received money: " << print_money(td.amount()) << ", with tx: " << txid);
|
||||
if (0 != m_callback)
|
||||
m_callback->on_money_received(height, txid, tx, td.m_amount, burnt, td.asset_type, td.m_subaddr_index, spends_one_of_ours(tx), td.m_tx.unlock_time);
|
||||
m_callback->on_money_received(height, txid, tx, td.m_amount, td.asset_type, td.m_subaddr_index, spends_one_of_ours(tx), td.m_tx.unlock_time, td.m_origin_td_idx);
|
||||
}
|
||||
total_received_1 += extra_amount;
|
||||
notify = true;
|
||||
@@ -13411,6 +13417,7 @@ size_t wallet2::import_outputs(const std::tuple<uint64_t, uint64_t, std::vector<
|
||||
td.m_key_image_partial = false;
|
||||
td.m_subaddr_index.major = etd.m_subaddr_index_major;
|
||||
td.m_subaddr_index.minor = etd.m_subaddr_index_minor;
|
||||
td.m_origin_td_idx = ((uint64_t)-1);
|
||||
|
||||
// skip those we've already imported, or which have different data
|
||||
if (i + offset < original_size)
|
||||
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
// Full wallet callbacks
|
||||
virtual void on_new_block(uint64_t height, const cryptonote::block& block) {}
|
||||
virtual void on_reorg(uint64_t height, uint64_t blocks_detached, size_t transfers_detached) {}
|
||||
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const std::string& asset_type, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time) {}
|
||||
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const std::string& asset_type, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time, const uint64_t& origin_td_idx) {}
|
||||
virtual void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index) {}
|
||||
virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& in_tx, uint64_t amount, const std::string& asset_type, const cryptonote::transaction& spend_tx, const cryptonote::subaddress_index& subaddr_index) {}
|
||||
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {}
|
||||
@@ -346,6 +346,7 @@ private:
|
||||
std::vector<multisig_info> m_multisig_info; // one per other participant
|
||||
std::vector<std::pair<uint64_t, crypto::hash>> m_uses;
|
||||
std::string asset_type;
|
||||
uint64_t m_origin_td_idx;
|
||||
|
||||
bool is_rct() const { return m_rct; }
|
||||
uint64_t amount() const { return m_amount; }
|
||||
@@ -381,6 +382,7 @@ private:
|
||||
FIELD(m_multisig_info)
|
||||
FIELD(m_uses)
|
||||
FIELD(asset_type)
|
||||
FIELD(m_origin_td_idx)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user