mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
coins: Encrypt wallets before importing seeds, allow BTC to start without wallet.
Create BTC wallet on unlock if missing.
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
name = "basicswap"
|
||||
|
||||
__version__ = "0.11.54"
|
||||
__version__ = "0.11.55"
|
||||
|
||||
@@ -655,7 +655,12 @@ class BasicSwap(BaseApp):
|
||||
self.createCoinInterface(c)
|
||||
|
||||
if self.coin_clients[c]['connection_type'] == 'rpc':
|
||||
self.waitForDaemonRPC(c)
|
||||
if c == Coins.BTC:
|
||||
self.waitForDaemonRPC(c, with_wallet=False)
|
||||
if len(self.callcoinrpc(c, 'listwallets')) >= 1:
|
||||
self.waitForDaemonRPC(c)
|
||||
else:
|
||||
self.waitForDaemonRPC(c)
|
||||
ci = self.ci(c)
|
||||
core_version = ci.getDaemonVersion()
|
||||
self.log.info('%s Core version %d', ci.coin_name(), core_version)
|
||||
@@ -1655,6 +1660,9 @@ class BasicSwap(BaseApp):
|
||||
if expect_seedid is None:
|
||||
self.log.warning('Can\'t find expected wallet seed id for coin {}'.format(ci.coin_name()))
|
||||
return False
|
||||
if len(ci.rpc_callback('listwallets')) < 1:
|
||||
self.log.warning('Missing wallet for coin {}'.format(ci.coin_name()))
|
||||
return False
|
||||
if ci.checkExpectedSeed(expect_seedid):
|
||||
ci.setWalletSeedWarning(False)
|
||||
return True
|
||||
|
||||
@@ -299,7 +299,8 @@ class BTCInterface(CoinInterface):
|
||||
raise ValueError('{} wallet restore height not found.'.format(self.coin_name()))
|
||||
|
||||
def getWalletSeedID(self) -> str:
|
||||
return self.rpc_callback('getwalletinfo')['hdseedid']
|
||||
wi = self.rpc_callback('getwalletinfo')
|
||||
return 'Not found' if 'hdseedid' not in wi else wi['hdseedid']
|
||||
|
||||
def checkExpectedSeed(self, expect_seedid) -> bool:
|
||||
self._expect_seedid_hex = expect_seedid
|
||||
@@ -1348,9 +1349,22 @@ class BTCInterface(CoinInterface):
|
||||
if password == '':
|
||||
return
|
||||
self._log.info('unlockWallet - {}'.format(self.ticker()))
|
||||
|
||||
if self.coin_type() == Coins.BTC:
|
||||
# Recreate wallet if none found
|
||||
# Required when encrypting an existing btc wallet, workaround is to delete the btc wallet and recreate
|
||||
wallets = self.rpc_callback('listwallets')
|
||||
if len(wallets) < 1:
|
||||
self._log.info('Creating wallet.dat for {}.'.format(self.coin_name()))
|
||||
# wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors
|
||||
self.rpc_callback('createwallet', ['wallet.dat', False, True, '', False, False])
|
||||
self.rpc_callback('encryptwallet', [password])
|
||||
|
||||
# Max timeout value, ~3 years
|
||||
self.rpc_callback('walletpassphrase', [password, 100000000])
|
||||
|
||||
self._sc.checkWalletSeed(self.coin_type())
|
||||
|
||||
def lockWallet(self):
|
||||
self._log.info('lockWallet - {}'.format(self.ticker()))
|
||||
self.rpc_callback('walletlock')
|
||||
|
||||
@@ -82,4 +82,4 @@
|
||||
{% include 'footer.html' %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user