Electroneum
Electroneum::WalletImpl Class Reference

#include <wallet.h>

Inheritance diagram for Electroneum::WalletImpl:
Collaboration diagram for Electroneum::WalletImpl:

Public Member Functions

 WalletImpl (NetworkType nettype=MAINNET, uint64_t kdf_rounds=1)
 
 ~WalletImpl ()
 
bool create (const std::string &path, const std::string &password, const std::string &language)
 
bool createWatchOnly (const std::string &path, const std::string &password, const std::string &language) const override
 createWatchOnly - Creates a watch only wallet More...
 
bool open (const std::string &path, const std::string &password)
 
bool recover (const std::string &path, const std::string &password, const std::string &seed)
 
bool recoverFromKeysWithPassword (const std::string &path, const std::string &password, const std::string &language, const std::string &address_string, const std::string &viewkey_string, const std::string &spendkey_string="")
 
bool recover (const std::string &path, const std::string &seed)
 
bool recoverFromKeys (const std::string &path, const std::string &language, const std::string &address_string, const std::string &viewkey_string, const std::string &spendkey_string="")
 
bool recoverFromDevice (const std::string &path, const std::string &password, const std::string &device_name)
 
Device getDeviceType () const override
 Queries backing device for wallet keys. More...
 
bool close (bool store=true)
 
std::string seed () const override
 
std::string getSeedLanguage () const override
 
void setSeedLanguage (const std::string &arg) override
 
int status () const override
 returns wallet status (Status_Ok | Status_Error) More...
 
std::string errorString () const override
 in case error status, returns error string More...
 
void statusWithErrorString (int &status, std::string &errorString) const override
 returns both error and error string atomically. suggested to use in instead of status() and errorString() More...
 
bool setPassword (const std::string &password) override
 
bool setDevicePin (const std::string &password) override
 
bool setDevicePassphrase (const std::string &password) override
 
std::string address (uint32_t accountIndex=0, uint32_t addressIndex=0) const override
 
std::string integratedAddress (const std::string &payment_id) const override
 integratedAddress - returns integrated address for current wallet address and given payment_id. if passed "payment_id" param is an empty string or not-valid payment id string (16 characters hexadecimal string) - random payment_id will be generated More...
 
std::string secretViewKey () const override
 secretViewKey - returns secret view key More...
 
std::string publicViewKey () const override
 publicViewKey - returns public view key More...
 
std::string secretSpendKey () const override
 secretSpendKey - returns secret spend key More...
 
std::string publicSpendKey () const override
 publicSpendKey - returns public spend key More...
 
std::string publicMultisigSignerKey () const override
 publicMultisigSignerKey - returns public signer key More...
 
std::string path () const override
 
bool store (const std::string &path) override
 store - stores wallet to file. More...
 
std::string filename () const override
 filename - returns wallet filename More...
 
std::string keysFilename () const override
 keysFilename - returns keys filename. usually this formed as "wallet_filename".keys More...
 
bool init (const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false) override
 init - initializes wallet with daemon connection params. if daemon_address is local address, "trusted daemon" will be set to true forcibly startRefresh() should be called when wallet is initialized. More...
 
bool connectToDaemon () override
 connectToDaemon - connects to the daemon. TODO: check if it can be removed More...
 
ConnectionStatus connected () const override
 connected - checks if the wallet connected to the daemon More...
 
void setTrustedDaemon (bool arg) override
 
bool trustedDaemon () const override
 
uint64_t balance (uint32_t accountIndex=0, bool public_blockchain=false) const override
 
uint64_t unlockedBalance (uint32_t accountIndex=0, bool public_blockchain=false) const override
 
uint64_t blockChainHeight () const override
 blockChainHeight - returns current blockchain height More...
 
uint64_t approximateBlockChainHeight () const override
 approximateBlockChainHeight - returns approximate blockchain height calculated from date/time More...
 
uint64_t estimateBlockChainHeight () const override
 estimateBlockChainHeight - returns estimate blockchain height. More accurate than approximateBlockChainHeight, uses daemon height and falls back to calculation from date/time More...
 
uint64_t daemonBlockChainHeight () const override
 daemonBlockChainHeight - returns daemon blockchain height More...
 
uint64_t daemonBlockChainTargetHeight () const override
 daemonBlockChainTargetHeight - returns daemon blockchain target height More...
 
bool synchronized () const override
 synchronized - checks if wallet was ever synchronized More...
 
bool refresh () override
 refresh - refreshes the wallet, updating transactions from daemon More...
 
void refreshAsync () override
 refreshAsync - refreshes wallet asynchronously. More...
 
bool rescanBlockchain () override
 rescanBlockchain - rescans the wallet, updating transactions from daemon More...
 
void rescanBlockchainAsync () override
 rescanBlockchainAsync - rescans wallet asynchronously, starting from genesys More...
 
void setAutoRefreshInterval (int millis) override
 setAutoRefreshInterval - setup interval for automatic refresh. More...
 
int autoRefreshInterval () const override
 autoRefreshInterval - returns automatic refresh interval in millis More...
 
void setRefreshFromBlockHeight (uint64_t refresh_from_block_height) override
 setRefreshFromBlockHeight - start refresh from block height on recover More...
 
uint64_t getRefreshFromBlockHeight () const override
 getRestoreHeight - get wallet creation height More...
 
void setRecoveringFromSeed (bool recoveringFromSeed) override
 setRecoveringFromSeed - set state recover form seed More...
 
void setRecoveringFromDevice (bool recoveringFromDevice) override
 setRecoveringFromDevice - set state to recovering from device More...
 
void setSubaddressLookahead (uint32_t major, uint32_t minor) override
 setSubaddressLookahead - set size of subaddress lookahead More...
 
bool watchOnly () const override
 watchOnly - checks if wallet is watch only More...
 
bool rescanSpent () override
 
NetworkType nettype () const override
 
void hardForkInfo (uint8_t &version, uint64_t &earliest_height) const override
 returns current hard fork info More...
 
bool useForkRules (uint8_t version, int64_t early_blocks) const override
 check if hard fork rules should be used More...
 
void addSubaddressAccount (const std::string &label) override
 addSubaddressAccount - appends a new subaddress account at the end of the last major index of existing subaddress accounts More...
 
size_t numSubaddressAccounts () const override
 numSubaddressAccounts - returns the number of existing subaddress accounts More...
 
size_t numSubaddresses (uint32_t accountIndex) const override
 numSubaddresses - returns the number of existing subaddresses associated with the specified subaddress account More...
 
void addSubaddress (uint32_t accountIndex, const std::string &label) override
 addSubaddress - appends a new subaddress at the end of the last minor index of the specified subaddress account More...
 
std::string getSubaddressLabel (uint32_t accountIndex, uint32_t addressIndex) const override
 getSubaddressLabel - gets the label of the specified subaddress More...
 
void setSubaddressLabel (uint32_t accountIndex, uint32_t addressIndex, const std::string &label) override
 setSubaddressLabel - sets the label of the specified subaddress More...
 
MultisigState multisig () const override
 multisig - returns current state of multisig wallet creation process More...
 
std::string getMultisigInfo () const override
 getMultisigInfo More...
 
std::string makeMultisig (const std::vector< std::string > &info, uint32_t threshold) override
 makeMultisig - switches wallet in multisig state. The one and only creation phase for N / N wallets More...
 
std::string exchangeMultisigKeys (const std::vector< std::string > &info) override
 exchange_multisig_keys - provides additional key exchange round for arbitrary multisig schemes (like N-1/N, M/N) More...
 
bool finalizeMultisig (const std::vector< std::string > &extraMultisigInfo) override
 finalizeMultisig - finalizes N - 1 / N multisig wallets creation More...
 
bool exportMultisigImages (std::string &images) override
 exportMultisigImages - exports transfers' key images More...
 
size_t importMultisigImages (const std::vector< std::string > &images) override
 importMultisigImages - imports other participants' multisig images More...
 
bool hasMultisigPartialKeyImages () const override
 hasMultisigPartialKeyImages - checks if wallet needs to import multisig key images from other participants More...
 
PendingTransactionrestoreMultisigTransaction (const std::string &signData) override
 restoreMultisigTransaction creates PendingTransaction from signData More...
 
PendingTransactioncreateTransaction (const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={}) override
 createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored More...
 
virtual PendingTransactioncreateSweepUnmixableTransaction () override
 createSweepUnmixableTransaction creates transaction with unmixable outputs. More...
 
bool submitTransaction (const std::string &fileName) override
 submitTransaction - submits transaction in signed tx file More...
 
virtual UnsignedTransactionloadUnsignedTx (const std::string &unsigned_filename) override
 loadUnsignedTx - creates transaction from unsigned tx file More...
 
bool exportKeyImages (const std::string &filename) override
 exportKeyImages - exports key images to file More...
 
bool importKeyImages (const std::string &filename) override
 importKeyImages - imports key images from file More...
 
virtual void disposeTransaction (PendingTransaction *t) override
 disposeTransaction - destroys transaction object More...
 
virtual TransactionHistoryhistory () override
 
virtual AddressBookaddressBook () override
 
virtual Subaddresssubaddress () override
 
virtual SubaddressAccountsubaddressAccount () override
 
virtual void setListener (WalletListener *l) override
 
virtual uint32_t defaultMixin () const override
 defaultMixin - returns number of mixins used in transactions More...
 
virtual void setDefaultMixin (uint32_t arg) override
 setDefaultMixin - setum number of mixins to be used for new transactions More...
 
virtual bool setUserNote (const std::string &txid, const std::string &note) override
 setUserNote - attach an arbitrary string note to a txid More...
 
virtual std::string getUserNote (const std::string &txid) const override
 getUserNote - return an arbitrary string note attached to a txid More...
 
virtual std::string getTxKey (const std::string &txid) const override
 
virtual bool checkTxKey (const std::string &txid, std::string tx_key, const std::string &address, uint64_t &received, bool &in_pool, uint64_t &confirmations) override
 
virtual std::string getTxProof (const std::string &txid, const std::string &address, const std::string &message) const override
 
virtual bool checkTxProof (const std::string &txid, const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &received, bool &in_pool, uint64_t &confirmations) override
 
virtual std::string getSpendProof (const std::string &txid, const std::string &message) const override
 
virtual bool checkSpendProof (const std::string &txid, const std::string &message, const std::string &signature, bool &good) const override
 
virtual std::string getReserveProof (bool all, uint32_t account_index, uint64_t amount, const std::string &message) const override
 getReserveProof - Generates a proof that proves the reserve of unspent funds Parameters account_index and amount are ignored when all is true More...
 
virtual bool checkReserveProof (const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &total, uint64_t &spent) const override
 
virtual std::string signMessage (const std::string &message) override
 
virtual bool verifySignedMessage (const std::string &message, const std::string &address, const std::string &signature) const override
 verifySignedMessage - verify a signature matches a given message More...
 
virtual std::string signMultisigParticipant (const std::string &message) const override
 signMultisigParticipant signs given message with the multisig public signer key More...
 
virtual bool verifyMessageWithPublicKey (const std::string &message, const std::string &publicKey, const std::string &signature) const override
 verifyMessageWithPublicKey verifies that message was signed with the given public key More...
 
virtual void startRefresh () override
 StartRefresh - Start/resume refresh thread (refresh every 10 seconds) More...
 
virtual void pauseRefresh () override
 pauseRefresh - pause refresh thread More...
 
virtual bool parse_uri (const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector< std::string > &unknown_parameters, std::string &error) override
 
virtual std::string getDefaultDataDir () const override
 
virtual bool lightWalletLogin (bool &isNewWallet) const override
 Light wallet authenticate and login. More...
 
virtual bool lightWalletImportWalletRequest (std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) override
 Initiates a light wallet import wallet request. More...
 
virtual bool blackballOutputs (const std::vector< std::string > &outputs, bool add) override
 blackballs a set of outputs More...
 
virtual bool blackballOutput (const std::string &amount, const std::string &offset) override
 blackballs an output More...
 
virtual bool unblackballOutput (const std::string &amount, const std::string &offset) override
 unblackballs an output More...
 
virtual bool getRing (const std::string &key_image, std::vector< uint64_t > &ring) const override
 gets the ring used for a key image, if any More...
 
virtual bool getRings (const std::string &txid, std::vector< std::pair< std::string, std::vector< uint64_t >>> &rings) const override
 gets the rings used for a txid, if any More...
 
virtual bool setRing (const std::string &key_image, const std::vector< uint64_t > &ring, bool relative) override
 sets the ring used for a key image More...
 
virtual void segregatePreForkOutputs (bool segregate) override
 sets whether pre-fork outs are to be segregated More...
 
virtual void segregationHeight (uint64_t height) override
 sets the height where segregation should occur More...
 
virtual void keyReuseMitigation2 (bool mitigation) override
 secondary key reuse mitigation More...
 
virtual bool lockKeysFile () override
 locks/unlocks the keys file; returns true on success More...
 
virtual bool unlockKeysFile () override
 
virtual bool isKeysFileLocked () override
 returns true if the keys file is locked More...
 
virtual uint64_t coldKeyImageSync (uint64_t &spent, uint64_t &unspent) override
 cold-device protocol key image sync More...
 
- Public Member Functions inherited from Electroneum::Wallet
virtual ~Wallet ()=0
 
std::string mainAddress () const
 
bool mainnet () const
 
bool testnet () const
 
bool stagenet () const
 
uint64_t balanceAll (bool public_blockchain) const
 
uint64_t unlockedBalanceAll (bool public_blockchain) const
 

Friends

class PendingTransactionImpl
 
class UnsignedTransactionImpl
 
class TransactionHistoryImpl
 
struct Wallet2CallbackImpl
 
class AddressBookImpl
 
class SubaddressImpl
 
class SubaddressAccountImpl
 

Additional Inherited Members

- Public Types inherited from Electroneum::Wallet
enum  Device { Device_Software = 0, Device_Ledger = 1, Device_Trezor = 2 }
 
enum  Status { Status_Ok, Status_Error, Status_Critical }
 
enum  ConnectionStatus { ConnectionStatus_Disconnected, ConnectionStatus_Connected, ConnectionStatus_WrongVersion }
 
- Static Public Member Functions inherited from Electroneum::Wallet
static std::string displayAmount (uint64_t amount)
 
static uint64_t amountFromString (const std::string &amount)
 
static uint64_t amountFromDouble (double amount)
 
static std::string genPaymentId ()
 
static bool paymentIdValid (const std::string &paiment_id)
 
static bool addressValid (const std::string &str, NetworkType nettype)
 
static bool addressValid (const std::string &str, bool testnet)
 
static bool keyValid (const std::string &secret_key_string, const std::string &address_string, bool isViewKey, NetworkType nettype, std::string &error)
 
static bool keyValid (const std::string &secret_key_string, const std::string &address_string, bool isViewKey, bool testnet, std::string &error)
 
static std::string paymentIdFromAddress (const std::string &str, NetworkType nettype)
 
static std::string paymentIdFromAddress (const std::string &str, bool testnet)
 
static uint64_t maximumAllowedAmount ()
 
static void init (const char *argv0, const char *default_log_base_name)
 
static void init (const char *argv0, const char *default_log_base_name, const std::string &log_path, bool console)
 
static void debug (const std::string &category, const std::string &str)
 
static void info (const std::string &category, const std::string &str)
 
static void warning (const std::string &category, const std::string &str)
 
static void error (const std::string &category, const std::string &str)
 

Detailed Description

Definition at line 53 of file wallet.h.

Constructor & Destructor Documentation

◆ WalletImpl()

Electroneum::WalletImpl::WalletImpl ( NetworkType  nettype = MAINNET,
uint64_t  kdf_rounds = 1 
)

Definition at line 420 of file wallet.cpp.

421  :m_wallet(nullptr)
422  , m_status(Wallet::Status_Ok)
423  , m_wallet2Callback(nullptr)
424  , m_recoveringFromSeed(false)
425  , m_recoveringFromDevice(false)
426  , m_synchronized(false)
427  , m_rebuildWalletCache(false)
428  , m_is_connected(false)
429  , m_refreshShouldRescan(false)
430 {
431  m_wallet.reset(new tools::wallet2(static_cast<cryptonote::network_type>(nettype), kdf_rounds, true));
432  m_history.reset(new TransactionHistoryImpl(this));
433  m_wallet2Callback.reset(new Wallet2CallbackImpl(this));
434  m_wallet->callback(m_wallet2Callback.get());
435  m_refreshThreadDone = false;
436  m_refreshEnabled = false;
437  m_addressBook.reset(new AddressBookImpl(this));
438  m_subaddress.reset(new SubaddressImpl(this));
439  m_subaddressAccount.reset(new SubaddressAccountImpl(this));
440 
441 
442  m_refreshIntervalMillis = DEFAULT_REFRESH_INTERVAL_MILLIS;
443 
444  m_refreshThread = boost::thread([this] () {
445  this->refreshThreadFunc();
446  });
447 
448 }
friend class AddressBookImpl
Definition: wallet.h:224
friend struct Wallet2CallbackImpl
Definition: wallet.h:223
friend class SubaddressAccountImpl
Definition: wallet.h:226
friend class TransactionHistoryImpl
Definition: wallet.h:222
NetworkType nettype() const override
Definition: wallet.h:132
friend class SubaddressImpl
Definition: wallet.h:225
Here is the call graph for this function:

◆ ~WalletImpl()

Electroneum::WalletImpl::~WalletImpl ( )

Definition at line 450 of file wallet.cpp.

451 {
452 
453  LOG_PRINT_L1(__FUNCTION__);
454  m_wallet->callback(NULL);
455  // Pause refresh thread - prevents refresh from starting again
456  pauseRefresh();
457  // Close wallet - stores cache and stops ongoing refresh operation
458  close(false); // do not store wallet as part of the closing activities
459  // Stop refresh thread
460  stopRefresh();
461 
462  if (m_wallet2Callback->getListener()) {
463  m_wallet2Callback->getListener()->onSetWallet(nullptr);
464  }
465 
466  LOG_PRINT_L1(__FUNCTION__ << " finished");
467 }
#define LOG_PRINT_L1(x)
Definition: misc_log_ex.h:100
bool close(bool store=true)
Definition: wallet.cpp:762
virtual void pauseRefresh() override
pauseRefresh - pause refresh thread
Definition: wallet.cpp:2161
Here is the call graph for this function:

Member Function Documentation

◆ address()

std::string Electroneum::WalletImpl::address ( uint32_t  accountIndex = 0,
uint32_t  addressIndex = 0 
) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 860 of file wallet.cpp.

861 {
862  return m_wallet->get_subaddress_as_str({accountIndex, addressIndex});
863 }
Here is the caller graph for this function:

◆ addressBook()

AddressBook * Electroneum::WalletImpl::addressBook ( )
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1679 of file wallet.cpp.

1680 {
1681  return m_addressBook.get();
1682 }
Here is the caller graph for this function:

◆ addSubaddress()

void Electroneum::WalletImpl::addSubaddress ( uint32_t  accountIndex,
const std::string &  label 
)
overridevirtual

addSubaddress - appends a new subaddress at the end of the last minor index of the specified subaddress account

Parameters
accountIndex- the major index specifying the subaddress account
label- the label for the new subaddress

Implements Electroneum::Wallet.

Definition at line 1218 of file wallet.cpp.

1219 {
1220  m_wallet->add_subaddress(accountIndex, label);
1221 }

◆ addSubaddressAccount()

void Electroneum::WalletImpl::addSubaddressAccount ( const std::string &  label)
overridevirtual

addSubaddressAccount - appends a new subaddress account at the end of the last major index of existing subaddress accounts

Parameters
label- the label for the new account (which is the as the label of the primary address (accountIndex,0))

Implements Electroneum::Wallet.

Definition at line 1206 of file wallet.cpp.

1207 {
1208  m_wallet->add_subaddress_account(label);
1209 }

◆ approximateBlockChainHeight()

uint64_t Electroneum::WalletImpl::approximateBlockChainHeight ( ) const
overridevirtual

approximateBlockChainHeight - returns approximate blockchain height calculated from date/time

Returns

Implements Electroneum::Wallet.

Definition at line 1013 of file wallet.cpp.

1014 {
1015  return m_wallet->get_approximate_blockchain_height();
1016 }

◆ autoRefreshInterval()

int Electroneum::WalletImpl::autoRefreshInterval ( ) const
overridevirtual

autoRefreshInterval - returns automatic refresh interval in millis

Returns

Implements Electroneum::Wallet.

Definition at line 1118 of file wallet.cpp.

1119 {
1120  return m_refreshIntervalMillis;
1121 }

◆ balance()

uint64_t Electroneum::WalletImpl::balance ( uint32_t  accountIndex = 0,
bool  public_blockchain = false 
) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 996 of file wallet.cpp.

997 {
998  return m_wallet->balance(accountIndex, public_blockchain);
999 }

◆ blackballOutput()

bool Electroneum::WalletImpl::blackballOutput ( const std::string &  amount,
const std::string &  offset 
)
overridevirtual

blackballs an output

Implements Electroneum::Wallet.

Definition at line 2298 of file wallet.cpp.

2299 {
2300  uint64_t raw_amount, raw_offset;
2301  if (!epee::string_tools::get_xtype_from_string(raw_amount, amount))
2302  {
2303  setStatusError(tr("Failed to parse output amount"));
2304  return false;
2305  }
2306  if (!epee::string_tools::get_xtype_from_string(raw_offset, offset))
2307  {
2308  setStatusError(tr("Failed to parse output offset"));
2309  return false;
2310  }
2311  bool ret = m_wallet->blackball_output(std::make_pair(raw_amount, raw_offset));
2312  if (!ret)
2313  {
2314  setStatusError(tr("Failed to mark output as spent"));
2315  return false;
2316  }
2317  return true;
2318 }
#define tr(x)
Definition: common_defines.h:4
unsigned __int64 uint64_t
Definition: stdint.h:136
PUSH_WARNINGS bool get_xtype_from_string(OUT XType &val, const std::string &str_id)
Definition: string_tools.h:125
Here is the call graph for this function:

◆ blackballOutputs()

bool Electroneum::WalletImpl::blackballOutputs ( const std::vector< std::string > &  outputs,
bool  add 
)
overridevirtual

blackballs a set of outputs

Implements Electroneum::Wallet.

Definition at line 2260 of file wallet.cpp.

2261 {
2262  std::vector<std::pair<uint64_t, uint64_t>> raw_outputs;
2263  raw_outputs.reserve(outputs.size());
2264  uint64_t amount = std::numeric_limits<uint64_t>::max(), offset, num_offsets;
2265  for (const std::string &str: outputs)
2266  {
2267  if (sscanf(str.c_str(), "@%" PRIu64, &amount) == 1)
2268  continue;
2269  if (amount == std::numeric_limits<uint64_t>::max())
2270  {
2271  setStatusError("First line is not an amount");
2272  return true;
2273  }
2274  if (sscanf(str.c_str(), "%" PRIu64 "*%" PRIu64, &offset, &num_offsets) == 2 && num_offsets <= std::numeric_limits<uint64_t>::max() - offset)
2275  {
2276  while (num_offsets--)
2277  raw_outputs.push_back(std::make_pair(amount, offset++));
2278  }
2279  else if (sscanf(str.c_str(), "%" PRIu64, &offset) == 1)
2280  {
2281  raw_outputs.push_back(std::make_pair(amount, offset));
2282  }
2283  else
2284  {
2285  setStatusError(tr("Invalid output: ") + str);
2286  return false;
2287  }
2288  }
2289  bool ret = m_wallet->set_blackballed_outputs(raw_outputs, add);
2290  if (!ret)
2291  {
2292  setStatusError(tr("Failed to mark outputs as spent"));
2293  return false;
2294  }
2295  return true;
2296 }
#define tr(x)
Definition: common_defines.h:4
::std::string string
Definition: gtest-port.h:1097
unsigned __int64 uint64_t
Definition: stdint.h:136
#define PRIu64
Definition: inttypes.h:142

◆ blockChainHeight()

uint64_t Electroneum::WalletImpl::blockChainHeight ( ) const
overridevirtual

blockChainHeight - returns current blockchain height

Returns

Implements Electroneum::Wallet.

Definition at line 1006 of file wallet.cpp.

1007 {
1008  if(m_wallet->light_wallet()) {
1009  return m_wallet->get_light_wallet_scanned_block_height();
1010  }
1011  return m_wallet->get_blockchain_current_height();
1012 }
Here is the caller graph for this function:

◆ checkReserveProof()

bool Electroneum::WalletImpl::checkReserveProof ( const std::string &  address,
const std::string &  message,
const std::string &  signature,
bool good,
uint64_t total,
uint64_t spent 
) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1923 of file wallet.cpp.

1923  {
1925  if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address))
1926  {
1927  setStatusError(tr("Failed to parse address"));
1928  return false;
1929  }
1930  if (info.is_subaddress)
1931  {
1932  setStatusError(tr("Address must not be a subaddress"));
1933  return false;
1934  }
1935 
1936  good = false;
1937  try
1938  {
1939  clearStatus();
1940  good = m_wallet->check_reserve_proof(info.address, message, signature, total, spent);
1941  return true;
1942  }
1943  catch (const std::exception &e)
1944  {
1945  setStatusError(e.what());
1946  return false;
1947  }
1948 }
#define tr(x)
Definition: common_defines.h:4
std::string address(uint32_t accountIndex=0, uint32_t addressIndex=0) const override
Definition: wallet.cpp:860
std::string message("Message requiring signing")
POD_CLASS signature
Definition: crypto.h:108
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
Here is the call graph for this function:

◆ checkSpendProof()

bool Electroneum::WalletImpl::checkSpendProof ( const std::string &  txid,
const std::string &  message,
const std::string &  signature,
bool good 
) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1883 of file wallet.cpp.

1883  {
1884  good = false;
1885  crypto::hash txid;
1886  if(!epee::string_tools::hex_to_pod(txid_str, txid))
1887  {
1888  setStatusError(tr("Failed to parse txid"));
1889  return false;
1890  }
1891 
1892  try
1893  {
1894  clearStatus();
1895  good = m_wallet->check_spend_proof(txid, message, signature);
1896  return true;
1897  }
1898  catch (const std::exception &e)
1899  {
1900  setStatusError(e.what());
1901  return false;
1902  }
1903 }
#define tr(x)
Definition: common_defines.h:4
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
std::string message("Message requiring signing")
POD_CLASS signature
Definition: crypto.h:108
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ checkTxKey()

bool Electroneum::WalletImpl::checkTxKey ( const std::string &  txid,
std::string  tx_key,
const std::string &  address,
uint64_t received,
bool in_pool,
uint64_t confirmations 
)
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1758 of file wallet.cpp.

1759 {
1760  crypto::hash txid;
1761  if (!epee::string_tools::hex_to_pod(txid_str, txid))
1762  {
1763  setStatusError(tr("Failed to parse txid"));
1764  return false;
1765  }
1766 
1767  crypto::secret_key tx_key;
1768  std::vector<crypto::secret_key> additional_tx_keys;
1769  if (!epee::string_tools::hex_to_pod(tx_key_str.substr(0, 64), tx_key))
1770  {
1771  setStatusError(tr("Failed to parse tx key"));
1772  return false;
1773  }
1774  tx_key_str = tx_key_str.substr(64);
1775  while (!tx_key_str.empty())
1776  {
1777  additional_tx_keys.resize(additional_tx_keys.size() + 1);
1778  if (!epee::string_tools::hex_to_pod(tx_key_str.substr(0, 64), additional_tx_keys.back()))
1779  {
1780  setStatusError(tr("Failed to parse tx key"));
1781  return false;
1782  }
1783  tx_key_str = tx_key_str.substr(64);
1784  }
1785 
1787  if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address_str))
1788  {
1789  setStatusError(tr("Failed to parse address"));
1790  return false;
1791  }
1792 
1793  try
1794  {
1795  m_wallet->check_tx_key(txid, tx_key, additional_tx_keys, info.address, received, in_pool, confirmations);
1796  clearStatus();
1797  return true;
1798  }
1799  catch (const std::exception &e)
1800  {
1801  setStatusError(e.what());
1802  return false;
1803  }
1804 }
#define tr(x)
Definition: common_defines.h:4
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ checkTxProof()

bool Electroneum::WalletImpl::checkTxProof ( const std::string &  txid,
const std::string &  address,
const std::string &  message,
const std::string &  signature,
bool good,
uint64_t received,
bool in_pool,
uint64_t confirmations 
)
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1834 of file wallet.cpp.

1835 {
1836  crypto::hash txid;
1837  if (!epee::string_tools::hex_to_pod(txid_str, txid))
1838  {
1839  setStatusError(tr("Failed to parse txid"));
1840  return false;
1841  }
1842 
1844  if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address_str))
1845  {
1846  setStatusError(tr("Failed to parse address"));
1847  return false;
1848  }
1849 
1850  try
1851  {
1852  good = m_wallet->check_tx_proof(txid, info.address, info.is_subaddress, message, signature, received, in_pool, confirmations);
1853  clearStatus();
1854  return true;
1855  }
1856  catch (const std::exception &e)
1857  {
1858  setStatusError(e.what());
1859  return false;
1860  }
1861 }
#define tr(x)
Definition: common_defines.h:4
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
std::string message("Message requiring signing")
POD_CLASS signature
Definition: crypto.h:108
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ close()

bool Electroneum::WalletImpl::close ( bool  store = true)

Definition at line 762 of file wallet.cpp.

763 {
764 
765  bool result = false;
766  LOG_PRINT_L1("closing wallet...");
767  try {
768  if (store) {
769  // Do not store wallet with invalid status
770  // Status Critical refers to errors on opening or creating wallets.
771  if (status() != Status_Critical)
772  m_wallet->store();
773  else
774  LOG_ERROR("Status_Critical - not saving wallet");
775  LOG_PRINT_L1("wallet::store done");
776  }
777  LOG_PRINT_L1("Calling wallet::stop...");
778  m_wallet->stop();
779  LOG_PRINT_L1("wallet::stop done");
780  m_wallet->deinit();
781  result = true;
782  clearStatus();
783  } catch (const std::exception &e) {
784  setStatusCritical(e.what());
785  LOG_ERROR("Error closing wallet: " << e.what());
786  }
787  return result;
788 }
#define LOG_PRINT_L1(x)
Definition: misc_log_ex.h:100
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
bool store(const std::string &path) override
store - stores wallet to file.
Definition: wallet.cpp:909
Here is the call graph for this function:
Here is the caller graph for this function:

