preparescript: Add WALLET_ENCRYPTION_PWD env var.

Removed unnecessary START_DAEMONS env var.
Remove all cached addresses from the basicswap db for a wallet after reseeding.
Check that addresses retreived from the db are owned by teh wallet before they're used/displayed
This commit is contained in:
tecnovert
2022-11-17 00:36:13 +02:00
parent aabf865873
commit 0f7df9e5f1
12 changed files with 189 additions and 57 deletions

View File

@@ -188,6 +188,7 @@ class BTCInterface(CoinInterface):
self._connection_type = coin_settings['connection_type']
self._sc = swap_client
self._log = self._sc.log if self._sc and self._sc.log else logging
self._expect_seedid_hex = None
def using_segwit(self):
return self._use_segwit
@@ -297,6 +298,7 @@ class BTCInterface(CoinInterface):
return self.rpc_callback('getwalletinfo')['hdseedid']
def checkExpectedSeed(self, expect_seedid):
self._expect_seedid_hex = expect_seedid
return expect_seedid == self.getWalletSeedID()
def getNewAddress(self, use_segwit, label='swap_receive'):
@@ -305,6 +307,15 @@ class BTCInterface(CoinInterface):
args.append('bech32')
return self.rpc_callback('getnewaddress', args)
def isAddressMine(self, address):
addr_info = self.rpc_callback('getaddressinfo', [address])
return addr_info['ismine']
def checkAddressMine(self, address):
addr_info = self.rpc_callback('getaddressinfo', [address])
ensure(addr_info['ismine'], 'ismine is false')
ensure(addr_info['hdseedid'] == self._expect_seedid_hex, 'unexpected seedid')
def get_fee_rate(self, conf_target=2):
try:
fee_rate = self.rpc_callback('estimatesmartfee', [conf_target])['feerate']

View File

@@ -55,6 +55,10 @@ class FIROInterface(BTCInterface):
addr_info = self.rpc_callback('validateaddress', [address])
return addr_info['iswatchonly']
def isAddressMine(self, address):
addr_info = self.rpc_callback('validateaddress', [address])
return addr_info['ismine']
def getSCLockScriptAddress(self, lock_script):
lock_tx_dest = self.getScriptDest(lock_script)
address = self.encodeScriptDest(lock_tx_dest)

View File

@@ -75,6 +75,7 @@ class XMRInterface(CoinInterface):
self._sc = swap_client
self._log = self._sc.log if self._sc and self._sc.log else logging
self._wallet_password = None
self._have_checked_seed = False
def setFeePriority(self, new_priority):
ensure(new_priority >= 0 and new_priority < 4, 'Invalid fee_priority value')
@@ -534,6 +535,13 @@ class XMRInterface(CoinInterface):
self._log.info('unlockWallet - {}'.format(self.ticker()))
self._wallet_password = password
if not self._have_checked_seed:
self._sc.checkWalletSeed(self.coin_type())
def lockWallet(self):
self._log.info('lockWallet - {}'.format(self.ticker()))
self._wallet_password = None
def isAddressMine(self, address):
# TODO
return True