Skip to content

taker.models

taker.models

Taker data models for CoinJoin protocol state management.

Contains the state enum, session data, and phase result types used throughout the CoinJoin protocol execution.

Classes

MakerSession

Session data for a single maker.

Source code in taker/src/taker/models.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@dataclass(config=ConfigDict(arbitrary_types_allowed=True))
class MakerSession:
    """Session data for a single maker."""

    nick: str
    offer: Offer
    utxos: list[dict[str, Any]] = Field(default_factory=list)
    cj_address: str = ""
    change_address: str = ""
    pubkey: str = ""  # Maker's NaCl public key (hex)
    auth_pubkey: str = ""  # Maker's EC auth public key from !ioauth (hex)
    crypto: CryptoSession | None = None  # Encryption session with this maker
    signature: dict[str, Any] | None = None
    responded_fill: bool = False
    responded_auth: bool = False
    responded_sig: bool = False
    supports_neutrino_compat: bool = False  # Supports extended UTXO metadata for Neutrino
    # Communication channel used for this session (must be consistent throughout)
    # "direct" = peer-to-peer onion connection
    # "directory:<host>:<port>" = relayed through specific directory
    comm_channel: str = ""
Attributes
auth_pubkey: str = '' class-attribute instance-attribute
change_address: str = '' class-attribute instance-attribute
cj_address: str = '' class-attribute instance-attribute
comm_channel: str = '' class-attribute instance-attribute
crypto: CryptoSession | None = None class-attribute instance-attribute
nick: str instance-attribute
offer: Offer instance-attribute
pubkey: str = '' class-attribute instance-attribute
responded_auth: bool = False class-attribute instance-attribute
responded_fill: bool = False class-attribute instance-attribute
responded_sig: bool = False class-attribute instance-attribute
signature: dict[str, Any] | None = None class-attribute instance-attribute
supports_neutrino_compat: bool = False class-attribute instance-attribute
utxos: list[dict[str, Any]] = Field(default_factory=list) class-attribute instance-attribute

PhaseResult

Result from a CoinJoin phase with failed maker tracking.

Used to communicate phase outcomes and enable maker replacement logic.

Source code in taker/src/taker/models.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
@dataclass
class PhaseResult:
    """Result from a CoinJoin phase with failed maker tracking.

    Used to communicate phase outcomes and enable maker replacement logic.
    """

    success: bool
    failed_makers: list[str] = Field(default_factory=list)
    blacklist_error: bool = False  # True if any maker rejected due to blacklisted commitment

    @property
    def needs_replacement(self) -> bool:
        """True if phase failed due to non-responsive makers (not other errors)."""
        return not self.success and len(self.failed_makers) > 0
Attributes
blacklist_error: bool = False class-attribute instance-attribute
failed_makers: list[str] = Field(default_factory=list) class-attribute instance-attribute
needs_replacement: bool property

True if phase failed due to non-responsive makers (not other errors).

success: bool instance-attribute

TakerState

Bases: StrEnum

Taker protocol states.

Source code in taker/src/taker/models.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class TakerState(StrEnum):
    """Taker protocol states."""

    IDLE = "idle"
    FETCHING_ORDERBOOK = "fetching_orderbook"
    SELECTING_MAKERS = "selecting_makers"
    FILLING = "filling"
    AUTHENTICATING = "authenticating"
    BUILDING_TX = "building_tx"
    COLLECTING_SIGNATURES = "collecting_signatures"
    BROADCASTING = "broadcasting"
    COMPLETE = "complete"
    FAILED = "failed"
    CANCELLED = "cancelled"  # User cancelled the operation
Attributes
AUTHENTICATING = 'authenticating' class-attribute instance-attribute
BROADCASTING = 'broadcasting' class-attribute instance-attribute
BUILDING_TX = 'building_tx' class-attribute instance-attribute
CANCELLED = 'cancelled' class-attribute instance-attribute
COLLECTING_SIGNATURES = 'collecting_signatures' class-attribute instance-attribute
COMPLETE = 'complete' class-attribute instance-attribute
FAILED = 'failed' class-attribute instance-attribute
FETCHING_ORDERBOOK = 'fetching_orderbook' class-attribute instance-attribute
FILLING = 'filling' class-attribute instance-attribute
IDLE = 'idle' class-attribute instance-attribute
SELECTING_MAKERS = 'selecting_makers' class-attribute instance-attribute