Skip to content

[BUG] clawrtc wallet create exits 1 on Windows after writing wallet due to Unicode banner #6899

@F3RC4O

Description

@F3RC4O

Bug report: clawrtc wallet create exits 1 on Windows after creating wallet

Payout address: RTC4764df477d822076239ba89069ae5a699b883842

Summary

On Windows, clawrtc wallet create successfully creates the Ed25519 wallet file, but then exits with UnicodeEncodeError while printing the success banner. The command returns exit code 1, so automation treats wallet creation as failed even though a private-key wallet has already been written to disk.

Environment

  • OS: Windows 11
  • Python: 3.14.3
  • clawrtc: 1.8.0
  • Console code page during repro: 850
  • Package path: C:\Users\Fernando\AppData\Roaming\Python\Python314\site-packages\clawrtc\cli.py

Steps to reproduce

Use a temporary home directory so the real wallet is not touched:

$tmp = Join-Path $PWD 'work\clawrtc-win-wallet-repro-home'
Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $tmp | Out-Null
$env:USERPROFILE=$tmp
$env:HOME=$tmp
& 'C:\Users\Fernando\AppData\Roaming\Python\Python314\Scripts\clawrtc.exe' wallet create
$LASTEXITCODE
Test-Path (Join-Path $tmp '.clawrtc\wallets\default.json')

Actual behavior

  • command exits with code 1;
  • wallet file exists after the failed command;
  • traceback occurs while printing the Unicode success banner.

Relevant traceback:

UnicodeEncodeError: 'charmap' codec can't encode characters in position 11-69: character maps to <undefined>

  File "...\site-packages\clawrtc\cli.py", line 681, in _wallet_create
    print(textwrap.dedent(f"""
    {GREEN}{BOLD}═══════════════════════════════════════════════════════════
...

Local repro evidence:

exit_code=1
wallet_exists=True
address=RTC21d37972906ca0dc3db51ad6c624d7f748ce3b11
has_private_key=True

Full local log: outputs/clawrtc_wallet_create_windows_unicode_repro.txt

Expected behavior

clawrtc wallet create should either:

  • print a Windows-safe success message and return exit code 0, or
  • avoid printing Unicode box-drawing/em dash characters when sys.stdout.encoding cannot encode them.

Impact

This is a user-facing Windows CLI bug. It is especially confusing because the command fails after writing the private key. A script may retry with --force, replacing the wallet, because the first run returned failure.

Suggested fix

Wrap the banner output in an encoding-safe helper, for example:

def safe_print(text: str) -> None:
    encoding = getattr(sys.stdout, "encoding", None) or "utf-8"
    try:
        print(text)
    except UnicodeEncodeError:
        print(text.encode(encoding, errors="replace").decode(encoding, errors="replace"))

Or keep the Windows banner ASCII-only when sys.stdout.encoding is a legacy code page. The wallet write should not be followed by an unhandled print-time exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions