ledger-core
Public Member Functions | Static Public Member Functions | List of all members
ledger::core::api::WalletPool Class Referenceabstract

#include <WalletPool.hpp>

+ Inheritance diagram for ledger::core::api::WalletPool:

Public Member Functions

virtual std::shared_ptr< LoggergetLogger ()=0
 
virtual std::string getName ()=0
 
virtual std::shared_ptr< PreferencesgetPreferences ()=0
 
virtual void getWalletCount (const std::shared_ptr< I32Callback > &callback)=0
 
virtual void getWallets (int32_t from, int32_t size, const std::shared_ptr< WalletListCallback > &callback)=0
 
virtual void getWallet (const std::string &name, const std::shared_ptr< WalletCallback > &callback)=0
 
virtual void updateWalletConfig (const std::string &name, const std::shared_ptr< DynamicObject > &configuration, const std::shared_ptr< ErrorCodeCallback > &callback)=0
 
virtual void createWallet (const std::string &name, const Currency &currency, const std::shared_ptr< DynamicObject > &configuration, const std::shared_ptr< WalletCallback > &callback)=0
 
virtual void getCurrencies (const std::shared_ptr< CurrencyListCallback > &callback)=0
 
virtual void getCurrency (const std::string &name, const std::shared_ptr< CurrencyCallback > &callback)=0
 
virtual void getLastBlock (const std::string &currencyName, const std::shared_ptr< BlockCallback > &callback)=0
 
virtual std::shared_ptr< EventBusgetEventBus ()=0
 
virtual void eraseDataSince (const std::chrono::system_clock::time_point &date, const std::shared_ptr< ErrorCodeCallback > &callback)=0
 
virtual void freshResetAll (const std::shared_ptr< ErrorCodeCallback > &callback)=0
 
virtual void changePassword (const std::string &oldPassword, const std::string &newPassword, const std::shared_ptr< ErrorCodeCallback > &callback)=0
 

Static Public Member Functions

static std::shared_ptr< WalletPoolnewInstance (const std::string &name, const std::string &password, const std::shared_ptr< HttpClient > &httpClient, const std::shared_ptr< WebSocketClient > &webSocketClient, const std::shared_ptr< PathResolver > &pathResolver, const std::shared_ptr< LogPrinter > &logPrinter, const std::shared_ptr< ThreadDispatcher > &dispatcher, const std::shared_ptr< RandomNumberGenerator > &rng, const std::shared_ptr< DatabaseBackend > &backend, const std::shared_ptr< DynamicObject > &configuration)
 

Detailed Description

Class respresenting a pool of wallets.

Member Function Documentation

◆ changePassword()

virtual void ledger::core::api::WalletPool::changePassword ( const std::string &  oldPassword,
const std::string &  newPassword,
const std::shared_ptr< ErrorCodeCallback > &  callback 
)
pure virtual

Change Database password.

Allow to change password of database holding all informations about accounts, wallets, transactions etc. and the wallet pool preferences.

WARNING: be careful to have no other instances of WalletPool using same database / preferences.

◆ createWallet()

virtual void ledger::core::api::WalletPool::createWallet ( const std::string &  name,
const Currency currency,
const std::shared_ptr< DynamicObject > &  configuration,
const std::shared_ptr< WalletCallback > &  callback 
)
pure virtual

Instanciate a new wallet under wallet pool.

Parameters
name,string,nameof newly created wallet
currency,Currencyobject, currency of the wallet
configuration,DynamicObjectobject, configuration of wallet (preferences)
callback,Callbackobject returning a Wallet object

◆ eraseDataSince()

virtual void ledger::core::api::WalletPool::eraseDataSince ( const std::chrono::system_clock::time_point &  date,
const std::shared_ptr< ErrorCodeCallback > &  callback 
)
pure virtual