◆ coldKeyImageSync()

uint64_t Electroneum::WalletImpl::coldKeyImageSync ( uint64_t spent,
uint64_t unspent 
)
overridevirtual

cold-device protocol key image sync

Implements Electroneum::Wallet.

Definition at line 2428 of file wallet.cpp.

2429 {
2430  return m_wallet->cold_key_image_sync(spent, unspent);
2431 }

◆ connected()

Wallet::ConnectionStatus Electroneum::WalletImpl::connected ( ) const
overridevirtual

connected - checks if the wallet connected to the daemon

Returns
- true if connected

Implements Electroneum::Wallet.

Definition at line 2021 of file wallet.cpp.

2022 {
2023  uint32_t version = 0;
2024  m_is_connected = m_wallet->check_connection(&version, NULL, DEFAULT_CONNECTION_TIMEOUT_MILLIS);
2025  if (!m_is_connected)
2027  // Version check is not implemented in light wallets nodes/wallets
2028  if (!m_wallet->light_wallet() && (version >> 16) != CORE_RPC_VERSION_MAJOR)
2031 }
unsigned int uint32_t
Definition: stdint.h:126
version
Supported socks variants.
Definition: socks.h:57
#define CORE_RPC_VERSION_MAJOR

◆ connectToDaemon()

bool Electroneum::WalletImpl::connectToDaemon ( )
overridevirtual

connectToDaemon - connects to the daemon. TODO: check if it can be removed

Returns

Implements Electroneum::Wallet.

Definition at line 2009 of file wallet.cpp.

2010 {
2011  bool result = m_wallet->check_connection(NULL, NULL, DEFAULT_CONNECTION_TIMEOUT_MILLIS);
2012  if (!result) {
2013  setStatusError("Error connecting to daemon at " + m_wallet->get_daemon_address());
2014  } else {
2015  clearStatus();
2016  // start refreshing here
2017  }
2018  return result;
2019 }

◆ create()

bool Electroneum::WalletImpl::create ( const std::string &  path,
const std::string &  password,
const std::string &  language 
)

Definition at line 469 of file wallet.cpp.

470 {
471 
472  clearStatus();
473  m_recoveringFromSeed = false;
474  m_recoveringFromDevice = false;
475  bool keys_file_exists;
476  bool wallet_file_exists;
477  tools::wallet2::wallet_exists(path, keys_file_exists, wallet_file_exists);
478  LOG_PRINT_L3("wallet_path: " << path << "");
479  LOG_PRINT_L3("keys_file_exists: " << std::boolalpha << keys_file_exists << std::noboolalpha
480  << " wallet_file_exists: " << std::boolalpha << wallet_file_exists << std::noboolalpha);
481 
482 
483  // add logic to error out if new wallet requested but named wallet file exists
484  if (keys_file_exists || wallet_file_exists) {
485  std::string error = "attempting to generate or restore wallet, but specified file(s) exist. Exiting to not risk overwriting.";
486  LOG_ERROR(error);
487  setStatusCritical(error);
488  return false;
489  }
490  // TODO: validate language
491  m_wallet->set_seed_language(language);
492  crypto::secret_key recovery_val, secret_key;
493  try {
494  recovery_val = m_wallet->generate(path, password, secret_key, false, false);
495  m_password = password;
496  clearStatus();
497  } catch (const std::exception &e) {
498  LOG_ERROR("Error creating wallet: " << e.what());
499  setStatusCritical(e.what());
500  return false;
501  }
502 
503  return true;
504 }
static void wallet_exists(const std::string &file_path, bool &keys_file_exists, bool &wallet_file_exists)
Check if wallet keys and bin files exist.
Definition: wallet2.cpp:5697
::std::string string
Definition: gtest-port.h:1097
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:82
static void error(const std::string &category, const std::string &str)
Definition: wallet.cpp:415
#define LOG_PRINT_L3(x)
Definition: misc_log_ex.h:102
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createSweepUnmixableTransaction()

PendingTransaction * Electroneum::WalletImpl::createSweepUnmixableTransaction ( )
overridevirtual

createSweepUnmixableTransaction creates transaction with unmixable outputs.

Returns
PendingTransaction object. caller is responsible to check PendingTransaction::status() after object returned

Implements Electroneum::Wallet.

Definition at line 1587 of file wallet.cpp.

1589 {
1590  clearStatus();
1592 
1594 
1595  do {
1596  try {
1597  transaction->m_pending_tx = m_wallet->create_unmixable_sweep_transactions();
1598  pendingTxPostProcess(transaction);
1599 
1600  } catch (const tools::error::daemon_busy&) {
1601  // TODO: make it translatable with "tr"?
1602  setStatusError(tr("daemon is busy. Please try again later."));
1603  } catch (const tools::error::no_connection_to_daemon&) {
1604  setStatusError(tr("no connection to daemon. Please make sure daemon is running."));
1605  } catch (const tools::error::wallet_rpc_error& e) {
1606  setStatusError(tr("RPC error: ") + e.to_string());
1607  } catch (const tools::error::get_outs_error&) {
1608  setStatusError(tr("failed to get outputs to mix"));
1609  } catch (const tools::error::not_enough_unlocked_etn& e) {
1610  setStatusError("");
1611  std::ostringstream writer;
1612 
1613  writer << boost::format(tr("not enough ETN to transfer, available only %s, sent amount %s")) %
1614  print_etn(e.available()) %
1615  print_etn(e.tx_amount());
1616  setStatusError(writer.str());
1617  } catch (const tools::error::not_enough_etn& e) {
1618  setStatusError("");
1619  std::ostringstream writer;
1620 
1621  writer << boost::format(tr("not enough ETN to transfer, overall balance only %s, sent amount %s")) %
1622  print_etn(e.available()) %
1623  print_etn(e.tx_amount());
1624  setStatusError(writer.str());
1625  } catch (const tools::error::tx_not_possible& e) {
1626  setStatusError("");
1627  std::ostringstream writer;
1628 
1629  writer << boost::format(tr("not enough ETN to transfer, available only %s, transaction amount %s = %s + %s (fee)")) %
1630  print_etn(e.available()) %
1631  print_etn(e.tx_amount() + e.fee()) %
1632  print_etn(e.tx_amount()) %
1633  print_etn(e.fee());
1634  setStatusError(writer.str());
1635  } catch (const tools::error::not_enough_outs_to_mix& e) {
1636  std::ostringstream writer;
1637  writer << tr("not enough outputs.");
1638  for (const std::pair<uint64_t, uint64_t> outs_for_amount : e.scanty_outs()) {
1639  writer << "\n" << tr("output amount") << " = " << print_etn(outs_for_amount.first) << ", " << tr("found outputs to use") << " = " << outs_for_amount.second;
1640  }
1641  setStatusError(writer.str());
1642  } catch (const tools::error::tx_not_constructed&) {
1643  setStatusError(tr("transaction was not constructed"));
1644  } catch (const tools::error::tx_rejected& e) {
1645  std::ostringstream writer;
1646  writer << (boost::format(tr("transaction %s was rejected by daemon with status: ")) % get_transaction_hash(e.tx())) << e.status();
1647  setStatusError(writer.str());
1648  } catch (const tools::error::tx_sum_overflow& e) {
1649  setStatusError(e.what());
1650  } catch (const tools::error::zero_destination&) {
1651  setStatusError(tr("one of destinations is zero"));
1652  } catch (const tools::error::tx_too_big& e) {
1653  setStatusError(tr("failed to find a suitable way to split transactions"));
1654  } catch (const tools::error::transfer_error& e) {
1655  setStatusError(string(tr("unknown transfer error: ")) + e.what());
1656  } catch (const tools::error::wallet_internal_error& e) {
1657  setStatusError(string(tr("internal error: ")) + e.what());
1658  } catch (const std::exception& e) {
1659  setStatusError(string(tr("unexpected error: ")) + e.what());
1660  } catch (...) {
1661  setStatusError(tr("unknown error"));
1662  }
1663  } while (false);
1664 
1665  statusWithErrorString(transaction->m_status, transaction->m_errorString);
1666  return transaction;
1667 }
#define tr(x)
Definition: common_defines.h:4
std::string print_etn(uint64_t amount, unsigned int decimal_point)
void statusWithErrorString(int &status, std::string &errorString) const override
returns both error and error string atomically. suggested to use in instead of status() and errorStri...
Definition: wallet.cpp:820
const scanty_outs_t & scanty_outs() const
const std::string & status() const
crypto::hash get_transaction_hash(const transaction &t)
friend class PendingTransactionImpl
Definition: wallet.h:220
std::string to_string() const
const cryptonote::transaction & tx() const
Here is the call graph for this function:

◆ createTransaction()

PendingTransaction * Electroneum::WalletImpl::createTransaction ( const std::string &  dst_addr,
const std::string &  payment_id,
optional< uint64_t amount,
uint32_t  mixin_count,
PendingTransaction::Priority  = PendingTransaction::Priority_Low,
uint32_t  subaddr_account = 0,
std::set< uint32_t subaddr_indices = {} 
)
overridevirtual

createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored

Parameters
dst_addrdestination address as string
payment_idoptional payment_id, can be empty string
amountamount
mixin_countmixin count. if 0 passed, wallet will use default value
subaddr_accountsubaddress account from which the input funds are taken
subaddr_indicesset of subaddress indices to use for transfer or sweeping. if set empty, all are chosen when sweeping, and one or more are automatically chosen when transferring. after execution, returns the set of actually used indices
priority
Returns
PendingTransaction object. caller is responsible to check PendingTransaction::status() after object returned

Implements Electroneum::Wallet.

Definition at line 1412 of file wallet.cpp.

1415 {
1416  clearStatus();
1417  // Pause refresh thread while creating transaction
1418  pauseRefresh();
1419 
1421 
1422  // indicates if dst_addr is integrated address (address + payment_id)
1423  // TODO: (https://bitcointalk.org/index.php?topic=753252.msg9985441#msg9985441)
1424  size_t fake_outs_count = mixin_count > 0 ? mixin_count : m_wallet->default_mixin();
1425  if (fake_outs_count == 0)
1426  fake_outs_count = DEFAULT_MIXIN;
1427  fake_outs_count = m_wallet->adjust_mixin(fake_outs_count);
1428 
1429  uint32_t adjusted_priority = m_wallet->adjust_priority(static_cast<uint32_t>(priority));
1430 
1432 
1433  do {
1434  if(!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), dst_addr)) {
1435  // TODO: copy-paste 'if treating as an address fails, try as url' from simplewallet.cpp:1982
1436  setStatusError(tr("Invalid destination address"));
1437  break;
1438  }
1439 
1440 
1441  std::vector<uint8_t> extra;
1442  // if dst_addr is not an integrated address, parse payment_id
1443  if (!info.has_payment_id && !payment_id.empty()) {
1444  // copy-pasted from simplewallet.cpp:2212
1445  crypto::hash payment_id_long;
1446  bool r = tools::wallet2::parse_long_payment_id(payment_id, payment_id_long);
1447  if (r) {
1448  std::string extra_nonce;
1449  cryptonote::set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id_long);
1450  r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
1451  } else {
1452  r = tools::wallet2::parse_short_payment_id(payment_id, info.payment_id);
1453  if (r) {
1454  std::string extra_nonce;
1455  crypto::hash payment_id = crypto::null_hash;
1456  memcpy(payment_id.data, info.payment_id.data, 8); // convert short pid to regular
1457  memset(payment_id.data + 8, 0, 24); // merely a sanity check
1458 
1459  set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
1460  r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
1461  }
1462  }
1463 
1464  if (!r) {
1465  setStatusError(tr("payment id has invalid format, expected 16 or 64 character hex string: ") + payment_id);
1466  break;
1467  }
1468  }
1469  else if (info.has_payment_id) {
1470  std::string extra_nonce;
1471  crypto::hash payment_id = crypto::null_hash;
1472  memcpy(payment_id.data, info.payment_id.data, 8); // convert short pid to regular
1473  memset(payment_id.data + 8, 0, 24); // merely a sanity check
1474 
1475  set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
1476  bool r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
1477  if (!r) {
1478  setStatusError(tr("Failed to add short payment id: ") + epee::string_tools::pod_to_hex(info.payment_id));
1479  break;
1480  }
1481  }
1482 
1483 
1484  //std::vector<tools::wallet2::pending_tx> ptx_vector;
1485 
1486  try {
1487  if (amount) {
1488  vector<cryptonote::tx_destination_entry> dsts;
1490  de.original = dst_addr;
1491  de.addr = info.address;
1492  de.amount = *amount;
1493  de.is_subaddress = info.is_subaddress;
1494  de.is_integrated = info.has_payment_id;
1495  dsts.push_back(de);
1496  transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */,
1497  adjusted_priority,
1498  extra, subaddr_account, subaddr_indices);
1499  } else {
1500  // for the GUI, sweep_all (i.e. amount set as "(all)") will always sweep all the funds in all the addresses
1501  if (subaddr_indices.empty())
1502  {
1503  for (uint32_t index = 0; index < m_wallet->get_num_subaddresses(subaddr_account); ++index)
1504  subaddr_indices.insert(index);
1505  }
1506  transaction->m_pending_tx = m_wallet->create_transactions_all(0, info.address, info.is_subaddress, 1, fake_outs_count, 0 /* unlock_time */,
1507  adjusted_priority,
1508  extra, subaddr_account, subaddr_indices);
1509  }
1510 
1511  pendingTxPostProcess(transaction);
1512 
1513  if (multisig().isMultisig) {
1514  auto tx_set = m_wallet->make_multisig_tx_set(transaction->m_pending_tx);
1515  transaction->m_pending_tx = tx_set.m_ptx;
1516  transaction->m_signers = tx_set.m_signers;
1517  }
1518  } catch (const tools::error::daemon_busy&) {
1519  // TODO: make it translatable with "tr"?
1520  setStatusError(tr("daemon is busy. Please try again later."));
1521  } catch (const tools::error::no_connection_to_daemon&) {
1522  setStatusError(tr("no connection to daemon. Please make sure daemon is running."));
1523  } catch (const tools::error::wallet_rpc_error& e) {
1524  setStatusError(tr("RPC error: ") + e.to_string());
1525  } catch (const tools::error::get_outs_error &e) {
1526  setStatusError((boost::format(tr("failed to get outputs to mix: %s")) % e.what()).str());
1527  } catch (const tools::error::not_enough_unlocked_etn& e) {
1528  std::ostringstream writer;
1529 
1530  writer << boost::format(tr("not enough ETN to transfer, available only %s, sent amount %s")) %
1531  print_etn(e.available()) %
1532  print_etn(e.tx_amount());
1533  setStatusError(writer.str());
1534  } catch (const tools::error::not_enough_etn& e) {
1535  std::ostringstream writer;
1536 
1537  writer << boost::format(tr("not enough ETN to transfer, overall balance only %s, sent amount %s")) %
1538  print_etn(e.available()) %
1539  print_etn(e.tx_amount());
1540  setStatusError(writer.str());
1541  } catch (const tools::error::tx_not_possible& e) {
1542  std::ostringstream writer;
1543 
1544  writer << boost::format(tr("not enough ETN to transfer, available only %s, transaction amount %s = %s + %s (fee)")) %
1545  print_etn(e.available()) %
1546  print_etn(e.tx_amount() + e.fee()) %
1547  print_etn(e.tx_amount()) %
1548  print_etn(e.fee());
1549  setStatusError(writer.str());
1550  } catch (const tools::error::not_enough_outs_to_mix& e) {
1551  std::ostringstream writer;
1552  writer << tr("not enough outputs.");
1553  for (const std::pair<uint64_t, uint64_t> outs_for_amount : e.scanty_outs()) {
1554  writer << "\n" << tr("output amount") << " = " << print_etn(outs_for_amount.first) << ", " << tr("found outputs to use") << " = " << outs_for_amount.second;
1555  }
1556  writer << "\n" << tr("Please sweep unmixable outputs.");
1557  setStatusError(writer.str());
1558  } catch (const tools::error::tx_not_constructed&) {
1559  setStatusError(tr("transaction was not constructed"));
1560  } catch (const tools::error::tx_rejected& e) {
1561  std::ostringstream writer;
1562  writer << (boost::format(tr("transaction %s was rejected by daemon with status: ")) % get_transaction_hash(e.tx())) << e.status();
1563  setStatusError(writer.str());
1564  } catch (const tools::error::tx_sum_overflow& e) {
1565  setStatusError(e.what());
1566  } catch (const tools::error::zero_destination&) {
1567  setStatusError(tr("one of destinations is zero"));
1568  } catch (const tools::error::tx_too_big& e) {
1569  setStatusError(tr("failed to find a suitable way to split transactions"));
1570  } catch (const tools::error::transfer_error& e) {
1571  setStatusError(string(tr("unknown transfer error: ")) + e.what());
1572  } catch (const tools::error::wallet_internal_error& e) {
1573  setStatusError(string(tr("internal error: ")) + e.what());
1574  } catch (const std::exception& e) {
1575  setStatusError(string(tr("unexpected error: ")) + e.what());
1576  } catch (...) {
1577  setStatusError(tr("unknown error"));
1578  }
1579  } while (false);
1580 
1581  statusWithErrorString(transaction->m_status, transaction->m_errorString);
1582  // Resume refresh thread
1583  startRefresh();
1584  return transaction;
1585 }
static bool parse_long_payment_id(const std::string &payment_id_str, crypto::hash &payment_id)
Definition: wallet2.cpp:5712
#define tr(x)
Definition: common_defines.h:4
::std::string string
Definition: gtest-port.h:1097
std::string print_etn(uint64_t amount, unsigned int decimal_point)
virtual void startRefresh() override
StartRefresh - Start/resume refresh thread (refresh every 10 seconds)
Definition: wallet.cpp:2140
void statusWithErrorString(int &status, std::string &errorString) const override
returns both error and error string atomically. suggested to use in instead of status() and errorStri...
Definition: wallet.cpp:820
virtual void pauseRefresh() override
pauseRefresh - pause refresh thread
Definition: wallet.cpp:2161
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
unsigned int uint32_t
Definition: stdint.h:126
MultisigState multisig() const override
multisig - returns current state of multisig wallet creation process
Definition: wallet.cpp:1248
uint64_t amount
const scanty_outs_t & scanty_outs() const
bool is_subaddress
bool is_integrated
static bool parse_short_payment_id(const std::string &payment_id_str, crypto::hash8 &payment_id)
Definition: wallet2.cpp:5725
account_public_address addr
std::string original
const std::string & status() const
void * memcpy(void *a, const void *b, size_t c)
crypto::hash get_transaction_hash(const transaction &t)
friend class PendingTransactionImpl
Definition: wallet.h:220
bool add_extra_nonce_to_tx_extra(std::vector< uint8_t > &tx_extra, const blobdata &extra_nonce)
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
std::string to_string() const
const cryptonote::transaction & tx() const
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
POD_CLASS hash
Definition: hash.h:50
void set_payment_id_to_tx_extra_nonce(blobdata &extra_nonce, const crypto::hash &payment_id)
Here is the call graph for this function:

