Merge pull request #6334

cc18926 wallet2_api: wallet recovery - seed offset passphrase support (xiphon)
This commit is contained in:
luigi1111 2020-04-04 12:41:32 -05:00
commit 6011064693
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
5 changed files with 14 additions and 6 deletions

View file

@ -725,7 +725,7 @@ bool WalletImpl::recover(const std::string &path, const std::string &seed)
return recover(path, "", seed); return recover(path, "", seed);
} }
bool WalletImpl::recover(const std::string &path, const std::string &password, const std::string &seed) bool WalletImpl::recover(const std::string &path, const std::string &password, const std::string &seed, const std::string &seed_offset/* = {}*/)
{ {
clearStatus(); clearStatus();
m_errorString.clear(); m_errorString.clear();
@ -743,6 +743,10 @@ bool WalletImpl::recover(const std::string &path, const std::string &password, c
setStatusError(tr("Electrum-style word list failed verification")); setStatusError(tr("Electrum-style word list failed verification"));
return false; return false;
} }
if (!seed_offset.empty())
{
recovery_key = cryptonote::decrypt_key(recovery_key, seed_offset);
}
if (old_language == crypto::ElectrumWords::old_language_name) if (old_language == crypto::ElectrumWords::old_language_name)
old_language = Language::English().get_language_name(); old_language = Language::English().get_language_name();

View file

@ -60,7 +60,7 @@ public:
const std::string &language) const override; const std::string &language) const override;
bool open(const std::string &path, const std::string &password); bool open(const std::string &path, const std::string &password);
bool recover(const std::string &path,const std::string &password, bool recover(const std::string &path,const std::string &password,
const std::string &seed); const std::string &seed, const std::string &seed_offset = {});
bool recoverFromKeysWithPassword(const std::string &path, bool recoverFromKeysWithPassword(const std::string &path,
const std::string &password, const std::string &password,
const std::string &language, const std::string &language,

View file

@ -1093,10 +1093,12 @@ struct WalletManager
* \param nettype Network type * \param nettype Network type
* \param restoreHeight restore from start height * \param restoreHeight restore from start height
* \param kdf_rounds Number of rounds for key derivation function * \param kdf_rounds Number of rounds for key derivation function
* \param seed_offset Seed offset passphrase (optional)
* \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully) * \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully)
*/ */
virtual Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic, virtual Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic,
NetworkType nettype = MAINNET, uint64_t restoreHeight = 0, uint64_t kdf_rounds = 1) = 0; NetworkType nettype = MAINNET, uint64_t restoreHeight = 0, uint64_t kdf_rounds = 1,
const std::string &seed_offset = {}) = 0;
Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic, Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic,
bool testnet = false, uint64_t restoreHeight = 0) // deprecated bool testnet = false, uint64_t restoreHeight = 0) // deprecated
{ {

View file

@ -93,13 +93,14 @@ Wallet *WalletManagerImpl::recoveryWallet(const std::string &path,
const std::string &mnemonic, const std::string &mnemonic,
NetworkType nettype, NetworkType nettype,
uint64_t restoreHeight, uint64_t restoreHeight,
uint64_t kdf_rounds) uint64_t kdf_rounds,
const std::string &seed_offset/* = {}*/)
{ {
WalletImpl * wallet = new WalletImpl(nettype, kdf_rounds); WalletImpl * wallet = new WalletImpl(nettype, kdf_rounds);
if(restoreHeight > 0){ if(restoreHeight > 0){
wallet->setRefreshFromBlockHeight(restoreHeight); wallet->setRefreshFromBlockHeight(restoreHeight);
} }
wallet->recover(path, password, mnemonic); wallet->recover(path, password, mnemonic, seed_offset);
return wallet; return wallet;
} }

View file

@ -46,7 +46,8 @@ public:
const std::string &mnemonic, const std::string &mnemonic,
NetworkType nettype, NetworkType nettype,
uint64_t restoreHeight, uint64_t restoreHeight,
uint64_t kdf_rounds = 1) override; uint64_t kdf_rounds = 1,
const std::string &seed_offset = {}) override;
virtual Wallet * createWalletFromKeys(const std::string &path, virtual Wallet * createWalletFromKeys(const std::string &path,
const std::string &password, const std::string &password,
const std::string &language, const std::string &language,