mirror of
https://github.com/basicswap/basicswap.git
synced 2025-12-29 08:51:37 +01:00
refactor: split watched classes into new file
This commit is contained in:
@@ -72,6 +72,7 @@ from .db_util import remove_expired_data
|
|||||||
from .http_server import HttpThread
|
from .http_server import HttpThread
|
||||||
from .rpc import escape_rpcauth
|
from .rpc import escape_rpcauth
|
||||||
from .rpc_xmr import make_xmr_rpc2_func
|
from .rpc_xmr import make_xmr_rpc2_func
|
||||||
|
from .types import WatchedTransaction, WatchedScript, WatchedOutput
|
||||||
from .ui.app import UIApp
|
from .ui.app import UIApp
|
||||||
from .ui.util import getCoinName
|
from .ui.util import getCoinName
|
||||||
from .util import (
|
from .util import (
|
||||||
@@ -287,37 +288,6 @@ def threadPollChainState(swap_client, coin_type):
|
|||||||
swap_client.chainstate_delay_event.wait(random.randrange(*poll_delay_range))
|
swap_client.chainstate_delay_event.wait(random.randrange(*poll_delay_range))
|
||||||
|
|
||||||
|
|
||||||
class WatchedOutput: # Watch for spends
|
|
||||||
__slots__ = ("bid_id", "txid_hex", "vout", "tx_type", "swap_type")
|
|
||||||
|
|
||||||
def __init__(self, bid_id: bytes, txid_hex: str, vout, tx_type, swap_type):
|
|
||||||
self.bid_id = bid_id
|
|
||||||
self.txid_hex = txid_hex
|
|
||||||
self.vout = vout
|
|
||||||
self.tx_type = tx_type
|
|
||||||
self.swap_type = swap_type
|
|
||||||
|
|
||||||
|
|
||||||
class WatchedScript: # Watch for txns containing outputs
|
|
||||||
__slots__ = ("bid_id", "script", "tx_type", "swap_type")
|
|
||||||
|
|
||||||
def __init__(self, bid_id: bytes, script: bytes, tx_type, swap_type):
|
|
||||||
self.bid_id = bid_id
|
|
||||||
self.script = script
|
|
||||||
self.tx_type = tx_type
|
|
||||||
self.swap_type = swap_type
|
|
||||||
|
|
||||||
|
|
||||||
class WatchedTransaction:
|
|
||||||
# TODO
|
|
||||||
# Watch for presence in mempool (getrawtransaction)
|
|
||||||
def __init__(self, bid_id: bytes, txid_hex: str, tx_type, swap_type):
|
|
||||||
self.bid_id = bid_id
|
|
||||||
self.txid_hex = txid_hex
|
|
||||||
self.tx_type = tx_type
|
|
||||||
self.swap_type = swap_type
|
|
||||||
|
|
||||||
|
|
||||||
class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||||
ws_server = None
|
ws_server = None
|
||||||
protocolInterfaces = {
|
protocolInterfaces = {
|
||||||
|
|||||||
51
basicswap/types.py
Normal file
51
basicswap/types.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (c) 2025 The Basicswap developers
|
||||||
|
# Distributed under the MIT software license, see the accompanying
|
||||||
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
||||||
|
class WatchedOutput: # Watch for spends
|
||||||
|
__slots__ = ("bid_id", "txid_hex", "vout", "tx_type", "swap_type")
|
||||||
|
|
||||||
|
def __init__(self, bid_id: bytes, txid_hex: str, vout, tx_type, swap_type):
|
||||||
|
self.bid_id = bid_id
|
||||||
|
self.txid_hex = txid_hex
|
||||||
|
self.vout = vout
|
||||||
|
self.tx_type = tx_type
|
||||||
|
self.swap_type = swap_type
|
||||||
|
|
||||||
|
|
||||||
|
class WatchedScript: # Watch for txns containing outputs
|
||||||
|
__slots__ = ("bid_id", "script", "tx_type", "swap_type")
|
||||||
|
|
||||||
|
def __init__(self, bid_id: bytes, script: bytes, tx_type, swap_type):
|
||||||
|
self.bid_id = bid_id
|
||||||
|
self.script = script
|
||||||
|
self.tx_type = tx_type
|
||||||
|
self.swap_type = swap_type
|
||||||
|
|
||||||
|
|
||||||
|
class WatchedTransaction:
|
||||||
|
__slots__ = (
|
||||||
|
"bid_id",
|
||||||
|
"coin_type",
|
||||||
|
"txid_hex",
|
||||||
|
"tx_type",
|
||||||
|
"swap_type",
|
||||||
|
"block_hash",
|
||||||
|
"depth",
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# Watch for presence in mempool (getrawtransaction)
|
||||||
|
def __init__(
|
||||||
|
self, bid_id: bytes, coin_type: int, txid_hex: str, tx_type, swap_type
|
||||||
|
):
|
||||||
|
self.bid_id = bid_id
|
||||||
|
self.coin_type = coin_type
|
||||||
|
self.txid_hex = txid_hex
|
||||||
|
self.tx_type = tx_type
|
||||||
|
self.swap_type = swap_type
|
||||||
|
self.block_hash = None
|
||||||
|
self.depth = -1
|
||||||
Reference in New Issue
Block a user