◆ createWatchOnly()

bool Electroneum::WalletImpl::createWatchOnly ( const std::string &  path,
const std::string &  password,
const std::string &  language 
) const
overridevirtual

createWatchOnly - Creates a watch only wallet

Parameters
path- where to store the wallet
password
language
Returns
- true if created successfully

Implements Electroneum::Wallet.

Definition at line 506 of file wallet.cpp.

507 {
508  clearStatus();
509  std::unique_ptr<tools::wallet2> view_wallet(new tools::wallet2(m_wallet->nettype()));
510 
511  // Store same refresh height as original wallet
512  view_wallet->set_refresh_from_block_height(m_wallet->get_refresh_from_block_height());
513 
514  bool keys_file_exists;
515  bool wallet_file_exists;
516  tools::wallet2::wallet_exists(path, keys_file_exists, wallet_file_exists);
517  LOG_PRINT_L3("wallet_path: " << path << "");
518  LOG_PRINT_L3("keys_file_exists: " << std::boolalpha << keys_file_exists << std::noboolalpha
519  << " wallet_file_exists: " << std::boolalpha << wallet_file_exists << std::noboolalpha);
520 
521  // add logic to error out if new wallet requested but named wallet file exists
522  if (keys_file_exists || wallet_file_exists) {
523  std::string error = "attempting to generate view only wallet, but specified file(s) exist. Exiting to not risk overwriting.";
524  LOG_ERROR(error);
525  setStatusError(error);
526  return false;
527  }
528  // TODO: validate language
529  view_wallet->set_seed_language(language);
530 
531  const crypto::secret_key viewkey = m_wallet->get_account().get_keys().m_view_secret_key;
532  const cryptonote::account_public_address address = m_wallet->get_account().get_keys().m_account_address;
533 
534  try {
535  // Generate view only wallet
536  view_wallet->generate(path, password, address, viewkey);
537 
538  // Export/Import outputs
539  auto outputs = m_wallet->export_outputs();
540  view_wallet->import_outputs(outputs);
541 
542  // Copy scanned blockchain
543  auto bc = m_wallet->export_blockchain();
544  view_wallet->import_blockchain(bc);
545 
546  // copy payments
547  auto payments = m_wallet->export_payments();
548  view_wallet->import_payments(payments);
549 
550  // copy confirmed outgoing payments
551  std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> out_payments;
552  m_wallet->get_payments_out(out_payments, 0);
553  view_wallet->import_payments_out(out_payments);
554 
555  // Export/Import key images
556  // We already know the spent status from the outputs we exported, thus no need to check them again
557  auto key_images = m_wallet->export_key_images();
558  uint64_t spent = 0;
559  uint64_t unspent = 0;
560  view_wallet->import_key_images(key_images.second, key_images.first, spent, unspent, false);
561  clearStatus();
562  } catch (const std::exception &e) {
563  LOG_ERROR("Error creating view only wallet: " << e.what());
564  setStatusError(e.what());
565  return false;
566  }
567  // Store wallet
568  view_wallet->store();
569  return true;
570 }
static void wallet_exists(const std::string &file_path, bool &keys_file_exists, bool &wallet_file_exists)
Check if wallet keys and bin files exist.
Definition: wallet2.cpp:5697
::std::string string
Definition: gtest-port.h:1097
std::string address(uint32_t accountIndex=0, uint32_t addressIndex=0) const override
Definition: wallet.cpp:860
static void error(const std::string &category, const std::string &str)
Definition: wallet.cpp:415
unsigned __int64 uint64_t
Definition: stdint.h:136
#define LOG_PRINT_L3(x)
Definition: misc_log_ex.h:102
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:

◆ daemonBlockChainHeight()

uint64_t Electroneum::WalletImpl::daemonBlockChainHeight ( ) const
overridevirtual

daemonBlockChainHeight - returns daemon blockchain height

Returns
0 - in case error communicating with the daemon. status() will return Status_Error and errorString() will return verbose error description

Implements Electroneum::Wallet.

Definition at line 1023 of file wallet.cpp.

1024 {
1025  if(m_wallet->light_wallet()) {
1026  return m_wallet->get_light_wallet_scanned_block_height();
1027  }
1028  if (!m_is_connected)
1029  return 0;
1030  std::string err;
1031  uint64_t result = m_wallet->get_daemon_blockchain_height(err);
1032  if (!err.empty()) {
1033  LOG_ERROR(__FUNCTION__ << ": " << err);
1034  result = 0;
1035  setStatusError(err);
1036  } else {
1037  clearStatus();
1038  }
1039  return result;
1040 }
::std::string string
Definition: gtest-port.h:1097
unsigned __int64 uint64_t
Definition: stdint.h:136
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
Here is the caller graph for this function:

◆ daemonBlockChainTargetHeight()

uint64_t Electroneum::WalletImpl::daemonBlockChainTargetHeight ( ) const
overridevirtual

daemonBlockChainTargetHeight - returns daemon blockchain target height

Returns
0 - in case error communicating with the daemon. status() will return Status_Error and errorString() will return verbose error description

Implements Electroneum::Wallet.

Definition at line 1042 of file wallet.cpp.

1043 {
1044  if(m_wallet->light_wallet()) {
1045  return m_wallet->get_light_wallet_blockchain_height();
1046  }
1047  if (!m_is_connected)
1048  return 0;
1049  std::string err;
1050  uint64_t result = m_wallet->get_daemon_blockchain_target_height(err);
1051  if (!err.empty()) {
1052  LOG_ERROR(__FUNCTION__ << ": " << err);
1053  result = 0;
1054  setStatusError(err);
1055  } else {
1056  clearStatus();
1057  }
1058  // Target height can be 0 when daemon is synced. Use blockchain height instead.
1059  if(result == 0)
1060  result = daemonBlockChainHeight();
1061  return result;
1062 }
::std::string string
Definition: gtest-port.h:1097
unsigned __int64 uint64_t
Definition: stdint.h:136
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
uint64_t daemonBlockChainHeight() const override
daemonBlockChainHeight - returns daemon blockchain height
Definition: wallet.cpp:1023
Here is the call graph for this function:

◆ defaultMixin()

uint32_t Electroneum::WalletImpl::defaultMixin ( ) const
overridevirtual

defaultMixin - returns number of mixins used in transactions

Returns

Implements Electroneum::Wallet.

Definition at line 1700 of file wallet.cpp.

1701 {
1702  return m_wallet->default_mixin();
1703 }

◆ disposeTransaction()

void Electroneum::WalletImpl::disposeTransaction ( PendingTransaction t)
overridevirtual

disposeTransaction - destroys transaction object

Parameters
t- pointer to the "PendingTransaction" object. Pointer is not valid after function returned;

Implements Electroneum::Wallet.

Definition at line 1669 of file wallet.cpp.

1670 {
1671  delete t;
1672 }

◆ errorString()

std::string Electroneum::WalletImpl::errorString ( ) const
overridevirtual

in case error status, returns error string

Implements Electroneum::Wallet.

Definition at line 814 of file wallet.cpp.

815 {
816  boost::lock_guard<boost::mutex> l(m_statusMutex);
817  return m_errorString;
818 }
Here is the caller graph for this function:

◆ estimateBlockChainHeight()

uint64_t Electroneum::WalletImpl::estimateBlockChainHeight ( ) const
overridevirtual

estimateBlockChainHeight - returns estimate blockchain height. More accurate than approximateBlockChainHeight, uses daemon height and falls back to calculation from date/time

Returns

Implements Electroneum::Wallet.

Definition at line 1018 of file wallet.cpp.

1019 {
1020  return m_wallet->estimate_blockchain_height();
1021 }
Here is the caller graph for this function:

◆ exchangeMultisigKeys()

std::string Electroneum::WalletImpl::exchangeMultisigKeys ( const std::vector< std::string > &  info)
overridevirtual

exchange_multisig_keys - provides additional key exchange round for arbitrary multisig schemes (like N-1/N, M/N)

Parameters
info- base58 encoded key derivations returned by makeMultisig or exchangeMultisigKeys function call
Returns
new info string if more rounds required or an empty string if wallet creation is done

Implements Electroneum::Wallet.

Definition at line 1284 of file wallet.cpp.

1284  {
1285  try {
1286  clearStatus();
1287  checkMultisigWalletNotReady(m_wallet);
1288 
1289  return m_wallet->exchange_multisig_keys(epee::wipeable_string(m_password), info);
1290  } catch (const exception& e) {
1291  LOG_ERROR("Error on exchanging multisig keys: " << e.what());
1292  setStatusError(string(tr("Failed to make multisig: ")) + e.what());
1293  }
1294 
1295  return string();
1296 }
#define tr(x)
Definition: common_defines.h:4
::std::string string
Definition: gtest-port.h:1097
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
Here is the call graph for this function:

◆ exportKeyImages()

bool Electroneum::WalletImpl::exportKeyImages ( const std::string &  filename)
overridevirtual

exportKeyImages - exports key images to file

Parameters
filename
Returns
- true on success

Implements Electroneum::Wallet.

Definition at line 1158 of file wallet.cpp.

