Monero
Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
simplewallet.cpp File Reference

Source file that defines simple_wallet class. More...

#include <thread>
#include <iostream>
#include <sstream>
#include <fstream>
#include <ctype.h>
#include <boost/lexical_cast.hpp>
#include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <boost/regex.hpp>
#include "include_base_utils.h"
#include "common/i18n.h"
#include "common/command_line.h"
#include "common/util.h"
#include "common/dns_utils.h"
#include "common/base58.h"
#include "common/scoped_message_writer.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
#include "simplewallet.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "storages/http_abstract_invoke.h"
#include "rpc/core_rpc_server_commands_defs.h"
#include "crypto/crypto.h"
#include "mnemonics/electrum-words.h"
#include "rapidjson/document.h"
#include "common/json_util.h"
#include "ringct/rctSigs.h"
#include "multisig/multisig.h"
#include "wallet/wallet_args.h"
#include "version.h"
#include <stdexcept>
Include dependency graph for simplewallet.cpp:

Namespaces

 anonymous_namespace{simplewallet.cpp}
 

Macros

#define MONERO_DEFAULT_LOG_CATEGORY   "wallet.simplewallet"
 
#define EXTENDED_LOGS_FILE   "wallet_details.log"
 
#define DEFAULT_MIX   10
 
#define MIN_RING_SIZE   11
 
#define LOCK_IDLE_SCOPE()
 
#define SCOPED_WALLET_UNLOCK()
 
#define CHECK_SIMPLE_VARIABLE(name, f, help)
 

Typedefs

typedef cryptonote::simple_wallet sw
 

Enumerations

enum  TransferType { Transfer, TransferLocked }
 

Functions

std::string anonymous_namespace{simplewallet.cpp}::input_line (const std::string &prompt)
 
epee::wipeable_string anonymous_namespace{simplewallet.cpp}::input_secure_line (const std::string &prompt)
 
boost::optional< tools::password_containeranonymous_namespace{simplewallet.cpp}::password_prompter (const char *prompt, bool verify)
 
boost::optional< tools::password_containeranonymous_namespace{simplewallet.cpp}::default_password_prompter (bool verify)
 
std::string anonymous_namespace{simplewallet.cpp}::interpret_rpc_response (bool ok, const std::string &status)
 
tools::scoped_message_writer anonymous_namespace{simplewallet.cpp}::success_msg_writer (bool color=false)
 
tools::scoped_message_writer anonymous_namespace{simplewallet.cpp}::message_writer (epee::console_colors color=epee::console_color_default, bool bright=false)
 
tools::scoped_message_writer anonymous_namespace{simplewallet.cpp}::fail_msg_writer ()
 
bool anonymous_namespace{simplewallet.cpp}::parse_bool (const std::string &s, bool &result)
 
template<typename F >
bool anonymous_namespace{simplewallet.cpp}::parse_bool_and_use (const std::string &s, F func)
 
bool anonymous_namespace{simplewallet.cpp}::parse_refresh_type (const std::string &s, tools::wallet2::RefreshType &refresh_type)
 
std::string anonymous_namespace{simplewallet.cpp}::get_refresh_type_name (tools::wallet2::RefreshType type)
 
std::string anonymous_namespace{simplewallet.cpp}::get_version_string (uint32_t version)
 
std::string anonymous_namespace{simplewallet.cpp}::oa_prompter (const std::string &url, const std::vector< std::string > &addresses, bool dnssec_valid)
 
bool anonymous_namespace{simplewallet.cpp}::parse_subaddress_indices (const std::string &arg, std::set< uint32_t > &subaddr_indices)
 
boost::optional< std::pair< uint32_t, uint32_t > > anonymous_namespace{simplewallet.cpp}::parse_subaddress_lookahead (const std::string &str)
 
void anonymous_namespace{simplewallet.cpp}::handle_transfer_exception (const std::exception_ptr &e, bool trusted_daemon)
 
bool anonymous_namespace{simplewallet.cpp}::check_file_overwrite (const std::string &filename)
 
void anonymous_namespace{simplewallet.cpp}::print_secret_key (const crypto::secret_key &k)
 
bool parse_priority (const std::string &arg, uint32_t &priority)
 
std::string join_priority_strings (const char *delimiter)
 
static bool might_be_partial_seed (const epee::wipeable_string &words)
 
static std::string get_human_readable_timestamp (uint64_t ts)
 
static std::string get_human_readable_timespan (std::chrono::seconds seconds)
 
int main (int argc, char *argv[])
 

Variables

const std::array< const char *const, 5 > anonymous_namespace{simplewallet.cpp}::allowed_priority_strings = {{"default", "unimportant", "normal", "elevated", "priority"}}
 
const auto anonymous_namespace{simplewallet.cpp}::arg_wallet_file = wallet_args::arg_wallet_file()
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_generate_new_wallet = {"generate-new-wallet", sw::tr("Generate new wallet and save it to <arg>"), ""}
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_generate_from_device = {"generate-from-device", sw::tr("Generate new wallet from device and save it to <arg>"), ""}
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_generate_from_view_key = {"generate-from-view-key", sw::tr("Generate incoming-only wallet from view key"), ""}
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_generate_from_spend_key = {"generate-from-spend-key", sw::tr("Generate deterministic wallet from spend key"), ""}
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_generate_from_keys = {"generate-from-keys", sw::tr("Generate wallet from private keys"), ""}
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_generate_from_multisig_keys = {"generate-from-multisig-keys", sw::tr("Generate a master wallet from multisig wallet keys"), ""}
 
