mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
wallet: add unlock_time details to show_transfers
also add a note when receiving the tx, because the user might not notice the "XXX blocks to unlock" in the balance.
This commit is contained in:
parent
f31438d9a6
commit
31f865f8e4
5 changed files with 30 additions and 7 deletions
|
@ -4970,7 +4970,7 @@ void simple_wallet::on_new_block(uint64_t height, const cryptonote::block& block
|
||||||
m_refresh_progress_reporter.update(height, false);
|
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, const cryptonote::subaddress_index& subaddr_index)
|
void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index, uint64_t unlock_time)
|
||||||
{
|
{
|
||||||
message_writer(console_color_green, false) << "\r" <<
|
message_writer(console_color_green, false) << "\r" <<
|
||||||
tr("Height ") << height << ", " <<
|
tr("Height ") << height << ", " <<
|
||||||
|
@ -4993,6 +4993,8 @@ void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_wallet->auto_confirm_churn() == 0) {
|
if (m_wallet->auto_confirm_churn() == 0) {
|
||||||
|
if (unlock_time)
|
||||||
|
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)
|
if (m_auto_refresh_refreshing)
|
||||||
m_cmd_binder.print_prompt();
|
m_cmd_binder.print_prompt();
|
||||||
else
|
else
|
||||||
|
@ -7731,6 +7733,8 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
|
||||||
local_args.erase(local_args.begin());
|
local_args.erase(local_args.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint64_t last_block_height = m_wallet->get_blockchain_current_height();
|
||||||
|
|
||||||
if (in || coinbase) {
|
if (in || coinbase) {
|
||||||
std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> payments;
|
std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> payments;
|
||||||
m_wallet->get_payments(payments, min_height, max_height, m_current_subaddress_account, subaddr_indices);
|
m_wallet->get_payments(payments, min_height, max_height, m_current_subaddress_account, subaddr_indices);
|
||||||
|
@ -7745,6 +7749,25 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
|
||||||
std::string destination = m_wallet->get_subaddress_as_str({m_current_subaddress_account, pd.m_subaddr_index.minor});
|
std::string destination = m_wallet->get_subaddress_as_str({m_current_subaddress_account, pd.m_subaddr_index.minor});
|
||||||
const std::string type = pd.m_coinbase ? tr("block") : tr("in");
|
const std::string type = pd.m_coinbase ? tr("block") : tr("in");
|
||||||
const bool unlocked = m_wallet->is_transfer_unlocked(pd.m_unlock_time, pd.m_block_height);
|
const bool unlocked = m_wallet->is_transfer_unlocked(pd.m_unlock_time, pd.m_block_height);
|
||||||
|
std::string locked_msg = "unlocked";
|
||||||
|
if (!unlocked)
|
||||||
|
{
|
||||||
|
locked_msg = "locked";
|
||||||
|
const uint64_t unlock_time = pd.m_unlock_time;
|
||||||
|
if (pd.m_unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER)
|
||||||
|
{
|
||||||
|
uint64_t bh = std::max(pd.m_unlock_time, pd.m_block_height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE);
|
||||||
|
if (bh >= last_block_height)
|
||||||
|
locked_msg = std::to_string(bh - last_block_height) + " blks";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint64_t current_time = static_cast<uint64_t>(time(NULL));
|
||||||
|
uint64_t threshold = current_time + (m_wallet->use_fork_rules(2, 0) ? CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2 : CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1);
|
||||||
|
if (threshold < pd.m_unlock_time)
|
||||||
|
locked_msg = get_human_readable_timespan(std::chrono::seconds(pd.m_unlock_time - threshold));
|
||||||
|
}
|
||||||
|
}
|
||||||
transfers.push_back({
|
transfers.push_back({
|
||||||
type,
|
type,
|
||||||
pd.m_block_height,
|
pd.m_block_height,
|
||||||
|
@ -7758,7 +7781,7 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
|
||||||
{{destination, pd.m_amount}},
|
{{destination, pd.m_amount}},
|
||||||
{pd.m_subaddr_index.minor},
|
{pd.m_subaddr_index.minor},
|
||||||
note,
|
note,
|
||||||
(unlocked) ? "unlocked" : "locked"
|
locked_msg
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,7 +312,7 @@ namespace cryptonote
|
||||||
|
|
||||||
//----------------- i_wallet2_callback ---------------------
|
//----------------- i_wallet2_callback ---------------------
|
||||||
virtual void on_new_block(uint64_t height, const cryptonote::block& block);
|
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, const cryptonote::subaddress_index& subaddr_index);
|
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, uint64_t unlock_time);
|
||||||
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_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 cryptonote::transaction& spend_tx, 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 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);
|
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx);
|
||||||
|
|
|
@ -157,7 +157,7 @@ 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, const cryptonote::subaddress_index& subaddr_index)
|
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, uint64_t unlock_time)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string tx_hash = epee::string_tools::pod_to_hex(txid);
|
std::string tx_hash = epee::string_tools::pod_to_hex(txid);
|
||||||
|
|
|
@ -2019,7 +2019,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||||
}
|
}
|
||||||
LOG_PRINT_L0("Received money: " << print_money(td.amount()) << ", with tx: " << txid);
|
LOG_PRINT_L0("Received money: " << print_money(td.amount()) << ", with tx: " << txid);
|
||||||
if (0 != m_callback)
|
if (0 != m_callback)
|
||||||
m_callback->on_money_received(height, txid, tx, td.m_amount, td.m_subaddr_index);
|
m_callback->on_money_received(height, txid, tx, td.m_amount, td.m_subaddr_index, td.m_tx.unlock_time);
|
||||||
}
|
}
|
||||||
total_received_1 += amount;
|
total_received_1 += amount;
|
||||||
notify = true;
|
notify = true;
|
||||||
|
@ -2089,7 +2089,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||||
|
|
||||||
LOG_PRINT_L0("Received money: " << print_money(td.amount()) << ", with tx: " << txid);
|
LOG_PRINT_L0("Received money: " << print_money(td.amount()) << ", with tx: " << txid);
|
||||||
if (0 != m_callback)
|
if (0 != m_callback)
|
||||||
m_callback->on_money_received(height, txid, tx, td.m_amount, td.m_subaddr_index);
|
m_callback->on_money_received(height, txid, tx, td.m_amount, td.m_subaddr_index, td.m_tx.unlock_time);
|
||||||
}
|
}
|
||||||
total_received_1 += extra_amount;
|
total_received_1 += extra_amount;
|
||||||
notify = true;
|
notify = true;
|
||||||
|
|
|
@ -118,7 +118,7 @@ private:
|
||||||
public:
|
public:
|
||||||
// Full wallet callbacks
|
// Full wallet callbacks
|
||||||
virtual void on_new_block(uint64_t height, const cryptonote::block& block) {}
|
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, const cryptonote::subaddress_index& subaddr_index) {}
|
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, uint64_t unlock_time) {}
|
||||||
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_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 cryptonote::transaction& spend_tx, 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 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) {}
|
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {}
|
||||||
|
|
Loading…
Reference in a new issue