<!-- XE-0038 · Windows builds cannot create or restore any wallet — core.autocrlf rewrites the embedded BIP39 wordlist to CRLF · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0038>. The page is the record; this is the same page for reading.*

XE-0038 · Bounty

# Windows builds cannot create or restore any wallet — core.autocrlf rewrites the embedded BIP39 wordlist to CRLF

Accepted
claimed Medium
[xe#31](https://github.com/xeprotocol/xe/issues/31)
filed 2026-10-24 13:23 UTC
by kenmungeneskar

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Medium

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 00:11 UTC

Told
:   2026-11-06 21:29 UTC

### Patches

- [xe#35](https://github.com/xeprotocol/xe/pull/35) open by ocakciomursel-pixel
  fix(core): enforce LF on embedded BIP39 wordlist and strip CR when loading phraseWords

### History

- [15425](https://bounty.xe.network/log/15425) 2026-11-06 21:29 UTC reply.mirrored
- [15421](https://bounty.xe.network/log/15421) 2026-11-06 21:29 UTC reply.sent
- [15420](https://bounty.xe.network/log/15420) 2026-11-06 21:29 UTC proposal.adopted
- [15419](https://bounty.xe.network/log/15419) 2026-11-06 21:29 UTC proposal.adopted
- [15418](https://bounty.xe.network/log/15418) 2026-11-06 21:29 UTC ticket.award
- [15417](https://bounty.xe.network/log/15417) 2026-11-06 21:28 UTC proposal.rejected
- [6880](https://bounty.xe.network/log/6880) 2026-11-05 13:45 UTC proposal.created
- [1805](https://bounty.xe.network/log/1805) 2026-11-02 19:16 UTC proposal.created
- [1804](https://bounty.xe.network/log/1804) 2026-11-02 19:16 UTC proposal.created
- [1459](https://bounty.xe.network/log/1459) 2026-11-02 10:11 UTC note.added
- [803](https://bounty.xe.network/log/803) 2026-10-29 14:22 UTC note.added
- [802](https://bounty.xe.network/log/802) 2026-10-29 14:22 UTC ticket.facts area, claimed\_tier

[Full history](https://bounty.xe.network/log?ref=XE-0038) · [JSON](https://bounty.xe.network/v1/tickets/XE-0038) · [markdown](https://bounty.xe.network/XE-0038.md)

### Report

**Severity (suggested):** Medium — Windows builds cannot create or restore any wallet; also breaks the documented
"same commit produces the same bytes on any machine" reproducibility claim for this asset.

**XE payout address:** will be provided in a follow-up comment.

### Environment

- Windows 11 (10.0.26200), git for Windows 2.54.0 with its **default `core.autocrlf=true`**
- Go 1.25.0 windows/amd64, `CGO_ENABLED=0` — source at `master` @ `9787859`
- Network `testnet-0005`

### Summary

A default `git clone` on Windows checks out `core/wordlist_english.txt` with CRLF line endings.
That file is `//go:embed`-ed as the BIP39 wordlist and `core/recovery_phrase.go:26` splits it with
`strings.Split(strings.TrimSuffix(wordlistEnglish, "\n"), "\n")`, so every word keeps a trailing `\r`.
`phraseIndex` lookup therefore fails on the first word, and **every** wallet operation that validates a
phrase fails:

```
$ ./xe.exe wallet create
error: derive wallet: unknown recovery phrase word at position 1
```

`wallet restore` and `wallet phrase` fail identically. A Windows user cannot create an account, cannot
restore one, and therefore cannot use the testnet at all — the getting-started guide is blocked at step 1\.

### Reproduction

```
git clone https://github.com/xeprotocol/xe      # git for Windows defaults to core.autocrlf=true
cd xe
go build -o xe.exe ./cmd/xe
./xe.exe wallet create
# error: derive wallet: unknown recovery phrase word at position 1

# proof that the embedded wordlist is the cause
$b = [IO.File]::ReadAllBytes("core/wordlist_english.txt")
"CR=$((($b | ? { $_ -eq 13 }).Count)) LF=$((($b | ? { $_ -eq 10 }).Count))"
# CR=2048 LF=2048
```

### Root cause

`core/wordlist_english.txt` is embedded verbatim (`//go:embed`, `core/recovery_phrase.go:22-26`) and is
never trimmed per line. `core.autocrlf=true` rewrites it to CRLF **at checkout time**, changing the content
of an embedded asset — not just source files. `ValidatePhrase` (`core/recovery_phrase.go:76-80`) then fails
on word 1 even though the generated phrase is perfectly valid.

This also means the same commit built on Windows and on Linux are **not byte-identical** for this asset,
so `make verify-repro`'s "same commit produces the same bytes on any machine" does not hold for Windows
checkouts of this file.

### Verification that this is the cause

Forcing LF (`git config core.autocrlf false` \+ re-checkout, or rewriting the file as LF) and rebuilding with
no other change makes it work immediately:

```
$ ./xe.exe wallet create
Wallet created!
  Address:    802d4ce502a4f806b3a0abf78f9f8fa54a80bb0010f0ce2212641eab20e484ef
```

### Suggested fix (any one of these)

1. Add `.gitattributes` (preferred, fixes every checkout):

   ```
   core/wordlist_english.txt text eol=lf
   ```
2. Defensive, trim CR when loading:

   ```
   phraseWords = strings.Split(strings.ReplaceAll(strings.TrimSuffix(wordlistEnglish, "\n"), "\r\n", "\n"), "\n")
   ```
3. Add a build-time assertion that `len(phraseWords) == 2048` — this would have caught it immediately.

### Impact

- Every Windows tester is blocked at step 1; not a fund or consensus issue.
- Cross-platform build reproducibility is not achieved for this embedded asset.

### Out of scope / already checked

Not a duplicate of #3 (that is a genesis-hash mismatch on boot; this is the embedded BIP39 wordlist).
I checked `autocrlf`, `wordlist`, `recovery phrase` and `wallet create` across this repo's issues before
filing — no existing report covers it.

### Thread

**greenblood33333**2026-10-25 11:55 UTCgithub

Same root cause, different file: with git-for-Windows' default `core.autocrlf=true` the **genesis bundle** is also rewritten to CRLF, and because the statechain hash covers raw file bytes, `verify-genesis` rejects the published bundle before the node can even start:

```
> xe.exe verify-genesis --genesis-dir .\genesis\testnet-0005 --expect-network-id testnet-0005
error: genesis: genesis\testnet-0005\statechain-genesis.json: genesis: hash mismatch:
  got d01aabc1a29d...8f296d6, want f620d15b4371961fe92a48720d47e7e84fc997c9ba038d226729d9b50b0ac981
```

`statechain-genesis.json` has 99 CR bytes in the CRLF checkout and 0 after `git config core.autocrlf false` \+ fresh checkout, after which the bundle verifies and both hashes match the README. A second symptom: a binary built from the CRLF tree embeds CRLF placeholder genesis files, so `verify-genesis` keeps failing on the *embedded* genesis (`got 96a5ac54...c212, want bbe4444d...be809`) until the binary is rebuilt from an LF tree.

Environment: Windows 11 (10.0.26200), git for Windows 2.56.0, Go 1.25.0 windows/amd64, `CGO_ENABLED=0`, master @ `9787859`.

Suggestion for #35: cover `genesis/**` (and ideally `* text=auto eol=lf`) in `.gitattributes`, not only the wordlist, and add a Windows CI job that runs `verify-genesis --genesis-dir genesis/testnet-0005` and `wallet create`.

**kenmungeneskar**2026-10-26 02:01 UTCgithub

**Independent reproduction — with one correction to the causal explanation**

Same root cause on the wordlist side (thanks, this is a useful extension), reproduced here on Windows 11 /
git-for-Windows / Go 1.25.0, master @ `9787859`:

```
genesis/testnet-0005/statechain-genesis.json   CR=99   LF=99
genesis/testnet-0005/ledger-genesis.json       CR=18   LF=18
genesis/testnet-0001/statechain-genesis.json   CR=99   LF=99
genesis/testnet-0003/statechain-genesis.json   CR=99   LF=99
```

and the same failure, byte-for-byte the same hashes:

```
error: genesis: genesis\testnet-0005\statechain-genesis.json: genesis: hash mismatch:
  got d01aabc1a29dc64bc6bbc30031a716cd2e0ceb867e5479953cd5ad22c8f296d6,
  want f620d15b4371961fe92a48720d47e7e84fc997c9ba038d226729d9b50b0ac981
```

**But the genesis hash does not cover raw file bytes.** I converted the bundle to LF in a scratch copy
(`\r\n -> \n`, so `statechain-genesis.json` goes from 99 CR to 0\) and re-ran the same command:

```
Genesis: ledger     .../ledger-genesis.json      hash=3ff640410d7879821b544d09545dcfb8e96fe4fc717634e8bff4e53cacd1e150
Genesis: statechain .../statechain-genesis.json  hash=d01aabc1a29dc64bc6bbc30031a716cd2e0ceb867e5479953cd5ad22c8f296d6
error: genesis: embedded statechain genesis: genesis: hash mismatch:
  got 96a5ac54247f0609ac51cfd925287dbfb73144adbb34eeb658784b511751c212,
  want bbe4444dcf6dda5f039c5bf4f13f7f6139adcb741bd76ac464c84436d0cbe809
```

The statechain hash is **`d01aabc1…` in both the CRLF and the LF tree** — the file's sha256 obviously changes,
the *genesis* hash does not. So EOL is not what moves that number, and stripping CR cannot make it match
`f620d15b…`. There are two separable problems here:

1. the published `testnet-0005` bundle's statechain hash is `d01aabc1…` while the tool expects `f620d15b…`
   — independent of line endings (this looks like the same family as #3), and
2. once the directory check is out of the way, the next check compares the bundle against the binary's
   **embedded** genesis (`96a5ac54…` vs `bbe4444d…`), i.e. the binary must be rebuilt from the very tree
   whose bundle you are verifying. A CRLF checkout at build time bakes the wrong placeholder in, which is
   exactly the second symptom you described.

One practical gotcha worth putting in the fix: `git config core.autocrlf false` in a **parent** repo does not
reach a nested clone. `third_party/xe` here is its own repository, so the top-level setting did nothing and
`git ls-files --eol genesis/` still reports `w/crlf`. That is another argument for doing it in `.gitattributes`
inside the XE repo (#35 does exactly that) rather than relying on local config.

So: \+1 on `.gitattributes` covering `core/wordlist_english.txt` **and** `genesis/**`, and \+1 on a Windows CI job
that runs `wallet create` and `verify-genesis --genesis-dir genesis/testnet-0005`; but note that (1) above
still fails on an LF tree, so the bundle hash expectation needs looking at separately.

**kenmungeneskar**2026-11-02 02:03 UTCgithub

**XE payout address for this report:** `b68f2b4d8a062d9219590f0c2d7753d783ec9f5d43d85a125230bb0f7a41a86e`

Locally held key; the address is `sha256("xe/account/v1" ‖ pubkey)` and does not depend on the network id, so the
same key yields the same address after a testnet wipe and at mainnet genesis.

One note on provenance, for the record while this is being triaged: PR #35 ("Fixes #31") is a third-party patch
submitted against this report — I did not write it. Per the programme rules ("One report per bug … Duplicate
reports go to the first verifiable submission"), the report is the submission, and the patch is welcome on its
own merits; I'm flagging it only so the beneficiary for this finding is unambiguous, as happened in #101.

**Joseph Denne**team2026-11-06 21:29 UTCgithub

Thanks for the report. To pay out we need an XE payout address in the report itself: please edit the issue body to add a line "Payout address: xe\_..." and say here when it is done. The desk entry is https://bounty.xe.network/XE-0038.

**kenmungeneskar**2026-11-09 02:02 UTCgithub

Done — the payout address is now in the report body, at the top:

`Payout address: b68f2b4d8a062d9219590f0c2d7753d783ec9f5d43d85a125230bb0f7a41a86e`

One clarification in case the desk wants a different representation: that is the full XE address as the protocol
derives it, `sha256("xe/account/v1" ‖ pubkey)` (64 hex chars, the same form the API returns from
`/accounts/{address}/balance`). If the desk expects it written as `xe_…` (or as a desk key identity such as
`xe:xxxxxxxx`), tell me the exact form and I will put that in the body instead — I would rather ask than guess at
a payout field. Same line has been added to my other two accepted reports (#30, #33) so they do not hit the same
round trip when they reach this stage.