const auto anonymous_namespace{simplewallet.cpp}::arg_generate_from_json = wallet_args::arg_generate_from_json()
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_mnemonic_language = {"mnemonic-language", sw::tr("Language for mnemonic"), ""}
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_electrum_seed = {"electrum-seed", sw::tr("Specify Electrum seed for wallet recovery/creation"), ""}
 
const command_line::arg_descriptor< boolanonymous_namespace{simplewallet.cpp}::arg_restore_deterministic_wallet = {"restore-deterministic-wallet", sw::tr("Recover wallet using Electrum-style mnemonic seed"), false}
 
const command_line::arg_descriptor< boolanonymous_namespace{simplewallet.cpp}::arg_restore_multisig_wallet = {"restore-multisig-wallet", sw::tr("Recover multisig wallet using Electrum-style mnemonic seed"), false}
 
const command_line::arg_descriptor< boolanonymous_namespace{simplewallet.cpp}::arg_non_deterministic = {"non-deterministic", sw::tr("Generate non-deterministic view and spend keys"), false}
 
const command_line::arg_descriptor< boolanonymous_namespace{simplewallet.cpp}::arg_allow_mismatched_daemon_version = {"allow-mismatched-daemon-version", sw::tr("Allow communicating with a daemon that uses a different RPC version"), false}
 
const command_line::arg_descriptor< uint64_t > anonymous_namespace{simplewallet.cpp}::arg_restore_height = {"restore-height", sw::tr("Restore from specific blockchain height"), 0}
 
const command_line::arg_descriptor< boolanonymous_namespace{simplewallet.cpp}::arg_do_not_relay = {"do-not-relay", sw::tr("The newly created transaction will not be relayed to the monero network"), false}
 
const command_line::arg_descriptor< boolanonymous_namespace{simplewallet.cpp}::arg_create_address_file = {"create-address-file", sw::tr("Create an address file for new wallets"), false}
 
const command_line::arg_descriptor< std::string > anonymous_namespace{simplewallet.cpp}::arg_subaddress_lookahead = {"subaddress-lookahead", tools::wallet2::tr("Set subaddress lookahead sizes to <major>:<minor>"), ""}
 
const command_line::arg_descriptor< boolanonymous_namespace{simplewallet.cpp}::arg_use_english_language_names = {"use-english-language-names", sw::tr("Display English language names"), false}
 
const command_line::arg_descriptor< std::vector< std::string > > anonymous_namespace{simplewallet.cpp}::arg_command = {"command", ""}
 
struct {
   const char *   anonymous_namespace{simplewallet.cpp}::name
 
   tools::wallet2::RefreshType   anonymous_namespace{simplewallet.cpp}::refresh_type
 
anonymous_namespace{simplewallet.cpp}::refresh_type_names []
 

Detailed Description

Source file that defines simple_wallet class.

Macro Definition Documentation

◆ CHECK_SIMPLE_VARIABLE

#define CHECK_SIMPLE_VARIABLE (   name,
  f,
  help 
)
Value:
do \
if (args[0] == name) { \
if (args.size() <= 1) \
{ \
fail_msg_writer() << "set " << #name << ": " << tr("needs an argument") << " (" << help << ")"; \
return true; \
} \
else \
{ \
f(args); \
return true; \
} \
} while(0)
#define tr(x)
Definition: common_defines.h:4
const char * name
Definition: simplewallet.cpp:319

◆ DEFAULT_MIX

#define DEFAULT_MIX   10

◆ EXTENDED_LOGS_FILE

#define EXTENDED_LOGS_FILE   "wallet_details.log"

◆ LOCK_IDLE_SCOPE

#define LOCK_IDLE_SCOPE ( )
Value:
bool auto_refresh_enabled = m_auto_refresh_enabled.load(std::memory_order_relaxed); \
m_auto_refresh_enabled.store(false, std::memory_order_relaxed); \
/* stop any background refresh, and take over */ \
m_wallet->stop(); \
boost::unique_lock<boost::mutex> lock(m_idle_mutex); \
m_idle_cond.notify_all(); \
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ \
m_auto_refresh_enabled.store(auto_refresh_enabled, std::memory_order_relaxed); \
})

◆ MIN_RING_SIZE

#define MIN_RING_SIZE   11

◆ MONERO_DEFAULT_LOG_CATEGORY

#define MONERO_DEFAULT_LOG_CATEGORY   "wallet.simplewallet"

◆ SCOPED_WALLET_UNLOCK

#define SCOPED_WALLET_UNLOCK ( )
Value:
boost::optional<tools::password_container> pwd_container = boost::none; \
if (m_wallet->ask_password() && !m_wallet->watch_only() && !(pwd_container = get_and_verify_password())) { return true; } \
tools::wallet_keys_unlocker unlocker(*m_wallet, pwd_container);
#define LOCK_IDLE_SCOPE()
Definition: simplewallet.cpp:93

Typedef Documentation

◆ sw

Enumeration Type Documentation

◆ TransferType

Enumerator
Transfer 
TransferLocked 

Function Documentation

◆ get_human_readable_timespan()

static std::string get_human_readable_timespan ( std::chrono::seconds  seconds)
static

◆ get_human_readable_timestamp()

static std::string get_human_readable_timestamp ( uint64_t  ts)
static

◆ join_priority_strings()

std::string join_priority_strings ( const char *  delimiter)

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ might_be_partial_seed()

static bool might_be_partial_seed ( const epee::wipeable_string &  words)
static

◆ parse_priority()

bool parse_priority ( const std::string &  arg,
uint32_t &  priority 
)