Erase data (in user's DB) relative to wallet since given date.

Parameters
date,startdate of data deletion

◆ freshResetAll()

virtual void ledger::core::api::WalletPool::freshResetAll ( const std::shared_ptr< ErrorCodeCallback > &  callback)
pure virtual

Reset wallet pool.

Resetting the wallet pool is an irreversible fresh reset of the whole wallet pool and all of its created (sub-)objects (wallets, accounts, transactions, etc.). Please consider a less destructive option before opting to use this. However, if you’re looking for a way to end up as if you were in a “fresh install” situation, this is the function to go to.

Final warning: this function effectively swipes off everything. You’ve been warned.

Note: when calling that function, you must re-create a WalletPool as all objects got destroyed. Consider restarting / exiting your application right after calling that function. You are also highly advised to run that function on a code path that doesn’t include having lots of objects in memory.

The return value is always true and doesn’t convey any useful information for now.

◆ getCurrencies()

virtual void ledger::core::api::WalletPool::getCurrencies ( const std::shared_ptr< CurrencyListCallback > &  callback)
pure virtual

Return all supported currencies by wallet pool, at least one wallet support one of returned currencies.

Parameters
callback,ListCallbackobject, returns a list of Currency objects

◆ getCurrency()

virtual void ledger::core::api::WalletPool::getCurrency ( const std::string &  name,
const std::shared_ptr< CurrencyCallback > &  callback 
)
pure virtual

Return currency of a specific wallet.

Parameters
name,wallet'sname to look for
callback,Callbackobject returning a Currency object

◆ getEventBus()

virtual std::shared_ptr<EventBus> ledger::core::api::WalletPool::getEventBus ( )
pure virtual

Get event bus (handler) through which wallet pool observe and gets notified (explorers, DBs ...).

Parameters
EventBusobject

Implemented in ledger::core::WalletPoolApi.

◆ getLastBlock()

virtual void ledger::core::api::WalletPool::getLastBlock ( const std::string &  currencyName,
const std::shared_ptr< BlockCallback > &  callback 
)
pure virtual

Return last block of blockchain of a given currency (if it is supported by the wallet pool).

Parameters
name,string,nameof currency we are interested into getting it's blockchain's last block
callback,Callbackobject returns a Block object

◆ getLogger()

virtual std::shared_ptr<Logger> ledger::core::api::WalletPool::getLogger ( )
pure virtual

Return used logger to dump logs in defined log path by PathResolver.

Returns
Logger object

Implemented in ledger::core::WalletPoolApi.

◆ getName()

virtual std::string ledger::core::api::WalletPool::getName ( )
pure virtual

Return the name of the wallet pool.

Returns
string

Implemented in ledger::core::WalletPoolApi.

◆ getPreferences()

virtual std::shared_ptr<Preferences> ledger::core::api::WalletPool::getPreferences ( )
pure virtual

Return preferences of wallet pool (deduced from configuration).

Returns
Preferences object

Implemented in ledger::core::WalletPoolApi.

◆ getWallet()

virtual void ledger::core::api::WalletPool::getWallet ( const std::string &  name,
const std::shared_ptr< WalletCallback > &  callback 
)
pure virtual

Get wallet with a giver name.

Parameters
name,string,nameof wallet to look for
callback,Callbackobject returns a Wallet object

◆ getWalletCount()

virtual void ledger::core::api::WalletPool::getWalletCount ( const std::shared_ptr< I32Callback > &  callback)
pure virtual

Return number of wallets instanciated under wallet pool.

Parameters
callback,Callbackobject returns a 32 bits integer, count of wallets

◆ getWallets()

virtual void ledger::core::api::WalletPool::getWallets ( int32_t  from,
int32_t  size,
const std::shared_ptr< WalletListCallback > &  callback 
)
pure virtual

Get instanciated wallets having index in a given range.

Parameters
from,32bits integer, lower bound of indices to pick
to,32bits integer, upper bound of indices to pick
callback,ListCallbackobject returns a list of Wallet objects

◆ newInstance()

static std::shared_ptr<WalletPool> ledger::core::api::WalletPool::newInstance ( const std::string &  name,
const std::string &  password,
const std::shared_ptr< HttpClient > &  httpClient,
const std::shared_ptr< WebSocketClient > &  webSocketClient,
const std::shared_ptr< PathResolver > &  pathResolver,
const std::shared_ptr< LogPrinter > &  logPrinter,
const std::shared_ptr< ThreadDispatcher > &  dispatcher,
const std::shared_ptr< RandomNumberGenerator > &  rng,
const std::shared_ptr< DatabaseBackend > &  backend,
const std::shared_ptr< DynamicObject > &  configuration 
)
static

Create a new instance of WalletPool object.

Parameters
name,string,nameof the wallet pool
password,string,passwordto lock wallet pool (empty string means no password)
http,HttpClientobject, http client used for all calls made by wallet pool (and aggregated wallets)
webSocketClient,WebSocketClientobject, socket through which wallet pool observe and get notified (explorer, DBs ...)
pathResolver,PathResolverObject, resolve paths to logs, databases, preferences ...
logPrinter,LogPrinterobject, used to dump/log for debug purpose
dispatcher,ThreadDispatcherobject, responsable of dispatching task through available threads
rng,RandomNumberGeneratorobject, needed for generating random numbers (for seeds, salts ...)
backend,DatabseBackendobject, DB in which wallet pool store all required infos (created wallets, their options, their accounts ...)
configuration,DynamicObjectobject, desired configuration for this wallet pool
Returns
WalletPool object, instance of WalletPool

◆ updateWalletConfig()

virtual void ledger::core::api::WalletPool::updateWalletConfig ( const std::string &  name,
const std::shared_ptr< DynamicObject > &  configuration,
const std::shared_ptr< ErrorCodeCallback > &  callback 
)
pure virtual

Update wallet configuration

Parameters
name,string,nameof wallet to update
configuration,DynamicObjectobject, configuration object with fields to update
callback,Callbackobject returns the error code, returns ErrorCode::FUTURE_WAS_SUCCESSFULL if everything is fine

Note: other fields that are not passed in 'configuration' parameter that might have been created before remain intact


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