mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
Fix adaptor sig swaps to Firo.
This commit is contained in:
@@ -79,6 +79,7 @@ class BCHInterface(BTCInterface):
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host
|
||||
)
|
||||
self.rpc_wallet_watch = self.rpc_wallet
|
||||
|
||||
def has_segwit(self) -> bool:
|
||||
# bch does not have segwit, but we return true here to avoid extra checks in basicswap.py
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2022-2023 tecnovert
|
||||
# Copyright (c) 2024 The Basicswap developers
|
||||
# Copyright (c) 2024-2025 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -44,6 +44,7 @@ class FIROInterface(BTCInterface):
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host
|
||||
)
|
||||
self.rpc_wallet_watch = self.rpc_wallet
|
||||
|
||||
if "wallet_name" in coin_settings:
|
||||
raise ValueError(f"Invalid setting for {self.coin_name()}: wallet_name")
|
||||
|
||||
@@ -98,6 +98,7 @@ class LTCInterfaceMWEB(LTCInterface):
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host, wallet=self._rpc_wallet
|
||||
)
|
||||
self.rpc_wallet_watch = self.rpc_wallet
|
||||
|
||||
def chainparams(self):
|
||||
return chainparams[Coins.LTC]
|
||||
|
||||
@@ -79,6 +79,7 @@ class NAVInterface(BTCInterface):
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host
|
||||
)
|
||||
self.rpc_wallet_watch = self.rpc_wallet
|
||||
|
||||
if "wallet_name" in coin_settings:
|
||||
raise ValueError(f"Invalid setting for {self.coin_name()}: wallet_name")
|
||||
|
||||
@@ -209,6 +209,15 @@ class PARTInterfaceBlind(PARTInterface):
|
||||
def xmr_swap_b_lock_spend_tx_vsize() -> int:
|
||||
return 980
|
||||
|
||||
@staticmethod
|
||||
def compareFeeRates(actual: int, expected: int) -> bool:
|
||||
# Allow the fee to be up to 10% larger than expected
|
||||
if actual < expected - 20:
|
||||
return False
|
||||
if actual > expected + expected * 0.1:
|
||||
return False
|
||||
return True
|
||||
|
||||
def coin_name(self) -> str:
|
||||
return super().coin_name() + " Blind"
|
||||
|
||||
@@ -678,6 +687,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||
witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack)
|
||||
vsize = self.getTxVSize(self.loadTx(tx_bytes), add_witness_bytes=witness_bytes)
|
||||
fee_paid = self.make_int(lock_refund_spend_tx_obj["vout"][0]["ct_fee"])
|
||||
|
||||
fee_rate_paid = fee_paid * 1000 // vsize
|
||||
ensure(
|
||||
self.compareFeeRates(fee_rate_paid, feerate),
|
||||
|
||||
@@ -33,6 +33,7 @@ class PIVXInterface(BTCInterface):
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host
|
||||
)
|
||||
self.rpc_wallet_watch = self.rpc_wallet
|
||||
|
||||
def encryptWallet(self, password: str, check_seed: bool = True):
|
||||
# Watchonly wallets are not encrypted
|
||||
|
||||
@@ -61,6 +61,7 @@ from tests.basicswap.common_xmr import (
|
||||
XMR_BASE_RPC_PORT,
|
||||
DOGE_BASE_RPC_PORT,
|
||||
NMC_BASE_RPC_PORT,
|
||||
FIRO_RPC_PORT_BASE,
|
||||
)
|
||||
from basicswap.interface.dcr.rpc import callrpc as callrpc_dcr
|
||||
import basicswap.bin.run as runSystem
|
||||
@@ -126,7 +127,7 @@ def callltcrpc(
|
||||
|
||||
|
||||
def calldcrrpc(
|
||||
node_id, method, params=[], wallet=None, base_rpc_port=DECRED_WALLET_RPC_PORT_BASE
|
||||
node_id, method, params=[], base_rpc_port=DECRED_WALLET_RPC_PORT_BASE + PORT_OFS
|
||||
):
|
||||
auth = "user:dcr_pwd"
|
||||
return callrpc_dcr(base_rpc_port + node_id, auth, method, params)
|
||||
@@ -143,6 +144,16 @@ def callnmcrpc(
|
||||
return callrpc(base_rpc_port + node_id, auth, method, params, wallet)
|
||||
|
||||
|
||||
def callfirorpc(
|
||||
node_id,
|
||||
method,
|
||||
params=[],
|
||||
base_rpc_port=FIRO_RPC_PORT_BASE + PORT_OFS,
|
||||
):
|
||||
auth = "test_firo_{0}:test_firo_pwd_{0}".format(node_id)
|
||||
return callrpc(base_rpc_port + node_id, auth, method, params)
|
||||
|
||||
|
||||
def callbchrpc(
|
||||
node_id,
|
||||
method,
|
||||
@@ -172,12 +183,14 @@ def updateThread(cls):
|
||||
callbtcrpc(0, "generatetoaddress", [1, cls.btc_addr])
|
||||
if cls.ltc_addr is not None:
|
||||
callltcrpc(0, "generatetoaddress", [1, cls.ltc_addr])
|
||||
if cls.nmc_addr is not None:
|
||||
callnmcrpc(0, "generatetoaddress", [1, cls.nmc_addr])
|
||||
if cls.firo_addr is not None:
|
||||
callfirorpc(0, "generatetoaddress", [1, cls.firo_addr])
|
||||
if cls.bch_addr is not None:
|
||||
callbchrpc(0, "generatetoaddress", [1, cls.bch_addr])
|
||||
if cls.doge_addr is not None:
|
||||
calldogerpc(0, "generatetoaddress", [1, cls.doge_addr])
|
||||
if cls.nmc_addr is not None:
|
||||
callnmcrpc(0, "generatetoaddress", [1, cls.nmc_addr])
|
||||
except Exception as e:
|
||||
print("updateThread error", str(e))
|
||||
cls.delay_event.wait(random.randrange(cls.update_min, cls.update_max))
|
||||
@@ -370,6 +383,22 @@ def start_processes(self):
|
||||
self.update_thread_dcr = threading.Thread(target=updateThreadDCR, args=(self,))
|
||||
self.update_thread_dcr.start()
|
||||
|
||||
if "firo" in TEST_COINS_LIST:
|
||||
self.firo_addr = callfirorpc(0, "getnewaddress", ["mining_addr"])
|
||||
num_blocks: int = 200
|
||||
have_blocks: int = callfirorpc(0, "getblockcount")
|
||||
if have_blocks < num_blocks:
|
||||
logging.info(
|
||||
"Mining %d Firo blocks to %s",
|
||||
num_blocks - have_blocks,
|
||||
self.firo_addr,
|
||||
)
|
||||
callfirorpc(
|
||||
0,
|
||||
"generatetoaddress",
|
||||
[num_blocks - have_blocks, self.firo_addr],
|
||||
)
|
||||
|
||||
if "bitcoincash" in TEST_COINS_LIST:
|
||||
self.bch_addr = callbchrpc(
|
||||
0, "getnewaddress", ["mining_addr"], wallet="wallet.dat"
|
||||
@@ -466,13 +495,13 @@ class BaseTestWithPrepare(unittest.TestCase):
|
||||
processes = []
|
||||
btc_addr = None
|
||||
ltc_addr = None
|
||||
bch_addr = None
|
||||
xmr_addr = None
|
||||
dcr_addr = "SsYbXyjkKAEXXcGdFgr4u4bo4L8RkCxwQpH"
|
||||
dcr_acc = None
|
||||
doge_addr = None
|
||||
nmc_addr = None
|
||||
|
||||
xmr_addr = None
|
||||
firo_addr = None
|
||||
bch_addr = None
|
||||
doge_addr = None
|
||||
initialised = False
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user