Electroneum
Loading...
Searching...
No Matches
cryptonote::account_base Class Reference

#include <account.h>

Public Member Functions

 account_base ()
crypto::secret_key generate (const crypto::secret_key &recovery_key=crypto::secret_key(), bool recover=false, bool two_random=false)
void create_from_device (const std::string &device_name)
void create_from_device (hw::device &hwdev)
void create_from_keys (const cryptonote::account_public_address &address, const crypto::secret_key &spendkey, const crypto::secret_key &viewkey)
void create_from_viewkey (const cryptonote::account_public_address &address, const crypto::secret_key &viewkey)
bool make_multisig (const crypto::secret_key &view_secret_key, const crypto::secret_key &spend_secret_key, const crypto::public_key &spend_public_key, const std::vector< crypto::secret_key > &multisig_keys)
void finalize_multisig (const crypto::public_key &spend_public_key)
const account_keysget_keys () const
std::string get_public_address_str (network_type nettype) const
std::string get_public_integrated_address_str (const crypto::hash8 &payment_id, network_type nettype) const
hw::deviceget_device () const
void set_device (hw::device &hwdev)
void deinit ()
uint64_t get_createtime () const
void set_createtime (uint64_t val)
bool load (const std::string &file_path)
bool store (const std::string &file_path)
void forget_spend_key ()
const std::vector< crypto::secret_key > & get_multisig_keys () const
void encrypt_keys (const crypto::chacha_key &key)
void decrypt_keys (const crypto::chacha_key &key)
void encrypt_viewkey (const crypto::chacha_key &key)
void decrypt_viewkey (const crypto::chacha_key &key)
template<class t_archive>
void serialize (t_archive &a, const unsigned int)

Detailed Description

Definition at line 76 of file account.h.

Constructor & Destructor Documentation

◆ account_base()

cryptonote::account_base::account_base ( )

Definition at line 132 of file account.cpp.

133 {
134 set_null();
135 }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ create_from_device() [1/2]

void cryptonote::account_base::create_from_device ( const std::string & device_name)

Definition at line 209 of file account.cpp.

210 {
211 hw::device &hwdev = hw::get_device(device_name);
212 hwdev.set_name(device_name);
213 create_from_device(hwdev);
214 }
void create_from_device(const std::string &device_name)
Definition account.cpp:209
virtual bool set_name(const std::string &name)=0
device & get_device(const std::string &device_descriptor)
Definition device.cpp:95
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_from_device() [2/2]

void cryptonote::account_base::create_from_device ( hw::device & hwdev)

Definition at line 216 of file account.cpp.

217 {
218 m_keys.set_device(hwdev);
219 MCDEBUG("device", "device type: "<<typeid(hwdev).name());
220 CHECK_AND_ASSERT_THROW_MES(hwdev.init(), "Device init failed");
221 CHECK_AND_ASSERT_THROW_MES(hwdev.connect(), "Device connect failed");
222 try {
223 CHECK_AND_ASSERT_THROW_MES(hwdev.get_public_address(m_keys.m_account_address), "Cannot get a device address");
224 CHECK_AND_ASSERT_THROW_MES(hwdev.get_secret_keys(m_keys.m_view_secret_key, m_keys.m_spend_secret_key), "Cannot get device secret");
225 } catch (const std::exception &e){
226 hwdev.disconnect();
227 throw;
228 }
229 struct tm timestamp = {0};
230 timestamp.tm_year = 2014 - 1900; // year 2014
231 timestamp.tm_mon = 4 - 1; // month april
232 timestamp.tm_mday = 15; // 15th of april
233 timestamp.tm_hour = 0;
234 timestamp.tm_min = 0;
235 timestamp.tm_sec = 0;
236
237 m_creation_timestamp = mktime(&timestamp);
238 if (m_creation_timestamp == (uint64_t)-1) // failure
239 m_creation_timestamp = 0; // lowest value
240 }
virtual bool connect(void)=0
virtual bool disconnect(void)=0
virtual bool init(void)=0
virtual bool get_secret_keys(crypto::secret_key &viewkey, crypto::secret_key &spendkey)=0
virtual bool get_public_address(cryptonote::account_public_address &pubkey)=0
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
#define MCDEBUG(cat, x)
Definition misc_log_ex.h:54
const char * name
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:

