account: allow creating an account from a public address and view secret key

This commit is contained in:
moneromooo-monero 2015-06-20 12:31:02 +01:00
parent e05a58aead
commit 6a0f61d800
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
2 changed files with 17 additions and 0 deletions

View File

@ -93,6 +93,22 @@ DISABLE_VS_WARNINGS(4244 4345)
return first; return first;
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
void account_base::create_from_viewkey(const cryptonote::account_public_address& address, const crypto::secret_key& viewkey)
{
m_keys.m_account_address = address;
m_keys.m_view_secret_key = viewkey;
struct tm timestamp;
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);
}
//-----------------------------------------------------------------
const account_keys& account_base::get_keys() const const account_keys& account_base::get_keys() const
{ {
return m_keys; return m_keys;

View File

@ -58,6 +58,7 @@ namespace cryptonote
public: public:
account_base(); account_base();
crypto::secret_key generate(const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false, bool two_random = false); crypto::secret_key generate(const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false, bool two_random = false);
void create_from_viewkey(const cryptonote::account_public_address& address, const crypto::secret_key& viewkey);
const account_keys& get_keys() const; const account_keys& get_keys() const;
std::string get_public_address_str(bool testnet) const; std::string get_public_address_str(bool testnet) const;
std::string get_public_integrated_address_str(const crypto::hash &payment_id, bool testnet) const; std::string get_public_integrated_address_str(const crypto::hash &payment_id, bool testnet) const;