Skip to content

taker.cli

taker.cli

Command-line interface for JoinMarket Taker.

Configuration is loaded with the following priority (highest to lowest): 1. CLI arguments 2. Environment variables 3. Config file (~/.joinmarket-ng/config.toml) 4. Built-in defaults

Attributes

__all__ = ['app', 'build_taker_config', 'create_backend'] module-attribute

app = SortedTyper(name='jm-taker', help='JoinMarket Taker - Execute CoinJoin transactions', no_args_is_help=True) module-attribute

Classes

Functions:

build_taker_config(settings: JoinMarketSettings, mnemonic: str, passphrase: str, amount: int = 0, destination: str = '', mixdepth: int = 0, counterparties: int | None = None, select_utxos: bool = False, network: NetworkType | None = None, bitcoin_network: NetworkType | None = None, data_dir: Path | None = None, backend_type: str | None = None, rpc_url: str | None = None, rpc_user: str | None = None, rpc_password: str | None = None, neutrino_url: str | None = None, neutrino_tls_cert: str | None = None, neutrino_auth_token: str | None = None, directory_servers: str | None = None, tor_socks_host: str | None = None, tor_socks_port: int | None = None, max_abs_fee: int | None = None, max_rel_fee: str | None = None, max_sweep_fee_change: float | None = None, fee_rate: float | None = None, block_target: int | None = None, tx_fee_factor: float | None = None, bondless_makers_allowance: float | None = None, bond_value_exponent: float | None = None, bondless_require_zero_fee: bool | None = None, require_quantized_cj_fees: bool | None = None, round_up_cj_fees: bool | None = None, equalize_cj_fees: bool | None = None) -> TakerConfig

Build TakerConfig from unified settings with CLI overrides.

CLI arguments (when not None) override settings from config file and env vars.

Source code in taker/src/taker/config_builder.py
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
def build_taker_config(
    settings: JoinMarketSettings,
    mnemonic: str,
    passphrase: str,
    # CoinJoin specific settings
    amount: int = 0,
    destination: str = "",
    mixdepth: int = 0,
    counterparties: int | None = None,
    select_utxos: bool = False,
    # CLI overrides (None means use settings value)
    network: NetworkType | None = None,
    bitcoin_network: NetworkType | None = None,
    data_dir: Path | None = None,
    backend_type: str | None = None,
    rpc_url: str | None = None,
    rpc_user: str | None = None,
    rpc_password: str | None = None,
    neutrino_url: str | None = None,
    neutrino_tls_cert: str | None = None,
    neutrino_auth_token: str | None = None,
    directory_servers: str | None = None,
    tor_socks_host: str | None = None,
    tor_socks_port: int | None = None,
    max_abs_fee: int | None = None,
    max_rel_fee: str | None = None,
    max_sweep_fee_change: float | None = None,
    fee_rate: float | None = None,
    block_target: int | None = None,
    tx_fee_factor: float | None = None,
    bondless_makers_allowance: float | None = None,
    bond_value_exponent: float | None = None,
    bondless_require_zero_fee: bool | None = None,
    require_quantized_cj_fees: bool | None = None,
    round_up_cj_fees: bool | None = None,
    equalize_cj_fees: bool | None = None,
) -> TakerConfig:
    """
    Build TakerConfig from unified settings with CLI overrides.

    CLI arguments (when not None) override settings from config file and env vars.
    """
    return TakerConfig(
        **build_taker_config_kwargs(
            settings,
            mnemonic,
            passphrase,
            amount=amount,
            destination=destination,
            mixdepth=mixdepth,
            counterparties=counterparties,
            select_utxos=select_utxos,
            network=network,
            bitcoin_network=bitcoin_network,
            data_dir=data_dir,
            backend_type=backend_type,
            rpc_url=rpc_url,
            rpc_user=rpc_user,
            rpc_password=rpc_password,
            neutrino_url=neutrino_url,
            neutrino_tls_cert=neutrino_tls_cert,
            neutrino_auth_token=neutrino_auth_token,
            directory_servers=directory_servers,
            tor_socks_host=tor_socks_host,
            tor_socks_port=tor_socks_port,
            max_abs_fee=max_abs_fee,
            max_rel_fee=max_rel_fee,
            max_sweep_fee_change=max_sweep_fee_change,
            fee_rate=fee_rate,
            block_target=block_target,
            tx_fee_factor=tx_fee_factor,
            bondless_makers_allowance=bondless_makers_allowance,
            bond_value_exponent=bond_value_exponent,
            bondless_require_zero_fee=bondless_require_zero_fee,
            require_quantized_cj_fees=require_quantized_cj_fees,
            round_up_cj_fees=round_up_cj_fees,
            equalize_cj_fees=equalize_cj_fees,
        )
    )

