Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::wallet_plugin Class Reference

#include <wallet_plugin.hpp>

Inheritance diagram for sysio::wallet_plugin:
Collaboration diagram for sysio::wallet_plugin:

Public Member Functions

 wallet_plugin ()
 
 wallet_plugin (const wallet_plugin &)=delete
 
 wallet_plugin (wallet_plugin &&)=delete
 
wallet_pluginoperator= (const wallet_plugin &)=delete
 
wallet_pluginoperator= (wallet_plugin &&)=delete
 
virtual ~wallet_plugin () override=default
 
virtual void set_program_options (options_description &cli, options_description &cfg) override
 
void plugin_initialize (const variables_map &options)
 
void plugin_startup ()
 
void plugin_shutdown ()
 
wallet_managerget_wallet_manager ()
 
- Public Member Functions inherited from appbase::plugin< wallet_plugin >
 plugin ()
 
virtual ~plugin ()
 
virtual state get_state () const override
 
virtual const std::string & name () const override
 
virtual void register_dependencies ()
 
virtual void initialize (const variables_map &options) override
 
virtual void handle_sighup () override
 
virtual void startup () override
 
virtual void shutdown () override
 
- Public Member Functions inherited from appbase::abstract_plugin
virtual ~abstract_plugin ()
 

Additional Inherited Members

- Public Types inherited from appbase::abstract_plugin
enum  state { registered , initialized , started , stopped }
 
- Protected Member Functions inherited from appbase::plugin< wallet_plugin >
 plugin (const string &name)
 

Detailed Description

Definition at line 17 of file wallet_plugin.hpp.

Constructor & Destructor Documentation

◆ wallet_plugin() [1/3]

sysio::wallet_plugin::wallet_plugin ( )

Definition at line 16 of file wallet_plugin.cpp.

16{}

◆ wallet_plugin() [2/3]

sysio::wallet_plugin::wallet_plugin ( const wallet_plugin & )
delete

◆ wallet_plugin() [3/3]

sysio::wallet_plugin::wallet_plugin ( wallet_plugin && )
delete

◆ ~wallet_plugin()

virtual sysio::wallet_plugin::~wallet_plugin ( )
overridevirtualdefault

Member Function Documentation

◆ get_wallet_manager()

wallet_manager & sysio::wallet_plugin::get_wallet_manager ( )

Definition at line 18 of file wallet_plugin.cpp.

18 {
19 return *wallet_manager_ptr;
20}

◆ operator=() [1/2]

wallet_plugin & sysio::wallet_plugin::operator= ( const wallet_plugin & )
delete

◆ operator=() [2/2]

wallet_plugin & sysio::wallet_plugin::operator= ( wallet_plugin && )
delete

◆ plugin_initialize()

void sysio::wallet_plugin::plugin_initialize ( const variables_map & options)

Definition at line 37 of file wallet_plugin.cpp.

37 {
38 ilog("initializing wallet plugin");
39 try {
40 wallet_manager_ptr = std::make_unique<wallet_manager>();
41
42 if (options.count("wallet-dir")) {
43 auto dir = options.at("wallet-dir").as<boost::filesystem::path>();
44 if (dir.is_relative())
45 dir = app().data_dir() / dir;
46 if( !bfs::exists(dir) )
47 bfs::create_directories(dir);
48 wallet_manager_ptr->set_dir(dir);
49 }
50 if (options.count("unlock-timeout")) {
51 auto timeout = options.at("unlock-timeout").as<int64_t>();
52 SYS_ASSERT(timeout > 0, chain::invalid_lock_timeout_exception, "Please specify a positive timeout ${t}", ("t", timeout));
53 std::chrono::seconds t(timeout);
54 wallet_manager_ptr->set_timeout(t);
55 }
56 if (options.count("yubihsm-authkey")) {
57 uint16_t key = options.at("yubihsm-authkey").as<uint16_t>();
58 string connector_endpoint = "http://localhost:12345";
59 if(options.count("yubihsm-url"))
60 connector_endpoint = options.at("yubihsm-url").as<string>();
61 try {
62 wallet_manager_ptr->own_and_use_wallet("YubiHSM", make_unique<yubihsm_wallet>(connector_endpoint, key));
64 }
66}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
bfs::path data_dir() const
Get data directory.
#define FC_LOG_AND_RETHROW()
#define ilog(FORMAT,...)
Definition logger.hpp:118
application & app()
unsigned short uint16_t
Definition stdint.h:125
signed __int64 int64_t
Definition stdint.h:135
Here is the call graph for this function:

◆ plugin_shutdown()

void sysio::wallet_plugin::plugin_shutdown ( )
inline

Definition at line 31 of file wallet_plugin.hpp.

31{}

◆ plugin_startup()

void sysio::wallet_plugin::plugin_startup ( )
inline

Definition at line 30 of file wallet_plugin.hpp.

30{}

◆ set_program_options()

void sysio::wallet_plugin::set_program_options ( options_description & cli,
options_description & cfg )
overridevirtual

Implements appbase::abstract_plugin.

Definition at line 22 of file wallet_plugin.cpp.

22 {
23 cfg.add_options()
24 ("wallet-dir", bpo::value<boost::filesystem::path>()->default_value("."),
25 "The path of the wallet files (absolute path or relative to application data dir)")
26 ("unlock-timeout", bpo::value<int64_t>()->default_value(900),
27 "Timeout for unlocked wallet in seconds (default 900 (15 minutes)). "
28 "Wallets will automatically lock after specified number of seconds of inactivity. "
29 "Activity is defined as any wallet command e.g. list-wallets.")
30 ("yubihsm-url", bpo::value<string>()->value_name("URL"),
31 "Override default URL of http://localhost:12345 for connecting to yubihsm-connector")
32 ("yubihsm-authkey", bpo::value<uint16_t>()->value_name("key_num"),
33 "Enables YubiHSM support using given Authkey")
34 ;
35}

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