mirror of
https://github.com/basicswap/basicswap.git
synced 2026-04-15 21:27:23 +02:00
Compare commits
12 Commits
3c76454e68
...
19d7d0a5b4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19d7d0a5b4 | ||
|
|
67b290db27 | ||
|
|
6df5c4687d | ||
|
|
7f125a2fe1 | ||
|
|
9b4a853c65 | ||
|
|
953ef6b4ae | ||
|
|
614d29c31c | ||
|
|
360d356cbf | ||
|
|
3ff67f0766 | ||
|
|
25b7ecfc42 | ||
|
|
da248239d4 | ||
|
|
0061b347f5 |
@@ -148,14 +148,7 @@ from .db import (
|
||||
XmrSwap,
|
||||
)
|
||||
from .wallet_manager import WalletManager
|
||||
from .db_wallet import (
|
||||
WalletAddress,
|
||||
WalletLockedUTXO,
|
||||
WalletPendingTx,
|
||||
WalletState,
|
||||
WalletTxCache,
|
||||
WalletWatchOnly,
|
||||
)
|
||||
|
||||
from .explorers import (
|
||||
ExplorerInsight,
|
||||
ExplorerBitAps,
|
||||
@@ -614,15 +607,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
|
||||
if not db_exists:
|
||||
self.log.info("First run")
|
||||
wallet_tables = [
|
||||
WalletAddress,
|
||||
WalletLockedUTXO,
|
||||
WalletPendingTx,
|
||||
WalletState,
|
||||
WalletTxCache,
|
||||
WalletWatchOnly,
|
||||
]
|
||||
create_db(self.sqlite_file, self.log, extra_tables=wallet_tables)
|
||||
create_db(self.sqlite_file, self.log)
|
||||
|
||||
cursor = self.openDB()
|
||||
try:
|
||||
@@ -3964,6 +3949,13 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
except Exception as e:
|
||||
raise ValueError(f"Invalid message networks: {e}")
|
||||
|
||||
def isValidSwapDest(self, ci, dest: bytes):
|
||||
ensure(isinstance(dest, bytes), "Swap destination must be bytes")
|
||||
if ci.coin_type() in (Coins.PART_BLIND,):
|
||||
return ci.isValidPubkey(dest)
|
||||
# TODO: allow p2wsh
|
||||
return ci.isValidAddressHash(dest)
|
||||
|
||||
def ensureWalletCanSend(
|
||||
self, ci, swap_type, ensure_balance: int, estimated_fee: int, for_offer=True
|
||||
) -> None:
|
||||
@@ -5365,12 +5357,13 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
self.loadBidTxns(bid, cursor)
|
||||
return bid, xmr_swap
|
||||
|
||||
def getXmrBid(self, bid_id: bytes):
|
||||
def getXmrBid(self, bid_id: bytes, cursor=None):
|
||||
try:
|
||||
cursor = self.openDB()
|
||||
return self.getXmrBidFromSession(cursor, bid_id)
|
||||
use_cursor = self.openDB(cursor)
|
||||
return self.getXmrBidFromSession(use_cursor, bid_id)
|
||||
finally:
|
||||
self.closeDB(cursor, commit=False)
|
||||
if cursor is None:
|
||||
self.closeDB(use_cursor, commit=False)
|
||||
|
||||
def getXmrOfferFromSession(self, cursor, offer_id: bytes):
|
||||
offer = self.queryOne(Offer, cursor, {"offer_id": offer_id})
|
||||
@@ -5875,7 +5868,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
)
|
||||
if bid.bid_id and bid_msg_id != bid.bid_id:
|
||||
self.log.warning(
|
||||
f"sendBidMessage: Mismatched bid ids: {bid.bid_id.hex()}, {bid_msg_id.hex()}."
|
||||
f"sendBidMessage: Mismatched bid ids: {self.log.id(bid.bid_id)}, {self.log.id(bid_msg_id)}."
|
||||
)
|
||||
return bid_msg_id
|
||||
|
||||
@@ -7771,7 +7764,12 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
len(xmr_swap.al_lock_refund_tx_sig) > 0
|
||||
and len(xmr_swap.af_lock_refund_tx_sig) > 0
|
||||
):
|
||||
|
||||
try:
|
||||
if bid.xmr_b_lock_tx is None and self.haveDebugInd(
|
||||
bid.bid_id, DebugTypes.WAIT_FOR_COIN_B_LOCK_BEFORE_PREREFUND
|
||||
):
|
||||
raise TemporaryError("Debug: Waiting for Coin B Lock Tx")
|
||||
txid = ci_from.publishTx(xmr_swap.a_lock_refund_tx)
|
||||
|
||||
# BCH txids change
|
||||
@@ -7821,6 +7819,10 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
self.saveBidInSession(bid_id, bid, cursor, xmr_swap)
|
||||
self.commitDB()
|
||||
return rv
|
||||
else:
|
||||
self.log.warning(
|
||||
f"Trying to publish coin a lock refund tx: {ex}"
|
||||
)
|
||||
|
||||
state = BidStates(bid.state)
|
||||
if state == BidStates.SWAP_COMPLETED:
|
||||
@@ -8067,6 +8069,15 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
self.log.warning(
|
||||
f"Not releasing ads script coin lock tx for bid {self.log.id(bid_id)}: Chain A lock refund tx already exists."
|
||||
)
|
||||
elif (
|
||||
bid.debug_ind == DebugTypes.DONT_RELEASE_COIN_A_LOCK
|
||||
):
|
||||
self.logBidEvent(
|
||||
bid_id,
|
||||
EventLogTypes.DEBUG_TWEAK_APPLIED,
|
||||
f"ind {DebugTypes.DONT_RELEASE_COIN_A_LOCK}",
|
||||
None,
|
||||
)
|
||||
else:
|
||||
delay = self.get_delay_event_seconds()
|
||||
self.log.info(
|
||||
@@ -8513,9 +8524,8 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
)
|
||||
|
||||
watched = self.coin_clients[coin_type]["watched_transactions"]
|
||||
|
||||
for wo in watched:
|
||||
if wo.bid_id == bid_id and wo.txid_hex == txid_hex:
|
||||
for wt in watched:
|
||||
if wt.bid_id == bid_id and wt.txid_hex == txid_hex:
|
||||
self.log.debug("Transaction already being watched.")
|
||||
return
|
||||
|
||||
@@ -8953,7 +8963,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
|
||||
else:
|
||||
self.log.info(
|
||||
f"Coin a lock refund spent by unknown tx, bid {self.log.id(bid_id)}."
|
||||
f"Coin a lock refund spent by unknown tx, bid {self.log.id(bid_id)}, txid {self.logIDT(spending_txid)}."
|
||||
)
|
||||
|
||||
mercy_keyshare = None
|
||||
@@ -8980,6 +8990,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
bid.setState(BidStates.XMR_SWAP_FAILED_SWIPED)
|
||||
else:
|
||||
delay = self.get_delay_event_seconds()
|
||||
self.log.info("Found mercy output.")
|
||||
self.log.info(
|
||||
f"Redeeming coin b lock tx for bid {self.log.id(bid_id)} in {delay} seconds."
|
||||
)
|
||||
@@ -9298,6 +9309,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
self.processFoundTransaction(
|
||||
t, block_hash, block["height"], chain_blocks
|
||||
)
|
||||
|
||||
for s in c["watched_scripts"]:
|
||||
for i, txo in enumerate(tx["vout"]):
|
||||
if "scriptPubKey" in txo and "hex" in txo["scriptPubKey"]:
|
||||
@@ -12174,7 +12186,9 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
xmr_swap.af_lock_refund_spend_tx_sig = ci_from.decryptOtVES(
|
||||
kbsl, xmr_swap.af_lock_refund_spend_tx_esig
|
||||
)
|
||||
prevout_amount = ci_from.getLockRefundTxSwapOutputValue(bid, xmr_swap)
|
||||
prevout_amount: int = ci_from.getLockRefundTxSwapOutputValue(
|
||||
bid, xmr_swap
|
||||
)
|
||||
al_lock_refund_spend_tx_sig = ci_from.signTx(
|
||||
kal,
|
||||
xmr_swap.a_lock_refund_spend_tx,
|
||||
@@ -12601,8 +12615,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
ci_from.verifyPubkey(msg_data.pkaf), "Invalid chain A follower public key"
|
||||
)
|
||||
ensure(
|
||||
ci_from.isValidAddressHash(msg_data.dest_af)
|
||||
or ci_from.isValidPubkey(msg_data.dest_af),
|
||||
self.isValidSwapDest(ci_from, msg_data.dest_af),
|
||||
"Invalid destination address",
|
||||
)
|
||||
if ci_to.curve_type() == Curves.ed25519:
|
||||
|
||||
@@ -240,8 +240,11 @@ class DebugTypes(IntEnum):
|
||||
OFFER_LOCK_2_VALUE_INC = auto()
|
||||
BID_STOP_AFTER_COIN_B_LOCK = auto()
|
||||
BID_DONT_SPEND_COIN_B_LOCK = auto()
|
||||
WAIT_FOR_COIN_B_LOCK_BEFORE_PREREFUND = auto()
|
||||
WAIT_FOR_COIN_B_LOCK_BEFORE_REFUND = auto()
|
||||
BID_DONT_SPEND_COIN_A_LOCK = auto()
|
||||
DONT_SEND_COIN_B_LOCK = auto()
|
||||
DONT_RELEASE_COIN_A_LOCK = auto()
|
||||
|
||||
|
||||
class NotificationTypes(IntEnum):
|
||||
|
||||
@@ -2892,9 +2892,15 @@ def main():
|
||||
coin_id = getCoinIdFromName(coin_name)
|
||||
coin_params = chainparams[coin_id]
|
||||
if coin_settings.get("core_type_group", "") == "xmr":
|
||||
default_name = "swap_wallet"
|
||||
default_name: str = "swap_wallet"
|
||||
use_name: str = default_name
|
||||
else:
|
||||
default_name = "wallet.dat"
|
||||
default_name: str = "wallet.dat"
|
||||
use_name: str = (
|
||||
"wallet.dat"
|
||||
if coin_id in (Coins.NAV, Coins.FIRO, Coins.DCR)
|
||||
else "bsx_wallet"
|
||||
)
|
||||
|
||||
if coin_name == "litecoin":
|
||||
set_name: str = getWalletName(
|
||||
@@ -2903,7 +2909,7 @@ def main():
|
||||
if set_name != "mweb":
|
||||
coin_settings["mweb_wallet_name"] = set_name
|
||||
|
||||
set_name: str = getWalletName(coin_params, default_name)
|
||||
set_name: str = getWalletName(coin_params, use_name)
|
||||
if set_name != default_name:
|
||||
coin_settings["wallet_name"] = set_name
|
||||
|
||||
|
||||
@@ -566,7 +566,7 @@ def getCoinIdFromTicker(ticker: str) -> str:
|
||||
raise ValueError(f"Unknown coin {ticker}")
|
||||
|
||||
|
||||
def getCoinIdFromName(name: str) -> str:
|
||||
def getCoinIdFromName(name: str) -> Coins:
|
||||
try:
|
||||
return name_map[name.lower()]
|
||||
except Exception:
|
||||
|
||||
@@ -772,12 +772,8 @@ class NetworkPortal(Table):
|
||||
created_at = Column("integer")
|
||||
|
||||
|
||||
def extract_schema(extra_tables: list = None) -> dict:
|
||||
g = globals().copy()
|
||||
|
||||
if extra_tables:
|
||||
for table_class in extra_tables:
|
||||
g[table_class.__name__] = table_class
|
||||
def extract_schema(input_globals: dict = None) -> dict:
|
||||
g = (input_globals if input_globals else globals()).copy()
|
||||
|
||||
tables = {}
|
||||
for name, obj in g.items():
|
||||
@@ -898,18 +894,21 @@ def create_table(c, table_name, table) -> None:
|
||||
c.execute(query)
|
||||
|
||||
|
||||
def create_db_(con, log, extra_tables: list = None) -> None:
|
||||
db_schema = extract_schema(extra_tables=extra_tables)
|
||||
def create_db_(con, log) -> None:
|
||||
from .db_wallet import extract_wallet_schema
|
||||
|
||||
db_schema = extract_schema()
|
||||
db_schema.update(extract_wallet_schema())
|
||||
c = con.cursor()
|
||||
for table_name, table in db_schema.items():
|
||||
create_table(c, table_name, table)
|
||||
|
||||
|
||||
def create_db(db_path: str, log, extra_tables: list = None) -> None:
|
||||
def create_db(db_path: str, log) -> None:
|
||||
con = None
|
||||
try:
|
||||
con = sqlite3.connect(db_path)
|
||||
create_db_(con, log, extra_tables=extra_tables)
|
||||
create_db_(con, log)
|
||||
con.commit()
|
||||
finally:
|
||||
if con:
|
||||
@@ -1229,7 +1228,6 @@ class DBMethods:
|
||||
values = {}
|
||||
constraint_values = {}
|
||||
set_columns = []
|
||||
|
||||
for mc in inspect.getmembers(obj.__class__):
|
||||
mc_name, mc_obj = mc
|
||||
if not hasattr(mc_obj, "__sqlite3_column__"):
|
||||
|
||||
@@ -18,14 +18,7 @@ from .db import (
|
||||
extract_schema,
|
||||
)
|
||||
|
||||
from .db_wallet import (
|
||||
WalletAddress,
|
||||
WalletLockedUTXO,
|
||||
WalletPendingTx,
|
||||
WalletState,
|
||||
WalletTxCache,
|
||||
WalletWatchOnly,
|
||||
)
|
||||
from .db_wallet import extract_wallet_schema
|
||||
|
||||
from .basicswap_util import (
|
||||
BidStates,
|
||||
@@ -277,15 +270,8 @@ def upgradeDatabase(self, db_version: int):
|
||||
),
|
||||
]
|
||||
|
||||
wallet_tables = [
|
||||
WalletAddress,
|
||||
WalletLockedUTXO,
|
||||
WalletPendingTx,
|
||||
WalletState,
|
||||
WalletTxCache,
|
||||
WalletWatchOnly,
|
||||
]
|
||||
expect_schema = extract_schema(extra_tables=wallet_tables)
|
||||
expect_schema = extract_schema()
|
||||
expect_schema.update(extract_wallet_schema())
|
||||
have_tables = {}
|
||||
try:
|
||||
cursor = self.openDB()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
from .db import Column, Index, Table, UniqueConstraint
|
||||
from .db import Column, Index, Table, UniqueConstraint, extract_schema
|
||||
|
||||
|
||||
class WalletAddress(Table):
|
||||
@@ -120,3 +120,7 @@ class WalletPendingTx(Table):
|
||||
|
||||
__unique_1__ = UniqueConstraint("coin_type", "txid")
|
||||
__index_pending_coin__ = Index("idx_pending_coin", "coin_type", "confirmed_at")
|
||||
|
||||
|
||||
def extract_wallet_schema() -> dict:
|
||||
return extract_schema(input_globals=globals())
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2024-2025 The Basicswap developers
|
||||
# Copyright (c) 2024-2026 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -10,7 +10,6 @@ from basicswap.contrib.test_framework.messages import COutPoint, CTransaction, C
|
||||
from basicswap.util import b2i, ensure, i2b
|
||||
from basicswap.util.script import decodePushData, decodeScriptNum
|
||||
from .btc import BTCInterface, ensure_op, findOutput
|
||||
from basicswap.rpc import make_rpc_func
|
||||
from basicswap.chainparams import Coins
|
||||
from basicswap.interface.contrib.bch_test_framework.cashaddress import Address
|
||||
from basicswap.util.crypto import hash160, sha256
|
||||
@@ -74,12 +73,7 @@ class BCHInterface(BTCInterface):
|
||||
|
||||
def __init__(self, coin_settings, network, swap_client=None):
|
||||
super(BCHInterface, self).__init__(coin_settings, network, swap_client)
|
||||
# No multiwallet support
|
||||
self.swap_client = swap_client
|
||||
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
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
import base64
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
@@ -381,7 +382,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
|
||||
if self._rpc_wallet not in wallets:
|
||||
self._log.debug(
|
||||
f"Wallet: {self._rpc_wallet} not active, attempting to load."
|
||||
f'{self.ticker()} wallet: "{self._rpc_wallet}" not active, attempting to load.'
|
||||
)
|
||||
try:
|
||||
self.rpc(
|
||||
@@ -425,32 +426,43 @@ class BTCInterface(Secp256k1Interface):
|
||||
except Exception as create_e:
|
||||
self._log.error(f"Error creating wallet: {create_e}")
|
||||
|
||||
if (
|
||||
self._rpc_wallet_watch != self._rpc_wallet
|
||||
and self._rpc_wallet_watch not in wallets
|
||||
):
|
||||
self._log.debug(
|
||||
f'{self.ticker()} watchonly wallet: "{self._rpc_wallet_watch}" not active, attempting to load.'
|
||||
)
|
||||
try:
|
||||
self.rpc(
|
||||
"loadwallet",
|
||||
[
|
||||
self._rpc_wallet_watch,
|
||||
],
|
||||
)
|
||||
wallets = self.rpc("listwallets")
|
||||
except Exception as e:
|
||||
self._log.debug(
|
||||
f'Error loading {self.ticker()} watchonly wallet "{self._rpc_wallet_watch}": {e}.'
|
||||
)
|
||||
|
||||
# Wallet name is "" for some LTC and PART installs on older cores
|
||||
if self._rpc_wallet not in wallets and len(wallets) > 0:
|
||||
self._log.warning(f"Changing {self.ticker()} wallet name.")
|
||||
for wallet_name in wallets:
|
||||
# Skip over other expected wallets
|
||||
if wallet_name in ("mweb",):
|
||||
continue
|
||||
|
||||
change_watchonly_wallet: bool = (
|
||||
self._rpc_wallet_watch == self._rpc_wallet
|
||||
if "" in wallets:
|
||||
self._log.warning(
|
||||
f"Nameless {self.ticker()} wallet found."
|
||||
+ '\nPlease set the "wallet_name" coin setting to "" or recreate the wallet'
|
||||
)
|
||||
# backupwallet and restorewallet with name should work.
|
||||
|
||||
self._rpc_wallet = wallet_name
|
||||
self._log.info(
|
||||
f"Switched {self.ticker()} wallet name to {self._rpc_wallet}."
|
||||
)
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport,
|
||||
self._rpcauth,
|
||||
host=self._rpc_host,
|
||||
wallet=self._rpc_wallet,
|
||||
)
|
||||
if change_watchonly_wallet:
|
||||
self.rpc_wallet_watch = self.rpc_wallet
|
||||
break
|
||||
|
||||
if self._rpc_wallet not in wallets:
|
||||
raise RuntimeError(
|
||||
f'{self.ticker()} wallet "{self._rpc_wallet}" not active'
|
||||
)
|
||||
if self._rpc_wallet_watch not in wallets:
|
||||
raise RuntimeError(
|
||||
f'{self.ticker()} watchonly wallet "{self._rpc_wallet_watch}" not active'
|
||||
)
|
||||
return len(wallets)
|
||||
|
||||
def testDaemonRPC(self, with_wallet=True) -> None:
|
||||
@@ -530,6 +542,16 @@ class BTCInterface(Secp256k1Interface):
|
||||
)
|
||||
return self.rpc("getblockheader", [block_hash])
|
||||
|
||||
def getPrevBlockInChain(self, block_header_in):
|
||||
block_header = copy.deeocopy(block_header_in)
|
||||
while True:
|
||||
previousblockhash = block_header.get("previousblockhash", None)
|
||||
if previousblockhash is None:
|
||||
raise RuntimeError("previousblockhash not in block_header")
|
||||
if block_header["confirmations"] > 0:
|
||||
return block_header
|
||||
block_header = self.rpc("getblockheader", [previousblockhash])
|
||||
|
||||
def getBlockHeaderAt(self, time_target: int, block_after=False):
|
||||
blockchaininfo = self.rpc("getblockchaininfo")
|
||||
last_block_header = self.rpc(
|
||||
@@ -1310,7 +1332,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
vkbv=None,
|
||||
kbsf=None,
|
||||
):
|
||||
# lock refund swipe tx
|
||||
# Lock refund swipe tx
|
||||
# Sends the coinA locked coin to the follower
|
||||
|
||||
tx_lock_refund = self.loadTx(tx_lock_refund_bytes)
|
||||
@@ -1584,7 +1606,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
)
|
||||
|
||||
if not self.compareFeeRates(fee_rate_paid, feerate):
|
||||
raise ValueError("Bad fee rate, expected: {}".format(feerate))
|
||||
raise ValueError(f"Bad fee rate, expected: {feerate}")
|
||||
|
||||
return txid, locked_coin, locked_n
|
||||
|
||||
@@ -1647,7 +1669,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
)
|
||||
|
||||
if not self.compareFeeRates(fee_rate_paid, feerate):
|
||||
raise ValueError("Bad fee rate, expected: {}".format(feerate))
|
||||
raise ValueError(f"Bad fee rate, expected: {feerate}")
|
||||
|
||||
return True
|
||||
|
||||
@@ -1706,7 +1728,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
)
|
||||
|
||||
if not self.compareFeeRates(fee_rate_paid, feerate):
|
||||
raise ValueError("Bad fee rate, expected: {}".format(feerate))
|
||||
raise ValueError(f"Bad fee rate, expected: {feerate}")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -1403,7 +1403,7 @@ class DCRInterface(Secp256k1Interface):
|
||||
)
|
||||
|
||||
if not self.compareFeeRates(fee_rate_paid, feerate):
|
||||
raise ValueError("Bad fee rate, expected: {}".format(feerate))
|
||||
raise ValueError(f"Bad fee rate, expected: {feerate}")
|
||||
|
||||
return True
|
||||
|
||||
@@ -1472,7 +1472,7 @@ class DCRInterface(Secp256k1Interface):
|
||||
)
|
||||
|
||||
if not self.compareFeeRates(fee_rate_paid, feerate):
|
||||
raise ValueError("Bad fee rate, expected: {}".format(feerate))
|
||||
raise ValueError(f"Bad fee rate, expected: {feerate}")
|
||||
|
||||
return txid, locked_coin, locked_n
|
||||
|
||||
@@ -1533,7 +1533,7 @@ class DCRInterface(Secp256k1Interface):
|
||||
)
|
||||
|
||||
if not self.compareFeeRates(fee_rate_paid, feerate):
|
||||
raise ValueError("Bad fee rate, expected: {}".format(feerate))
|
||||
raise ValueError(f"Bad fee rate, expected: {feerate}")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -658,7 +658,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||
|
||||
ensure(
|
||||
self.compareFeeRates(fee_rate_paid, feerate),
|
||||
"Bad fee rate, expected: {}".format(feerate),
|
||||
f"Bad fee rate, expected: {feerate}",
|
||||
)
|
||||
|
||||
return (
|
||||
@@ -734,7 +734,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||
fee_rate_paid = fee_paid * 1000 // vsize
|
||||
ensure(
|
||||
self.compareFeeRates(fee_rate_paid, feerate),
|
||||
"Bad fee rate, expected: {}".format(feerate),
|
||||
f"Bad fee rate, expected: {feerate}",
|
||||
)
|
||||
|
||||
return True
|
||||
@@ -958,7 +958,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||
fee_rate_paid = fee_paid * 1000 // vsize
|
||||
self._log.info("vsize, feerate: %ld, %ld", vsize, fee_rate_paid)
|
||||
if not self.compareFeeRates(fee_rate_paid, feerate):
|
||||
raise ValueError("Bad fee rate, expected: {}".format(feerate))
|
||||
raise ValueError(f"Bad fee rate, expected: {feerate}")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -45,3 +45,21 @@ class BSXLogger(logging.Logger):
|
||||
def info_s(self, msg, *args, **kwargs):
|
||||
if self.safe_logs is False:
|
||||
self.info(msg, *args, **kwargs)
|
||||
|
||||
|
||||
class BSXLogAdapter(logging.LoggerAdapter):
|
||||
def __init__(self, logger, prefix):
|
||||
super().__init__(logger, {})
|
||||
self.prefix = prefix
|
||||
|
||||
def process(self, msg, kwargs):
|
||||
return f"{self.prefix} {msg}", kwargs
|
||||
|
||||
def addr(self, addr: str) -> str:
|
||||
return self.logger.addr(addr)
|
||||
|
||||
def id(self, concept_id: bytes, prefix: str = "") -> str:
|
||||
return self.logger.id(concept_id, prefix)
|
||||
|
||||
def info_s(self, msg, *args, **kwargs):
|
||||
return self.logger.info_s(msg, *args, **kwargs)
|
||||
|
||||
@@ -95,7 +95,7 @@ def prepareDataDir(
|
||||
fp.write("fallbackfee=0.01\n")
|
||||
fp.write("acceptnonstdtxn=0\n")
|
||||
fp.write("txindex=1\n")
|
||||
fp.write("wallet=wallet.dat\n")
|
||||
fp.write("wallet=bsx_wallet\n")
|
||||
|
||||
fp.write("findpeers=0\n")
|
||||
|
||||
@@ -290,7 +290,7 @@ def wait_for_event(
|
||||
|
||||
|
||||
def wait_for_offer(delay_event, swap_client, offer_id, wait_for=20):
|
||||
logging.info("wait_for_offer %s", offer_id.hex())
|
||||
logging.info(f"wait_for_offer {offer_id.hex()}")
|
||||
for i in range(wait_for):
|
||||
if delay_event.is_set():
|
||||
raise ValueError("Test stopped.")
|
||||
|
||||
@@ -112,7 +112,7 @@ def prepareOtherDir(datadir, nodeId, conf_file="dash.conf"):
|
||||
fp.write("acceptnonstdtxn=0\n")
|
||||
|
||||
if conf_file == "bitcoin.conf":
|
||||
fp.write("wallet=wallet.dat\n")
|
||||
fp.write("wallet=bsx_wallet\n")
|
||||
|
||||
|
||||
def prepareDir(datadir, nodeId, network_key, network_pubkey):
|
||||
@@ -137,7 +137,7 @@ def prepareDir(datadir, nodeId, network_key, network_pubkey):
|
||||
fp.write("debug=1\n")
|
||||
fp.write("debugexclude=libevent\n")
|
||||
fp.write("zmqpubsmsg=tcp://127.0.0.1:" + str(BASE_ZMQ_PORT + nodeId) + "\n")
|
||||
fp.write("wallet=wallet.dat\n")
|
||||
fp.write("wallet=bsx_wallet\n")
|
||||
fp.write("fallbackfee=0.01\n")
|
||||
|
||||
fp.write("acceptnonstdtxn=0\n")
|
||||
@@ -313,7 +313,7 @@ class Test(unittest.TestCase):
|
||||
cfg.BITCOIN_BINDIR,
|
||||
btc_data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat -legacy create",
|
||||
"-wallet=bsx_wallet -legacy create",
|
||||
"bitcoin-wallet",
|
||||
)
|
||||
except Exception:
|
||||
@@ -321,7 +321,7 @@ class Test(unittest.TestCase):
|
||||
cfg.BITCOIN_BINDIR,
|
||||
btc_data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
"bitcoin-wallet",
|
||||
)
|
||||
cls.daemons.append(startDaemon(btc_data_dir, cfg.BITCOIN_BINDIR, cfg.BITCOIND))
|
||||
@@ -333,7 +333,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
if os.path.exists(os.path.join(DASH_BINDIR, 'dash-wallet')):
|
||||
logging.info('Creating DASH wallet.')
|
||||
callrpc_cli(DASH_BINDIR, dash_data_dir, 'regtest', '-wallet=wallet.dat create', 'dash-wallet')
|
||||
callrpc_cli(DASH_BINDIR, dash_data_dir, 'regtest', '-wallet=bsx_wallet create', 'dash-wallet')
|
||||
"""
|
||||
cls.daemons.append(startDaemon(dash_data_dir, DASH_BINDIR, DASHD))
|
||||
logging.info("Started %s %d", DASHD, cls.daemons[-1].handle.pid)
|
||||
@@ -346,7 +346,7 @@ class Test(unittest.TestCase):
|
||||
cfg.PARTICL_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat -legacy create",
|
||||
"-wallet=bsx_wallet -legacy create",
|
||||
"particl-wallet",
|
||||
)
|
||||
except Exception:
|
||||
@@ -354,7 +354,7 @@ class Test(unittest.TestCase):
|
||||
cfg.PARTICL_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
"particl-wallet",
|
||||
)
|
||||
cls.daemons.append(startDaemon(data_dir, cfg.PARTICL_BINDIR, cfg.PARTICLD))
|
||||
@@ -410,7 +410,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
waitForRPC(dashRpc, delay_event, rpc_command="getblockchaininfo")
|
||||
if len(dashRpc("listwallets")) < 1:
|
||||
dashRpc("createwallet wallet.dat")
|
||||
dashRpc("createwallet wbsx_wallet")
|
||||
|
||||
sc.start()
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ class Test(TestFunctions):
|
||||
dogeRpc = make_rpc_func(i, base_rpc_port=DOGE_BASE_RPC_PORT)
|
||||
waitForRPC(dogeRpc, test_delay_event, rpc_command="getblockchaininfo")
|
||||
if len(dogeRpc("listwallets")) < 1:
|
||||
dogeRpc("createwallet", ["wallet.dat", False, True, "", False, False])
|
||||
dogeRpc("createwallet", ["bsx_wallet", False, True, "", False, False])
|
||||
wif_prefix: int = 239
|
||||
wif = toWIF(wif_prefix, bytes.fromhex(cls.doge_seeds[i]), False)
|
||||
dogeRpc("sethdseed", [True, wif])
|
||||
|
||||
@@ -160,7 +160,7 @@ class Test(BaseTest):
|
||||
FIRO_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
"firo-wallet",
|
||||
)
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ class Test(unittest.TestCase):
|
||||
cfg.PARTICL_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat -legacy create",
|
||||
"-wallet=bsx_wallet -legacy create",
|
||||
"particl-wallet",
|
||||
)
|
||||
|
||||
@@ -286,7 +286,7 @@ class Test(unittest.TestCase):
|
||||
cfg.BITCOIN_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat -legacy create",
|
||||
"-wallet=bsx_wallet -legacy create",
|
||||
"bitcoin-wallet",
|
||||
)
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ class TestNMC(BasicSwapTest):
|
||||
if len(nmc_rpc("listwallets")) < 1:
|
||||
nmc_rpc(
|
||||
"createwallet",
|
||||
["wallet.dat", False, True, "", False, NMC_USE_DESCRIPTORS],
|
||||
["bsx_wallet", False, True, "", False, NMC_USE_DESCRIPTORS],
|
||||
)
|
||||
if NMC_USE_DESCRIPTORS:
|
||||
nmc_rpc(
|
||||
|
||||
@@ -118,7 +118,7 @@ def prepareOtherDir(datadir, nodeId, conf_file="pivx.conf"):
|
||||
fp.write(f"paramsdir={params_dir}\n")
|
||||
|
||||
if conf_file == "bitcoin.conf":
|
||||
fp.write("wallet=wallet.dat\n")
|
||||
fp.write("wallet=bsx_wallet\n")
|
||||
|
||||
|
||||
def prepareDir(datadir, nodeId, network_key, network_pubkey):
|
||||
@@ -143,7 +143,7 @@ def prepareDir(datadir, nodeId, network_key, network_pubkey):
|
||||
fp.write("debug=1\n")
|
||||
fp.write("debugexclude=libevent\n")
|
||||
fp.write("zmqpubsmsg=tcp://127.0.0.1:" + str(BASE_ZMQ_PORT + nodeId) + "\n")
|
||||
fp.write("wallet=wallet.dat\n")
|
||||
fp.write("wallet=bsx_wallet\n")
|
||||
fp.write("fallbackfee=0.01\n")
|
||||
|
||||
fp.write("acceptnonstdtxn=0\n")
|
||||
@@ -324,7 +324,7 @@ class Test(unittest.TestCase):
|
||||
cfg.BITCOIN_BINDIR,
|
||||
btc_data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat -legacy create",
|
||||
"-wallet=bsx_wallet -legacy create",
|
||||
"bitcoin-wallet",
|
||||
)
|
||||
except Exception:
|
||||
@@ -332,7 +332,7 @@ class Test(unittest.TestCase):
|
||||
cfg.BITCOIN_BINDIR,
|
||||
btc_data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
"bitcoin-wallet",
|
||||
)
|
||||
cls.daemons.append(startDaemon(btc_data_dir, cfg.BITCOIN_BINDIR, cfg.BITCOIND))
|
||||
@@ -352,7 +352,7 @@ class Test(unittest.TestCase):
|
||||
cfg.PARTICL_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat -legacy create",
|
||||
"-wallet=bsx_wallet -legacy create",
|
||||
"particl-wallet",
|
||||
)
|
||||
except Exception:
|
||||
@@ -360,7 +360,7 @@ class Test(unittest.TestCase):
|
||||
cfg.PARTICL_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
"particl-wallet",
|
||||
)
|
||||
cls.daemons.append(startDaemon(data_dir, cfg.PARTICL_BINDIR, cfg.PARTICLD))
|
||||
|
||||
@@ -313,7 +313,7 @@ class Test(unittest.TestCase):
|
||||
ltc_datadir = os.path.join(test_path, "litecoin")
|
||||
rv = json.loads(
|
||||
callcoincli(
|
||||
ltc_cli_path, ltc_datadir, "getwalletinfo", wallet="wallet.dat"
|
||||
ltc_cli_path, ltc_datadir, "getwalletinfo", wallet="bsx_wallet"
|
||||
)
|
||||
)
|
||||
assert "unlocked_until" in rv
|
||||
@@ -474,7 +474,7 @@ class Test(unittest.TestCase):
|
||||
ltc_datadir = os.path.join(test_path, "litecoin")
|
||||
rv = json.loads(
|
||||
callcoincli(
|
||||
ltc_cli_path, ltc_datadir, "getwalletinfo", wallet="wallet.dat"
|
||||
ltc_cli_path, ltc_datadir, "getwalletinfo", wallet="bsx_wallet"
|
||||
)
|
||||
)
|
||||
assert "unlocked_until" in rv
|
||||
@@ -653,7 +653,7 @@ class Test(unittest.TestCase):
|
||||
logging.info("Check both LTC wallets are encrypted and mweb seeds match.")
|
||||
rv = json.loads(
|
||||
callcoincli(
|
||||
ltc_cli_path, ltc_datadir, "getwalletinfo", wallet="wallet.dat"
|
||||
ltc_cli_path, ltc_datadir, "getwalletinfo", wallet="bsx_wallet"
|
||||
)
|
||||
)
|
||||
assert "unlocked_until" in rv
|
||||
@@ -769,7 +769,7 @@ class Test(unittest.TestCase):
|
||||
)
|
||||
|
||||
walletdir = os.path.join(test_path, "regtest", "wallets", "bdb_wallet")
|
||||
walletpath = os.path.join(walletdir, "wallet.dat")
|
||||
walletpath = os.path.join(walletdir, "bsx_wallet")
|
||||
|
||||
db = berkeleydb.db.DB()
|
||||
db.open(
|
||||
@@ -812,10 +812,10 @@ class Test(unittest.TestCase):
|
||||
],
|
||||
)
|
||||
|
||||
bkp_path = os.path.join(walletdir, "wallet.dat" + ".bkp")
|
||||
bkp_path = os.path.join(walletdir, "bsx_wallet" + ".bkp")
|
||||
for i in range(1000):
|
||||
if os.path.exists(bkp_path):
|
||||
bkp_path = os.path.join(walletdir, "wallet.dat" + f".bkp{i}")
|
||||
bkp_path = os.path.join(walletdir, "bsx_wallet" + f".bkp{i}")
|
||||
|
||||
assert os.path.exists(bkp_path) is False
|
||||
if os.path.isfile(walletpath):
|
||||
@@ -940,7 +940,7 @@ class Test(unittest.TestCase):
|
||||
)
|
||||
logging.info(f"Looking for hdchain for {seedid_bytes.hex()}")
|
||||
walletdir = os.path.join(test_path, "regtest", "wallets", "bdb_wallet2")
|
||||
walletpath = os.path.join(walletdir, "wallet.dat")
|
||||
walletpath = os.path.join(walletdir, "bsx_wallet")
|
||||
found_hdchain = False
|
||||
max_key_count = 4000000 # arbitrary
|
||||
with open(walletpath, "rb") as fp:
|
||||
@@ -1134,7 +1134,7 @@ class Test(unittest.TestCase):
|
||||
)
|
||||
|
||||
walletdir = os.path.join(test_path, "regtest", "wallets", "descr_wallet")
|
||||
walletpath = os.path.join(walletdir, "wallet.dat")
|
||||
walletpath = os.path.join(walletdir, "bsx_wallet")
|
||||
|
||||
orig_active_descriptors = []
|
||||
with sqlite3.connect(walletpath) as conn:
|
||||
@@ -1234,10 +1234,10 @@ class Test(unittest.TestCase):
|
||||
"descr_wallet",
|
||||
],
|
||||
)
|
||||
bkp_path = os.path.join(walletdir, "wallet.dat" + ".bkp")
|
||||
bkp_path = os.path.join(walletdir, "bsx_wallet" + ".bkp")
|
||||
for i in range(1000):
|
||||
if os.path.exists(bkp_path):
|
||||
bkp_path = os.path.join(walletdir, "wallet.dat" + f".bkp{i}")
|
||||
bkp_path = os.path.join(walletdir, "bsx_wallet" + f".bkp{i}")
|
||||
|
||||
assert os.path.exists(bkp_path) is False
|
||||
if os.path.isfile(walletpath):
|
||||
|
||||
@@ -154,7 +154,7 @@ class Test(TestBase):
|
||||
|
||||
num_blocks = 431
|
||||
self.ltc_addr = callltcnoderpc(
|
||||
1, "getnewaddress", ["mining_addr", "bech32"], wallet="wallet.dat"
|
||||
1, "getnewaddress", ["mining_addr", "bech32"], wallet="bsx_wallet"
|
||||
)
|
||||
logging.info("Mining %d Litecoin blocks to %s", num_blocks, self.ltc_addr)
|
||||
callltcnoderpc(1, "generatetoaddress", [num_blocks, self.ltc_addr])
|
||||
@@ -162,7 +162,7 @@ class Test(TestBase):
|
||||
mweb_addr = callltcnoderpc(
|
||||
1, "getnewaddress", ["mweb_addr", "mweb"], wallet="mweb"
|
||||
)
|
||||
callltcnoderpc(1, "sendtoaddress", [mweb_addr, 1], wallet="wallet.dat")
|
||||
callltcnoderpc(1, "sendtoaddress", [mweb_addr, 1], wallet="bsx_wallet")
|
||||
num_blocks = 69
|
||||
callltcnoderpc(1, "generatetoaddress", [num_blocks, self.ltc_addr])
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ def callbtcrpc(
|
||||
node_id,
|
||||
method,
|
||||
params=[],
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
base_rpc_port=BITCOIN_RPC_PORT_BASE + PORT_OFS,
|
||||
):
|
||||
auth = "test_btc_{0}:test_btc_pwd_{0}".format(node_id)
|
||||
@@ -153,7 +153,7 @@ def callnmcrpc(
|
||||
node_id,
|
||||
method,
|
||||
params=[],
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
base_rpc_port=NAMECOIN_RPC_PORT_BASE + PORT_OFS,
|
||||
):
|
||||
auth = "test_nmc_{0}:test_nmc_pwd_{0}".format(node_id)
|
||||
@@ -336,7 +336,7 @@ def start_processes(self):
|
||||
|
||||
if "litecoin" in self.test_coins_list:
|
||||
self.ltc_addr = callltcrpc(
|
||||
0, "getnewaddress", ["mining_addr"], wallet="wallet.dat"
|
||||
0, "getnewaddress", ["mining_addr"], wallet="bsx_wallet"
|
||||
)
|
||||
num_blocks: int = 431
|
||||
have_blocks: int = callltcrpc(0, "getblockcount")
|
||||
@@ -346,7 +346,7 @@ def start_processes(self):
|
||||
0,
|
||||
"generatetoaddress",
|
||||
[num_blocks - have_blocks, self.ltc_addr],
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
# https://github.com/litecoin-project/litecoin/issues/807
|
||||
@@ -354,7 +354,7 @@ def start_processes(self):
|
||||
mweb_addr = callltcrpc(
|
||||
0, "getnewaddress", ["mweb_addr", "mweb"], wallet="mweb"
|
||||
)
|
||||
callltcrpc(0, "sendtoaddress", [mweb_addr, 1.0], wallet="wallet.dat")
|
||||
callltcrpc(0, "sendtoaddress", [mweb_addr, 1.0], wallet="bsx_wallet")
|
||||
num_blocks = 69
|
||||
|
||||
have_blocks: int = callltcrpc(0, "getblockcount")
|
||||
@@ -362,7 +362,7 @@ def start_processes(self):
|
||||
0,
|
||||
"generatetoaddress",
|
||||
[500 - have_blocks, self.ltc_addr],
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
if "decred" in self.test_coins_list:
|
||||
@@ -413,7 +413,7 @@ def start_processes(self):
|
||||
|
||||
if "bitcoincash" in self.test_coins_list:
|
||||
self.bch_addr = callbchrpc(
|
||||
0, "getnewaddress", ["mining_addr"], wallet="wallet.dat"
|
||||
0, "getnewaddress", ["mining_addr"], wallet="bsx_wallet"
|
||||
)
|
||||
num_blocks: int = 200
|
||||
have_blocks: int = callbchrpc(0, "getblockcount")
|
||||
@@ -427,7 +427,7 @@ def start_processes(self):
|
||||
0,
|
||||
"generatetoaddress",
|
||||
[num_blocks - have_blocks, self.bch_addr],
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
if "dogecoin" in self.test_coins_list:
|
||||
|
||||
@@ -144,7 +144,7 @@ class TestBCH(BasicSwapTest):
|
||||
BITCOINCASH_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
bch_wallet_bin,
|
||||
)
|
||||
except Exception as e:
|
||||
@@ -172,7 +172,7 @@ class TestBCH(BasicSwapTest):
|
||||
"getnewaddress",
|
||||
["mining_addr"],
|
||||
base_rpc_port=BCH_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
if not cls.restore_instance:
|
||||
num_blocks: int = 200
|
||||
@@ -182,7 +182,7 @@ class TestBCH(BasicSwapTest):
|
||||
"generatetoaddress",
|
||||
[num_blocks, cls.bch_addr],
|
||||
base_rpc_port=BCH_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -1999,7 +1999,7 @@ class BasicSwapTest(TestFunctions):
|
||||
assert addr1_info[key_id_field] == addr_int1_info[key_id_field]
|
||||
assert original_seed_id == after_seed_id
|
||||
finally:
|
||||
ci.setActiveWallet("wallet.dat")
|
||||
ci.setActiveWallet("bsx_wallet")
|
||||
chain_client_settings["manage_daemon"] = False
|
||||
|
||||
def test_015_changetype(self):
|
||||
|
||||
@@ -229,22 +229,24 @@ class Test(unittest.TestCase):
|
||||
== "0dde9df8660d3e0f28fe00d648b70e0323e9c192fe9b94f1cf7138515e877725"
|
||||
)
|
||||
|
||||
sum_secp256k1 = ci_btc.sumPubkeys(
|
||||
pk_secp256k1 = ci_btc.sumPubkeys(
|
||||
ci_btc.getPubkey(keys[0]), ci_btc.getPubkey(keys[1])
|
||||
)
|
||||
assert (
|
||||
sum_secp256k1.hex()
|
||||
pk_secp256k1.hex()
|
||||
== "028c30392e35620af0787b363a03cf9a695336759664436e1f609481c869541a5c"
|
||||
)
|
||||
|
||||
sum_ed25519 = ci_xmr.sumPubkeys(
|
||||
pk_ed25519 = ci_xmr.sumPubkeys(
|
||||
ci_xmr.getPubkey(keys[0]), ci_xmr.getPubkey(keys[1])
|
||||
)
|
||||
assert (
|
||||
sum_ed25519.hex()
|
||||
pk_ed25519.hex()
|
||||
== "4b2dd2dc9acc9be7efed4fdbfb96f0002aeb9e4c8638c5b24562a7158b283626"
|
||||
)
|
||||
|
||||
assert pk_secp256k1 == ci_btc.getPubkey(sum_secp256k1)
|
||||
|
||||
def test_ecdsa_otves(self):
|
||||
ci = self.ci_btc()
|
||||
vk_sign = ci.getNewRandomKey()
|
||||
|
||||
@@ -88,7 +88,7 @@ class Test(BaseTest):
|
||||
"getnewaddress",
|
||||
["initial funds", "bech32"],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
callnoderpc(
|
||||
@@ -99,7 +99,7 @@ class Test(BaseTest):
|
||||
"sendtoaddress",
|
||||
[ltc_addr1, 1000],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
wait_for_balance(
|
||||
@@ -975,7 +975,7 @@ class Test(BaseTest):
|
||||
"getnewaddress",
|
||||
["Withdrawal test", "legacy"],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
wallets0 = read_json_api(TEST_HTTP_PORT + 0, "wallets")
|
||||
assert float(wallets0["LTC"]["balance"]) > 100
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2020-2024 tecnovert
|
||||
# Copyright (c) 2024-2025 The Basicswap developers
|
||||
# Copyright (c) 2024-2026 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -164,6 +164,7 @@ def prepare_swapclient_dir(
|
||||
"bindir": cfg.PARTICL_BINDIR,
|
||||
"blocks_confirmed": 2, # Faster testing
|
||||
"anon_tx_ring_size": 5, # Faster testing
|
||||
"wallet_name": "bsx_wallet",
|
||||
},
|
||||
"bitcoin": {
|
||||
"connection_type": "rpc",
|
||||
@@ -176,6 +177,7 @@ def prepare_swapclient_dir(
|
||||
"use_segwit": True,
|
||||
"use_descriptors": BTC_USE_DESCRIPTORS,
|
||||
"use_legacy_key_paths": BTC_USE_LEGACY_KEY_PATHS,
|
||||
"wallet_name": "bsx_wallet",
|
||||
},
|
||||
},
|
||||
"check_progress_seconds": 2,
|
||||
@@ -263,9 +265,7 @@ def waitForXMRNode(rpc_offset, max_tries=7):
|
||||
except Exception as ex:
|
||||
if i < max_tries:
|
||||
logging.warning(
|
||||
"Can't connect to XMR RPC: %s. Retrying in %d second/s.",
|
||||
str(ex),
|
||||
(i + 1),
|
||||
f"Can't connect to XMR RPC: {ex}. Retrying in {i + 1} second/s."
|
||||
)
|
||||
time.sleep(i + 1)
|
||||
raise ValueError("waitForXMRNode failed")
|
||||
@@ -281,9 +281,7 @@ def waitForXMRWallet(rpc_offset, auth, max_tries=7):
|
||||
except Exception as ex:
|
||||
if i < max_tries:
|
||||
logging.warning(
|
||||
"Can't connect to XMR wallet RPC: %s. Retrying in %d second/s.",
|
||||
str(ex),
|
||||
(i + 1),
|
||||
f"Can't connect to XMR wallet RPC: {ex}. Retrying in {i + 1} second/s."
|
||||
)
|
||||
time.sleep(i + 1)
|
||||
raise ValueError("waitForXMRWallet failed")
|
||||
@@ -304,7 +302,7 @@ def run_coins_loop(cls):
|
||||
cls.coins_loop()
|
||||
except Exception as e:
|
||||
logging.warning("run_coins_loop " + str(e))
|
||||
test_delay_event.wait(1.0)
|
||||
test_delay_event.wait(cls.coins_loop_delay)
|
||||
|
||||
|
||||
def run_loop(cls):
|
||||
@@ -336,6 +334,7 @@ class BaseTest(unittest.TestCase):
|
||||
xmr_addr = None
|
||||
btc_addr = None
|
||||
ltc_addr = None
|
||||
coins_loop_delay = 1.0
|
||||
|
||||
@classmethod
|
||||
def getRandomPubkey(cls):
|
||||
@@ -345,7 +344,7 @@ class BaseTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if signal_event.is_set():
|
||||
raise ValueError("Test has been cancelled.")
|
||||
raise ValueError("Test has been cancelled")
|
||||
test_delay_event.clear()
|
||||
random.seed(time.time())
|
||||
|
||||
@@ -400,7 +399,7 @@ class BaseTest(unittest.TestCase):
|
||||
cls.prepareTestDir()
|
||||
|
||||
try:
|
||||
logging.info("Preparing coin nodes.")
|
||||
logging.info("Preparing coin nodes")
|
||||
part_wallet_bin = "particl-wallet" + (".exe" if os.name == "nt" else "")
|
||||
for i in range(NUM_NODES):
|
||||
if not cls.restore_instance:
|
||||
@@ -411,14 +410,14 @@ class BaseTest(unittest.TestCase):
|
||||
part_wallet_bin,
|
||||
)
|
||||
):
|
||||
logging.warning(f"{part_wallet_bin} not found.")
|
||||
logging.warning(f"{part_wallet_bin} not found")
|
||||
else:
|
||||
try:
|
||||
callrpc_cli(
|
||||
cfg.PARTICL_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat -legacy create",
|
||||
"-wallet=bsx_wallet -legacy create",
|
||||
part_wallet_bin,
|
||||
)
|
||||
except Exception as e:
|
||||
@@ -429,7 +428,7 @@ class BaseTest(unittest.TestCase):
|
||||
cfg.PARTICL_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
part_wallet_bin,
|
||||
)
|
||||
|
||||
@@ -507,7 +506,7 @@ class BaseTest(unittest.TestCase):
|
||||
cfg.BITCOIN_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat -legacy create",
|
||||
"-wallet=bsx_wallet -legacy create",
|
||||
btc_wallet_bin,
|
||||
)
|
||||
except Exception as e:
|
||||
@@ -518,7 +517,7 @@ class BaseTest(unittest.TestCase):
|
||||
cfg.BITCOIN_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
btc_wallet_bin,
|
||||
)
|
||||
|
||||
@@ -540,7 +539,7 @@ class BaseTest(unittest.TestCase):
|
||||
)
|
||||
# wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors
|
||||
rpc_func(
|
||||
"createwallet", ["wallet.dat", False, True, "", False, True]
|
||||
"createwallet", ["bsx_wallet", False, True, "", False, True]
|
||||
)
|
||||
rpc_func("createwallet", ["bsx_watch", True, True, "", False, True])
|
||||
else:
|
||||
@@ -570,7 +569,7 @@ class BaseTest(unittest.TestCase):
|
||||
cfg.LITECOIN_BINDIR,
|
||||
data_dir,
|
||||
"regtest",
|
||||
"-wallet=wallet.dat create",
|
||||
"-wallet=bsx_wallet create",
|
||||
ltc_wallet_bin,
|
||||
)
|
||||
|
||||
@@ -623,10 +622,8 @@ class BaseTest(unittest.TestCase):
|
||||
)
|
||||
|
||||
for i in range(NUM_XMR_NODES):
|
||||
cls.xmr_wallet_auth.append(
|
||||
("test{0}".format(i), "test_pass{0}".format(i))
|
||||
)
|
||||
logging.info("Creating XMR wallet %i", i)
|
||||
cls.xmr_wallet_auth.append((f"test{i}", f"test_pass{i}"))
|
||||
logging.info(f"Creating XMR wallet {i}")
|
||||
|
||||
waitForXMRWallet(i, cls.xmr_wallet_auth[i])
|
||||
|
||||
@@ -729,10 +726,10 @@ class BaseTest(unittest.TestCase):
|
||||
"getnewaddress",
|
||||
["mining_addr", "bech32"],
|
||||
base_rpc_port=BTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
num_blocks = 400 # Mine enough to activate segwit
|
||||
logging.info("Mining %d Bitcoin blocks to %s", num_blocks, cls.btc_addr)
|
||||
logging.info(f"Mining {num_blocks} Bitcoin blocks to {cls.btc_addr}")
|
||||
callnoderpc(
|
||||
0,
|
||||
"generatetoaddress",
|
||||
@@ -745,7 +742,7 @@ class BaseTest(unittest.TestCase):
|
||||
"getnewaddress",
|
||||
["initial addr"],
|
||||
base_rpc_port=BTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
for i in range(5):
|
||||
callnoderpc(
|
||||
@@ -753,7 +750,7 @@ class BaseTest(unittest.TestCase):
|
||||
"sendtoaddress",
|
||||
[btc_addr1, 100],
|
||||
base_rpc_port=BTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
# Switch addresses so wallet amounts stay constant
|
||||
@@ -763,7 +760,7 @@ class BaseTest(unittest.TestCase):
|
||||
.ci(Coins.BTC)
|
||||
.pubkey_to_segwit_address(void_block_rewards_pubkey)
|
||||
)
|
||||
logging.info("Mining %d Bitcoin blocks to %s", num_blocks, cls.btc_addr)
|
||||
logging.info(f"Mining {num_blocks} Bitcoin blocks to {cls.btc_addr}")
|
||||
callnoderpc(
|
||||
0,
|
||||
"generatetoaddress",
|
||||
@@ -798,17 +795,17 @@ class BaseTest(unittest.TestCase):
|
||||
"getnewaddress",
|
||||
["mining_addr", "bech32"],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
logging.info(
|
||||
"Mining %d Litecoin blocks to %s", num_blocks, cls.ltc_addr
|
||||
f"Mining {num_blocks} Litecoin blocks to {cls.ltc_addr}"
|
||||
)
|
||||
callnoderpc(
|
||||
0,
|
||||
"generatetoaddress",
|
||||
[num_blocks, cls.ltc_addr],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
num_blocks = 31
|
||||
@@ -825,7 +822,7 @@ class BaseTest(unittest.TestCase):
|
||||
"generatetoaddress",
|
||||
[num_blocks, cls.ltc_addr],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
# https://github.com/litecoin-project/litecoin/issues/807
|
||||
@@ -835,14 +832,14 @@ class BaseTest(unittest.TestCase):
|
||||
"getnewaddress",
|
||||
["mweb_addr", "mweb"],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
callnoderpc(
|
||||
0,
|
||||
"sendtoaddress",
|
||||
[mweb_addr, 1],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
ltc_addr1 = callnoderpc(
|
||||
@@ -850,7 +847,7 @@ class BaseTest(unittest.TestCase):
|
||||
"getnewaddress",
|
||||
["initial addr"],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
for i in range(5):
|
||||
callnoderpc(
|
||||
@@ -858,7 +855,7 @@ class BaseTest(unittest.TestCase):
|
||||
"sendtoaddress",
|
||||
[ltc_addr1, 100],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
num_blocks = 69
|
||||
@@ -872,7 +869,7 @@ class BaseTest(unittest.TestCase):
|
||||
"generatetoaddress",
|
||||
[num_blocks, cls.ltc_addr],
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
|
||||
checkForks(
|
||||
@@ -880,7 +877,7 @@ class BaseTest(unittest.TestCase):
|
||||
0,
|
||||
"getblockchaininfo",
|
||||
base_rpc_port=LTC_BASE_RPC_PORT,
|
||||
wallet="wallet.dat",
|
||||
wallet="bsx_wallet",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user