◆ create_from_keys()

void cryptonote::account_base::create_from_keys ( const cryptonote::account_public_address & address,
const crypto::secret_key & spendkey,
const crypto::secret_key & viewkey )

Definition at line 189 of file account.cpp.

190 {
191 m_keys.m_account_address = address;
192 m_keys.m_spend_secret_key = spendkey;
193 m_keys.m_view_secret_key = viewkey;
194
195 struct tm timestamp = {0};
196 timestamp.tm_year = 2014 - 1900; // year 2014
197 timestamp.tm_mon = 4 - 1; // month april
198 timestamp.tm_mday = 15; // 15th of april
199 timestamp.tm_hour = 0;
200 timestamp.tm_min = 0;
201 timestamp.tm_sec = 0;
202
203 m_creation_timestamp = mktime(&timestamp);
204 if (m_creation_timestamp == (uint64_t)-1) // failure
205 m_creation_timestamp = 0; // lowest value
206 }
const char * address
Definition multisig.cpp:37
const char * spendkey
Definition multisig.cpp:38
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_from_viewkey()

void cryptonote::account_base::create_from_viewkey ( const cryptonote::account_public_address & address,
const crypto::secret_key & viewkey )

Definition at line 243 of file account.cpp.

244 {
246 memset(&unwrap(unwrap(fake)), 0, sizeof(fake));
247 create_from_keys(address, fake, viewkey);
248 }
void create_from_keys(const cryptonote::account_public_address &address, const crypto::secret_key &spendkey, const crypto::secret_key &viewkey)
Definition account.cpp:189
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:82
T & unwrap(mlocked< T > &src)
Definition mlocker.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrypt_keys()

void cryptonote::account_base::decrypt_keys ( const crypto::chacha_key & key)
inline

Definition at line 105 of file account.h.

105{ m_keys.decrypt(key); }
const char * key
Here is the caller graph for this function:

◆ decrypt_viewkey()

void cryptonote::account_base::decrypt_viewkey ( const crypto::chacha_key & key)
inline

Definition at line 107 of file account.h.

107{ m_keys.decrypt_viewkey(key); }
Here is the caller graph for this function:

◆ deinit()

void cryptonote::account_base::deinit ( )

Definition at line 143 of file account.cpp.

144 {
145 try{
146 m_keys.get_device().disconnect();
147 } catch (const std::exception &e){
148 MERROR("Device disconnect exception: " << e.what());
149 }
150 }
#define MERROR(x)
Definition misc_log_ex.h:73
Here is the call graph for this function:
Here is the caller graph for this function:

◆ encrypt_keys()

void cryptonote::account_base::encrypt_keys ( const crypto::chacha_key & key)
inline

Definition at line 104 of file account.h.

104{ m_keys.encrypt(key); }
Here is the caller graph for this function:

◆ encrypt_viewkey()

void cryptonote::account_base::encrypt_viewkey ( const crypto::chacha_key & key)
inline

Definition at line 106 of file account.h.

106{ m_keys.encrypt_viewkey(key); }
Here is the caller graph for this function:

◆ finalize_multisig()

void cryptonote::account_base::finalize_multisig ( const crypto::public_key & spend_public_key)

Definition at line 259 of file account.cpp.

