mirror of
https://github.com/basicswap/basicswap.git
synced 2024-11-16 15:58:17 +00:00
xmr: Cache main wallet address
This commit is contained in:
parent
a40519737d
commit
6a9e759629
3 changed files with 11 additions and 5 deletions
|
@ -1230,12 +1230,15 @@ class BasicSwap(BaseApp):
|
|||
self.setStringKV(key_str, addr)
|
||||
return addr
|
||||
|
||||
def getCachedMainWalletAddress(self, ci):
|
||||
return self.getStringKV('main_wallet_addr_' + ci.coin_name().lower())
|
||||
|
||||
def checkWalletSeed(self, c):
|
||||
ci = self.ci(c)
|
||||
if c == Coins.PART:
|
||||
return True # TODO
|
||||
if c == Coins.XMR:
|
||||
expect_address = self.getStringKV('main_wallet_addr_' + ci.coin_name().lower())
|
||||
expect_address = self.getCachedMainWalletAddress(ci)
|
||||
if expect_address is None:
|
||||
self.log.warning('Can\'t find expected main wallet address for coin {}'.format(ci.coin_name()))
|
||||
return False
|
||||
|
@ -4281,7 +4284,7 @@ class BasicSwap(BaseApp):
|
|||
vkbs = ci_to.sumKeys(kbsl, kbsf)
|
||||
|
||||
try:
|
||||
address_to = ci_to.getMainWalletAddress() # TODO: cache main wallet address to reduce network traffic
|
||||
address_to = self.getCachedMainWalletAddress(ci_to)
|
||||
txid = ci_to.spendBLockTx(address_to, xmr_swap.vkbv, vkbs, bid.amount_to, xmr_offer.b_fee_rate, xmr_swap.b_restore_height)
|
||||
self.log.debug('Submitted lock B spend txn %s to %s chain for bid %s', txid.hex(), ci_to.coin_name(), bid_id.hex())
|
||||
self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_B_SPEND_TX_PUBLISHED, '', session)
|
||||
|
@ -4337,7 +4340,7 @@ class BasicSwap(BaseApp):
|
|||
vkbs = ci_to.sumKeys(kbsl, kbsf)
|
||||
|
||||
try:
|
||||
address_to = ci_to.getMainWalletAddress()
|
||||
address_to = self.getCachedMainWalletAddress(ci_to)
|
||||
txid = ci_to.spendBLockTx(address_to, xmr_swap.vkbv, vkbs, bid.amount_to, xmr_offer.b_fee_rate, xmr_swap.b_restore_height)
|
||||
self.log.debug('Submitted lock B refund txn %s to %s chain for bid %s', txid.hex(), ci_to.coin_name(), bid_id.hex())
|
||||
self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_B_REFUND_TX_PUBLISHED, '', session)
|
||||
|
|
|
@ -89,7 +89,7 @@ def validateTextInput(text, name, messages, max_length=None):
|
|||
if max_length is not None and len(text) > max_length:
|
||||
messages.append(f'Error: {name} is too long')
|
||||
return False
|
||||
if len(text) > 0 and text.isalnum() is False:
|
||||
if len(text) > 0 and all(c.isalnum() or c.isspace() for c in text) is False:
|
||||
messages.append(f'Error: {name} must consist of only letters and digits')
|
||||
return False
|
||||
return True
|
||||
|
|
|
@ -371,6 +371,9 @@ class Test(unittest.TestCase):
|
|||
sc.setDaemonPID(Coins.BTC, cls.btc_daemons[i].pid)
|
||||
sc.setDaemonPID(Coins.PART, cls.part_daemons[i].pid)
|
||||
sc.start()
|
||||
# Set XMR main wallet address
|
||||
xmr_ci = sc.ci(Coins.XMR)
|
||||
sc.setStringKV('main_wallet_addr_' + xmr_ci.coin_name().lower(), xmr_ci.getMainWalletAddress())
|
||||
cls.swap_clients.append(sc)
|
||||
|
||||
t = HttpThread(cls.swap_clients[i].fp, TEST_HTTP_HOST, TEST_HTTP_PORT + i, False, cls.swap_clients[i])
|
||||
|
@ -520,7 +523,7 @@ class Test(unittest.TestCase):
|
|||
found = True
|
||||
assert(found is False)
|
||||
|
||||
# Reenable
|
||||
# Re-enable
|
||||
post_json = {
|
||||
'address': new_address,
|
||||
'active_ind': '1',
|
||||
|
|
Loading…
Reference in a new issue