clear_ignored_makers(data_dir: Annotated[Path | None, typer.Option('--data-dir', '-d', envvar='JOINMARKET_DATA_DIR', help='Data directory for JoinMarket files')] = None, config_file: Annotated[Path | None, typer.Option('--config-file', envvar='JOINMARKET_CONFIG_FILE', help='Config file path (decoupled from data dir). Defaults to <data-dir>/config.toml')] = None) -> None

Clear the list of ignored makers.

Source code in taker/src/taker/cli.py
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
@app.command()
def clear_ignored_makers(
    data_dir: Annotated[
        Path | None,
        typer.Option(
            "--data-dir",
            "-d",
            envvar="JOINMARKET_DATA_DIR",
            help="Data directory for JoinMarket files",
        ),
    ] = None,
    config_file: Annotated[
        Path | None,
        typer.Option(
            "--config-file",
            envvar="JOINMARKET_CONFIG_FILE",
            help="Config file path (decoupled from data dir). Defaults to <data-dir>/config.toml",
        ),
    ] = None,
) -> None:
    """Clear the list of ignored makers."""
    from jmcore.paths import get_ignored_makers_path

    # Load settings so a config file (possibly decoupled via --config-file)
    # that sets data_dir is honored when no explicit --data-dir is given.
    if data_dir is None:
        settings = setup_cli(None, config_file=config_file)
        data_dir = settings.get_data_dir()

    ignored_makers_path = get_ignored_makers_path(data_dir)

    if not ignored_makers_path.exists():
        typer.echo("No ignored makers file found.")
        return

    # Count makers before deletion
    try:
        with open(ignored_makers_path, encoding="utf-8") as f:
            count = sum(1 for line in f if line.strip())
    except Exception as e:
        typer.echo(f"Error reading ignored makers file: {e}", err=True)
        raise typer.Exit(1)

    # Ask for confirmation
    if not typer.confirm(f"Clear {count} ignored maker(s)?"):
        typer.echo("Cancelled.")
        return

    # Delete the file
    try:
        ignored_makers_path.unlink()
        typer.echo(f"Cleared {count} ignored maker(s).")
    except Exception as e:
        typer.echo(f"Error deleting ignored makers file: {e}", err=True)
        raise typer.Exit(1)

