From a08bdfbdb81b04af7240d301e243fdd8af1ba149 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sat, 4 May 2024 19:11:50 +0200 Subject: [PATCH] Fix LTC getUnspentsByAddr() returning MWEB UTXOs. --- basicswap/interface/btc.py | 4 +++- basicswap/interface/firo.py | 2 -- basicswap/interface/nav.py | 2 -- tests/basicswap/test_ltc_xmr.py | 10 ++++++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/basicswap/interface/btc.py b/basicswap/interface/btc.py index 11bf565..dbade0b 100644 --- a/basicswap/interface/btc.py +++ b/basicswap/interface/btc.py @@ -1376,7 +1376,9 @@ class BTCInterface(CoinInterface): unspent_addr = dict() unspent = self.rpc_wallet('listunspent') for u in unspent: - if u['spendable'] is not True: + if u.get('spendable', False) is False: + continue + if u.get('solveable', False) is False: continue if 'address' not in u: continue diff --git a/basicswap/interface/firo.py b/basicswap/interface/firo.py index d1daf8a..a750777 100644 --- a/basicswap/interface/firo.py +++ b/basicswap/interface/firo.py @@ -277,8 +277,6 @@ class FIROInterface(BTCInterface): break utxos_hash = hasher.digest() - self._log.debug('sign_for_addr %s', sign_for_addr) - if self.using_segwit(): # TODO: Use isSegwitAddress when scantxoutset can use combo # 'Address does not refer to key' for non p2pkh pkh = self.decodeAddress(sign_for_addr) diff --git a/basicswap/interface/nav.py b/basicswap/interface/nav.py index 2a8dc1c..c7995bf 100644 --- a/basicswap/interface/nav.py +++ b/basicswap/interface/nav.py @@ -216,8 +216,6 @@ class NAVInterface(BTCInterface): break utxos_hash = hasher.digest() - self._log.debug('sign_for_addr %s', sign_for_addr) - if self.using_segwit(): # TODO: Use isSegwitAddress when scantxoutset can use combo # 'Address does not refer to key' for non p2pkh addr_info = self.rpc('validateaddress', [addr, ]) diff --git a/tests/basicswap/test_ltc_xmr.py b/tests/basicswap/test_ltc_xmr.py index 6b2508c..2007760 100644 --- a/tests/basicswap/test_ltc_xmr.py +++ b/tests/basicswap/test_ltc_xmr.py @@ -177,8 +177,14 @@ class TestLTC(BasicSwapTest): tx = ci1.rpc_wallet('gettransaction', [mweb_tx['txid'],]) blockhash = tx['blockhash'] - block = ci1.rpc('getblock', [blockhash, 3]) - block = ci1.rpc('getblock', [blockhash, 0]) + block3 = ci1.rpc('getblock', [blockhash, 3]) + block0 = ci1.rpc('getblock', [blockhash, 0]) + + require_amount: int = ci1.make_int(1) + unspent_addr = ci1.getUnspentsByAddr() + for addr, _ in unspent_addr.items(): + if 'mweb1' in addr: + raise ValueError('getUnspentsByAddr should exclude mweb UTXOs.') # TODO