Final fix to refunds path, increase test coverage

This commit is contained in:
mainnet-pat
2024-10-30 05:37:01 +00:00
committed by tecnovert
parent b7da4f2096
commit a7c2fbba1f
3 changed files with 69 additions and 56 deletions

View File

@@ -57,17 +57,15 @@ from coincurve.ecdsaotves import (
ecdsaotves_rec_enc_key,
)
def findOutput(tx, script_pk: bytes):
for i in range(len(tx.vout)):
if tx.vout[i].scriptPubKey == script_pk:
return i
return None
class BCHInterface(BTCInterface):
@staticmethod
def coin_type():
return Coins.BCH
@staticmethod
def xmr_swap_a_lock_spend_tx_vsize() -> int:
return 302
def __init__(self, coin_settings, network, swap_client=None):
super(BCHInterface, self).__init__(coin_settings, network, swap_client)
# No multiwallet support
@@ -85,6 +83,17 @@ class BCHInterface(BTCInterface):
args = [label]
return self.rpc_wallet('getnewaddress', args)
def getUnspentsByAddr(self):
unspent_addr = dict()
unspent = self.rpc_wallet('listunspent')
for u in unspent:
if u.get('spendable', False) is False:
continue
if 'address' not in u:
continue
unspent_addr[u['address']] = unspent_addr.get(u['address'], 0) + self.make_int(u['amount'], r=1)
return unspent_addr
# returns pkh
def decodeAddress(self, address: str) -> bytes:
return bytes(Address.from_string(address).payload)