coinjoin(amount: Annotated[int | None, typer.Option('--amount', '-a', help='Amount in sats (0 for sweep; with --select-utxos, defaults to sweep)')] = None, destination: Annotated[str, typer.Option('--destination', '-d', help="Destination address (or 'INTERNAL' for next mixdepth)")] = 'INTERNAL', mixdepth: Annotated[int | None, typer.Option('--mixdepth', '-m', help='Source mixdepth (default 0; with --select-utxos, derived from the selection unless set explicitly; --input-utxo entries must belong to this mixdepth)')] = None, counterparties: Annotated[int | None, typer.Option('--counterparties', '-n', help='Number of makers')] = None, mnemonic_file: Annotated[Path | None, typer.Option('--mnemonic-file', '-f', help='Path to mnemonic file')] = None, prompt_bip39_passphrase: Annotated[bool, typer.Option('--prompt-bip39-passphrase', help='Prompt for BIP39 passphrase interactively')] = False, network: Annotated[NetworkType | None, typer.Option('--network', case_sensitive=False, help='Protocol network for handshakes')] = None, bitcoin_network: Annotated[NetworkType | None, typer.Option('--bitcoin-network', case_sensitive=False, help='Bitcoin network for addresses (defaults to --network)')] = None, backend_type: Annotated[str | None, typer.Option('--backend', '-b', help='Backend type: descriptor_wallet | neutrino')] = None, rpc_url: Annotated[str | None, typer.Option('--rpc-url', envvar='BITCOIN_RPC_URL', help='Bitcoin full node RPC URL')] = None, neutrino_url: Annotated[str | None, typer.Option('--neutrino-url', envvar='NEUTRINO_URL', help='Neutrino REST API URL')] = None, directory_servers: Annotated[str | None, typer.Option('--directory', '-D', envvar='DIRECTORY_SERVERS', help='Directory servers (comma-separated)')] = None, tor_socks_host: Annotated[str | None, typer.Option(help='Tor SOCKS proxy host (overrides TOR__SOCKS_HOST)')] = None, tor_socks_port: Annotated[int | None, typer.Option(help='Tor SOCKS proxy port (overrides TOR__SOCKS_PORT)')] = None, max_abs_fee: Annotated[int | None, typer.Option('--max-abs-fee', help='Max absolute fee in sats')] = None, max_rel_fee: Annotated[str | None, typer.Option('--max-rel-fee', help='Max relative fee (0.001=0.1%)')] = None, fee_rate: Annotated[float | None, typer.Option('--fee-rate', help='Manual fee rate in sat/vB. Mutually exclusive with --block-target.')] = None, block_target: Annotated[int | None, typer.Option('--block-target', help='Target blocks for fee estimation (1-1008). Cannot be used with neutrino.')] = None, bondless_makers_allowance: Annotated[float | None, typer.Option('--bondless-allowance', envvar='BONDLESS_MAKERS_ALLOWANCE', help='Fraction of allowance slots chosen uniformly from zero-fee offers (0.0-1.0)')] = None, bond_value_exponent: Annotated[float | None, typer.Option('--bond-exponent', envvar='BOND_VALUE_EXPONENT', help='Exponent for fidelity bond value calculation')] = None, bondless_require_zero_fee: Annotated[bool | None, typer.Option('--bondless-zero-fee/--no-bondless-zero-fee', envvar='BONDLESS_REQUIRE_ZERO_FEE', help='Restrict allowance spots to zero-fee offers')] = None, quantized_offers_only: Annotated[bool | None, typer.Option('--quantized-offers-only/--allow-non-quantized-offers', help='Only select offers whose advertised CoinJoin fee is on the public grid')] = None, round_up_cj_fees: Annotated[bool | None, typer.Option('--round-up-cj-fees/--no-round-up-cj-fees', help='Round selected maker fees up to public fee quanta')] = None, equalize_cj_fees: Annotated[bool | None, typer.Option('--equalize-cj-fees/--no-equalize-cj-fees', help='Pay all selected makers the highest realized fee in the selected set')] = None, select_utxos: Annotated[bool, typer.Option('--select-utxos', '-s', help='Interactively select UTXOs (fzf-like TUI)')] = False, input_utxo: Annotated[list[str] | None, typer.Option('--input-utxo', help='Explicit input UTXO as txid:vout (repeatable). CoinJoin spends exactly the given UTXOs, including for sweeps, and never adds other inputs. Every UTXO must be eligible and belong to --mixdepth. Mutually exclusive with --select-utxos.')] = None, yes: Annotated[bool, typer.Option('--yes', '-y', help='Skip confirmation prompt')] = False, data_dir: Annotated[Path | None, typer.Option('--data-dir', envvar='JOINMARKET_DATA_DIR', help='Data directory (default: ~/.joinmarket-ng or $JOINMARKET_DATA_DIR)')] = None, config_file: Annotated[Path | None, typer.Option('--config-file', envvar='JOINMARKET_CONFIG_FILE', help='Config file path (decoupled from data dir). Defaults to <data-dir>/config.toml')] = None, log_level: Annotated[str | None, typer.Option('--log-level', '-l', help='Log level')] = None) -> None

Execute a single CoinJoin transaction.

Configuration is loaded from ~/.joinmarket-ng/config.toml (or $JOINMARKET_DATA_DIR/config.toml), environment variables, and CLI arguments. CLI arguments have the highest priority.

Source code in taker/src/taker/cli.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@app.command()
def coinjoin(
    amount: Annotated[
        int | None,
        typer.Option(
            "--amount",
            "-a",
            help="Amount in sats (0 for sweep; with --select-utxos, defaults to sweep)",
        ),
    ] = None,
    destination: Annotated[
        str,
        typer.Option(
            "--destination",
            "-d",
            help="Destination address (or 'INTERNAL' for next mixdepth)",
        ),
    ] = "INTERNAL",
    mixdepth: Annotated[
        int | None,
        typer.Option(
            "--mixdepth",
            "-m",
            help="Source mixdepth (default 0; with --select-utxos, derived from "
            "the selection unless set explicitly; --input-utxo entries must belong "
            "to this mixdepth)",
        ),
    ] = None,
    counterparties: Annotated[
        int | None, typer.Option("--counterparties", "-n", help="Number of makers")
    ] = None,
    mnemonic_file: Annotated[
        Path | None, typer.Option("--mnemonic-file", "-f", help="Path to mnemonic file")
    ] = None,
    prompt_bip39_passphrase: Annotated[
        bool,
        typer.Option(
            "--prompt-bip39-passphrase",
            help="Prompt for BIP39 passphrase interactively",
        ),
    ] = False,
    network: Annotated[
        NetworkType | None,
        typer.Option("--network", case_sensitive=False, help="Protocol network for handshakes"),
    ] = None,
    bitcoin_network: Annotated[
        NetworkType | None,
        typer.Option(
            "--bitcoin-network",
            case_sensitive=False,
            help="Bitcoin network for addresses (defaults to --network)",
        ),
    ] = None,
    backend_type: Annotated[
        str | None,
        typer.Option("--backend", "-b", help="Backend type: descriptor_wallet | neutrino"),
    ] = None,
    rpc_url: Annotated[
        str | None,
        typer.Option(
            "--rpc-url",
            envvar="BITCOIN_RPC_URL",
            help="Bitcoin full node RPC URL",
        ),
    ] = None,
    neutrino_url: Annotated[
        str | None,
        typer.Option(
            "--neutrino-url",
            envvar="NEUTRINO_URL",
            help="Neutrino REST API URL",
        ),
    ] = None,
    directory_servers: Annotated[
        str | None,
        typer.Option(
            "--directory",
            "-D",
            envvar="DIRECTORY_SERVERS",
            help="Directory servers (comma-separated)",
        ),
    ] = None,
    tor_socks_host: Annotated[
        str | None, typer.Option(help="Tor SOCKS proxy host (overrides TOR__SOCKS_HOST)")
    ] = None,
    tor_socks_port: Annotated[
        int | None, typer.Option(help="Tor SOCKS proxy port (overrides TOR__SOCKS_PORT)")
    ] = None,
    max_abs_fee: Annotated[
        int | None, typer.Option("--max-abs-fee", help="Max absolute fee in sats")
    ] = None,
    max_rel_fee: Annotated[
        str | None, typer.Option("--max-rel-fee", help="Max relative fee (0.001=0.1%)")
    ] = None,
    fee_rate: Annotated[
        float | None,
        typer.Option(
            "--fee-rate",
            help="Manual fee rate in sat/vB. Mutually exclusive with --block-target.",
        ),
    ] = None,
    block_target: Annotated[
        int | None,
        typer.Option(
            "--block-target",
            help="Target blocks for fee estimation (1-1008). Cannot be used with neutrino.",
        ),
    ] = None,
    bondless_makers_allowance: Annotated[
        float | None,
        typer.Option(
            "--bondless-allowance",
            envvar="BONDLESS_MAKERS_ALLOWANCE",
            help="Fraction of allowance slots chosen uniformly from zero-fee offers (0.0-1.0)",
        ),
    ] = None,
    bond_value_exponent: Annotated[
        float | None,
        typer.Option(
            "--bond-exponent",
            envvar="BOND_VALUE_EXPONENT",
            help="Exponent for fidelity bond value calculation",
        ),
    ] = None,
    bondless_require_zero_fee: Annotated[
        bool | None,
        typer.Option(
            "--bondless-zero-fee/--no-bondless-zero-fee",
            envvar="BONDLESS_REQUIRE_ZERO_FEE",
            help="Restrict allowance spots to zero-fee offers",
        ),
    ] = None,
    quantized_offers_only: Annotated[
        bool | None,
        typer.Option(
            "--quantized-offers-only/--allow-non-quantized-offers",
            help="Only select offers whose advertised CoinJoin fee is on the public grid",
        ),
    ] = None,
    round_up_cj_fees: Annotated[
        bool | None,
        typer.Option(
            "--round-up-cj-fees/--no-round-up-cj-fees",
            help="Round selected maker fees up to public fee quanta",
        ),
    ] = None,
    equalize_cj_fees: Annotated[
        bool | None,
        typer.Option(
            "--equalize-cj-fees/--no-equalize-cj-fees",
            help="Pay all selected makers the highest realized fee in the selected set",
        ),
    ] = None,
    select_utxos: Annotated[
        bool,
        typer.Option(
            "--select-utxos",
            "-s",
            help="Interactively select UTXOs (fzf-like TUI)",
        ),
    ] = False,
    input_utxo: Annotated[
        list[str] | None,
        typer.Option(
            "--input-utxo",
            help="Explicit input UTXO as txid:vout (repeatable). CoinJoin spends exactly "
            "the given UTXOs, including for sweeps, and never adds other inputs. Every "
            "UTXO must be eligible and belong to --mixdepth. Mutually exclusive with "
            "--select-utxos.",
        ),
    ] = None,
    yes: Annotated[bool, typer.Option("--yes", "-y", help="Skip confirmation prompt")] = False,
    data_dir: Annotated[
        Path | None,
        typer.Option(
            "--data-dir",
            envvar="JOINMARKET_DATA_DIR",
            help="Data directory (default: ~/.joinmarket-ng or $JOINMARKET_DATA_DIR)",
        ),
    ] = None,
    config_file: Annotated[
        Path | None,
        typer.Option(
            "--config-file",
            envvar="JOINMARKET_CONFIG_FILE",
            help="Config file path (decoupled from data dir). Defaults to <data-dir>/config.toml",
        ),
    ] = None,
    log_level: Annotated[
        str | None,
        typer.Option("--log-level", "-l", help="Log level"),
    ] = None,
) -> None:
    """
    Execute a single CoinJoin transaction.

    Configuration is loaded from ~/.joinmarket-ng/config.toml (or $JOINMARKET_DATA_DIR/config.toml),
    environment variables, and CLI arguments. CLI arguments have the highest priority.
    """
    if select_utxos and input_utxo:
        logger.error("Cannot specify both --select-utxos and --input-utxo")
        raise typer.Exit(1)

    if amount is None:
        if not select_utxos:
            logger.error("--amount is required unless --select-utxos is used")
            raise typer.Exit(1)
        amount = 0

    # Load settings (log_level=None means use settings.logging.level)
    settings = setup_cli(log_level, data_dir=data_dir, config_file=config_file)

    # Ensure config file exists
    ensure_config_file(settings.get_data_dir())

    # Load mnemonic using unified resolver
    try:
        resolved = resolve_mnemonic(
            settings,
            mnemonic_file=mnemonic_file,
            prompt_bip39_passphrase=prompt_bip39_passphrase,
        )
        resolved_mnemonic = resolved.mnemonic if resolved else ""
        resolved_passphrase = resolved.bip39_passphrase if resolved else ""
        resolved_creation_height = resolved.creation_height if resolved else None
    except (ValueError, FileNotFoundError) as e:
        logger.error(str(e))
        raise typer.Exit(1)

    # Build config with CLI overrides
    try:
        config = build_taker_config(
            settings=settings,
            mnemonic=resolved_mnemonic,
            passphrase=resolved_passphrase,
            amount=amount,
            destination=destination,
            mixdepth=mixdepth if mixdepth is not None else 0,
            counterparties=counterparties,
            select_utxos=select_utxos,
            network=network,
            bitcoin_network=bitcoin_network,
            backend_type=backend_type,
            rpc_url=rpc_url,
            neutrino_url=neutrino_url,
            directory_servers=directory_servers,
            tor_socks_host=tor_socks_host,
            tor_socks_port=tor_socks_port,
            max_abs_fee=max_abs_fee,
            max_rel_fee=max_rel_fee,
            fee_rate=fee_rate,
            block_target=block_target,
            bondless_makers_allowance=bondless_makers_allowance,
            bond_value_exponent=bond_value_exponent,
            bondless_require_zero_fee=bondless_require_zero_fee,
            require_quantized_cj_fees=quantized_offers_only,
            round_up_cj_fees=round_up_cj_fees,
            equalize_cj_fees=equalize_cj_fees,
        )
    except ValueError as e:
        logger.error(str(e))
        raise typer.Exit(1)

    if resolved_creation_height is not None:
        config.creation_height = resolved_creation_height
    if resolved is not None:
        config.mnemonic_file = resolved.mnemonic_file

    # Log configuration source
    logger.info(f"Using network: {config.network.value}")
    logger.info(f"Using backend: {config.backend_type}")
    logger.info("Tor SOCKS proxy configured")
    logger.bind(sensitive=True).info(f"Tor SOCKS: {config.socks_host}:{config.socks_port}")

    try:
        asyncio.run(
            _run_coinjoin(
                settings=settings,
                config=config,
                amount=amount,
                destination=destination,
                mixdepth=mixdepth,
                counterparties=config.counterparty_count,
                skip_confirmation=yes,
                input_utxos=input_utxo,
            )
        )
    except RuntimeError as e:
        # Clean error for expected failures (e.g., connection failures)
        logger.error("CoinJoin failed")
        logger.bind(sensitive=True).error("CoinJoin failure detail: {}", e)
        raise typer.Exit(1)
    except KeyboardInterrupt:
        logger.info("Interrupted by user")
        raise typer.Exit(130)
    except Exception:
        logger.error("Unexpected CoinJoin error")
        logger.bind(sensitive=True).exception("Unexpected CoinJoin error")
        raise typer.Exit(1)