1159 {
1160  if (m_wallet->watch_only())
1161  {
1162  setStatusError(tr("Wallet is view only"));
1163  return false;
1164  }
1165 
1166  try
1167  {
1168  if (!m_wallet->export_key_images(filename))
1169  {
1170  setStatusError(tr("failed to save file ") + filename);
1171  return false;
1172  }
1173  }
1174  catch (const std::exception &e)
1175  {
1176  LOG_ERROR("Error exporting key images: " << e.what());
1177  setStatusError(e.what());
1178  return false;
1179  }
1180  return true;
1181 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
std::string filename() const override
filename - returns wallet filename
Definition: wallet.cpp:927
Here is the call graph for this function:

◆ exportMultisigImages()

bool Electroneum::WalletImpl::exportMultisigImages ( std::string &  images)
overridevirtual

exportMultisigImages - exports transfers' key images

Parameters
images- output paramter for hex encoded array of images
Returns
true if success

Implements Electroneum::Wallet.

Definition at line 1316 of file wallet.cpp.

1316  {
1317  try {
1318  clearStatus();
1319  checkMultisigWalletReady(m_wallet);
1320 
1321  auto blob = m_wallet->export_multisig();
1323  return true;
1324  } catch (const exception& e) {
1325  LOG_ERROR("Error on exporting multisig images: " << e.what());
1326  setStatusError(string(tr("Failed to export multisig images: ")) + e.what());
1327  }
1328 
1329  return false;
1330 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
std::string buff_to_hex_nodelimer(const std::string &src)
Definition: string_tools.h:87
Here is the call graph for this function:

◆ filename()

string Electroneum::WalletImpl::filename ( ) const
overridevirtual

filename - returns wallet filename

Returns

Implements Electroneum::Wallet.

Definition at line 927 of file wallet.cpp.

928 {
929  return m_wallet->get_wallet_file();
930 }
Here is the caller graph for this function:

◆ finalizeMultisig()

bool Electroneum::WalletImpl::finalizeMultisig ( const std::vector< std::string > &  extraMultisigInfo)
overridevirtual

finalizeMultisig - finalizes N - 1 / N multisig wallets creation

Parameters
extraMultisigInfo- wallet participants' extra multisig info obtained with makeMultisig call
Returns
true if success

Implements Electroneum::Wallet.

Definition at line 1298 of file wallet.cpp.

1298  {
1299  try {
1300  clearStatus();
1301  checkMultisigWalletNotReady(m_wallet);
1302 
1303  if (m_wallet->finalize_multisig(epee::wipeable_string(m_password), extraMultisigInfo)) {
1304  return true;
1305  }
1306 
1307  setStatusError(tr("Failed to finalize multisig wallet creation"));
1308  } catch (const exception& e) {
1309  LOG_ERROR("Error on finalizing multisig wallet creation: " << e.what());
1310  setStatusError(string(tr("Failed to finalize multisig wallet creation: ")) + e.what());
1311  }
1312 
1313  return false;
1314 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98

◆ getDefaultDataDir()

std::string Electroneum::WalletImpl::getDefaultDataDir ( ) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 2227 of file wallet.cpp.

2228 {
2229  return tools::get_default_data_dir();
2230 }
std::string get_default_data_dir()
Returns the default data directory.
Definition: util.cpp:600
Here is the call graph for this function:

◆ getDeviceType()

Wallet::Device Electroneum::WalletImpl::getDeviceType ( ) const
overridevirtual

Queries backing device for wallet keys.

Returns
Device they are on

Implements Electroneum::Wallet.

Definition at line 694 of file wallet.cpp.

695 {
696  return static_cast<Wallet::Device>(m_wallet->get_device_type());
697 }

◆ getMultisigInfo()

string Electroneum::WalletImpl::getMultisigInfo ( ) const
overridevirtual

getMultisigInfo

Returns
serialized and signed multisig info string

Implements Electroneum::Wallet.

Definition at line 1255 of file wallet.cpp.

1255  {
1256  try {
1257  clearStatus();
1258  return m_wallet->get_multisig_info();
1259  } catch (const exception& e) {
1260  LOG_ERROR("Error on generating multisig info: " << e.what());
1261  setStatusError(string(tr("Failed to get multisig info: ")) + e.what());
1262  }
1263 
1264  return string();
1265 }
#define tr(x)
Definition: common_defines.h:4
::std::string string
Definition: gtest-port.h:1097
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98

◆ getRefreshFromBlockHeight()

uint64_t Electroneum::WalletImpl::getRefreshFromBlockHeight ( ) const
inlineoverridevirtual

getRestoreHeight - get wallet creation height

Implements Electroneum::Wallet.

Definition at line 126 of file wallet.h.

126 { return m_wallet->get_refresh_from_block_height(); };

◆ getReserveProof()

std::string Electroneum::WalletImpl::getReserveProof ( bool  all,
uint32_t  account_index,
uint64_t  amount,
const std::string &  message 
) const
overridevirtual

getReserveProof - Generates a proof that proves the reserve of unspent funds Parameters account_index and amount are ignored when all is true

Implements Electroneum::Wallet.

Definition at line 1905 of file wallet.cpp.

1905  {
1906  try
1907  {
1908  clearStatus();
1909  boost::optional<std::pair<uint32_t, uint64_t>> account_minreserve;
1910  if (!all)
1911  {
1912  account_minreserve = std::make_pair(account_index, amount);
1913  }
1914  return m_wallet->get_reserve_proof(account_minreserve, message);
1915  }
1916  catch (const std::exception &e)
1917  {
1918  setStatusError(e.what());
1919  return "";
1920  }
1921 }
std::string message("Message requiring signing")
Here is the call graph for this function:

◆ getRing()

bool Electroneum::WalletImpl::getRing ( const std::string &  key_image,
std::vector< uint64_t > &  ring 
) const
overridevirtual

gets the ring used for a key image, if any

Implements Electroneum::Wallet.

Definition at line 2342 of file wallet.cpp.

2343 {
2344  crypto::key_image raw_key_image;
2345  if (!epee::string_tools::hex_to_pod(key_image, raw_key_image))
2346  {
2347  setStatusError(tr("Failed to parse key image"));
2348  return false;
2349  }
2350  bool ret = m_wallet->get_ring(raw_key_image, ring);
2351  if (!ret)
2352  {
2353  setStatusError(tr("Failed to get ring"));
2354  return false;
2355  }
2356  return true;
2357 }
#define tr(x)
Definition: common_defines.h:4
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
POD_CLASS key_image
Definition: crypto.h:102
Here is the call graph for this function:

◆ getRings()

bool Electroneum::WalletImpl::getRings ( const std::string &  txid,
std::vector< std::pair< std::string, std::vector< uint64_t >>> &  rings 
) const
overridevirtual

gets the rings used for a txid, if any

Implements Electroneum::Wallet.

Definition at line 2359 of file wallet.cpp.

2360 {
2361  crypto::hash raw_txid;
2362  if (!epee::string_tools::hex_to_pod(txid, raw_txid))
2363  {
2364  setStatusError(tr("Failed to parse txid"));
2365  return false;
2366  }
2367  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> raw_rings;
2368  bool ret = m_wallet->get_rings(raw_txid, raw_rings);
2369  if (!ret)
2370  {
2371  setStatusError(tr("Failed to get rings"));
2372  return false;
2373  }
2374  for (const auto &r: raw_rings)
2375  {
2376  rings.push_back(std::make_pair(epee::string_tools::pod_to_hex(r.first), r.second));
2377  }
2378  return true;
2379 }
#define tr(x)
Definition: common_defines.h:4
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ getSeedLanguage()

std::string Electroneum::WalletImpl::getSeedLanguage ( ) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 798 of file wallet.cpp.

799 {
800  return m_wallet->get_seed_language();
801 }

◆ getSpendProof()

std::string Electroneum::WalletImpl::getSpendProof ( const std::string &  txid,
const std::string &  message 
) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1863 of file wallet.cpp.

1863  {
1864  crypto::hash txid;
1865  if(!epee::string_tools::hex_to_pod(txid_str, txid))
1866  {
1867  setStatusError(tr("Failed to parse txid"));
1868  return "";
1869  }
1870 
1871  try
1872  {
1873  clearStatus();
1874  return m_wallet->get_spend_proof(txid, message);
1875  }
1876  catch (const std::exception &e)
1877  {
1878  setStatusError(e.what());
1879  return "";
1880  }
1881 }
#define tr(x)
Definition: common_defines.h:4
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
std::string message("Message requiring signing")
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ getSubaddressLabel()

std::string Electroneum::WalletImpl::getSubaddressLabel ( uint32_t  accountIndex,
uint32_t  addressIndex 
) const
overridevirtual

getSubaddressLabel - gets the label of the specified subaddress

Parameters
accountIndex- the major index specifying the subaddress account
addressIndex- the minor index specifying the subaddress

Implements Electroneum::Wallet.

Definition at line 1222 of file wallet.cpp.

1223 {
1224  try
1225  {
1226  return m_wallet->get_subaddress_label({accountIndex, addressIndex});
1227  }
1228  catch (const std::exception &e)
1229  {
1230  LOG_ERROR("Error getting subaddress label: " << e.what());
1231  setStatusError(string(tr("Failed to get subaddress label: ")) + e.what());
1232  return "";
1233  }
1234 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98

◆ getTxKey()

std::string Electroneum::WalletImpl::getTxKey ( const std::string &  txid) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1731 of file wallet.cpp.

1732 {
1733  crypto::hash txid;
1734  if(!epee::string_tools::hex_to_pod(txid_str, txid))
1735  {
1736  setStatusError(tr("Failed to parse txid"));
1737  return "";
1738  }
1739 
1740  crypto::secret_key tx_key;
1741  std::vector<crypto::secret_key> additional_tx_keys;
1742  if (m_wallet->get_tx_key(txid, tx_key, additional_tx_keys))
1743  {
1744  clearStatus();
1745  std::ostringstream oss;
1746  oss << epee::string_tools::pod_to_hex(tx_key);
1747  for (size_t i = 0; i < additional_tx_keys.size(); ++i)
1748  oss << epee::string_tools::pod_to_hex(additional_tx_keys[i]);
1749  return oss.str();
1750  }
1751  else
1752  {
1753  setStatusError(tr("no tx keys found for this txid"));
1754  return "";
1755  }
1756 }
#define tr(x)
Definition: common_defines.h:4
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ getTxProof()

std::string Electroneum::WalletImpl::getTxProof ( const std::string &  txid,
const std::string &  address,
const std::string &  message 
) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1806 of file wallet.cpp.

1807 {
1808  crypto::hash txid;
1809  if (!epee::string_tools::hex_to_pod(txid_str, txid))
1810  {
1811  setStatusError(tr("Failed to parse txid"));
1812  return "";
1813  }
1814 
1816  if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address_str))
1817  {
1818  setStatusError(tr("Failed to parse address"));
1819  return "";
1820  }
1821 
1822  try
1823  {
1824  clearStatus();
1825  return m_wallet->get_tx_proof(txid, info.address, info.is_subaddress, message);
1826  }
1827  catch (const std::exception &e)
1828  {
1829  setStatusError(e.what());
1830  return "";
1831  }
1832 }
#define tr(x)
Definition: common_defines.h:4
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
std::string message("Message requiring signing")
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ getUserNote()

std::string Electroneum::WalletImpl::getUserNote ( const std::string &  txid) const
overridevirtual

getUserNote - return an arbitrary string note attached to a txid

Parameters
txid- the transaction id to attach the note to
Returns
the attached note, or empty string if there is none

Implements Electroneum::Wallet.

Definition at line 1721 of file wallet.cpp.

1722 {
1723  cryptonote::blobdata txid_data;
1724  if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data) || txid_data.size() != sizeof(crypto::hash))
1725  return "";
1726  const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
1727 
1728  return m_wallet->get_tx_note(htxid);
1729 }
std::string blobdata
Definition: blobdatatype.h:39
POD_CLASS hash
Definition: hash.h:50
bool parse_hexstr_to_binbuff(const epee::span< const char > s, epee::span< char > &res)
Definition: string_tools.h:92
Here is the call graph for this function:

◆ hardForkInfo()

void Electroneum::WalletImpl::hardForkInfo ( uint8_t version,
uint64_t earliest_height 
) const
overridevirtual

returns current hard fork info

Implements Electroneum::Wallet.

Definition at line 2250 of file wallet.cpp.

2251 {
2252  m_wallet->get_hard_fork_info(version, earliest_height);
2253 }
version
Supported socks variants.
Definition: socks.h:57

◆ hasMultisigPartialKeyImages()

bool Electroneum::WalletImpl::hasMultisigPartialKeyImages ( ) const
overridevirtual

hasMultisigPartialKeyImages - checks if wallet needs to import multisig key images from other participants

Returns
true if there are partial key images

Implements Electroneum::Wallet.

Definition at line 1360 of file wallet.cpp.

