aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic/account.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/cryptonote_basic/account.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/cryptonote_basic/account.cpp b/src/cryptonote_basic/account.cpp
index 1b38d99b3..26c823c2a 100644
--- a/src/cryptonote_basic/account.cpp
+++ b/src/cryptonote_basic/account.cpp
@@ -40,6 +40,7 @@ extern "C"
}
#include "cryptonote_basic_impl.h"
#include "cryptonote_format_utils.h"
+#include "device/device.hpp"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "account"
@@ -50,6 +51,17 @@ DISABLE_VS_WARNINGS(4244 4345)
namespace cryptonote
{
+
+ //-----------------------------------------------------------------
+ hw::device& account_keys::get_device() const {
+ return *m_device;
+ }
+ //-----------------------------------------------------------------
+ void account_keys::set_device( hw::device &hwdev) {
+ m_device = &hwdev;
+ MCDEBUG("device", "account_keys::set_device device type: "<<typeid(hwdev).name());
+ }
+
//-----------------------------------------------------------------
account_base::account_base()
{
@@ -116,6 +128,34 @@ DISABLE_VS_WARNINGS(4244 4345)
if (m_creation_timestamp == (uint64_t)-1) // failure
m_creation_timestamp = 0; // lowest value
}
+
+ //-----------------------------------------------------------------
+ void account_base::create_from_device(const std::string &device_name)
+ {
+
+ hw::device &hwdev = hw::get_device(device_name);
+ m_keys.set_device(hwdev);
+ hwdev.set_name(device_name);
+ MCDEBUG("ledger", "device type: "<<typeid(hwdev).name());
+ hwdev.init();
+ hwdev.connect();
+ hwdev.get_public_address(m_keys.m_account_address);
+ #ifdef DEBUG_HWDEVICE
+ hwdev.get_secret_keys(m_keys.m_view_secret_key, m_keys.m_spend_secret_key);
+ #endif
+ struct tm timestamp = {0};
+ timestamp.tm_year = 2014 - 1900; // year 2014
+ timestamp.tm_mon = 4 - 1; // month april
+ timestamp.tm_mday = 15; // 15th of april
+ timestamp.tm_hour = 0;
+ timestamp.tm_min = 0;
+ timestamp.tm_sec = 0;
+
+ m_creation_timestamp = mktime(&timestamp);
+ if (m_creation_timestamp == (uint64_t)-1) // failure
+ m_creation_timestamp = 0; // lowest value
+ }
+
//-----------------------------------------------------------------
void account_base::create_from_viewkey(const cryptonote::account_public_address& address, const crypto::secret_key& viewkey)
{