config_init(data_dir: Annotated[Path | None, typer.Option('--data-dir', '-d', envvar='JOINMARKET_DATA_DIR', help='Data directory for JoinMarket files')] = None, config_file: Annotated[Path | None, typer.Option('--config-file', envvar='JOINMARKET_CONFIG_FILE', help='Config file path (decoupled from data dir). Defaults to <data-dir>/config.toml')] = None) -> None

Initialize the config file with default settings.

Source code in taker/src/taker/cli.py
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
@app.command()
def config_init(
    data_dir: Annotated[
        Path | None,
        typer.Option(
            "--data-dir",
            "-d",
            envvar="JOINMARKET_DATA_DIR",
            help="Data directory for JoinMarket files",
        ),
    ] = None,
    config_file: Annotated[
        Path | None,
        typer.Option(
            "--config-file",
            envvar="JOINMARKET_CONFIG_FILE",
            help="Config file path (decoupled from data dir). Defaults to <data-dir>/config.toml",
        ),
    ] = None,
) -> None:
    """Initialize the config file with default settings."""
    from jmcore.paths import get_default_data_dir

    if data_dir is None:
        data_dir = get_default_data_dir()

    config_path = ensure_config_file(data_dir, config_file=config_file)
    typer.echo(f"Config file created at: {config_path}")
    typer.echo("\nAll settings are commented out by default.")
    typer.echo("Edit the file to customize your configuration.")

