From d186cf95c1e7d68ed96dd57acc011dd59b16bd39 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Thu, 14 Sep 2023 11:55:29 +0100 Subject: [PATCH] added the initial framework for the Fulmo-specific commands in the CLI wallet; more branding / renaming work --- src/blockchain_utilities/CMakeLists.txt | 18 ++-- src/daemon/CMakeLists.txt | 2 +- src/debug_utilities/CMakeLists.txt | 6 +- src/gen_multisig/CMakeLists.txt | 2 +- src/gen_ssl_cert/CMakeLists.txt | 2 +- src/simplewallet/simplewallet.cpp | 117 +++++++++++++++++++++++- src/simplewallet/simplewallet.h | 6 +- src/wallet/wallet2.h | 3 + 8 files changed, 139 insertions(+), 17 deletions(-) diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt index 224a9e63c..525adf369 100644 --- a/src/blockchain_utilities/CMakeLists.txt +++ b/src/blockchain_utilities/CMakeLists.txt @@ -157,7 +157,7 @@ endif() set_property(TARGET blockchain_import PROPERTY - OUTPUT_NAME "monero-blockchain-import") + OUTPUT_NAME "fulmo-blockchain-import") install(TARGETS blockchain_import DESTINATION bin) monero_add_executable(blockchain_export @@ -178,7 +178,7 @@ target_link_libraries(blockchain_export set_property(TARGET blockchain_export PROPERTY - OUTPUT_NAME "monero-blockchain-export") + OUTPUT_NAME "fulmo-blockchain-export") install(TARGETS blockchain_export DESTINATION bin) monero_add_executable(blockchain_blackball @@ -200,7 +200,7 @@ target_link_libraries(blockchain_blackball set_property(TARGET blockchain_blackball PROPERTY - OUTPUT_NAME "monero-blockchain-mark-spent-outputs") + OUTPUT_NAME "fulmo-blockchain-mark-spent-outputs") install(TARGETS blockchain_blackball DESTINATION bin) @@ -222,7 +222,7 @@ target_link_libraries(blockchain_usage set_property(TARGET blockchain_usage PROPERTY - OUTPUT_NAME "monero-blockchain-usage") + OUTPUT_NAME "fulmo-blockchain-usage") install(TARGETS blockchain_usage DESTINATION bin) monero_add_executable(blockchain_ancestry @@ -243,7 +243,7 @@ target_link_libraries(blockchain_ancestry set_property(TARGET blockchain_ancestry PROPERTY - OUTPUT_NAME "monero-blockchain-ancestry") + OUTPUT_NAME "fulmo-blockchain-ancestry") install(TARGETS blockchain_ancestry DESTINATION bin) monero_add_executable(blockchain_depth @@ -264,7 +264,7 @@ target_link_libraries(blockchain_depth set_property(TARGET blockchain_depth PROPERTY - OUTPUT_NAME "monero-blockchain-depth") + OUTPUT_NAME "fulmo-blockchain-depth") install(TARGETS blockchain_depth DESTINATION bin) monero_add_executable(blockchain_stats @@ -285,7 +285,7 @@ target_link_libraries(blockchain_stats set_property(TARGET blockchain_stats PROPERTY - OUTPUT_NAME "monero-blockchain-stats") + OUTPUT_NAME "fulmo-blockchain-stats") install(TARGETS blockchain_stats DESTINATION bin) monero_add_executable(blockchain_prune_known_spent_data @@ -307,7 +307,7 @@ target_link_libraries(blockchain_prune_known_spent_data set_property(TARGET blockchain_prune_known_spent_data PROPERTY - OUTPUT_NAME "monero-blockchain-prune-known-spent-data") + OUTPUT_NAME "fulmo-blockchain-prune-known-spent-data") install(TARGETS blockchain_prune_known_spent_data DESTINATION bin) monero_add_executable(blockchain_prune @@ -316,7 +316,7 @@ monero_add_executable(blockchain_prune set_property(TARGET blockchain_prune PROPERTY - OUTPUT_NAME "monero-blockchain-prune") + OUTPUT_NAME "fulmo-blockchain-prune") install(TARGETS blockchain_prune DESTINATION bin) target_link_libraries(blockchain_prune diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index cc32afbea..02f0463b1 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -71,5 +71,5 @@ target_link_libraries(daemon ${Blocks}) set_property(TARGET daemon PROPERTY - OUTPUT_NAME "elbowd") + OUTPUT_NAME "fulmod") install(TARGETS daemon DESTINATION bin) diff --git a/src/debug_utilities/CMakeLists.txt b/src/debug_utilities/CMakeLists.txt index 58cb713df..44ceed669 100644 --- a/src/debug_utilities/CMakeLists.txt +++ b/src/debug_utilities/CMakeLists.txt @@ -46,7 +46,7 @@ target_link_libraries(cn_deserialize set_property(TARGET cn_deserialize PROPERTY - OUTPUT_NAME "monero-utils-deserialize") + OUTPUT_NAME "fulmo-utils-deserialize") set(object_sizes_sources @@ -67,7 +67,7 @@ target_link_libraries(object_sizes set_property(TARGET object_sizes PROPERTY - OUTPUT_NAME "monero-utils-object-sizes") + OUTPUT_NAME "fulmo-utils-object-sizes") set(dns_checks_sources @@ -89,5 +89,5 @@ target_link_libraries(dns_checks set_property(TARGET dns_checks PROPERTY - OUTPUT_NAME "monero-utils-dns-checks") + OUTPUT_NAME "fulmo-utils-dns-checks") diff --git a/src/gen_multisig/CMakeLists.txt b/src/gen_multisig/CMakeLists.txt index e88d21902..0145901ab 100644 --- a/src/gen_multisig/CMakeLists.txt +++ b/src/gen_multisig/CMakeLists.txt @@ -50,5 +50,5 @@ add_dependencies(gen_multisig version) set_property(TARGET gen_multisig PROPERTY - OUTPUT_NAME "monero-gen-trusted-multisig") + OUTPUT_NAME "fulmo-gen-trusted-multisig") install(TARGETS gen_multisig DESTINATION bin) diff --git a/src/gen_ssl_cert/CMakeLists.txt b/src/gen_ssl_cert/CMakeLists.txt index e86518844..38d13f5fe 100644 --- a/src/gen_ssl_cert/CMakeLists.txt +++ b/src/gen_ssl_cert/CMakeLists.txt @@ -45,5 +45,5 @@ add_dependencies(gen_ssl_cert version) set_property(TARGET gen_ssl_cert PROPERTY - OUTPUT_NAME "monero-gen-ssl-cert") + OUTPUT_NAME "fulmo-gen-ssl-cert") install(TARGETS gen_ssl_cert DESTINATION bin) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 02955fcaf..811b18449 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -196,7 +196,11 @@ namespace const char* USAGE_SWEEP_ACCOUNT("sweep_account [index=[,,...] | index=all] [] [] [outputs=]
[]"); const char* USAGE_SWEEP_BELOW("sweep_below [index=[,,...]] [] []
[]"); const char* USAGE_SWEEP_SINGLE("sweep_single [] [] [outputs=]
[]"); + const char* USAGE_BURN("burn [index=[,,...]] "); const char* USAGE_CONVERT("convert [index=[,,...]] [] [] ( |
) []"); + const char* USAGE_PRICE_INFO("price_info"); + const char* USAGE_SUPPLY_INFO("supply_info"); + const char* USAGE_YIELD_INFO("yield_info"); const char* USAGE_DONATE("donate [index=[,,...]] [] [] []"); const char* USAGE_SIGN_TRANSFER("sign_transfer [export_raw] []"); const char* USAGE_SET_LOG("set_log |{+,-,}"); @@ -3108,10 +3112,26 @@ simple_wallet::simple_wallet() boost::bind(&simple_wallet::on_command, this, &simple_wallet::sweep_single, _1), tr(USAGE_SWEEP_SINGLE), tr("Send a single output of the given key image to an address without change.")); + m_cmd_binder.set_handler("burn", + boost::bind(&simple_wallet::burn, this, _1), + tr(USAGE_BURN), + tr("PERMANENTLY destroys (burns) of ")); m_cmd_binder.set_handler("convert", boost::bind(&simple_wallet::convert, this, _1), tr(USAGE_CONVERT), - tr("Converts Fulmo (FULM) to Fulmo Dollars (FUSD), with optional [0-5]")); + tr("Converts into , with optional [0-5]")); + m_cmd_binder.set_handler("price_info", + boost::bind(&simple_wallet::price_info, this, _1), + tr(USAGE_PRICE_INFO), + tr("Displays the current exchange rate information for FULM <--> FUSD conversions")); + m_cmd_binder.set_handler("supply_info", + boost::bind(&simple_wallet::supply_info, this, _1), + tr(USAGE_SUPPLY_INFO), + tr("Displays the current circulating supply information for FULM and FUSD currencies")); + m_cmd_binder.set_handler("yield_info", + boost::bind(&simple_wallet::yield_info, this, _1), + tr(USAGE_YIELD_INFO), + tr("Displays the statistics for yield returns over the last blocks")); m_cmd_binder.set_handler("donate", boost::bind(&simple_wallet::on_command, this, &simple_wallet::donate, _1), tr(USAGE_DONATE), @@ -7484,6 +7504,32 @@ bool simple_wallet::sweep_below(const std::vector &args_) return true; } //---------------------------------------------------------------------------------------------------- +bool simple_wallet::burn(const std::vector &args_) +{ + // TODO: add locked versions + if (args_.size() < 3) + { + PRINT_USAGE(USAGE_BURN); + return true; + } + + std::vector local_args = args_; + + // Get the asset type + std::string asset_type; + std::string strLastArg = local_args.back(); + std::transform(strLastArg.begin(), strLastArg.end(), strLastArg.begin(), ::toupper); + if (strLastArg not_eq "FULM" and strLastArg not_eq "FUSD") { + PRINT_USAGE(USAGE_BURN); + return true; + } + asset_type = strLastArg; + local_args.pop_back(); + + transfer_main(Transfer, asset_type, "", local_args, false); + return true; +} +//---------------------------------------------------------------------------------------------------- bool simple_wallet::convert(const std::vector &args_) { // TODO: add locked versions @@ -7530,6 +7576,75 @@ bool simple_wallet::convert(const std::vector &args_) return true; } //---------------------------------------------------------------------------------------------------- +bool simple_wallet::price_info(const std::vector &args) { + // get circulating supply + std::vector> supply_amounts; + if(!m_wallet->get_circulating_supply(supply_amounts)) { + fail_msg_writer() << "failed to get circulating supply. Make sure you are connected to a daemon."; + return false; + } + + // get pricing record + std::string err; + uint64_t bc_height = get_daemon_blockchain_height(err); + oracle::pricing_record pr; + if (!m_wallet->get_pricing_record(pr, bc_height-1)) { + fail_msg_writer() << "failed to get pricing record. Make sure you are connected to a daemon."; + return false; + } + + // calculate current block cap + //uint64_t block_cap = cryptonote::get_block_cap(supply_amounts, pr, m_wallet->get_current_hard_fork()); + //message_writer() << boost::format(tr("Current Block Cap(height %d): %d XHV")) % bc_height % print_money(block_cap); + return true; +} +//---------------------------------------------------------------------------------------------------- +bool simple_wallet::supply_info(const std::vector &args) { + // get circulating supply + std::vector> supply_amounts; + if(!m_wallet->get_circulating_supply(supply_amounts)) { + fail_msg_writer() << "failed to get circulating supply. Make sure you are connected to a daemon."; + return false; + } + + // get pricing record + std::string err; + uint64_t bc_height = get_daemon_blockchain_height(err); + oracle::pricing_record pr; + if (!m_wallet->get_pricing_record(pr, bc_height-1)) { + fail_msg_writer() << "failed to get pricing record. Make sure you are connected to a daemon."; + return false; + } + + // calculate current block cap + //uint64_t block_cap = cryptonote::get_block_cap(supply_amounts, pr, m_wallet->get_current_hard_fork()); + //message_writer() << boost::format(tr("Current Block Cap(height %d): %d XHV")) % bc_height % print_money(block_cap); + return true; +} +//---------------------------------------------------------------------------------------------------- +bool simple_wallet::yield_info(const std::vector &args) { + // get circulating supply + std::vector> supply_amounts; + if(!m_wallet->get_circulating_supply(supply_amounts)) { + fail_msg_writer() << "failed to get circulating supply. Make sure you are connected to a daemon."; + return false; + } + + // get pricing record + std::string err; + uint64_t bc_height = get_daemon_blockchain_height(err); + oracle::pricing_record pr; + if (!m_wallet->get_pricing_record(pr, bc_height-1)) { + fail_msg_writer() << "failed to get pricing record. Make sure you are connected to a daemon."; + return false; + } + + // calculate current block cap + //uint64_t block_cap = cryptonote::get_block_cap(supply_amounts, pr, m_wallet->get_current_hard_fork()); + //message_writer() << boost::format(tr("Current Block Cap(height %d): %d XHV")) % bc_height % print_money(block_cap); + return true; +} +//---------------------------------------------------------------------------------------------------- bool simple_wallet::donate(const std::vector &args_) { std::vector local_args = args_; diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 6e068bcd8..27f65d82f 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -169,7 +169,6 @@ namespace cryptonote bool show_blockchain_height(const std::vector &args); bool transfer_main(int transfer_type, const std::string& source_asset, const std::string& dest_asset, const std::vector &args, bool called_by_mms); bool transfer(const std::vector &args); - bool convert(const std::vector &args); bool locked_transfer(const std::vector &args); bool locked_sweep_all(const std::vector &args); bool sweep_main(uint32_t account, uint64_t below, bool locked, const std::vector &args); @@ -178,6 +177,11 @@ namespace cryptonote bool sweep_below(const std::vector &args); bool sweep_single(const std::vector &args); bool sweep_unmixable(const std::vector &args); + bool burn(const std::vector &args); + bool convert(const std::vector &args); + bool price_info(const std::vector &args); + bool supply_info(const std::vector &args); + bool yield_info(const std::vector &args); bool donate(const std::vector &args); bool sign_transfer(const std::vector &args); bool submit_transfer(const std::vector &args); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 55b8bee73..87a59acab 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1645,6 +1645,9 @@ private: static std::string get_default_daemon_address() { CRITICAL_REGION_LOCAL(default_daemon_address_lock); return default_daemon_address; } + bool get_pricing_record(oracle::pricing_record& pr, const uint64_t height); + bool get_circulating_supply(std::vector> &amounts); + private: /*! * \brief Stores wallet information to wallet file.