@ -7,10 +7,11 @@
# include <cmath>
# include <filesystem>
neroshop : : Wallet : : Wallet ( ) : process ( nullptr ) , percentage ( 0.0 ) , monero_wallet_obj ( nullptr )
neroshop : : Wallet : : Wallet ( ) : wallet_type ( WalletType : : Monero ) , monero_wallet_obj ( nullptr ) ,
process ( nullptr ) , percentage ( 0.0 )
{ }
//-------------------------------------------------------
monero: : monero_network_t ype neroshop : : Wallet : : network_type ( monero_network_type: : STAGENET ) ;
neroshop: : WalletNetworkT ype neroshop : : Wallet : : network_type ( WalletNetworkType: : Stagenet ) ;
//-------------------------------------------------------
neroshop : : Wallet : : ~ Wallet ( )
{
@ -18,7 +19,7 @@ neroshop::Wallet::~Wallet()
// remove listener
monero_wallet_obj - > remove_listener ( * this ) ; //int listener_count = monero_wallet_obj->get_listeners().size();if(listener_count > 0) { std::cout << NEROSHOP_TAG "still need to delete listeners (" << listener_count << ")" << std::endl; }
// close monero wallet
close( false ) ;
monero_wallet_obj- > close( false ) ;
// reset (delete) monero wallet
monero_wallet_obj . reset ( ) ; // will call monero_wallet_full destructor
if ( ! monero_wallet_obj . get ( ) ) std : : cout < < " monero wallet deleted \n " ; // just to confirm that the monero wallet has been set to nullptr after deletion
@ -49,13 +50,11 @@ int neroshop::Wallet::create_random(const std::string& password, const std::stri
neroshop : : print ( " Wallet file with the same name already exists " , 1 ) ;
return static_cast < int > ( WalletError : : AlreadyExists ) ;
}
// This is deprecated :(
////monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_random (path, password, network_type/*, const monero_rpc_connection &daemon_connection=monero_rpc_connection(), const std::string &language="English", std::unique_ptr< epee::net_utils::http::http_client_factory > http_client_factory=nullptr*/));
monero : : monero_wallet_config wallet_config_obj ;
wallet_config_obj . m_path = path ;
wallet_config_obj . m_password = password ;
wallet_config_obj . m_network_type = this- > network_type ;
wallet_config_obj . m_network_type = static_cast< monero : : monero_network_type > ( this- > network_type ) ;
monero_wallet_obj = std : : unique_ptr < monero_wallet_full > ( monero_wallet_full : : create_wallet ( wallet_config_obj , nullptr ) ) ;
if ( monero_wallet_obj . get ( ) ) std : : cout < < " \033 [1;35;49m " < < " created wallet \" " < < path < < " .keys \" " < < " \033 [0m " < < std : : endl ;
@ -76,13 +75,11 @@ int neroshop::Wallet::create_from_seed(const std::string& seed, const std::strin
neroshop : : print ( " Wallet file with the same name already exists " , 1 ) ;
return static_cast < int > ( WalletError : : AlreadyExists ) ;
}
// This is deprecated :(
////monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_from_mnemonic (path, password, network_type, mnemonic));
monero : : monero_wallet_config wallet_config_obj ;
wallet_config_obj . m_path = path ;
wallet_config_obj . m_password = password ;
wallet_config_obj . m_network_type = this- > network_type ;
wallet_config_obj . m_network_type = static_cast< monero : : monero_network_type > ( this- > network_type ) ;
wallet_config_obj . m_seed = seed ;
monero_wallet_obj = std : : unique_ptr < monero_wallet_full > ( monero_wallet_full : : create_wallet ( wallet_config_obj , nullptr ) ) ;
@ -106,13 +103,11 @@ int neroshop::Wallet::create_from_keys(const std::string& primary_address, const
neroshop : : print ( " Wallet file with the same name already exists " , 1 ) ;
return static_cast < int > ( WalletError : : AlreadyExists ) ;
}
// This is deprecated :(
////monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_from_keys(path, password, network_type, primary_address, view_key, spend_key));
monero : : monero_wallet_config wallet_config_obj ;
wallet_config_obj . m_path = path ;
wallet_config_obj . m_password = password ;
wallet_config_obj . m_network_type = this- > network_type ;
wallet_config_obj . m_network_type = static_cast< monero : : monero_network_type > ( this- > network_type ) ;
wallet_config_obj . m_primary_address = primary_address ;
wallet_config_obj . m_private_view_key = view_key ;
wallet_config_obj . m_private_spend_key = spend_key ;
@ -129,13 +124,10 @@ int neroshop::Wallet::create_from_keys(const std::string& primary_address, const
//-------------------------------------------------------
int neroshop : : Wallet : : restore_from_seed ( const std : : string & seed )
{
// This is deprecated :(
//monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_from_mnemonic("", "", network_type, mnemonic)); // set path to "" for an in-memory wallet
monero : : monero_wallet_config wallet_config_obj ;
wallet_config_obj . m_path = " " ;
wallet_config_obj . m_path = " " ; // set path to "" for an in-memory wallet
wallet_config_obj . m_password = " " ;
wallet_config_obj . m_network_type = this- > network_type ;
wallet_config_obj . m_network_type = static_cast< monero : : monero_network_type > ( this- > network_type ) ;
wallet_config_obj . m_seed = seed ;
wallet_config_obj . m_restore_height = 0 ;
@ -148,17 +140,15 @@ int neroshop::Wallet::restore_from_seed(const std::string& seed)
int neroshop : : Wallet : : restore_from_keys ( const std : : string & primary_address , const std : : string & view_key , const std : : string & spend_key )
{
// Check validity of primary address
if ( ! monero_utils : : is_valid_address ( primary_address , this- > network_type ) ) {
if ( ! monero_utils : : is_valid_address ( primary_address , static_cast< monero : : monero_network_type > ( this- > network_type ) ) ) {
neroshop : : print ( " Invalid Monero address " , 1 ) ;
return false ;
return static_cast < int > ( WalletError : : IsNotOpened ) ;
}
// This is deprecated :(
//monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_from_keys ("", "", network_type, primary_address, view_key, spend_key)); // set path to "" for an in-memory wallet
monero : : monero_wallet_config wallet_config_obj ;
wallet_config_obj . m_path = " " ;
wallet_config_obj . m_path = " " ; // set path to "" for an in-memory wallet
wallet_config_obj . m_password = " " ;
wallet_config_obj . m_network_type = this- > network_type ;
wallet_config_obj . m_network_type = static_cast< monero : : monero_network_type > ( this- > network_type ) ;
wallet_config_obj . m_primary_address = primary_address ;
wallet_config_obj . m_private_view_key = view_key ;
wallet_config_obj . m_private_spend_key = spend_key ;
@ -175,7 +165,7 @@ int neroshop::Wallet::open(const std::string& path, const std::string& password)
}
try {
monero_wallet_obj = std : : unique_ptr < monero_wallet_full > ( monero : : monero_wallet_full : : open_wallet ( path , password , this- > network_type ) ) ;
monero_wallet_obj = std : : unique_ptr < monero_wallet_full > ( monero : : monero_wallet_full : : open_wallet ( path , password , static_cast< monero : : monero_network_type > ( this- > network_type ) ) ) ;
} catch ( const std : : exception & e ) {
std : : string error_msg = e . what ( ) ;
neroshop : : print ( error_msg , 1 ) ; //tools::error::invalid_password
@ -200,8 +190,16 @@ int neroshop::Wallet::open(const std::string& path, const std::string& password)
//-------------------------------------------------------
void neroshop : : Wallet : : close ( bool save )
{
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
monero_wallet_obj - > close ( save ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
monero_wallet_obj - > close ( save ) ;
break ;
case WalletType : : Wownero :
break ;
default :
break ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : upload ( bool open , std : : string password ) { // opens the wallet file
@ -226,7 +224,7 @@ bool neroshop::Wallet::verify_password(const std::string& password) {
return verify_message ( password , this - > password_hash ) ;
}
//-------------------------------------------------------
// refer to https:// moneroecosystem.org/monero-cpp /structmonero_1_1monero__tx__config.html
// refer to https:// woodser.github.io/monero-cpp/doxygen /structmonero_1_1monero__tx__config.html
//-------------------------------------------------------
void neroshop : : Wallet : : transfer ( const std : : string & address , double amount ) {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
@ -237,11 +235,10 @@ void neroshop::Wallet::transfer(const std::string& address, double amount) {
neroshop : : print ( " Monero address is invalid " , 1 ) ; return ;
}
// Convert monero to piconero
double piconero = 0.000000000001 ;
uint64_t monero_to_piconero = amount / piconero ; //std::cout << neroshop::string::precision(amount, 12) << " xmr to piconero: " << monero_to_piconero << "\n";
uint64_t monero_to_piconero = amount / PICONERO ; //std::cout << neroshop::string::precision(amount, 12) << " xmr to piconero: " << monero_to_piconero << "\n";
// TODO: for the 2-of-3 escrow system, take 0.5% of order total in piconeros
// Check if amount is zero or too low
if ( ( amount < piconero ) | | ( monero_to_piconero = = 0 ) ) {
if ( ( amount < PICONERO ) | | ( monero_to_piconero = = 0 ) ) {
neroshop : : print ( " Nothing to send (amount is zero) " , 1 ) ; return ;
}
// Check if balance is sufficient
@ -267,7 +264,7 @@ void neroshop::Wallet::transfer(const std::string& address, double amount) {
bool in_pool = sent_tx - > m_in_tx_pool . get ( ) ; // true
// Get tx fee and hash
uint64_t fee = sent_tx - > m_fee . get ( ) ; // "Are you sure you want to send ...?"
std : : cout < < " Estimated fee: " < < ( fee * piconero ) < < " \n " ;
std : : cout < < " Estimated fee: " < < ( fee * PICONERO ) < < " \n " ;
//uint64_t deducted_amount = (monero_to_piconero + fee);
std : : string tx_hash = monero_wallet_obj - > relay_tx ( * sent_tx ) ; // recipient receives notification within 5 seconds
std : : cout < < " Tx hash: " < < tx_hash < < " \n " ;
@ -288,7 +285,6 @@ void neroshop::Wallet::transfer(const std::vector<std::pair<std::string, double>
tx_config . m_account_index = 0 ; // withdraw funds from this account
tx_config . m_relay = false ; // create transaction and relay to the network if true
double piconero = 0.000000000001 ;
// Calculate the total amount owed
double total_amount = 0.000000000000 ;
for ( const auto & address : payment_addresses ) {
@ -296,7 +292,7 @@ void neroshop::Wallet::transfer(const std::vector<std::pair<std::string, double>
}
std : : cout < < " Total amount to pay: " < < total_amount < < " (xmr) \n " ;
// Check if balance is sufficient
uint64_t total_to_piconero = total_amount / piconero ;
uint64_t total_to_piconero = total_amount / PICONERO ;
std : : cout < < " Wallet balance (spendable): " < < monero_wallet_obj - > get_unlocked_balance ( ) < < " (picos) \n " ;
std : : cout < < " Amount to send: " < < total_to_piconero < < " (picos) \n " ;
if ( monero_wallet_obj - > get_unlocked_balance ( ) < total_to_piconero ) {
@ -311,7 +307,7 @@ void neroshop::Wallet::transfer(const std::vector<std::pair<std::string, double>
continue ; // skip to the next address
}
// Convert monero to piconero
uint64_t monero_to_piconero = address . second / piconero ; //std::cout << neroshop::string::precision(address.second, 12) << " xmr to piconero: " << monero_to_piconero << "\n";
uint64_t monero_to_piconero = address . second / PICONERO ; //std::cout << neroshop::string::precision(address.second, 12) << " xmr to piconero: " << monero_to_piconero << "\n";
destinations . push_back ( std : : make_shared < monero_destination > ( address . first , monero_to_piconero ) ) ;
// Print address and amount
std : : cout < < " Address: " < < address . first < < " , Amount: " < < address . second < < std : : endl ;
@ -326,13 +322,27 @@ void neroshop::Wallet::transfer(const std::vector<std::pair<std::string, double>
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : sign_message ( const std : : string & message , monero_message_signature_type signature_type ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > sign_message ( message , signature_type , 0 , 0 ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > sign_message ( message , signature_type , 0 , 0 ) ;
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
bool neroshop : : Wallet : : verify_message ( const std : : string & message , const std : : string & signature ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > verify_message ( message , monero_wallet_obj . get ( ) - > get_primary_address ( ) , signature ) . m_is_good ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > verify_message ( message , monero_wallet_obj . get ( ) - > get_primary_address ( ) , signature ) . m_is_good ;
case WalletType : : Wownero :
return false ;
default :
return false ;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
@ -347,17 +357,33 @@ monero::monero_subaddress neroshop::Wallet::create_subaddress(unsigned int accou
}
//-------------------------------------------------------
//-------------------------------------------------------
void neroshop : : Wallet : : set_wallet_type ( WalletType wallet_type ) {
this - > wallet_type = wallet_type ;
}
//-------------------------------------------------------
// NOTE: It is IMPOSSIBLE to change the network type of a pre-existing monero wallet, but it can be set before its creation
void neroshop : : Wallet : : set_network_type ( monero : : monero_network_type network_type ) {
if ( get_network_type ( ) = = network_type ) return ;
if ( monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " Cannot change the network type of " + get_network_type_string ( ) + " wallet " ) ;
void neroshop : : Wallet : : set_network_type ( WalletNetworkType network_type ) {
auto current_network_type = get_network_type ( ) ;
if ( current_network_type = = network_type ) {
return ;
}
auto network_type_str = get_network_type_as_string ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " cannot change " + network_type_str + " wallet network type " ) ;
break ;
case WalletType : : Wownero :
break ;
default :
break ;
}
this - > network_type = network_type ;
}
//-------------------------------------------------------
void neroshop : : Wallet : : set_network_type_by_string ( const std : : string & network_type ) {
if ( network_type = = " mainnet " ) set_network_type ( monero_network_type : : MAINNET ) ;
if ( network_type = = " testnet " ) set_network_type ( monero_network_type : : TESTNET ) ;
if ( network_type = = " stagenet " ) set_network_type ( monero_network_type : : STAGENET ) ;
if ( network_type = = " mainnet " ) set_network_type ( WalletNetworkType: : Mainnet ) ;
if ( network_type = = " testnet " ) set_network_type ( WalletNetworkType: : Testnet ) ;
if ( network_type = = " stagenet " ) set_network_type ( WalletNetworkType: : Stagenet ) ;
std : : cout < < " Monero network type has been set to: " < < network_type < < std : : endl ;
}
//-------------------------------------------------------
@ -471,8 +497,6 @@ std::string neroshop::Wallet::generate_uri(const std::string& payment_address, d
//-------------------------------------------------------
// override
//-------------------------------------------------------
// I get the error: "../../src/xcb_io.c:641: _XReply: Assertion `!xcb_xlib_threads_sequence_lost' failed." when using this function
// or maybe its just some random threading error
void neroshop : : Wallet : : on_sync_progress ( uint64_t height , uint64_t start_height , uint64_t end_height , double percent_done , const std : : string & message ) {
// all of this takes place in a separate thread
// if monero_wallet is already synced, skip this function (this function keeps spamming throughout the entire app session -.-)
@ -514,8 +538,7 @@ void neroshop::Wallet::on_output_received(const monero_output_wallet& output) {
int account_index = output . m_account_index . get ( ) ; // should always be 0 (default)
int subaddress_index = output . m_subaddress_index . get ( ) ;
// get balance (actual)
double piconero = 0.000000000001 ;
double balance = ( amount * piconero ) ;
double balance = ( amount * PICONERO ) ;
// get the subaddress
std : : string subaddress = get_address ( subaddress_index ) ;
// you've received some xmr but it may be unspendable for the meantime
@ -529,25 +552,6 @@ void neroshop::Wallet::on_output_received(const monero_output_wallet& output) {
// at this point, any recently used subaddress will be removed from vector returned by Wallet::addresses_unused() (this is the final confirmation) - sometimes this message shows twice
if ( is_confirmed ) {
std : : cout < < " \033 [1;32;49m " < < " You have received " < < std : : fixed < < std : : setprecision ( 12 ) < < balance < < std : : fixed < < std : : setprecision ( 2 ) < < " xmr " < < " (txid: " < < tx_hash < < " , account_idx: " < < account_index < < " , subaddress_idx: " < < subaddress_index < < " ) " < < " \033 [0m " < < std : : endl ;
// set message box text then show message box
// box text0 (label)
/*neroshop::Message::get_second()->set_text(String::to_string_with_precision(balance, 12) + " xmr was deposited into your account ", 0, 107, 61);//56, 117, 11);//if(get_monero_wallet() != nullptr) //neroshop::Message::get_second()->set_text(std::string("You have received " + String::to_string_with_precision(balance, 12) + " xmr"), 56, 117, 11);//34, 139, 34);//neroshop::Message message(std::string("output received: " + std::to_string(balance) + " xmr"), 34, 139, 34);//(address: " + String::get_first_n_characters(subaddress, 4) + ".." + String::get_last_n_characters(subaddress, 4) + ")"
neroshop : : Message : : get_second ( ) - > get_label ( 0 ) - > set_alignment ( " none " ) ;
neroshop : : Message : : get_second ( ) - > get_label ( 0 ) - > set_relative_position ( ( neroshop : : Message : : get_second ( ) - > get_width ( ) / 2 ) - ( neroshop : : Message : : get_second ( ) - > get_label ( 0 ) - > get_width ( ) / 2 ) , ( ( neroshop : : Message : : get_second ( ) - > get_height ( ) - neroshop : : Message : : get_second ( ) - > get_label ( 0 ) - > get_height ( ) ) / 2 ) - 20 ) ;
std : : cout < < neroshop : : Message : : get_second ( ) - > get_label ( 0 ) - > get_string ( ) < < " (width: " < < ( neroshop : : Message : : get_second ( ) - > get_label ( 0 ) - > get_string ( ) . length ( ) * 10 ) < < " ) " < < std : : endl ;
// box text1
int text_gap = 10 ; //5; // space between text0 and text1 (vertically)
neroshop : : Message : : get_second ( ) - > set_text ( String : : get_first_n_characters ( subaddress , 15 ) + " .. " + String : : get_last_n_characters ( subaddress , 15 ) + " (idx: " + std : : to_string ( subaddress_index ) + " ) " , 1 ) ;
neroshop : : Message : : get_second ( ) - > get_label ( 1 ) - > set_alignment ( " none " ) ; //neroshop::Message::get_second()->get_label(0)->get_relative_x()
neroshop : : Message : : get_second ( ) - > get_label ( 1 ) - > set_relative_position ( ( ( neroshop : : Message : : get_second ( ) - > get_width ( ) / 2 ) - ( neroshop : : Message : : get_second ( ) - > get_label ( 1 ) - > get_string ( ) . length ( ) * 10 / 2 ) ) - ( 10 * std : : to_string ( subaddress_index ) . length ( ) ) , neroshop : : Message : : get_second ( ) - > get_label ( 0 ) - > get_relative_y ( ) + neroshop : : Message : : get_second ( ) - > get_label ( 0 ) - > get_height ( ) + text_gap ) ; // 1
// cancel button
neroshop : : Message : : get_second ( ) - > get_button ( 0 ) - > set_text ( " Close " ) ;
neroshop : : Message : : get_second ( ) - > get_button ( 0 ) - > set_color ( 214 , 31 , 31 , 1.0 ) ;
neroshop : : Message : : get_second ( ) - > get_button ( 0 ) - > set_relative_position ( ( neroshop : : Message : : get_second ( ) - > get_width ( ) / 2 ) - ( neroshop : : Message : : get_second ( ) - > get_button ( 0 ) - > get_width ( ) / 2 ) , neroshop : : Message : : get_second ( ) - > get_height ( ) - neroshop : : Message : : get_second ( ) - > get_button ( 0 ) - > get_height ( ) - 20 ) ; //200-30(height)-20(bottompadding) = 150(button_y)
// show message box, labels and buttons
neroshop : : Message : : get_second ( ) - > get_label ( 1 ) - > show ( ) ;
neroshop : : Message : : get_second ( ) - > get_button ( 0 ) - > show ( ) ;
neroshop : : Message : : get_second ( ) - > show ( ) ; */
}
}
//-------------------------------------------------------
@ -555,9 +559,8 @@ void neroshop::Wallet::on_balances_changed(uint64_t new_balance, uint64_t new_un
// if wallet is not fully synced with a daemon, skip this function
if ( ! monero_wallet_obj . get ( ) ) return ;
if ( ! monero_wallet_obj . get ( ) - > is_synced ( ) ) return ;
double piconero = 0.000000000001 ;
double balance = ( new_balance * piconero ) ;
double unlocked_balance = ( new_unlocked_balance * piconero ) ;
double balance = ( new_balance * PICONERO ) ;
double unlocked_balance = ( new_unlocked_balance * PICONERO ) ;
// if total balance is still locked, display it
// but if total balance is fully unlocked, then you already have the balance so no need to keep displaying it
if ( unlocked_balance ! = balance ) {
@ -595,7 +598,8 @@ void neroshop::Wallet::daemon_open(const std::string& daemon_dir, bool confirm_e
std : : string args = ( " --data-dir= " + data_dir ) + ( " --rpc-bind-ip= " + ip ) + ( " --rpc-bind-port=38081 " ) ;
if ( confirm_external_bind = = true ) { args = args + " --confirm-external-bind " ; }
if ( confirm_external_bind = = true & & restricted_rpc = = true ) { args = args + " --restricted-rpc " ; }
if ( neroshop : : string : : lower ( this - > get_network_type_string ( ) ) ! = " mainnet " ) args = args + ( " -- " + neroshop : : string : : lower ( this - > get_network_type_string ( ) ) ) ;
auto network_type_str = get_network_type_as_string ( ) ;
if ( neroshop : : string : : lower ( network_type_str ) ! = " mainnet " ) args = args + ( " -- " + neroshop : : string : : lower ( network_type_str ) ) ;
args = args + ( " --detach " ) ; // https://monero.stackexchange.com/questions/12005/what-is-the-difference-between-monerod-detach-and-monerod-non-interactive
std : : cout < < " \033 [1;95;49m " < < " $ " < < daemon_dir + args < < " \033 [0m " < < std : : endl ;
// start the daemon (monerod) as a new process on launch
@ -688,14 +692,13 @@ void neroshop::Wallet::wallet_info() {
std : : string restored_primary = monero_wallet_obj - > get_primary_address ( ) ; // same as: monero_wallet_obj->get_account(0, true).m_primary_address.get()
std : : cout < < " primary_address: " < < restored_primary < < std : : endl ;
uint64_t balance_raw = monero_wallet_obj - > get_balance ( ) ; // can specify account and subaddress indices
double piconero = 0.000000000001 ; // the smallest unit of a monero (monero has 12 decimal places) // https://web.getmonero.org/resources/moneropedia/denominations.html
double balance = ( double ) balance_raw * piconero ;
double balance = ( double ) balance_raw * PICONERO ;
std : : cout < < std : : fixed < < std : : setprecision ( 12 ) < < " balance: " < < balance < < std : : fixed < < std : : setprecision ( 2 ) < < std : : endl ;
// account ---------------------------------------------------------------
// account_0 is the default/main account where the primary address derives from
monero_account account = monero_wallet_obj - > get_account ( 0 , true ) ; // get account with subaddresses
uint64_t unlocked_balance_raw = account . m_unlocked_balance . get ( ) ;
double unlocked_balance = ( double ) unlocked_balance_raw * piconero ;
double unlocked_balance = ( double ) unlocked_balance_raw * PICONERO ;
std : : cout < < std : : fixed < < std : : setprecision ( 12 ) < < " unlocked_balance: " < < unlocked_balance < < std : : fixed < < std : : setprecision ( 2 ) < < std : : endl ; // uint64_t
// view and spend keys ----------------------------------------------------
std : : cout < < " view_key: " < < get_view_keys ( ) . first < < std : : endl ;
@ -719,6 +722,33 @@ void neroshop::Wallet::set_tx_note(const std::string& txid, const std::string& t
//-------------------------------------------------------
// getters
//-------------------------------------------------------
neroshop : : WalletType neroshop : : Wallet : : get_wallet_type ( ) const {
return wallet_type ;
}
//-------------------------------------------------------
neroshop : : WalletNetworkType neroshop : : Wallet : : get_network_type ( ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) return this - > network_type ;
return static_cast < WalletNetworkType > ( monero_wallet_obj - > get_network_type ( ) ) ;
case WalletType : : Wownero :
return this - > network_type ;
default :
return this - > network_type ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_network_type_as_string ( ) const {
auto network_type = get_network_type ( ) ;
switch ( network_type ) {
case WalletNetworkType : : Mainnet : return " mainnet " ; // 0
case WalletNetworkType : : Testnet : return " testnet " ; // 1
case WalletNetworkType : : Stagenet : return " stagenet " ; // 2
default : return " mainnet " ;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
double neroshop : : Wallet : : get_sync_percentage ( ) const {
std : : lock_guard < std : : mutex > lock ( wallet_data_mutex ) ;
return percentage ;
@ -746,47 +776,137 @@ std::string neroshop::Wallet::get_sync_message() const {
//-------------------------------------------------------
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_primary_address ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_primary_address ( ) ; // same as://monero_wallet_obj->get_account(0, true).m_primary_address.get();//monero_account monero::monero_wallet_full::get_account ( const uint32_t account_idx,bool include_subaddresses ) //const
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_primary_address ( ) ; // same as: monero_wallet_obj->get_account(0, true).m_primary_address.get();
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_address ( unsigned int index ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_account ( 0 , true ) . m_subaddresses [ index ] . m_address . get ( ) ; // account_idx "0" is default
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_account ( 0 , true ) . m_subaddresses [ index ] . m_address . get ( ) ; // account_idx is 0
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
unsigned int neroshop : : Wallet : : get_address_count ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_account ( 0 , true ) . m_subaddresses . size ( ) ; // all subaddresses will be created on the default account at index 0
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_account ( 0 , true ) . m_subaddresses . size ( ) ; // subaddresses will be created on account_idx 0
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
uint64_t neroshop : : Wallet : : get_balance_raw ( ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_balance ( ) ; // get wallet balance
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//-------------------------------------------------------
uint64_t neroshop : : Wallet : : get_balance_raw ( unsigned int account_index ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_balance ( account_index ) ; // get balance from account
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//------------------------------------------------------- for some reason, "account.m_subaddresses[i].m_address.get()" fails, but "monero_wallet_obj->get_account(0, true).m_subaddresses.size()" usually succeeds ...-> https://stackoverflow.com/questions/68733975/difficult-to-understand-runtime-error-this-is-initialized-failure-in-boost#comment121472560_68733975
double neroshop : : Wallet : : get_balance_raw ( unsigned int account_index , unsigned int subaddress_index ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
// get balance from subaddress
if ( subaddress_index > 0 ) return monero_wallet_obj - > get_balance ( account_index , subaddress_index ) ; //uint64_t monero::monero_wallet_full::get_balance ( uint32_t account_idx, uint32_t subaddress_idx ) //const
// get balance from account (primary address)
else return monero_wallet_obj - > get_balance ( account_index ) ; //uint64_t monero::monero_wallet_full::get_balance ( uint32_t account_idx ) const
return 0.0 ;
} // "balance"
//-------------------------------------------------------
double neroshop : : Wallet : : get_unlocked_balance_raw ( unsigned int account_index , unsigned int subaddress_index ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
// get a subaddress's unlocked balance
if ( subaddress_index > 0 ) return monero_wallet_obj - > get_unlocked_balance ( account_index , subaddress_index ) ; //uint64_t monero::monero_wallet_full::get_unlocked_balance ( uint32_t account_idx, uint32_t subaddress_idx ) const
// get an account's unlocked balance (primary address)
else return monero_wallet_obj - > get_unlocked_balance ( account_index ) ; //uint64_t monero::monero_wallet_full::get_unlocked_balance ( ) const//uint64_t monero::monero_wallet_full::get_unlocked_balance ( uint32_t account_idx ) const
return 0.0 ;
} // "balance"
uint64_t neroshop : : Wallet : : get_balance_raw ( unsigned int account_index , unsigned int subaddress_index ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_balance ( account_index , subaddress_index ) ; // get balance from subaddress
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//-------------------------------------------------------
uint64_t neroshop : : Wallet : : get_unlocked_balance_raw ( ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_unlocked_balance ( ) ; // get wallet unlocked balance
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//-------------------------------------------------------
uint64_t neroshop : : Wallet : : get_unlocked_balance_raw ( unsigned int account_index ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_unlocked_balance ( account_index ) ; // get unlocked balance from account
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//-------------------------------------------------------
uint64_t neroshop : : Wallet : : get_unlocked_balance_raw ( unsigned int account_index , unsigned int subaddress_index ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_unlocked_balance ( account_index , subaddress_index ) ; // get unlocked balance from subaddress
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
double neroshop : : Wallet : : get_balance ( ) const {
return get_balance_raw ( ) * PICONERO ;
}
//-------------------------------------------------------
double neroshop : : Wallet : : get_balance ( unsigned int account_index ) const {
return get_balance_raw ( account_index ) * PICONERO ;
}
//-------------------------------------------------------
double neroshop : : Wallet : : get_balance ( unsigned int account_index , unsigned int subaddress_index ) const {
double piconero = 0.000000000001 ;
return get_balance_raw ( account_index , subaddress_index ) * piconero ;
return get_balance_raw ( account_index , subaddress_index ) * PICONERO ;
}
//-------------------------------------------------------
double neroshop : : Wallet : : get_unlocked_balance ( ) const {
return get_unlocked_balance_raw ( ) * PICONERO ;
}
//-------------------------------------------------------
double neroshop : : Wallet : : get_unlocked_balance ( unsigned int account_index ) const {
return get_unlocked_balance_raw ( account_index ) * PICONERO ;
}
//-------------------------------------------------------
double neroshop : : Wallet : : get_unlocked_balance ( unsigned int account_index , unsigned int subaddress_index ) const {
double piconero = 0.000000000001 ;
return get_unlocked_balance_raw ( account_index , subaddress_index ) * piconero ;
return get_unlocked_balance_raw ( account_index , subaddress_index ) * PICONERO ;
}
//-------------------------------------------------------
std : : vector < std : : string > neroshop : : Wallet : : get_transactions ( ) const {
@ -842,61 +962,105 @@ std::string neroshop::Wallet::get_last_subaddress() const
//std::string neroshop::Wallet::get_tx_note(const std::string& txid) const {return "";} // "get_tx_note <txid>" - useful for retrieving address information
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_private_view_key ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_private_view_key ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_private_view_key ( ) ;
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_public_view_key ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_public_view_key ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_public_view_key ( ) ;
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
std : : pair < std : : string , std : : string > neroshop : : Wallet : : get_view_keys ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return std : : make_pair ( monero_wallet_obj - > get_private_view_key ( ) , monero_wallet_obj - > get_public_view_key ( ) ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return std : : make_pair ( monero_wallet_obj - > get_private_view_key ( ) , monero_wallet_obj - > get_public_view_key ( ) ) ;
case WalletType : : Wownero :
return std : : make_pair ( " " , " " ) ;
default :
return std : : make_pair ( " " , " " ) ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_private_spend_key ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_private_spend_key ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_private_spend_key ( ) ;
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_public_spend_key ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_public_spend_key ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_public_spend_key ( ) ;
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
std : : pair < std : : string , std : : string > neroshop : : Wallet : : get_spend_keys ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return std : : make_pair ( monero_wallet_obj - > get_private_spend_key ( ) , monero_wallet_obj - > get_public_spend_key ( ) ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return std : : make_pair ( monero_wallet_obj - > get_private_spend_key ( ) , monero_wallet_obj - > get_public_spend_key ( ) ) ;
case WalletType : : Wownero :
return std : : make_pair ( " " , " " ) ;
default :
return std : : make_pair ( " " , " " ) ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_seed ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_seed ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_seed ( ) ;
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-Image * neroshop::Wallet::get_qr_code() const {} // returns address qrcode // "show_qr_code"
//-Image * neroshop::Wallet::get_qr_code(unsigned int address_index) const {} // returns the qrcode of the address at "index"
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_path ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > monero_wallet_full : : get_path ( ) ; // returns the path of this wallet's file on disk (without the .keys ext)
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > monero_wallet_full : : get_path ( ) ; // returns the path of this wallet's file on disk (without the .keys ext)
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_description ( ) const {
/*std::string neroshop::Wallet::get_description() const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return " " ;
} // "wallet_info"
} */
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_type ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
@ -904,65 +1068,122 @@ std::string neroshop::Wallet::get_type() const {
} // "wallet_info": Normal, HW
//-------------------------------------------------------
unsigned int neroshop : : Wallet : : get_daemon_height ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_daemon_height ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_daemon_height ( ) ;
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//-------------------------------------------------------
unsigned int neroshop : : Wallet : : get_height ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_height ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_height ( ) ;
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
}
//-------------------------------------------------------
unsigned int neroshop : : Wallet : : get_height_by_date ( int year , int month , int day ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_height_by_date ( year , month , day ) ;
}
//-------------------------------------------------------
monero : : monero_network_type neroshop : : Wallet : : get_network_type ( ) const {
if ( ! monero_wallet_obj . get ( ) ) return this - > network_type ;
return monero_wallet_obj - > get_network_type ( ) ;
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_network_type_string ( ) const {
switch ( this - > get_network_type ( ) ) {
case monero_network_type : : MAINNET : return " mainnet " ; break ; // 0
case monero_network_type : : TESTNET : return " testnet " ; break ; // 1
case monero_network_type : : STAGENET : return " stagenet " ; break ; // 2
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > get_height_by_date ( year , month , day ) ;
case WalletType : : Wownero :
return 0 ;
default :
return 0 ;
}
return " mainnet " ;
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_status ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return " " ;
} // "status" - Check current status of wallet.
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return " " ;
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
std : : string neroshop : : Wallet : : get_version ( ) const {
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
//monero_version monero::monero_wallet_full::get_version();
return " " ;
} // "version" - Check software version.
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return " " ; //monero_version monero::monero_wallet_full::get_version();
break ;
case WalletType : : Wownero :
return " " ;
default :
return " " ;
}
}
//-------------------------------------------------------
monero_wallet_full * neroshop : : Wallet : : get_monero_wallet ( ) const
{
return monero_wallet_obj . get ( ) ;
}
//-------------------------------------------------------
// callbacks
//-------------------------------------------------------
void neroshop : : Wallet : : load_from_config ( std : : string /*const std::string&*/ password ) // load configs on opening
{
}
//-------------------------------------------------------
//-------------------------------------------------------
//void neroshop::Wallet::set_daemon() {} // "set_daemon <host>[:<port>] [trusted|untrusted|this-is-probably-a-spy-node]" - connects to a daemon
//-------------------------------------------------------
//void neroshop::Wallet::refresh() {}
//-------------------------------------------------------
bool neroshop : : Wallet : : is_opened ( ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
return ( monero_wallet_obj ! = nullptr ) ;
case WalletType : : Wownero :
return false ;
default :
return false ;
}
}
//-------------------------------------------------------
bool neroshop : : Wallet : : is_connected_to_daemon ( ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > is_connected_to_daemon ( ) ;
case WalletType : : Wownero :
return false ;
default :
return false ;
}
}
//-------------------------------------------------------
bool neroshop : : Wallet : : is_synced ( ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
return monero_wallet_obj - > is_synced ( ) ;
case WalletType : : Wownero :
return false ;
default :
return false ;
}
}
//-------------------------------------------------------
bool neroshop : : Wallet : : is_daemon_synced ( ) const {
switch ( wallet_type ) {
case WalletType : : Monero :
if ( ! monero_wallet_obj . get ( ) ) throw std : : runtime_error ( " monero_wallet_full is not opened " ) ;
if ( ! monero_wallet_obj - > is_connected_to_daemon ( ) ) {
return false ;
}
return monero_wallet_obj - > is_daemon_synced ( ) ; // will cause crash if wallet is not connected to daemon
case WalletType : : Wownero :
return false ;
default :
return false ;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
bool neroshop : : Wallet : : file_exists ( const std : : string & filename ) const {
@ -970,6 +1191,18 @@ bool neroshop::Wallet::file_exists(const std::string& filename) const {
}
//-------------------------------------------------------
bool neroshop : : Wallet : : is_valid_address ( const std : : string & address ) const {
return monero_utils : : is_valid_address ( address , this - > get_network_type ( ) ) ;
auto network_type = get_network_type ( ) ;
switch ( wallet_type ) {
case WalletType : : Monero :
return monero_utils : : is_valid_address ( address , static_cast < monero : : monero_network_type > ( network_type ) ) ;
case WalletType : : Wownero :
return false ;
default :
return false ;
}
}
//-------------------------------------------------------
bool neroshop : : Wallet : : is_cryptonote_based ( ) const {
return ( wallet_type = = WalletType : : Monero | | wallet_type = = WalletType : : Wownero ) ;
}
//-------------------------------------------------------