1360  {
1361  try {
1362  clearStatus();
1363  checkMultisigWalletReady(m_wallet);
1364 
1365  return m_wallet->has_multisig_partial_key_images();
1366  } catch (const exception& e) {
1367  LOG_ERROR("Error on checking for partial multisig key images: " << e.what());
1368  setStatusError(string(tr("Failed to check for partial multisig key images: ")) + e.what());
1369  }
1370 
1371  return false;
1372 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98

◆ history()

TransactionHistory * Electroneum::WalletImpl::history ( )
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1674 of file wallet.cpp.

1675 {
1676  return m_history.get();
1677 }

◆ importKeyImages()

bool Electroneum::WalletImpl::importKeyImages ( const std::string &  filename)
overridevirtual

importKeyImages - imports key images from file

Parameters
filename
Returns
- true on success

Implements Electroneum::Wallet.

Definition at line 1183 of file wallet.cpp.

1184 {
1185  if (!trustedDaemon()) {
1186  setStatusError(tr("Key images can only be imported with a trusted daemon"));
1187  return false;
1188  }
1189  try
1190  {
1191  uint64_t spent = 0, unspent = 0;
1192  uint64_t height = m_wallet->import_key_images(filename, spent, unspent);
1193  LOG_PRINT_L2("Signed key images imported to height " << height << ", "
1194  << print_etn(spent) << " spent, " << print_etn(unspent) << " unspent");
1195  }
1196  catch (const std::exception &e)
1197  {
1198  LOG_ERROR("Error exporting key images: " << e.what());
1199  setStatusError(string(tr("Failed to import key images: ")) + e.what());
1200  return false;
1201  }
1202 
1203  return true;
1204 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_PRINT_L2(x)
Definition: misc_log_ex.h:101
std::string print_etn(uint64_t amount, unsigned int decimal_point)
uint64_t height
Definition: blockchain.cpp:91
bool trustedDaemon() const override
Definition: wallet.cpp:2038
unsigned __int64 uint64_t
Definition: stdint.h:136
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
std::string filename() const override
filename - returns wallet filename
Definition: wallet.cpp:927
Here is the call graph for this function:

◆ importMultisigImages()

size_t Electroneum::WalletImpl::importMultisigImages ( const std::vector< std::string > &  images)
overridevirtual

importMultisigImages - imports other participants' multisig images

Parameters
images- array of hex encoded arrays of images obtained with exportMultisigImages
Returns
number of imported images

Implements Electroneum::Wallet.

Definition at line 1332 of file wallet.cpp.

1332  {
1333  try {
1334  clearStatus();
1335  checkMultisigWalletReady(m_wallet);
1336 
1337  std::vector<std::string> blobs;
1338  blobs.reserve(images.size());
1339 
1340  for (const auto& image: images) {
1341  std::string blob;
1342  if (!epee::string_tools::parse_hexstr_to_binbuff(image, blob)) {
1343  LOG_ERROR("Failed to parse imported multisig images");
1344  setStatusError(tr("Failed to parse imported multisig images"));
1345  return 0;
1346  }
1347 
1348  blobs.emplace_back(std::move(blob));
1349  }
1350 
1351  return m_wallet->import_multisig(blobs);
1352  } catch (const exception& e) {
1353  LOG_ERROR("Error on importing multisig images: " << e.what());
1354  setStatusError(string(tr("Failed to import multisig images: ")) + e.what());
1355  }
1356 
1357  return 0;
1358 }
#define tr(x)
Definition: common_defines.h:4
::std::string string
Definition: gtest-port.h:1097
const T & move(const T &t)
Definition: gtest-port.h:1317
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
bool parse_hexstr_to_binbuff(const epee::span< const char > s, epee::span< char > &res)
Definition: string_tools.h:92
Here is the call graph for this function:

◆ init()

bool Electroneum::WalletImpl::init ( const std::string &  daemon_address,
uint64_t  upper_transaction_size_limit = 0,
const std::string &  daemon_username = "",
const std::string &  daemon_password = "",
bool  use_ssl = false,
bool  lightWallet = false 
)
overridevirtual

init - initializes wallet with daemon connection params. if daemon_address is local address, "trusted daemon" will be set to true forcibly startRefresh() should be called when wallet is initialized.

Parameters
daemon_address- daemon address in "hostname:port" format
upper_transaction_size_limit
daemon_username
daemon_password
lightWallet- start wallet in light mode, connect to a openmonero compatible server.
Returns
- true on success

Implements Electroneum::Wallet.

Definition at line 937 of file wallet.cpp.

938 {
939  clearStatus();
940  m_wallet->set_light_wallet(lightWallet);
941  if(daemon_username != "")
942  m_daemon_login.emplace(daemon_username, daemon_password);
943  return doInit(daemon_address, upper_transaction_size_limit, use_ssl);
944 }
string daemon_address
Definition: transfers.cpp:42

◆ integratedAddress()

std::string Electroneum::WalletImpl::integratedAddress ( const std::string &  payment_id) const
overridevirtual

integratedAddress - returns integrated address for current wallet address and given payment_id. if passed "payment_id" param is an empty string or not-valid payment id string (16 characters hexadecimal string) - random payment_id will be generated

Parameters
payment_id- 16 characters hexadecimal string or empty string if new random payment id needs to be generated
Returns
- 106 characters string representing integrated address

Implements Electroneum::Wallet.

Definition at line 865 of file wallet.cpp.

866 {
867  crypto::hash8 pid;
868  if (!tools::wallet2::parse_short_payment_id(payment_id, pid)) {
869  return "";
870  }
871  return m_wallet->get_integrated_address_as_str(pid);
872 }
static bool parse_short_payment_id(const std::string &payment_id_str, crypto::hash8 &payment_id)
Definition: wallet2.cpp:5725
POD_CLASS hash8
Definition: hash.h:53
Here is the call graph for this function:

◆ isKeysFileLocked()

bool Electroneum::WalletImpl::isKeysFileLocked ( )
overridevirtual

returns true if the keys file is locked

Implements Electroneum::Wallet.

Definition at line 2423 of file wallet.cpp.

2424 {
2425  return m_wallet->is_keys_file_locked();
2426 }

◆ keyReuseMitigation2()

void Electroneum::WalletImpl::keyReuseMitigation2 ( bool  mitigation)
overridevirtual

secondary key reuse mitigation

Implements Electroneum::Wallet.

Definition at line 2408 of file wallet.cpp.

2409 {
2410  m_wallet->key_reuse_mitigation2(mitigation);
2411 }

◆ keysFilename()

string Electroneum::WalletImpl::keysFilename ( ) const
overridevirtual

keysFilename - returns keys filename. usually this formed as "wallet_filename".keys

Returns

Implements Electroneum::Wallet.

Definition at line 932 of file wallet.cpp.

933 {
934  return m_wallet->get_keys_file();
935 }

◆ lightWalletImportWalletRequest()

bool Electroneum::WalletImpl::lightWalletImportWalletRequest ( std::string &  payment_id,
uint64_t fee,
bool new_request,
bool request_fulfilled,
std::string &  payment_address,
std::string &  status 
)
overridevirtual

Initiates a light wallet import wallet request.

Implements Electroneum::Wallet.

Definition at line 951 of file wallet.cpp.

952 {
953  try
954  {
956  if(!m_wallet->light_wallet_import_wallet_request(response)){
957  setStatusError(tr("Failed to send import wallet request"));
958  return false;
959  }
960  fee = response.import_fee;
961  payment_id = response.payment_id;
962  new_request = response.new_request;
963  request_fulfilled = response.request_fulfilled;
964  payment_address = response.payment_address;
965  status = response.status;
966  }
967  catch (const std::exception &e)
968  {
969  LOG_ERROR("Error sending import wallet request: " << e.what());
970  setStatusError(e.what());
971  return false;
972  }
973  return true;
974 }
#define tr(x)
Definition: common_defines.h:4
epee::misc_utils::struct_init< response_t > response
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
Here is the call graph for this function:

◆ lightWalletLogin()

bool Electroneum::WalletImpl::lightWalletLogin ( bool isNewWallet) const
overridevirtual

Light wallet authenticate and login.

Implements Electroneum::Wallet.

Definition at line 946 of file wallet.cpp.

947 {
948  return m_wallet->light_wallet_login(isNewWallet);
949 }

◆ loadUnsignedTx()

UnsignedTransaction * Electroneum::WalletImpl::loadUnsignedTx ( const std::string &  unsigned_filename)
overridevirtual

loadUnsignedTx - creates transaction from unsigned tx file

Returns
- UnsignedTransaction object. caller is responsible to check UnsignedTransaction::status() after object returned

Implements Electroneum::Wallet.

Definition at line 1123 of file wallet.cpp.

1123  {
1124  clearStatus();
1126  if (!m_wallet->load_unsigned_tx(unsigned_filename, transaction->m_unsigned_tx_set)){
1127  setStatusError(tr("Failed to load unsigned transactions"));
1128  }
1129 
1130  // Check tx data and construct confirmation message
1131  std::string extra_message;
1132  if (!transaction->m_unsigned_tx_set.transfers.second.empty())
1133  extra_message = (boost::format("%u outputs to import. ") % (unsigned)transaction->m_unsigned_tx_set.transfers.second.size()).str();
1134  transaction->checkLoadedTx([&transaction](){return transaction->m_unsigned_tx_set.txes.size();}, [&transaction](size_t n)->const tools::wallet2::tx_construction_data&{return transaction->m_unsigned_tx_set.txes[n];}, extra_message);
1135  setStatus(transaction->status(), transaction->errorString());
1136 
1137  return transaction;
1138 }
#define tr(x)
Definition: common_defines.h:4
::std::string string
Definition: gtest-port.h:1097
friend class UnsignedTransactionImpl
Definition: wallet.h:221

◆ lockKeysFile()

bool Electroneum::WalletImpl::lockKeysFile ( )
overridevirtual

locks/unlocks the keys file; returns true on success

Implements Electroneum::Wallet.

Definition at line 2413 of file wallet.cpp.

2414 {
2415  return m_wallet->lock_keys_file();
2416 }

◆ makeMultisig()

string Electroneum::WalletImpl::makeMultisig ( const std::vector< std::string > &  info,
uint32_t  threshold 
)
overridevirtual

makeMultisig - switches wallet in multisig state. The one and only creation phase for N / N wallets

Parameters
info- vector of multisig infos from other participants obtained with getMulitisInfo call
threshold- number of required signers to make valid transaction. Must be equal to number of participants (N) or N - 1
Returns
in case of N / N wallets returns empty string since no more key exchanges needed. For N - 1 / N wallets returns base58 encoded extra multisig info

Implements Electroneum::Wallet.

Definition at line 1267 of file wallet.cpp.

1267  {
1268  try {
1269  clearStatus();
1270 
1271  if (m_wallet->multisig()) {
1272  throw runtime_error("Wallet is already multisig");
1273  }
1274 
1275  return m_wallet->make_multisig(epee::wipeable_string(m_password), info, threshold);
1276  } catch (const exception& e) {
1277  LOG_ERROR("Error on making multisig wallet: " << e.what());
1278  setStatusError(string(tr("Failed to make multisig: ")) + e.what());
1279  }
1280 
1281  return string();
1282 }
#define tr(x)
Definition: common_defines.h:4
::std::string string
Definition: gtest-port.h:1097
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
uint8_t threshold
Definition: blockchain.cpp:92
Here is the call graph for this function:

◆ multisig()

MultisigState Electroneum::WalletImpl::multisig ( ) const
overridevirtual

multisig - returns current state of multisig wallet creation process

Returns
MultisigState struct

Implements Electroneum::Wallet.

Definition at line 1248 of file wallet.cpp.

1248  {
1249  MultisigState state;
1250  state.isMultisig = m_wallet->multisig(&state.isReady, &state.threshold, &state.total);
1251 
1252  return state;
1253 }
Definition: blake256.h:37
Here is the caller graph for this function:

◆ nettype()

NetworkType Electroneum::WalletImpl::nettype ( ) const
inlineoverridevirtual

Implements Electroneum::Wallet.

Definition at line 132 of file wallet.h.

132 {return static_cast<NetworkType>(m_wallet->nettype());}
Here is the caller graph for this function:

◆ numSubaddressAccounts()

size_t Electroneum::WalletImpl::numSubaddressAccounts ( ) const
overridevirtual

numSubaddressAccounts - returns the number of existing subaddress accounts

Implements Electroneum::Wallet.

Definition at line 1210 of file wallet.cpp.

1211 {
1212  return m_wallet->get_num_subaddress_accounts();
1213 }

◆ numSubaddresses()

size_t Electroneum::WalletImpl::numSubaddresses ( uint32_t  accountIndex) const
overridevirtual

numSubaddresses - returns the number of existing subaddresses associated with the specified subaddress account

Parameters
accountIndex- the major index specifying the subaddress account

Implements Electroneum::Wallet.

Definition at line 1214 of file wallet.cpp.

1215 {
1216  return m_wallet->get_num_subaddresses(accountIndex);
1217 }

◆ open()

bool Electroneum::WalletImpl::open ( const std::string &  path,
const std::string &  password 
)

Definition at line 699 of file wallet.cpp.

700 {
701  clearStatus();
702  m_recoveringFromSeed = false;
703  m_recoveringFromDevice = false;
704  try {
705  // TODO: handle "deprecated"
706  // Check if wallet cache exists
707  bool keys_file_exists;
708  bool wallet_file_exists;
709  tools::wallet2::wallet_exists(path, keys_file_exists, wallet_file_exists);
710  if(!wallet_file_exists){
711  // Rebuilding wallet cache, using refresh height from .keys file
712  m_rebuildWalletCache = true;
713  }
714  m_wallet->set_ring_database(get_default_ringdb_path(m_wallet->nettype()));
715  m_wallet->load(path, password);
716 
717  m_password = password;
718  } catch (const std::exception &e) {
719  LOG_ERROR("Error opening wallet: " << e.what());
720  setStatusCritical(e.what());
721  }
722  return status() == Status_Ok;
723 }
static void wallet_exists(const std::string &file_path, bool &keys_file_exists, bool &wallet_file_exists)
Check if wallet keys and bin files exist.
Definition: wallet2.cpp:5697
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_uri()

bool Electroneum::WalletImpl::parse_uri ( const std::string &  uri,
std::string &  address,
std::string &  payment_id,
uint64_t amount,
std::string &  tx_description,
std::string &  recipient_name,
std::vector< std::string > &  unknown_parameters,
std::string &  error 
)
overridevirtual

Implements Electroneum::Wallet.

Definition at line 2222 of file wallet.cpp.

2223 {
2224  return m_wallet->parse_uri(uri, address, payment_id, amount, tx_description, recipient_name, unknown_parameters, error);
2225 }
std::string address(uint32_t accountIndex=0, uint32_t addressIndex=0) const override
Definition: wallet.cpp:860
static void error(const std::string &category, const std::string &str)
Definition: wallet.cpp:415
Here is the call graph for this function:

◆ path()

std::string Electroneum::WalletImpl::path ( ) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 904 of file wallet.cpp.

905 {
906  return m_wallet->path();
907 }
Here is the caller graph for this function:

◆ pauseRefresh()

void Electroneum::WalletImpl::pauseRefresh ( )
overridevirtual

pauseRefresh - pause refresh thread

Implements Electroneum::Wallet.

Definition at line 2161 of file wallet.cpp.

2162 {
2163  LOG_PRINT_L2(__FUNCTION__ << ": refresh paused...");
2164  // TODO synchronize access
2165  if (!m_refreshThreadDone) {
2166  m_refreshEnabled = false;
2167  }
2168 }
#define LOG_PRINT_L2(x)
Definition: misc_log_ex.h:101
Here is the caller graph for this function:

◆ publicMultisigSignerKey()

std::string Electroneum::WalletImpl::publicMultisigSignerKey ( ) const
overridevirtual

publicMultisigSignerKey - returns public signer key

Returns
- public multisignature signer key or empty string if wallet is not multisig

Implements Electroneum::Wallet.

Definition at line 894 of file wallet.cpp.

895 {
896  try {
897  crypto::public_key signer = m_wallet->get_multisig_signer_public_key();
898  return epee::string_tools::pod_to_hex(signer);
899  } catch (const std::exception&) {
900  return "";
901  }
902 }
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
POD_CLASS public_key
Definition: crypto.h:76
Here is the call graph for this function:

◆ publicSpendKey()

std::string Electroneum::WalletImpl::publicSpendKey ( ) const
overridevirtual

publicSpendKey - returns public spend key

Returns
- public spend key

Implements Electroneum::Wallet.

Definition at line 889 of file wallet.cpp.

890 {
891  return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_account_address.m_spend_public_key);
892 }
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
Here is the call graph for this function:

◆ publicViewKey()

std::string Electroneum::WalletImpl::publicViewKey ( ) const
overridevirtual

publicViewKey - returns public view key

Returns
- public view key

Implements Electroneum::Wallet.

Definition at line 879 of file wallet.cpp.

880 {
881  return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_account_address.m_view_public_key);
882 }
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
Here is the call graph for this function:

◆ recover() [1/2]

bool Electroneum::WalletImpl::recover ( const std::string &  path,
const std::string &  password,
const std::string &  seed 
)

Definition at line 730 of file wallet.cpp.

731 {
732  clearStatus();
733  m_errorString.clear();
734  if (seed.empty()) {
735  LOG_ERROR("Electrum seed is empty");
736  setStatusError(tr("Electrum seed is empty"));
737  return false;
738  }
739 
740  m_recoveringFromSeed = true;
741  m_recoveringFromDevice = false;
742  crypto::secret_key recovery_key;
743  std::string old_language;
744  if (!crypto::ElectrumWords::words_to_bytes(seed, recovery_key, old_language)) {
745  setStatusError(tr("Electrum-style word list failed verification"));
746  return false;
747  }
748 
749  if (old_language == crypto::ElectrumWords::old_language_name)
750  old_language = Language::English().get_language_name();
751 
752  try {
753  m_wallet->set_seed_language(old_language);
754  m_wallet->generate(path, password, recovery_key, true, false);
755 
756  } catch (const std::exception &e) {
757  setStatusCritical(e.what());
758  }
759  return status() == Status_Ok;
760 }
#define tr(x)
Definition: common_defines.h:4
const std::string & get_language_name() const
Returns the name of the language.
::std::string string
Definition: gtest-port.h:1097
const std::string old_language_name
bool words_to_bytes(const epee::wipeable_string &words, epee::wipeable_string &dst, size_t len, bool duplicate, std::string &language_name)
Converts seed words to bytes (secret key).
std::string seed() const override
Definition: wallet.cpp:790
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recover() [2/2]

bool Electroneum::WalletImpl::recover ( const std::string &  path,
const std::string &  seed 
)

Definition at line 725 of file wallet.cpp.

726 {
727  return recover(path, "", seed);
728 }
bool recover(const std::string &path, const std::string &password, const std::string &seed)
Definition: wallet.cpp:730
std::string seed() const override
Definition: wallet.cpp:790
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:

◆ recoverFromDevice()

bool Electroneum::WalletImpl::recoverFromDevice ( const std::string &  path,
const std::string &  password,
const std::string &  device_name 
)

Definition at line 677 of file wallet.cpp.

