libwallet_api: Added option to restore from specific height
This commit is contained in:
parent
9798bde11e
commit
36a89ab435
|
@ -404,6 +404,10 @@ void WalletImpl::initAsync(const string &daemon_address, uint64_t upper_transact
|
||||||
startRefresh();
|
startRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WalletImpl::setRefreshFromBlockHeight(uint64_t refresh_from_block_height)
|
||||||
|
{
|
||||||
|
m_wallet->set_refresh_from_block_height(refresh_from_block_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64_t WalletImpl::balance() const
|
uint64_t WalletImpl::balance() const
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
void refreshAsync();
|
void refreshAsync();
|
||||||
void setAutoRefreshInterval(int millis);
|
void setAutoRefreshInterval(int millis);
|
||||||
int autoRefreshInterval() const;
|
int autoRefreshInterval() const;
|
||||||
|
void setRefreshFromBlockHeight(uint64_t refresh_from_block_height);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,12 @@ Wallet *WalletManagerImpl::openWallet(const std::string &path, const std::string
|
||||||
return wallet;
|
return wallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet *WalletManagerImpl::recoveryWallet(const std::string &path, const std::string &memo, bool testnet)
|
Wallet *WalletManagerImpl::recoveryWallet(const std::string &path, const std::string &memo, bool testnet, uint64_t restoreHeight)
|
||||||
{
|
{
|
||||||
WalletImpl * wallet = new WalletImpl(testnet);
|
WalletImpl * wallet = new WalletImpl(testnet);
|
||||||
|
if(restoreHeight > 0){
|
||||||
|
wallet->setRefreshFromBlockHeight(restoreHeight);
|
||||||
|
}
|
||||||
wallet->recover(path, memo);
|
wallet->recover(path, memo);
|
||||||
return wallet;
|
return wallet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
Wallet * createWallet(const std::string &path, const std::string &password,
|
Wallet * createWallet(const std::string &path, const std::string &password,
|
||||||
const std::string &language, bool testnet);
|
const std::string &language, bool testnet);
|
||||||
Wallet * openWallet(const std::string &path, const std::string &password, bool testnet);
|
Wallet * openWallet(const std::string &path, const std::string &password, bool testnet);
|
||||||
virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet);
|
virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet, uint64_t restoreHeight);
|
||||||
virtual bool closeWallet(Wallet *wallet);
|
virtual bool closeWallet(Wallet *wallet);
|
||||||
bool walletExists(const std::string &path);
|
bool walletExists(const std::string &path);
|
||||||
std::vector<std::string> findWallets(const std::string &path);
|
std::vector<std::string> findWallets(const std::string &path);
|
||||||
|
|
|
@ -219,6 +219,13 @@ struct Wallet
|
||||||
*/
|
*/
|
||||||
virtual void initAsync(const std::string &daemon_address, uint64_t upper_transaction_size_limit) = 0;
|
virtual void initAsync(const std::string &daemon_address, uint64_t upper_transaction_size_limit) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief setRefreshFromBlockHeight - start refresh from block height on recover
|
||||||
|
*
|
||||||
|
* \param refresh_from_block_height - blockchain start height
|
||||||
|
*/
|
||||||
|
virtual void setRefreshFromBlockHeight(uint64_t refresh_from_block_height) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief connectToDaemon - connects to the daemon. TODO: check if it can be removed
|
* @brief connectToDaemon - connects to the daemon. TODO: check if it can be removed
|
||||||
* @return
|
* @return
|
||||||
|
@ -347,9 +354,11 @@ struct WalletManager
|
||||||
* \brief recovers existing wallet using memo (electrum seed)
|
* \brief recovers existing wallet using memo (electrum seed)
|
||||||
* \param path Name of wallet file to be created
|
* \param path Name of wallet file to be created
|
||||||
* \param memo memo (25 words electrum seed)
|
* \param memo memo (25 words electrum seed)
|
||||||
|
* \param testnet testnet
|
||||||
|
* \param restoreHeight restore from start height
|
||||||
* \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 &memo, bool testnet = false) = 0;
|
virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet = false, uint64_t restoreHeight = 0) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Closes wallet. In case operation succeded, wallet object deleted. in case operation failed, wallet object not deleted
|
* \brief Closes wallet. In case operation succeded, wallet object deleted. in case operation failed, wallet object not deleted
|
||||||
|
|
Loading…
Reference in New Issue