From cb6cdac603af360de8bc472b672987a25776ea9b Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Mon, 17 Mar 2025 11:22:21 +0000 Subject: [PATCH] fixed sorting of yield_info output in CLI --- src/daemon/main.cpp | 13 ++++++------- src/simplewallet/simplewallet.cpp | 8 +++++++- src/wallet/wallet2.cpp | 2 +- src/wallet/wallet2.h | 5 ++++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp index 96a2719cd..68ebfd280 100644 --- a/src/daemon/main.cpp +++ b/src/daemon/main.cpp @@ -124,7 +124,7 @@ bool isFat32(const wchar_t* root_path) // Helper function to generate genesis transaction void print_genesis_tx_hex(const cryptonote::network_type nettype) { - /* + using namespace cryptonote; account_base miner_acc1; @@ -141,9 +141,9 @@ void print_genesis_tx_hex(const cryptonote::network_type nettype) { miner_key_file << "Miner account address:" << std::endl; miner_key_file << cryptonote::get_account_address_as_str((network_type)nettype, false, miner_acc1.get_keys().m_account_address); miner_key_file << std::endl<< "Miner spend secret key:" << std::endl; - epee::to_hex::formatted(miner_key_file, epee::as_byte_span(miner_acc1.get_keys().m_spend_secret_key)); + epee::to_hex::formatted(miner_key_file, epee::as_byte_span(unwrap(unwrap(miner_acc1.get_keys().m_spend_secret_key)))); miner_key_file << std::endl << "Miner view secret key:" << std::endl; - epee::to_hex::formatted(miner_key_file, epee::as_byte_span(miner_acc1.get_keys().m_view_secret_key)); + epee::to_hex::formatted(miner_key_file, epee::as_byte_span(unwrap(unwrap(miner_acc1.get_keys().m_view_secret_key)))); miner_key_file << std::endl << std::endl; miner_key_file.close(); @@ -153,13 +153,13 @@ void print_genesis_tx_hex(const cryptonote::network_type nettype) { std::cout << "Object:" << std::endl; std::cout << obj_to_json_str(tx_genesis) << std::endl << std::endl; - std::cout << "Gennerating miner wallet..." << std::endl; + std::cout << "Generating miner wallet..." << std::endl; std::cout << "Miner account address:" << std::endl; std::cout << cryptonote::get_account_address_as_str((network_type)nettype, false, miner_acc1.get_keys().m_account_address); std::cout << std::endl << "Miner spend secret key:" << std::endl; - epee::to_hex::formatted(std::cout, epee::as_byte_span(miner_acc1.get_keys().m_spend_secret_key)); + epee::to_hex::formatted(std::cout, epee::as_byte_span(unwrap(unwrap(miner_acc1.get_keys().m_spend_secret_key)))); std::cout << std::endl << "Miner view secret key:" << std::endl; - epee::to_hex::formatted(std::cout, epee::as_byte_span(miner_acc1.get_keys().m_view_secret_key)); + epee::to_hex::formatted(std::cout, epee::as_byte_span(unwrap(unwrap(miner_acc1.get_keys().m_view_secret_key)))); std::cout << std::endl << std::endl; std::stringstream ss; @@ -168,7 +168,6 @@ void print_genesis_tx_hex(const cryptonote::network_type nettype) { std::string tx_hex = ss.str(); std::cout << "Insert this line into your coin configuration file: " << std::endl; std::cout << "std::string const GENESIS_TX = \"" << epee::string_tools::buff_to_hex_nodelimer(tx_hex) << "\";" << std::endl; - */ return; } diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 5ad9fb2d6..b660b96b4 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -8549,12 +8549,18 @@ bool simple_wallet::yield_info(const std::vector &args) { // EXPERIMENTAL - change to get_yield_summary_info() method uint64_t t_burnt, t_supply, t_locked, t_yield, yps, ybi_size; - std::vector> yield_payouts; + std::vector yield_payouts; if (!m_wallet->get_yield_summary_info(t_burnt, t_supply, t_locked, t_yield, yps, ybi_size, yield_payouts)) { fail_msg_writer() << "failed to get yield info. Make sure you are connected to a daemon."; return false; } + // Resort the payouts so they're in height order + std::sort( yield_payouts.begin( ), yield_payouts.end( ), [ ]( const tools::wallet2::yield_payout_t& lhs, const tools::wallet2::yield_payout_t& rhs ) + { + return std::get<0>(lhs) < std::get<0>(rhs); + }); + // Get the chain height const uint64_t blockchain_height = m_wallet->get_blockchain_current_height(); uint64_t stake_lock_period = get_config(m_wallet->nettype()).STAKE_LOCK_PERIOD; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 30cea02b4..713a6c015 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2412,7 +2412,7 @@ bool wallet2::get_yield_summary_info(uint64_t &total_burnt, uint64_t &total_yield, uint64_t &yield_per_stake, uint64_t &ybi_data_size, - std::vector> &payouts + std::vector &payouts ) { // Get the total circulating supply of SALs diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 3851ae938..faffb7791 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1760,13 +1760,16 @@ private: bool get_pricing_record(oracle::pricing_record& pr, const uint64_t height); bool get_circulating_supply(std::vector> &amounts); bool get_yield_info(std::vector& ybi_data); + + typedef std::tuple yield_payout_t; + bool get_yield_summary_info(uint64_t &total_burnt, uint64_t &total_supply, uint64_t &total_locked, uint64_t &total_yield, uint64_t &yield_per_stake, uint64_t &ybi_data_size, - std::vector> &payouts + std::vector &payouts ); private: