Electroneum
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Electroneum::Wallet Struct Referenceabstract

Interface for wallet operations. TODO: check if /include/IWallet.h is still actual. More...

#include <wallet2_api.h>

Inheritance diagram for Electroneum::Wallet:
Inheritance graph
[legend]

Public Types

enum  Status { Status_Ok, Status_Error, Status_Critical }
 
enum  ConnectionStatus { ConnectionStatus_Disconnected, ConnectionStatus_Connected, ConnectionStatus_WrongVersion }
 

Public Member Functions

virtual ~Wallet ()=0
 
virtual std::string seed () const =0
 
virtual std::string getSeedLanguage () const =0
 
virtual void setSeedLanguage (const std::string &arg)=0
 
virtual int status () const =0
 returns wallet status (Status_Ok | Status_Error) More...
 
virtual std::string errorString () const =0
 in case error status, returns error string More...
 
virtual bool setPassword (const std::string &password)=0
 
virtual std::string address () const =0
 
virtual std::string path () const =0
 
virtual bool testnet () const =0
 
virtual void hardForkInfo (uint8_t &version, uint64_t &earliest_height) const =0
 returns current hard fork info More...
 
virtual bool useForkRules (uint8_t version, int64_t early_blocks) const =0
 check if hard fork rules should be used More...
 
virtual std::string integratedAddress (const std::string &payment_id) const =0
 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...
 
virtual std::string secretViewKey () const =0
 secretViewKey - returns secret view key More...
 
virtual std::string publicViewKey () const =0
 publicViewKey - returns public view key More...
 
virtual std::string secretSpendKey () const =0
 secretSpendKey - returns secret spend key More...
 
virtual std::string publicSpendKey () const =0
 publicSpendKey - returns public spend key More...
 
virtual bool store (const std::string &path)=0
 store - stores wallet to file. More...
 
virtual std::string filename () const =0
 filename - returns wallet filename More...
 
virtual std::string keysFilename () const =0
 keysFilename - returns keys filename. usually this formed as "wallet_filename".keys More...
 
virtual bool init (const std::string &daemon_address, uint64_t upper_transaction_size_limit, const std::string &daemon_username="", const std::string &daemon_password="")=0
 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...
 
virtual bool createWatchOnly (const std::string &path, const std::string &password, const std::string &language) const =0
 createWatchOnly - Creates a watch only wallet More...
 
virtual void setRefreshFromBlockHeight (uint64_t refresh_from_block_height)=0
 setRefreshFromBlockHeight - start refresh from block height on recover More...
 
virtual uint64_t getRefreshFromBlockHeight () const =0
 getRestoreHeight - get wallet creation height More...
 
virtual void setRecoveringFromSeed (bool recoveringFromSeed)=0
 setRecoveringFromSeed - set state recover form seed More...
 
virtual bool connectToDaemon ()=0
 connectToDaemon - connects to the daemon. TODO: check if it can be removed More...
 
virtual ConnectionStatus connected () const =0
 connected - checks if the wallet connected to the daemon More...
 
virtual void setTrustedDaemon (bool arg)=0
 
virtual bool trustedDaemon () const =0
 
virtual uint64_t balance () const =0
 
virtual uint64_t unlockedBalance () const =0
 
virtual bool watchOnly () const =0
 watchOnly - checks if wallet is watch only More...
 
virtual uint64_t blockChainHeight () const =0
 blockChainHeight - returns current blockchain height More...
 
virtual uint64_t approximateBlockChainHeight () const =0
 approximateBlockChainHeight - returns approximate blockchain height calculated from date/time More...
 
virtual uint64_t daemonBlockChainHeight () const =0
 daemonBlockChainHeight - returns daemon blockchain height More...
 
virtual uint64_t daemonBlockChainTargetHeight () const =0
 daemonBlockChainTargetHeight - returns daemon blockchain target height More...
 
virtual bool synchronized () const =0
 synchronized - checks if wallet was ever synchronized More...
 
virtual void startRefresh ()=0
 StartRefresh - Start/resume refresh thread (refresh every 10 seconds) More...
 
