Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
wallet_manager.hpp
Go to the documentation of this file.
1#pragma once
4#include <boost/asio/deadline_timer.hpp>
5#include <boost/filesystem/path.hpp>
6#include <boost/interprocess/sync/file_lock.hpp>
7#include <chrono>
8
9namespace fc { class variant; }
10
11namespace sysio {
12namespace wallet {
13
19public:
26
29 void set_dir(const boost::filesystem::path& p) {
30 dir = p;
31 initialize_lock();
32 }
33
37 void set_timeout(const std::chrono::seconds& t);
38
41 void set_timeout(int64_t secs) { set_timeout(std::chrono::seconds(secs)); }
42
50 chain::signed_transaction sign_transaction(const chain::signed_transaction& txn, const flat_set<public_key_type>& keys,
51 const chain::chain_id_type& id);
52
53
60
68 std::string create(const std::string& name);
69
74 void open(const std::string& name);
75
77 std::vector<std::string> list_wallets();
78
80 map<public_key_type,private_key_type> list_keys(const string& name, const string& pw);
81
83 flat_set<public_key_type> get_public_keys();
84
86 void lock_all();
87
92 void lock(const std::string& name);
93
99 void unlock(const std::string& name, const std::string& password);
100
107 void import_key(const std::string& name, const std::string& wif_key);
108
115 void remove_key(const std::string& name, const std::string& password, const std::string& key);
116
123 string create_key(const std::string& name, const std::string& key_type);
124
126 void own_and_use_wallet(const string& name, std::unique_ptr<wallet_api>&& wallet);
127
128private:
131 void check_timeout();
132
133private:
134 using timepoint_t = std::chrono::time_point<std::chrono::system_clock>;
135 std::map<std::string, std::unique_ptr<wallet_api>> wallets;
136 std::chrono::seconds timeout = std::chrono::seconds::max();
137 mutable timepoint_t timeout_time = timepoint_t::max();
138 boost::filesystem::path dir = ".";
139 boost::filesystem::path lock_path = dir / "wallet.lock";
140 std::unique_ptr<boost::interprocess::file_lock> wallet_dir_lock;
141
142 void start_lock_watch(std::shared_ptr<boost::asio::deadline_timer> t);
143 void initialize_lock();
144};
145
146} // namespace wallet
147} // namespace sysio
148
149
const mie::Vuint & p
Definition bn.cpp:27
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
void unlock(const std::string &name, const std::string &password)
void own_and_use_wallet(const string &name, std::unique_ptr< wallet_api > &&wallet)
Takes ownership of a wallet to use.
map< public_key_type, private_key_type > list_keys(const string &name, const string &pw)
void set_timeout(const std::chrono::seconds &t)
void lock_all()
Locks all the unlocked wallets.
wallet_manager(const wallet_manager &)=delete
chain::signed_transaction sign_transaction(const chain::signed_transaction &txn, const flat_set< public_key_type > &keys, const chain::chain_id_type &id)
wallet_manager(wallet_manager &&)=delete
flat_set< public_key_type > get_public_keys()
void import_key(const std::string &name, const std::string &wif_key)
std::string create(const std::string &name)
void open(const std::string &name)
wallet_manager & operator=(wallet_manager &&)=delete
void remove_key(const std::string &name, const std::string &password, const std::string &key)
string create_key(const std::string &name, const std::string &key_type)
chain::signature_type sign_digest(const chain::digest_type &digest, const public_key_type &key)
void set_dir(const boost::filesystem::path &p)
wallet_manager & operator=(const wallet_manager &)=delete
std::vector< std::string > list_wallets()
namespace sysio::chain
Definition authority.cpp:3
fc::sha256 digest(const T &value)
Definition digest.hpp:9
signed __int64 int64_t
Definition stdint.h:135
Immutable except for fc::from_variant.
Definition name.hpp:43
void lock()
struct @108 key_type