260 {
261 m_keys.m_account_address.m_spend_public_key = spend_public_key;
262 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forget_spend_key()

void cryptonote::account_base::forget_spend_key ( )

Definition at line 152 of file account.cpp.

153 {
154 m_keys.m_spend_secret_key = crypto::secret_key();
155 m_keys.m_multisig_keys.clear();
156 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate()

crypto::secret_key cryptonote::account_base::generate ( const crypto::secret_key & recovery_key = crypto::secret_key(),
bool recover = false,
bool two_random = false )

Definition at line 158 of file account.cpp.

159 {
160 crypto::secret_key first = generate_keys(m_keys.m_account_address.m_spend_public_key, m_keys.m_spend_secret_key, recovery_key, recover);
161
162 // rng for generating second set of keys is hash of first rng. means only one set of electrum-style words needed for recovery
163 crypto::secret_key second;
164 keccak((uint8_t *)&m_keys.m_spend_secret_key, sizeof(crypto::secret_key), (uint8_t *)&second, sizeof(crypto::secret_key));
165
166 generate_keys(m_keys.m_account_address.m_view_public_key, m_keys.m_view_secret_key, second, two_random ? false : true);
167
168 struct tm timestamp = {0};
169 timestamp.tm_year = 2014 - 1900; // year 2014
170 timestamp.tm_mon = 6 - 1; // month june
171 timestamp.tm_mday = 8; // 8th of june
172 timestamp.tm_hour = 0;
173 timestamp.tm_min = 0;
174 timestamp.tm_sec = 0;
175
176 if (recover)
177 {
178 m_creation_timestamp = mktime(&timestamp);
179 if (m_creation_timestamp == (uint64_t)-1) // failure
180 m_creation_timestamp = 0; // lowest value
181 }
182 else
183 {
184 m_creation_timestamp = time(NULL);
185 }
186 return first;
187 }
time_t time
void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen)
secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key &recovery_key=secret_key(), bool recover=false)
Definition crypto.h:250
unsigned char uint8_t
Definition stdint.h:124
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_createtime()

uint64_t cryptonote::account_base::get_createtime ( ) const
inline

Definition at line 95 of file account.h.

95{ return m_creation_timestamp; }

◆ get_device()

hw::device & cryptonote::account_base::get_device ( ) const
inline

Definition at line 91 of file account.h.

91{return m_keys.get_device();}
Here is the caller graph for this function:

◆ get_keys()

const account_keys & cryptonote::account_base::get_keys ( ) const

Definition at line 264 of file account.cpp.

265 {
266 return m_keys;
267 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_multisig_keys()

const std::vector< crypto::secret_key > & cryptonote::account_base::get_multisig_keys ( ) const
inline

Definition at line 102 of file account.h.

102{ return m_keys.m_multisig_keys; }
Here is the caller graph for this function:

◆ get_public_address_str()

std::string cryptonote::account_base::get_public_address_str ( network_type nettype) const

Definition at line 269 of file account.cpp.

270 {
271 //TODO: change this code into base 58
272 return get_account_address_as_str(nettype, false, m_keys.m_account_address);
273 }
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_public_integrated_address_str()

std::string cryptonote::account_base::get_public_integrated_address_str ( const crypto::hash8 & payment_id,
network_type nettype ) const

Definition at line 275 of file account.cpp.

276 {
277 //TODO: change this code into base 58
278 return get_account_integrated_address_as_str(nettype, m_keys.m_account_address, payment_id);
279 }
std::string get_account_integrated_address_as_str(network_type nettype, account_public_address const &adr, crypto::hash8 const &payment_id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

bool cryptonote::account_base::load ( const std::string & file_path)

◆ make_multisig()

bool cryptonote::account_base::make_multisig ( const crypto::secret_key & view_secret_key,
const crypto::secret_key & spend_secret_key,
const crypto::public_key & spend_public_key,
const std::vector< crypto::secret_key > & multisig_keys )

Definition at line 250 of file account.cpp.

251 {
252 m_keys.m_account_address.m_spend_public_key = spend_public_key;
253 m_keys.m_view_secret_key = view_secret_key;
254 m_keys.m_spend_secret_key = spend_secret_key;
255 m_keys.m_multisig_keys = multisig_keys;
256 return crypto::secret_key_to_public_key(view_secret_key, m_keys.m_account_address.m_view_public_key);
257 }
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition crypto.h:262
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialize()

template<class t_archive>
void cryptonote::account_base::serialize ( t_archive & a,
const unsigned int  )
inline

Definition at line 110 of file account.h.

111 {
112 a & m_keys;
113 a & m_creation_timestamp;
114 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124

◆ set_createtime()

void cryptonote::account_base::set_createtime ( uint64_t val)
inline

Definition at line 96 of file account.h.

96{ m_creation_timestamp = val; }

◆ set_device()

void cryptonote::account_base::set_device ( hw::device & hwdev)
inline

Definition at line 92 of file account.h.

92{m_keys.set_device(hwdev);}

◆ store()

bool cryptonote::account_base::store ( const std::string & file_path)
Here is the call graph for this function:

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/cryptonote_basic/account.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/cryptonote_basic/account.cpp