create_backend(config: TakerConfig) -> Any

Create appropriate backend based on config.

Source code in taker/src/taker/cli.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def create_backend(config: TakerConfig) -> Any:
    """Create appropriate backend based on config."""
    bitcoin_network = config.bitcoin_network or config.network

    from jmwallet.backends.descriptor_wallet import (
        DescriptorWalletBackend,
        generate_wallet_name,
        get_mnemonic_fingerprint,
    )
    from jmwallet.backends.neutrino import NeutrinoBackend

    backend: DescriptorWalletBackend | NeutrinoBackend
    if config.backend_type == "neutrino":
        backend = NeutrinoBackend(
            neutrino_url=config.backend_config.get("neutrino_url", "http://127.0.0.1:8334"),
            network=bitcoin_network.value,
            scan_start_height=config.backend_config.get("scan_start_height"),
            add_peers=config.backend_config.get("add_peers", []),
            tls_cert_path=config.backend_config.get("tls_cert_path"),
            auth_token=config.backend_config.get("auth_token"),
            include_mempool=config.backend_config.get("include_mempool", True),
            fee_estimate_url=config.backend_config.get("fee_estimate_url"),
            fee_estimate_proxy=config.backend_config.get("fee_estimate_proxy"),
        )
    elif config.backend_type == "descriptor_wallet":
        fingerprint = get_mnemonic_fingerprint(
            config.mnemonic.get_secret_value(), config.passphrase.get_secret_value() or ""
        )
        wallet_name = generate_wallet_name(fingerprint, bitcoin_network.value)
        backend = DescriptorWalletBackend(
            rpc_url=config.backend_config["rpc_url"],
            rpc_user=config.backend_config["rpc_user"],
            rpc_password=config.backend_config["rpc_password"],
            wallet_name=wallet_name,
        )
    else:
        raise ValueError(f"Unknown backend type: {config.backend_type}")

    if config.creation_height is not None:
        backend.set_wallet_creation_height(config.creation_height)

    return backend

main() -> None

Entry point.

Source code in taker/src/taker/cli.py
640
641
642
643
644
645
646
def main() -> None:
    """Entry point."""
    from jmcore.process_hardening import harden_current_process

    # Disable core dumps and ptrace before any wallet command loads secrets.
    harden_current_process()
    app()