678 {
679  clearStatus();
680  m_recoveringFromSeed = false;
681  m_recoveringFromDevice = true;
682  try
683  {
684  m_wallet->restore(path, password, device_name);
685  LOG_PRINT_L1("Generated new wallet from device: " + device_name);
686  }
687  catch (const std::exception& e) {
688  setStatusError(string(tr("failed to generate new wallet: ")) + e.what());
689  return false;
690  }
691  return true;
692 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_PRINT_L1(x)
Definition: misc_log_ex.h:100
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recoverFromKeys()

bool Electroneum::WalletImpl::recoverFromKeys ( const std::string &  path,
const std::string &  language,
const std::string &  address_string,
const std::string &  viewkey_string,
const std::string &  spendkey_string = "" 
)

Definition at line 572 of file wallet.cpp.

577 {
578  return recoverFromKeysWithPassword(path, "", language, address_string, viewkey_string, spendkey_string);
579 }
bool recoverFromKeysWithPassword(const std::string &path, const std::string &password, const std::string &language, const std::string &address_string, const std::string &viewkey_string, const std::string &spendkey_string="")
Definition: wallet.cpp:581
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:

◆ recoverFromKeysWithPassword()

bool Electroneum::WalletImpl::recoverFromKeysWithPassword ( const std::string &  path,
const std::string &  password,
const std::string &  language,
const std::string &  address_string,
const std::string &  viewkey_string,
const std::string &  spendkey_string = "" 
)

Definition at line 581 of file wallet.cpp.

587 {
589  if(!get_account_address_from_str(info, m_wallet->nettype(), address_string))
590  {
591  setStatusError(tr("failed to parse address"));
592  return false;
593  }
594 
595  // parse optional spend key
597  bool has_spendkey = false;
598  if (!spendkey_string.empty()) {
599  cryptonote::blobdata spendkey_data;
600  if(!epee::string_tools::parse_hexstr_to_binbuff(spendkey_string, spendkey_data) || spendkey_data.size() != sizeof(crypto::secret_key))
601  {
602  setStatusError(tr("failed to parse secret spend key"));
603  return false;
604  }
605  has_spendkey = true;
606  spendkey = *reinterpret_cast<const crypto::secret_key*>(spendkey_data.data());
607  }
608 
609  // parse view secret key
610  bool has_viewkey = true;
611  crypto::secret_key viewkey;
612  if (viewkey_string.empty()) {
613  if(has_spendkey) {
614  has_viewkey = false;
615  }
616  else {
617  setStatusError(tr("Neither view key nor spend key supplied, cancelled"));
618  return false;
619  }
620  }
621  if(has_viewkey) {
622  cryptonote::blobdata viewkey_data;
623  if(!epee::string_tools::parse_hexstr_to_binbuff(viewkey_string, viewkey_data) || viewkey_data.size() != sizeof(crypto::secret_key))
624  {
625  setStatusError(tr("failed to parse secret view key"));
626  return false;
627  }
628  viewkey = *reinterpret_cast<const crypto::secret_key*>(viewkey_data.data());
629  }
630  // check the spend and view keys match the given address
631  crypto::public_key pkey;
632  if(has_spendkey) {
634  setStatusError(tr("failed to verify secret spend key"));
635  return false;
636  }
637  if (info.address.m_spend_public_key != pkey) {
638  setStatusError(tr("spend key does not match address"));
639  return false;
640  }
641  }
642  if(has_viewkey) {
643  if (!crypto::secret_key_to_public_key(viewkey, pkey)) {
644  setStatusError(tr("failed to verify secret view key"));
645  return false;
646  }
647  if (info.address.m_view_public_key != pkey) {
648  setStatusError(tr("view key does not match address"));
649  return false;
650  }
651  }
652 
653  try
654  {
655  if (has_spendkey && has_viewkey) {
656  m_wallet->generate(path, password, info.address, spendkey, viewkey);
657  LOG_PRINT_L1("Generated new wallet from spend key and view key");
658  }
659  if(!has_spendkey && has_viewkey) {
660  m_wallet->generate(path, password, info.address, viewkey);
661  LOG_PRINT_L1("Generated new view only wallet from keys");
662  }
663  if(has_spendkey && !has_viewkey) {
664  m_wallet->generate(path, password, spendkey, true, false);
665  setSeedLanguage(language);
666  LOG_PRINT_L1("Generated deterministic wallet from spend key with seed language: " + language);
667  }
668 
669  }
670  catch (const std::exception& e) {
671  setStatusError(string(tr("failed to generate new wallet: ")) + e.what());
672  return false;
673  }
674  return true;
675 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_PRINT_L1(x)
Definition: misc_log_ex.h:100
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:82
void setSeedLanguage(const std::string &arg) override
Definition: wallet.cpp:803
POD_CLASS public_key
Definition: crypto.h:76
std::string blobdata
Definition: blobdatatype.h:39
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition: crypto.h:262
const char * spendkey
Definition: multisig.cpp:38
bool parse_hexstr_to_binbuff(const epee::span< const char > s, epee::span< char > &res)
Definition: string_tools.h:92
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:
Here is the caller graph for this function:

◆ refresh()

bool Electroneum::WalletImpl::refresh ( )
overridevirtual

refresh - refreshes the wallet, updating transactions from daemon

Returns
- true if refreshed successfully;

Implements Electroneum::Wallet.

Definition at line 1077 of file wallet.cpp.

1078 {
1079  clearStatus();
1080  //TODO: make doRefresh return bool to know whether the error occured during refresh or not
1081  //otherwise one may try, say, to send transaction, transfer fails and this method returns false
1082  doRefresh();
1083  return status() == Status_Ok;
1084 }
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
Here is the call graph for this function:

◆ refreshAsync()

void Electroneum::WalletImpl::refreshAsync ( )
overridevirtual

refreshAsync - refreshes wallet asynchronously.

Implements Electroneum::Wallet.

Definition at line 1086 of file wallet.cpp.

1087 {
1088  LOG_PRINT_L3(__FUNCTION__ << ": Refreshing asynchronously..");
1089  clearStatus();
1090  m_refreshCV.notify_one();
1091 }
#define LOG_PRINT_L3(x)
Definition: misc_log_ex.h:102
Here is the caller graph for this function:

◆ rescanBlockchain()

bool Electroneum::WalletImpl::rescanBlockchain ( )
overridevirtual

rescanBlockchain - rescans the wallet, updating transactions from daemon

Returns
- true if refreshed successfully;

Implements Electroneum::Wallet.

Definition at line 1093 of file wallet.cpp.

1094 {
1095  clearStatus();
1096  m_refreshShouldRescan = true;
1097  doRefresh();
1098  return status() == Status_Ok;
1099 }
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
Here is the call graph for this function:

◆ rescanBlockchainAsync()

void Electroneum::WalletImpl::rescanBlockchainAsync ( )
overridevirtual

rescanBlockchainAsync - rescans wallet asynchronously, starting from genesys

Implements Electroneum::Wallet.

Definition at line 1101 of file wallet.cpp.

1102 {
1103  m_refreshShouldRescan = true;
1104  refreshAsync();
1105 }
void refreshAsync() override
refreshAsync - refreshes wallet asynchronously.
Definition: wallet.cpp:1086
Here is the call graph for this function:

◆ rescanSpent()

bool Electroneum::WalletImpl::rescanSpent ( )
overridevirtual

Implements Electroneum::Wallet.

Definition at line 2232 of file wallet.cpp.

2233 {
2234  clearStatus();
2235  if (!trustedDaemon()) {
2236  setStatusError(tr("Rescan spent can only be used with a trusted daemon"));
2237  return false;
2238  }
2239  try {
2240  m_wallet->rescan_spent();
2241  } catch (const std::exception &e) {
2242  LOG_ERROR(__FUNCTION__ << " error: " << e.what());
2243  setStatusError(e.what());
2244  return false;
2245  }
2246  return true;
2247 }
#define tr(x)
Definition: common_defines.h:4
bool trustedDaemon() const override
Definition: wallet.cpp:2038
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
Here is the call graph for this function:

◆ restoreMultisigTransaction()

PendingTransaction * Electroneum::WalletImpl::restoreMultisigTransaction ( const std::string &  signData)
overridevirtual

restoreMultisigTransaction creates PendingTransaction from signData

Parameters
signDataencrypted unsigned transaction. Obtained with PendingTransaction::multisigSignData
Returns
PendingTransaction

Implements Electroneum::Wallet.

Definition at line 1374 of file wallet.cpp.

1374  {
1375  try {
1376  clearStatus();
1377  checkMultisigWalletReady(m_wallet);
1378 
1379  string binary;
1380  if (!epee::string_tools::parse_hexstr_to_binbuff(signData, binary)) {
1381  throw runtime_error("Failed to deserialize multisig transaction");
1382  }
1383 
1385  if (!m_wallet->load_multisig_tx(binary, txSet, {})) {
1386  throw runtime_error("couldn't parse multisig transaction data");
1387  }
1388 
1389  auto ptx = new PendingTransactionImpl(*this);
1390  ptx->m_pending_tx = txSet.m_ptx;
1391  ptx->m_signers = txSet.m_signers;
1392 
1393  return ptx;
1394  } catch (exception& e) {
1395  LOG_ERROR("Error on restoring multisig transaction: " << e.what());
1396  setStatusError(string(tr("Failed to restore multisig transaction: ")) + e.what());
1397  }
1398 
1399  return nullptr;
1400 }
#define tr(x)
Definition: common_defines.h:4
std::unordered_set< crypto::public_key > m_signers
Definition: wallet2.h:513
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
friend class PendingTransactionImpl
Definition: wallet.h:220
std::vector< pending_tx > m_ptx
Definition: wallet2.h:512
bool parse_hexstr_to_binbuff(const epee::span< const char > s, epee::span< char > &res)
Definition: string_tools.h:92
Here is the call graph for this function:

◆ secretSpendKey()

std::string Electroneum::WalletImpl::secretSpendKey ( ) const
overridevirtual

secretSpendKey - returns secret spend key

Returns
- secret spend key

Implements Electroneum::Wallet.

Definition at line 884 of file wallet.cpp.

885 {
886  return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_spend_secret_key);
887 }
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
Here is the call graph for this function:

◆ secretViewKey()

std::string Electroneum::WalletImpl::secretViewKey ( ) const
overridevirtual

secretViewKey - returns secret view key

Returns
- secret view key

Implements Electroneum::Wallet.

Definition at line 874 of file wallet.cpp.

875 {
876  return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key);
877 }
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
Here is the call graph for this function:

◆ seed()

std::string Electroneum::WalletImpl::seed ( ) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 790 of file wallet.cpp.

791 {
793  if (m_wallet)
794  m_wallet->get_seed(seed);
795  return std::string(seed.data(), seed.size()); // TODO
796 }
::std::string string
Definition: gtest-port.h:1097
std::string seed() const override
Definition: wallet.cpp:790
Here is the caller graph for this function:

◆ segregatePreForkOutputs()

void Electroneum::WalletImpl::segregatePreForkOutputs ( bool  segregate)
overridevirtual

sets whether pre-fork outs are to be segregated

Implements Electroneum::Wallet.

Definition at line 2398 of file wallet.cpp.

2399 {
2400  m_wallet->segregate_pre_fork_outputs(segregate);
2401 }

◆ segregationHeight()

void Electroneum::WalletImpl::segregationHeight ( uint64_t  height)
overridevirtual

sets the height where segregation should occur

Implements Electroneum::Wallet.

Definition at line 2403 of file wallet.cpp.

2404 {
2405  m_wallet->segregation_height(height);
2406 }
uint64_t height
Definition: blockchain.cpp:91

◆ setAutoRefreshInterval()

void Electroneum::WalletImpl::setAutoRefreshInterval ( int  millis)
overridevirtual

setAutoRefreshInterval - setup interval for automatic refresh.

Parameters
seconds- interval in millis. if zero or less than zero - automatic refresh disabled;

Implements Electroneum::Wallet.

Definition at line 1107 of file wallet.cpp.

1108 {
1109  if (millis > MAX_REFRESH_INTERVAL_MILLIS) {
1110  LOG_ERROR(__FUNCTION__<< ": invalid refresh interval " << millis
1111  << " ms, maximum allowed is " << MAX_REFRESH_INTERVAL_MILLIS << " ms");
1112  m_refreshIntervalMillis = MAX_REFRESH_INTERVAL_MILLIS;
1113  } else {
1114  m_refreshIntervalMillis = millis;
1115  }
1116 }
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98

◆ setDefaultMixin()

void Electroneum::WalletImpl::setDefaultMixin ( uint32_t  arg)
overridevirtual

setDefaultMixin - setum number of mixins to be used for new transactions

Parameters
arg

Implements Electroneum::Wallet.

Definition at line 1705 of file wallet.cpp.

1706 {
1707  m_wallet->default_mixin(arg);
1708 }

◆ setDevicePassphrase()

bool Electroneum::WalletImpl::setDevicePassphrase ( const std::string &  password)
overridevirtual

Reimplemented from Electroneum::Wallet.

Definition at line 849 of file wallet.cpp.

850 {
851  clearStatus();
852  try {
853  m_wallet->get_account().get_device().set_passphrase(epee::wipeable_string(passphrase.data(), passphrase.size()));
854  } catch (const std::exception &e) {
855  setStatusError(e.what());
856  }
857  return status() == Status_Ok;
858 }
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
Here is the call graph for this function:

◆ setDevicePin()

bool Electroneum::WalletImpl::setDevicePin ( const std::string &  password)
overridevirtual

Reimplemented from Electroneum::Wallet.

Definition at line 838 of file wallet.cpp.

839 {
840  clearStatus();
841  try {
842  m_wallet->get_account().get_device().set_pin(epee::wipeable_string(pin.data(), pin.size()));
843  } catch (const std::exception &e) {
844  setStatusError(e.what());
845  }
846  return status() == Status_Ok;
847 }
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
Here is the call graph for this function:

◆ setListener()

void Electroneum::WalletImpl::setListener ( WalletListener l)
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1694 of file wallet.cpp.

1695 {
1696  // TODO thread synchronization;
1697  m_wallet2Callback->setListener(l);
1698 }
Here is the caller graph for this function:

◆ setPassword()

bool Electroneum::WalletImpl::setPassword ( const std::string &  password)
overridevirtual

Implements Electroneum::Wallet.

Definition at line 826 of file wallet.cpp.

827 {
828  clearStatus();
829  try {
830  m_wallet->change_password(m_wallet->get_wallet_file(), m_password, password);
831  m_password = password;
832  } catch (const std::exception &e) {
833  setStatusError(e.what());
834  }
835  return status() == Status_Ok;
836 }
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
Here is the call graph for this function:

◆ setRecoveringFromDevice()

void Electroneum::WalletImpl::setRecoveringFromDevice ( bool  recoveringFromDevice)
overridevirtual

setRecoveringFromDevice - set state to recovering from device

Parameters
recoveringFromDevice- true/false

Implements Electroneum::Wallet.

Definition at line 986 of file wallet.cpp.

987 {
988  m_recoveringFromDevice = recoveringFromDevice;
989 }

◆ setRecoveringFromSeed()

void Electroneum::WalletImpl::setRecoveringFromSeed ( bool  recoveringFromSeed)
overridevirtual

setRecoveringFromSeed - set state recover form seed

Parameters
recoveringFromSeed- true/false

Implements Electroneum::Wallet.

Definition at line 981 of file wallet.cpp.

982 {
983  m_recoveringFromSeed = recoveringFromSeed;
984 }

◆ setRefreshFromBlockHeight()

void Electroneum::WalletImpl::setRefreshFromBlockHeight ( uint64_t  refresh_from_block_height)
overridevirtual

setRefreshFromBlockHeight - start refresh from block height on recover

Parameters
refresh_from_block_height- blockchain start height

Implements Electroneum::Wallet.

Definition at line 976 of file wallet.cpp.

977 {
978  m_wallet->set_refresh_from_block_height(refresh_from_block_height);
979 }
Here is the caller graph for this function:

◆ setRing()

bool Electroneum::WalletImpl::setRing ( const std::string &  key_image,
const std::vector< uint64_t > &  ring,
bool  relative 
)
overridevirtual

sets the ring used for a key image