virtual void pauseRefresh ()=0
 pauseRefresh - pause refresh thread More...
 
virtual bool refresh ()=0
 refresh - refreshes the wallet, updating transactions from daemon More...
 
virtual void refreshAsync ()=0
 refreshAsync - refreshes wallet asynchronously. More...
 
virtual void setAutoRefreshInterval (int millis)=0
 setAutoRefreshInterval - setup interval for automatic refresh. More...
 
virtual int autoRefreshInterval () const =0
 autoRefreshInterval - returns automatic refresh interval in millis More...
 
virtual PendingTransactioncreateTransaction (const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority=PendingTransaction::Priority_Low)=0
 createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored More...
 
virtual PendingTransactioncreateSweepUnmixableTransaction ()=0
 createSweepUnmixableTransaction creates transaction with unmixable outputs. More...
 
virtual UnsignedTransactionloadUnsignedTx (const std::string &unsigned_filename)=0
 loadUnsignedTx - creates transaction from unsigned tx file More...
 
virtual bool submitTransaction (const std::string &fileName)=0
 submitTransaction - submits transaction in signed tx file More...
 
virtual void disposeTransaction (PendingTransaction *t)=0
 disposeTransaction - destroys transaction object More...
 
virtual bool exportKeyImages (const std::string &filename)=0
 exportKeyImages - exports key images to file More...
 
virtual bool importKeyImages (const std::string &filename)=0
 importKeyImages - imports key images from file More...
 
virtual TransactionHistoryhistory () const =0
 
virtual AddressBookaddressBook () const =0
 
virtual void setListener (WalletListener *)=0
 
virtual bool setUserNote (const std::string &txid, const std::string &note)=0
 
virtual std::string getUserNote (const std::string &txid) const =0
 getUserNote - return an arbitrary string note attached to a txid More...
 
virtual std::string getTxKey (const std::string &txid) const =0
 
virtual std::string signMessage (const std::string &message)=0
 
virtual bool verifySignedMessage (const std::string &message, const std::string &addres, const std::string &signature) const =0
 verifySignedMessage - verify a signature matches a given message 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)=0
 
virtual std::string getDefaultDataDir () const =0
 
virtual bool rescanSpent ()=0
 

Static Public Member Functions

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, bool testnet)
 
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, bool testnet)
 
static uint64_t maximumAllowedAmount ()
 
static void init (const char *argv0, const char *default_log_base_name)
 
static void debug (const std::string &str)
 

Detailed Description

Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.

Member Enumeration Documentation

◆ ConnectionStatus

Enumerator
ConnectionStatus_Disconnected 
ConnectionStatus_Connected 
ConnectionStatus_WrongVersion 

◆ Status

Enumerator
Status_Ok 
Status_Error 
Status_Critical 

Constructor & Destructor Documentation

◆ ~Wallet()

Electroneum::Wallet::~Wallet ( )
pure virtual

Member Function Documentation

◆ address()

virtual std::string Electroneum::Wallet::address ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ addressBook()

virtual AddressBook* Electroneum::Wallet::addressBook ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ addressValid()

bool Electroneum::Wallet::addressValid ( const std::string &  str,
bool  testnet 
)
static

◆ amountFromDouble()

uint64_t Electroneum::Wallet::amountFromDouble ( double  amount)
static

◆ amountFromString()

uint64_t Electroneum::Wallet::amountFromString ( const std::string &  amount)
static

◆ approximateBlockChainHeight()

virtual uint64_t Electroneum::Wallet::approximateBlockChainHeight ( ) const
pure virtual

approximateBlockChainHeight - returns approximate blockchain height calculated from date/time

Returns

Implemented in Electroneum::WalletImpl.

◆ autoRefreshInterval()

virtual int Electroneum::Wallet::autoRefreshInterval ( ) const
pure virtual

autoRefreshInterval - returns automatic refresh interval in millis

Returns

Implemented in Electroneum::WalletImpl.

◆ balance()

virtual uint64_t Electroneum::Wallet::balance ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ blockChainHeight()

virtual uint64_t Electroneum::Wallet::blockChainHeight ( ) const
pure virtual

blockChainHeight - returns current blockchain height

Returns

Implemented in Electroneum::WalletImpl.

◆ connected()

virtual ConnectionStatus Electroneum::Wallet::connected ( ) const
pure virtual

connected - checks if the wallet connected to the daemon

Returns
- true if connected

Implemented in Electroneum::WalletImpl.

◆ connectToDaemon()

virtual bool Electroneum::Wallet::connectToDaemon ( )
pure virtual

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

Returns

Implemented in Electroneum::WalletImpl.

◆ createSweepUnmixableTransaction()

virtual PendingTransaction* Electroneum::Wallet::createSweepUnmixableTransaction ( )
pure virtual

createSweepUnmixableTransaction creates transaction with unmixable outputs.

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

Implemented in Electroneum::WalletImpl.

◆ createTransaction()

virtual PendingTransaction* Electroneum::Wallet::createTransaction ( const std::string &  dst_addr,
const std::string &  payment_id,
optional< uint64_t >  amount,
uint32_t  mixin_count,
PendingTransaction::Priority  = PendingTransaction::Priority_Low 
)
pure virtual

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
priority
Returns
PendingTransaction object. caller is responsible to check PendingTransaction::status() after object returned

Implemented in Electroneum::WalletImpl.

◆ createWatchOnly()

virtual bool Electroneum::Wallet::createWatchOnly ( const std::string &  path,
const std::string &  password,
const std::string &  language 
) const
pure virtual

createWatchOnly - Creates a watch only wallet

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

Implemented in Electroneum::WalletImpl.

◆ daemonBlockChainHeight()

virtual uint64_t Electroneum::Wallet::daemonBlockChainHeight ( ) const
pure virtual

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

Implemented in Electroneum::WalletImpl.

◆ daemonBlockChainTargetHeight()

virtual uint64_t Electroneum::Wallet::daemonBlockChainTargetHeight ( ) const
pure virtual

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

Implemented in Electroneum::WalletImpl.

◆ debug()

void Electroneum::Wallet::debug ( const std::string &  str)
static

◆ displayAmount()

string Electroneum::Wallet::displayAmount ( uint64_t  amount)
static

◆ disposeTransaction()

virtual void Electroneum::Wallet::disposeTransaction ( PendingTransaction t)
pure virtual

disposeTransaction - destroys transaction object

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

Implemented in Electroneum::WalletImpl.

◆ errorString()

virtual std::string Electroneum::Wallet::errorString ( ) const
pure virtual

in case error status, returns error string

Implemented in Electroneum::WalletImpl.

◆ exportKeyImages()

virtual bool Electroneum::Wallet::exportKeyImages ( const std::string &  filename)
pure virtual

exportKeyImages - exports key images to file

Parameters
filename
Returns
- true on success

Implemented in Electroneum::WalletImpl.

◆ filename()

virtual std::string Electroneum::Wallet::filename ( ) const
pure virtual

filename - returns wallet filename

Returns

Implemented in Electroneum::WalletImpl.

◆ genPaymentId()

std::string Electroneum::Wallet::genPaymentId ( )
static

◆ getDefaultDataDir()

virtual std::string Electroneum::Wallet::getDefaultDataDir ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ getRefreshFromBlockHeight()

virtual uint64_t Electroneum::Wallet::getRefreshFromBlockHeight ( ) const
pure virtual

getRestoreHeight - get wallet creation height

Implemented in Electroneum::WalletImpl.

◆ getSeedLanguage()

virtual std::string Electroneum::Wallet::getSeedLanguage ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ getTxKey()

virtual std::string Electroneum::Wallet::getTxKey ( const std::string &  txid) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ getUserNote()

virtual std::string Electroneum::Wallet::getUserNote ( const std::string &  txid) const
pure virtual

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

Implemented in Electroneum::WalletImpl.

◆ hardForkInfo()

virtual void Electroneum::Wallet::hardForkInfo ( uint8_t &  version,
uint64_t &  earliest_height 
) const
pure virtual

returns current hard fork info

Implemented in Electroneum::WalletImpl.

◆ history()

virtual TransactionHistory* Electroneum::Wallet::history ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ importKeyImages()

virtual bool Electroneum::Wallet::importKeyImages ( const std::string &  filename)
pure virtual

importKeyImages - imports key images from file

Parameters
filename
Returns
- true on success

Implemented in Electroneum::WalletImpl.

◆ init() [1/2]

virtual bool Electroneum::Wallet::init ( const std::string &  daemon_address,
uint64_t  upper_transaction_size_limit,
const std::string &  daemon_username = "",
const std::string &  daemon_password = "" 
)
pure virtual

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
Returns
- true on success

Implemented in Electroneum::WalletImpl.

◆ init() [2/2]

void Electroneum::Wallet::init ( const char *  argv0,
const char *  default_log_base_name 
)
static

◆ integratedAddress()

virtual std::string Electroneum::Wallet::integratedAddress ( const std::string &  payment_id) const
pure virtual

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

Implemented in Electroneum::WalletImpl.

◆ keysFilename()

virtual std::string Electroneum::Wallet::keysFilename ( ) const
pure virtual

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

Returns

Implemented in Electroneum::WalletImpl.

◆ keyValid()

bool Electroneum::Wallet::keyValid ( const std::string &  secret_key_string,
const std::string &  address_string,
bool  isViewKey,
bool  testnet,
std::string &  error 
)
static

◆ loadUnsignedTx()

virtual UnsignedTransaction* Electroneum::Wallet::loadUnsignedTx ( const std::string &  unsigned_filename)
pure virtual

loadUnsignedTx - creates transaction from unsigned tx file

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

Implemented in Electroneum::WalletImpl.

◆ maximumAllowedAmount()

uint64_t Electroneum::Wallet::maximumAllowedAmount ( )
static

◆ parse_uri()

virtual bool Electroneum::Wallet::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 
)
pure virtual

Implemented in Electroneum::WalletImpl.

◆ path()

virtual std::string Electroneum::Wallet::path ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ pauseRefresh()

virtual void Electroneum::Wallet::pauseRefresh ( )
pure virtual

pauseRefresh - pause refresh thread

Implemented in Electroneum::WalletImpl.

◆ paymentIdFromAddress()

std::string Electroneum::Wallet::paymentIdFromAddress ( const std::string &  str,
bool  testnet 
)
static

◆ paymentIdValid()

bool Electroneum::Wallet::paymentIdValid ( const std::string &  paiment_id)
static

◆ publicSpendKey()

virtual std::string Electroneum::Wallet::publicSpendKey ( ) const
pure virtual

publicSpendKey - returns public spend key

Returns
- public spend key

Implemented in Electroneum::WalletImpl.

◆ publicViewKey()

virtual std::string Electroneum::Wallet::publicViewKey ( ) const
pure virtual

publicViewKey - returns public view key

Returns
- public view key

Implemented in Electroneum::WalletImpl.

◆ refresh()

virtual bool Electroneum::Wallet::refresh ( )
pure virtual

refresh - refreshes the wallet, updating transactions from daemon

Returns
- true if refreshed successfully;

Implemented in Electroneum::WalletImpl.

◆ refreshAsync()

virtual void Electroneum::Wallet::refreshAsync ( )
pure virtual

refreshAsync - refreshes wallet asynchronously.

Implemented in Electroneum::WalletImpl.

◆ rescanSpent()

virtual bool Electroneum::Wallet::rescanSpent ( )
pure virtual

Implemented in Electroneum::WalletImpl.

◆ secretSpendKey()

virtual std::string Electroneum::Wallet::secretSpendKey ( ) const
pure virtual

secretSpendKey - returns secret spend key

Returns
- secret spend key

Implemented in Electroneum::WalletImpl.

◆ secretViewKey()

virtual std::string Electroneum::Wallet::secretViewKey ( ) const
pure virtual

secretViewKey - returns secret view key

Returns
- secret view key

