Fix XMR withdrawals

This commit is contained in:
tecnovert 2023-02-09 23:21:52 +02:00
parent c9e04332fc
commit 9117e2b723
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
2 changed files with 23 additions and 4 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2022 tecnovert
# Copyright (c) 2020-2023 tecnovert
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
@ -422,10 +422,12 @@ class XMRInterface(CoinInterface):
value_sats = make_int(value, self.exp())
self.openWallet(self._wallet_filename)
self.rpc_wallet_cb('refresh')
if subfee:
balance = self.rpc_wallet_cb('get_balance')
if balance['unlocked_balance'] - value_sats <= 10:
diff = balance['unlocked_balance'] - value_sats
if diff > 0 and diff <= 10:
self._log.info('subfee enabled and value close to total, using sweep_all.')
params = {'address': addr_to}
if self._fee_priority > 0:

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2022 tecnovert
# Copyright (c) 2020-2023 tecnovert
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
@ -997,7 +997,24 @@ class Test(BaseTest):
js_1 = read_json_api(1801, 'wallets')
assert (float(js_1[Coins.XMR.name]['balance']) > 0.0)
swap_clients[1].withdrawCoin(Coins.XMR, 1.1, address_to, False)
post_json = {
'value': 0.001,
'address': address_to,
'subfee': True,
}
rv = read_json_api(1801, 'wallets/xmr/withdraw', post_json)
assert ('Withdraw value must be close to total to use subfee' in rv['error'])
post_json['value'] = 1000000000.0
rv = read_json_api(1801, 'wallets/xmr/withdraw', post_json)
assert ('Withdraw value must be close to total to use subfee' in rv['error'])
post_json = {
'value': 1.1,
'address': address_to,
'subfee': False,
}
rv = read_json_api(1801, 'wallets/xmr/withdraw', post_json)
assert (len(rv['txid']) == 64)
def test_09_auto_accept(self):
logging.info('---------- Test BTC to XMR auto accept')