Implements Electroneum::Wallet.

Definition at line 2381 of file wallet.cpp.

2382 {
2383  crypto::key_image raw_key_image;
2384  if (!epee::string_tools::hex_to_pod(key_image, raw_key_image))
2385  {
2386  setStatusError(tr("Failed to parse key image"));
2387  return false;
2388  }
2389  bool ret = m_wallet->set_ring(raw_key_image, ring, relative);
2390  if (!ret)
2391  {
2392  setStatusError(tr("Failed to set ring"));
2393  return false;
2394  }
2395  return true;
2396 }
#define tr(x)
Definition: common_defines.h:4
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Definition: string_tools.h:324
POD_CLASS key_image
Definition: crypto.h:102
Here is the call graph for this function:

◆ setSeedLanguage()

void Electroneum::WalletImpl::setSeedLanguage ( const std::string &  arg)
overridevirtual

Implements Electroneum::Wallet.

Definition at line 803 of file wallet.cpp.

804 {
805  m_wallet->set_seed_language(arg);
806 }
Here is the caller graph for this function:

◆ setSubaddressLabel()

void Electroneum::WalletImpl::setSubaddressLabel ( uint32_t  accountIndex,
uint32_t  addressIndex,
const std::string &  label 
)
overridevirtual

setSubaddressLabel - sets the label of the specified subaddress

Parameters
accountIndex- the major index specifying the subaddress account
addressIndex- the minor index specifying the subaddress
label- the new label for the specified subaddress

Implements Electroneum::Wallet.

Definition at line 1235 of file wallet.cpp.

1236 {
1237  try
1238  {
1239  return m_wallet->set_subaddress_label({accountIndex, addressIndex}, label);
1240  }
1241  catch (const std::exception &e)
1242  {
1243  LOG_ERROR("Error setting subaddress label: " << e.what());
1244  setStatusError(string(tr("Failed to set subaddress label: ")) + e.what());
1245  }
1246 }
#define tr(x)
Definition: common_defines.h:4
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98

◆ setSubaddressLookahead()

void Electroneum::WalletImpl::setSubaddressLookahead ( uint32_t  major,
uint32_t  minor 
)
overridevirtual

setSubaddressLookahead - set size of subaddress lookahead

Parameters
major- size fot the major index
minor- size fot the minor index

Implements Electroneum::Wallet.

Definition at line 991 of file wallet.cpp.

992 {
993  m_wallet->set_subaddress_lookahead(major, minor);
994 }
Here is the caller graph for this function:

◆ setTrustedDaemon()

void Electroneum::WalletImpl::setTrustedDaemon ( bool  arg)
overridevirtual

Implements Electroneum::Wallet.

Definition at line 2033 of file wallet.cpp.

2034 {
2035  m_wallet->set_trusted_daemon(arg);
2036 }

◆ setUserNote()

bool Electroneum::WalletImpl::setUserNote ( const std::string &  txid,
const std::string &  note 
)
overridevirtual

setUserNote - attach an arbitrary string note to a txid

Parameters
txid- the transaction id to attach the note to
note- the note
Returns
true if successful, false otherwise

Implements Electroneum::Wallet.

Definition at line 1710 of file wallet.cpp.

1711 {
1712  cryptonote::blobdata txid_data;
1713  if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data) || txid_data.size() != sizeof(crypto::hash))
1714  return false;
1715  const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
1716 
1717  m_wallet->set_tx_note(htxid, note);
1718  return true;
1719 }
std::string blobdata
Definition: blobdatatype.h:39
POD_CLASS hash
Definition: hash.h:50
bool parse_hexstr_to_binbuff(const epee::span< const char > s, epee::span< char > &res)
Definition: string_tools.h:92
Here is the call graph for this function:

◆ signMessage()

std::string Electroneum::WalletImpl::signMessage ( const std::string &  message)
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1950 of file wallet.cpp.

1951 {
1952  return m_wallet->sign(message);
1953 }
std::string message("Message requiring signing")
Here is the call graph for this function:

◆ signMultisigParticipant()

std::string Electroneum::WalletImpl::signMultisigParticipant ( const std::string &  message) const
overridevirtual

signMultisigParticipant signs given message with the multisig public signer key

Parameters
messagemessage to sign
Returns
signature in case of success. Sets status to Error and return empty string in case of error

Implements Electroneum::Wallet.

Definition at line 1965 of file wallet.cpp.

1966 {
1967  clearStatus();
1968 
1969  bool ready = false;
1970  if (!m_wallet->multisig(&ready) || !ready) {
1971  m_status = Status_Error;
1972  m_errorString = tr("The wallet must be in multisig ready state");
1973  return {};
1974  }
1975 
1976  try {
1977  return m_wallet->sign_multisig_participant(message);
1978  } catch (const std::exception& e) {
1979  m_status = Status_Error;
1980  m_errorString = e.what();
1981  }
1982 
1983  return {};
1984 }
#define tr(x)
Definition: common_defines.h:4
std::string message("Message requiring signing")
Here is the call graph for this function:

◆ startRefresh()

void Electroneum::WalletImpl::startRefresh ( )
overridevirtual

StartRefresh - Start/resume refresh thread (refresh every 10 seconds)

Implements Electroneum::Wallet.

Definition at line 2140 of file wallet.cpp.

2141 {
2142  if (!m_refreshEnabled) {
2143  LOG_PRINT_L2(__FUNCTION__ << ": refresh started/resumed...");
2144  m_refreshEnabled = true;
2145  m_refreshCV.notify_one();
2146  }
2147 }
#define LOG_PRINT_L2(x)
Definition: misc_log_ex.h:101
Here is the caller graph for this function:

◆ status()

int Electroneum::WalletImpl::status ( ) const
overridevirtual

returns wallet status (Status_Ok | Status_Error)

Implements Electroneum::Wallet.

Definition at line 808 of file wallet.cpp.

809 {
810  boost::lock_guard<boost::mutex> l(m_statusMutex);
811  return m_status;
812 }
Here is the caller graph for this function:

◆ statusWithErrorString()

void Electroneum::WalletImpl::statusWithErrorString ( int &  status,
std::string &  errorString 
) const
overridevirtual

returns both error and error string atomically. suggested to use in instead of status() and errorString()

Implements Electroneum::Wallet.

Definition at line 820 of file wallet.cpp.

820  {
821  boost::lock_guard<boost::mutex> l(m_statusMutex);
822  status = m_status;
823  errorString = m_errorString;
824 }
std::string errorString() const override
in case error status, returns error string
Definition: wallet.cpp:814
int status() const override
returns wallet status (Status_Ok | Status_Error)
Definition: wallet.cpp:808
Here is the call graph for this function:
Here is the caller graph for this function:

◆ store()

bool Electroneum::WalletImpl::store ( const std::string &  path)
overridevirtual

store - stores wallet to file.

Parameters
path- main filename to store wallet to. additionally stores address file and keys file. to store to the same file - just pass empty string;
Returns

Implements Electroneum::Wallet.

Definition at line 909 of file wallet.cpp.

910 {
911  clearStatus();
912  try {
913  if (path.empty()) {
914  m_wallet->store();
915  } else {
916  m_wallet->store_to(path, m_password);
917  }
918  } catch (const std::exception &e) {
919  LOG_ERROR("Error saving wallet: " << e.what());
920  setStatusError(e.what());
921  return false;
922  }
923 
924  return true;
925 }
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
std::string path() const override
Definition: wallet.cpp:904
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subaddress()

Subaddress * Electroneum::WalletImpl::subaddress ( )
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1684 of file wallet.cpp.

1685 {
1686  return m_subaddress.get();
1687 }

◆ subaddressAccount()

SubaddressAccount * Electroneum::WalletImpl::subaddressAccount ( )
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1689 of file wallet.cpp.

1690 {
1691  return m_subaddressAccount.get();
1692 }

◆ submitTransaction()

bool Electroneum::WalletImpl::submitTransaction ( const std::string &  fileName)
overridevirtual

submitTransaction - submits transaction in signed tx file

Returns
- true on success

Implements Electroneum::Wallet.

Definition at line 1140 of file wallet.cpp.

1140  {
1141  clearStatus();
1142  std::unique_ptr<PendingTransactionImpl> transaction(new PendingTransactionImpl(*this));
1143 
1144  bool r = m_wallet->load_tx(fileName, transaction->m_pending_tx);
1145  if (!r) {
1146  setStatus(Status_Ok, tr("Failed to load transaction from file"));
1147  return false;
1148  }
1149 
1150  if(!transaction->commit()) {
1151  setStatusError(transaction->m_errorString);
1152  return false;
1153  }
1154 
1155  return true;
1156 }
#define tr(x)
Definition: common_defines.h:4
friend class PendingTransactionImpl
Definition: wallet.h:220

◆ synchronized()

bool Electroneum::WalletImpl::synchronized ( ) const
overridevirtual

synchronized - checks if wallet was ever synchronized

Returns

Implements Electroneum::Wallet.

Definition at line 1072 of file wallet.cpp.

1073 {
1074  return m_synchronized;
1075 }

◆ trustedDaemon()

bool Electroneum::WalletImpl::trustedDaemon ( ) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 2038 of file wallet.cpp.

2039 {
2040  return m_wallet->is_trusted_daemon();
2041 }
Here is the caller graph for this function:

◆ unblackballOutput()

bool Electroneum::WalletImpl::unblackballOutput ( const std::string &  amount,
const std::string &  offset 
)
overridevirtual

unblackballs an output

Implements Electroneum::Wallet.

Definition at line 2320 of file wallet.cpp.

2321 {
2322  uint64_t raw_amount, raw_offset;
2323  if (!epee::string_tools::get_xtype_from_string(raw_amount, amount))
2324  {
2325  setStatusError(tr("Failed to parse output amount"));
2326  return false;
2327  }
2328  if (!epee::string_tools::get_xtype_from_string(raw_offset, offset))
2329  {
2330  setStatusError(tr("Failed to parse output offset"));
2331  return false;
2332  }
2333  bool ret = m_wallet->unblackball_output(std::make_pair(raw_amount, raw_offset));
2334  if (!ret)
2335  {
2336  setStatusError(tr("Failed to mark output as unspent"));
2337  return false;
2338  }
2339  return true;
2340 }
#define tr(x)
Definition: common_defines.h:4
unsigned __int64 uint64_t
Definition: stdint.h:136
PUSH_WARNINGS bool get_xtype_from_string(OUT XType &val, const std::string &str_id)
Definition: string_tools.h:125
Here is the call graph for this function:

◆ unlockedBalance()

uint64_t Electroneum::WalletImpl::unlockedBalance ( uint32_t  accountIndex = 0,
bool  public_blockchain = false 
) const
overridevirtual

Implements Electroneum::Wallet.

Definition at line 1001 of file wallet.cpp.

1002 {
1003  return m_wallet->unlocked_balance(accountIndex, public_blockchain);
1004 }

◆ unlockKeysFile()

bool Electroneum::WalletImpl::unlockKeysFile ( )
overridevirtual

Implements Electroneum::Wallet.

Definition at line 2418 of file wallet.cpp.

2419 {
2420  return m_wallet->unlock_keys_file();
2421 }

◆ useForkRules()

bool Electroneum::WalletImpl::useForkRules ( uint8_t  version,
int64_t  early_blocks 
) const
overridevirtual

check if hard fork rules should be used

Implements Electroneum::Wallet.

Definition at line 2255 of file wallet.cpp.

2256 {
2257  return m_wallet->use_fork_rules(version,early_blocks);
2258 }
version
Supported socks variants.
Definition: socks.h:57

◆ verifyMessageWithPublicKey()

bool Electroneum::WalletImpl::verifyMessageWithPublicKey ( const std::string &  message,
const std::string &  publicKey,
const std::string &  signature 
) const
overridevirtual

verifyMessageWithPublicKey verifies that message was signed with the given public key

Parameters
messagemessage
publicKeyhex encoded public key
signaturesignature of the message
Returns
true if the signature is correct. false and sets error state in case of error

Implements Electroneum::Wallet.

Definition at line 1986 of file wallet.cpp.

1987 {
1988  clearStatus();
1989 
1990  cryptonote::blobdata pkeyData;
1991  if(!epee::string_tools::parse_hexstr_to_binbuff(publicKey, pkeyData) || pkeyData.size() != sizeof(crypto::public_key))
1992  {
1993  m_status = Status_Error;
1994  m_errorString = tr("Given string is not a key");
1995  return false;
1996  }
1997 
1998  try {
1999  crypto::public_key pkey = *reinterpret_cast<const crypto::public_key*>(pkeyData.data());
2000  return m_wallet->verify_with_public_key(message, pkey, signature);
2001  } catch (const std::exception& e) {
2002  m_status = Status_Error;
2003  m_errorString = e.what();
2004  }
2005 
2006  return false;
2007 }
#define tr(x)
Definition: common_defines.h:4
std::string publicKey
POD_CLASS public_key
Definition: crypto.h:76
std::string message("Message requiring signing")
std::string blobdata
Definition: blobdatatype.h:39
POD_CLASS signature
Definition: crypto.h:108
bool parse_hexstr_to_binbuff(const epee::span< const char > s, epee::span< char > &res)
Definition: string_tools.h:92
Here is the call graph for this function:

◆ verifySignedMessage()

bool Electroneum::WalletImpl::verifySignedMessage ( const std::string &  message,
const std::string &  addres,
const std::string &  signature 
) const
overridevirtual

verifySignedMessage - verify a signature matches a given message

Parameters
message- the message (arbitrary byte data)
address- the address the signature claims to be made with
signature- the signature
Returns
true if the signature verified, false otherwise

Implements Electroneum::Wallet.

Definition at line 1955 of file wallet.cpp.

1956 {
1958 
1959  if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address))
1960  return false;
1961 
1962  return m_wallet->verify(message, info.address, signature);
1963 }
std::string address(uint32_t accountIndex=0, uint32_t addressIndex=0) const override
Definition: wallet.cpp:860
std::string message("Message requiring signing")
POD_CLASS signature
Definition: crypto.h:108
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
static void info(const std::string &category, const std::string &str)
Definition: wallet.cpp:407
Here is the call graph for this function:

◆ watchOnly()

bool Electroneum::WalletImpl::watchOnly ( ) const
overridevirtual

watchOnly - checks if wallet is watch only

Returns
- true if watch only

Implements Electroneum::Wallet.

Definition at line 2043 of file wallet.cpp.

2044 {
2045  return m_wallet->watch_only();
2046 }
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ AddressBookImpl

friend class AddressBookImpl
friend

Definition at line 224 of file wallet.h.

◆ PendingTransactionImpl

friend class PendingTransactionImpl
friend

Definition at line 220 of file wallet.h.

◆ SubaddressAccountImpl

friend class SubaddressAccountImpl
friend

Definition at line 226 of file wallet.h.

◆ SubaddressImpl

friend class SubaddressImpl
friend

Definition at line 225 of file wallet.h.

◆ TransactionHistoryImpl

friend class TransactionHistoryImpl
friend

Definition at line 222 of file wallet.h.

◆ UnsignedTransactionImpl

friend class UnsignedTransactionImpl
friend

Definition at line 221 of file wallet.h.

◆ Wallet2CallbackImpl

friend struct Wallet2CallbackImpl
friend

Definition at line 223 of file wallet.h.


The documentation for this class was generated from the following files: