1
0
Fork 0
forked from lthn/blockchain

added command to simplewallet for printing output distribution

This commit is contained in:
cryptozoidberg 2019-12-03 02:18:45 +01:00
parent 3eb68cb8fb
commit 91be33581a
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
4 changed files with 25 additions and 0 deletions

View file

@ -207,6 +207,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("fix_collisions", boost::bind(&simple_wallet::fix_collisions, this, _1), "Rescan transfers for key image collisions");
m_cmd_binder.set_handler("scan_transfers_for_id", boost::bind(&simple_wallet::scan_transfers_for_id, this, _1), "Rescan transfers for tx_id");
m_cmd_binder.set_handler("scan_transfers_for_ki", boost::bind(&simple_wallet::scan_transfers_for_ki, this, _1), "Rescan transfers for key image");
m_cmd_binder.set_handler("print_utxo_distribution", boost::bind(&simple_wallet::print_utxo_distribution, this, _1), "Prints utxo distribution");
m_cmd_binder.set_handler("address", boost::bind(&simple_wallet::print_address, this, _1), "Show current wallet public address");
m_cmd_binder.set_handler("integrated_address", boost::bind(&simple_wallet::integrated_address, this, _1), "integrated_address [<payment_id>|<integrated_address] - encodes given payment_id along with wallet's address into an integrated address (random payment_id will be used if none is provided). Decodes given integrated_address into standard address");
@ -949,6 +950,18 @@ bool simple_wallet::scan_transfers_for_ki(const std::vector<std::string> &args)
print_td_list(td);
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::print_utxo_distribution(const std::vector<std::string> &args)
{
std::map<uint64_t, uint64_t> distribution;
m_wallet->get_utxo_distribution(distribution);
for (auto& e : distribution)
{
message_writer() << std::left << setw(25) << print_money(e.first) << "|" << e.second;
}
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::get_transfer_info(const std::vector<std::string> &args)
{

View file

@ -67,6 +67,7 @@ namespace currency
bool fix_collisions(const std::vector<std::string> &args );
bool scan_transfers_for_id(const std::vector<std::string> &args);
bool scan_transfers_for_ki(const std::vector<std::string> &args);
bool print_utxo_distribution(const std::vector<std::string> &args);
bool show_blockchain_height(const std::vector<std::string> &args);
bool show_wallet_bcheight(const std::vector<std::string> &args);
bool transfer(const std::vector<std::string> &args);

View file

@ -2442,6 +2442,16 @@ void wallet2::sign_transfer_files(const std::string& tx_sources_file, const std:
THROW_IF_FALSE_WALLET_CMN_ERR_EX(r, "failed to store signed tx to file " << signed_tx_file);
}
//----------------------------------------------------------------------------------------------------
bool wallet2::get_utxo_distribution(std::map<uint64_t, uint64_t>& distribution)
{
prepare_free_transfers_cache(0);
for (auto ent : m_found_free_amounts)
{
distribution[ent.first] = ent.second.size();
}
return true;
}
//----------------------------------------------------------------------------------------------------
void wallet2::submit_transfer(const std::string& signed_tx_blob, currency::transaction& tx)
{
// decrypt sources

View file

@ -740,6 +740,7 @@ namespace tools
std::string get_log_prefix() const { return m_log_prefix; }
static uint64_t get_max_unlock_time_from_receive_indices(const currency::transaction& tx, const money_transfer2_details& td);
bool get_utxo_distribution(std::map<uint64_t, uint64_t>& distribution);
private:
void add_transfers_to_expiration_list(const std::vector<uint64_t>& selected_transfers, uint64_t expiration, uint64_t change_amount, const crypto::hash& related_tx_id);