Implemented in Electroneum::WalletImpl.

◆ seed()

virtual std::string Electroneum::Wallet::seed ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ setAutoRefreshInterval()

virtual void Electroneum::Wallet::setAutoRefreshInterval ( int  millis)
pure virtual

setAutoRefreshInterval - setup interval for automatic refresh.

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

Implemented in Electroneum::WalletImpl.

◆ setListener()

virtual void Electroneum::Wallet::setListener ( WalletListener )
pure virtual

Implemented in Electroneum::WalletImpl.

◆ setPassword()

virtual bool Electroneum::Wallet::setPassword ( const std::string &  password)
pure virtual

Implemented in Electroneum::WalletImpl.

◆ setRecoveringFromSeed()

virtual void Electroneum::Wallet::setRecoveringFromSeed ( bool  recoveringFromSeed)
pure virtual

setRecoveringFromSeed - set state recover form seed

Parameters
recoveringFromSeed- true/false

Implemented in Electroneum::WalletImpl.

◆ setRefreshFromBlockHeight()

virtual void Electroneum::Wallet::setRefreshFromBlockHeight ( uint64_t  refresh_from_block_height)
pure virtual

setRefreshFromBlockHeight - start refresh from block height on recover

Parameters
refresh_from_block_height- blockchain start height

Implemented in Electroneum::WalletImpl.

◆ setSeedLanguage()

virtual void Electroneum::Wallet::setSeedLanguage ( const std::string &  arg)
pure virtual

Implemented in Electroneum::WalletImpl.

◆ setTrustedDaemon()

virtual void Electroneum::Wallet::setTrustedDaemon ( bool  arg)
pure virtual

Implemented in Electroneum::WalletImpl.

◆ setUserNote()

virtual bool Electroneum::Wallet::setUserNote ( const std::string &  txid,
const std::string &  note 
)
pure virtual

Implemented in Electroneum::WalletImpl.

◆ signMessage()

virtual std::string Electroneum::Wallet::signMessage ( const std::string &  message)
pure virtual

Implemented in Electroneum::WalletImpl.

◆ startRefresh()

virtual void Electroneum::Wallet::startRefresh ( )
pure virtual

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

Implemented in Electroneum::WalletImpl.

◆ status()

virtual int Electroneum::Wallet::status ( ) const
pure virtual

returns wallet status (Status_Ok | Status_Error)

Implemented in Electroneum::WalletImpl.

◆ store()

virtual bool Electroneum::Wallet::store ( const std::string &  path)
pure virtual

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

Implemented in Electroneum::WalletImpl.

◆ submitTransaction()

virtual bool Electroneum::Wallet::submitTransaction ( const std::string &  fileName)
pure virtual

submitTransaction - submits transaction in signed tx file

Returns
- true on success

Implemented in Electroneum::WalletImpl.

◆ synchronized()

virtual bool Electroneum::Wallet::synchronized ( ) const
pure virtual

synchronized - checks if wallet was ever synchronized

Returns

Implemented in Electroneum::WalletImpl.

◆ testnet()

virtual bool Electroneum::Wallet::testnet ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ trustedDaemon()

virtual bool Electroneum::Wallet::trustedDaemon ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ unlockedBalance()

virtual uint64_t Electroneum::Wallet::unlockedBalance ( ) const
pure virtual

Implemented in Electroneum::WalletImpl.

◆ useForkRules()

virtual bool Electroneum::Wallet::useForkRules ( uint8_t  version,
int64_t  early_blocks 
) const
pure virtual

check if hard fork rules should be used

Implemented in Electroneum::WalletImpl.

◆ verifySignedMessage()

virtual bool Electroneum::Wallet::verifySignedMessage ( const std::string &  message,
const std::string &  addres,
const std::string &  signature 
) const
pure virtual

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

Implemented in Electroneum::WalletImpl.

◆ watchOnly()

virtual bool Electroneum::Wallet::watchOnly ( ) const
pure virtual

watchOnly - checks if wallet is watch only

Returns
- true if watch only

Implemented in Electroneum::WalletImpl.


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