Skip to content

jmwallet.cli.registry

jmwallet.cli.registry

Bond registry command: registry-show.

registry-list and registry-sync have been merged into list-bonds (see bonds.py). list-bonds works in two modes: - Without --mnemonic-file: shows bonds from the local registry (offline). - With --mnemonic-file: scans the blockchain and updates the registry.

Attributes

Functions

registry_show(address: Annotated[str, typer.Argument(help='Bond address to show')], mnemonic_file: Annotated[Path | None, typer.Option('--mnemonic-file', '-f', envvar='MNEMONIC_FILE')] = None, prompt_bip39_passphrase: Annotated[bool, typer.Option('--prompt-bip39-passphrase', help='Prompt for BIP39 passphrase')] = False, wallet_fingerprint: Annotated[str | None, typer.Option('--wallet-fingerprint', help="Select the per-wallet bond registry by its 8-char hex BIP32 master fingerprint. Use this instead of --mnemonic-file when you already know the fingerprint (e.g. from 'jm-wallet info'). When neither is provided and exactly one wallet has a registry in the data directory, that wallet is selected automatically.")] = None, data_dir: Annotated[Path | None, typer.Option('--data-dir', envvar='JOINMARKET_DATA_DIR', help='Data directory (default: ~/.joinmarket-ng or $JOINMARKET_DATA_DIR)')] = None, json_output: Annotated[bool, typer.Option('--json', '-j', help='Output as JSON')] = False, log_level: Annotated[str, typer.Option('--log-level', '-l')] = 'WARNING') -> None

Show detailed information about a specific fidelity bond.

Source code in jmwallet/src/jmwallet/cli/registry.py
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 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
 81
 82
 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
@app.command("registry-show", no_args_is_help=True)
def registry_show(
    address: Annotated[str, typer.Argument(help="Bond address to show")],
    mnemonic_file: Annotated[
        Path | None, typer.Option("--mnemonic-file", "-f", envvar="MNEMONIC_FILE")
    ] = None,
    prompt_bip39_passphrase: Annotated[
        bool, typer.Option("--prompt-bip39-passphrase", help="Prompt for BIP39 passphrase")
    ] = False,
    wallet_fingerprint: Annotated[
        str | None,
        typer.Option(
            "--wallet-fingerprint",
            help=(
                "Select the per-wallet bond registry by its 8-char hex BIP32 "
                "master fingerprint. Use this instead of --mnemonic-file when "
                "you already know the fingerprint (e.g. from 'jm-wallet info'). "
                "When neither is provided and exactly one wallet has a "
                "registry in the data directory, that wallet is selected "
                "automatically."
            ),
        ),
    ] = None,
    data_dir: Annotated[
        Path | None,
        typer.Option(
            "--data-dir",
            envvar="JOINMARKET_DATA_DIR",
            help="Data directory (default: ~/.joinmarket-ng or $JOINMARKET_DATA_DIR)",
        ),
    ] = None,
    json_output: Annotated[
        bool,
        typer.Option("--json", "-j", help="Output as JSON"),
    ] = False,
    log_level: Annotated[str, typer.Option("--log-level", "-l")] = "WARNING",
) -> None:
    """Show detailed information about a specific fidelity bond."""
    settings = setup_cli(log_level, data_dir=data_dir)

    from jmcore.btc_script import disassemble_script

    from jmwallet.cli._wallet_selection import resolve_wallet_fingerprint
    from jmwallet.wallet.bond_registry import (
        get_registry_path,
        list_registry_fingerprints,
        load_registry,
    )

    resolved_data_dir = data_dir if data_dir else settings.get_data_dir()

    # Per-wallet registry scoping (issue #492) requires a wallet identity
    # to know which file to read. Accept it via --mnemonic-file,
    # --wallet-fingerprint, or auto-detect when only one wallet is present.
    fingerprint = resolve_wallet_fingerprint(
        settings,
        mnemonic_file=mnemonic_file,
        wallet_fingerprint=wallet_fingerprint,
        prompt_bip39_passphrase=prompt_bip39_passphrase,
        list_known_fingerprints=lambda: list_registry_fingerprints(resolved_data_dir),
        command_label="jm-wallet registry-show",
        fall_back_to_configured_mnemonic=True,
    )
    if fingerprint is None:
        logger.error(
            "registry-show requires a wallet identity. Pass --mnemonic-file "
            "(with --prompt-bip39-passphrase if needed) or --wallet-fingerprint."
        )
        raise typer.Exit(1)

    registry = load_registry(resolved_data_dir, fingerprint)
    registry_path = get_registry_path(resolved_data_dir, fingerprint)

    bond = registry.get_bond_by_address(address)
    if not bond:
        print(f"\nBond not found: {address}")
        print(f"Registry: {registry_path}")
        raise typer.Exit(1)

    if json_output:
        import json

        print(json.dumps(bond.model_dump(), indent=2))
        return

    print("\n" + "=" * 80)
    print("FIDELITY BOND DETAILS")
    print("=" * 80)
    print(f"\nAddress:          {bond.address}")
    print(f"Network:          {bond.network}")
    print(f"Index:            {bond.index}")
    print(f"Path:             {bond.path}")
    print(f"Public Key:       {bond.pubkey}")
    print()
    print(f"Locktime:         {bond.locktime} ({bond.locktime_human})")
    if bond.is_expired:
        print("Status:           EXPIRED (can be spent)")
    else:
        remaining = bond.time_until_unlock
        days = remaining // 86400
        hours = (remaining % 86400) // 3600
        print(f"Status:           LOCKED ({days}d {hours}h remaining)")
    print()
    print("-" * 80)
    print("WITNESS SCRIPT")
    print("-" * 80)
    witness_script = bytes.fromhex(bond.witness_script_hex)
    print(f"Hex:          {bond.witness_script_hex}")
    print(f"Disassembled: {disassemble_script(witness_script)}")
    print()
    print("-" * 80)
    print("FUNDING STATUS")
    print("-" * 80)
    if bond.is_funded:
        print(f"TXID:         {bond.txid}")
        print(f"Vout:         {bond.vout}")
        print(f"Value:        {bond.value:,} sats")
        print(f"Confirmations: {bond.confirmations}")
    else:
        print("Not funded (or not yet synced)")
    print()
    print(f"Created:      {bond.created_at}")
    print("=" * 80 + "\n")