{"id":"XE-0038","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"31","source_url":"https://github.com/xeprotocol/xe/issues/31","reporter_id":10,"title":"Windows builds cannot create or restore any wallet — core.autocrlf rewrites the embedded BIP39 wordlist to CRLF","area":"sdk-docs-web","claimed_tier":"medium","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:17.224391+00:00","updated_at":"2026-11-10T00:11:57.952213+00:00","source_created_at":"2026-10-24T13:23:46+00:00","told_at":"2026-11-06T21:29:17+00:00","status_changed_at":"2026-10-29T14:04:13.479244+00:00","url":"https://bounty.xe.network/XE-0038","body":"**Severity (suggested):** Medium — Windows builds cannot create or restore any wallet; also breaks the documented\n\"same commit produces the same bytes on any machine\" reproducibility claim for this asset.\n\n**XE payout address:** will be provided in a follow-up comment.\n\n### Environment\n\n- Windows 11 (10.0.26200), git for Windows 2.54.0 with its **default `core.autocrlf=true`**\n- Go 1.25.0 windows/amd64, `CGO_ENABLED=0` — source at `master` @ `9787859`\n- Network `testnet-0005`\n\n### Summary\n\nA default `git clone` on Windows checks out `core/wordlist_english.txt` with CRLF line endings.\nThat file is `//go:embed`-ed as the BIP39 wordlist and `core/recovery_phrase.go:26` splits it with\n`strings.Split(strings.TrimSuffix(wordlistEnglish, \"\\n\"), \"\\n\")`, so every word keeps a trailing `\\r`.\n`phraseIndex` lookup therefore fails on the first word, and **every** wallet operation that validates a\nphrase fails:\n\n```\n$ ./xe.exe wallet create\nerror: derive wallet: unknown recovery phrase word at position 1\n```\n\n`wallet restore` and `wallet phrase` fail identically. A Windows user cannot create an account, cannot\nrestore one, and therefore cannot use the testnet at all — the getting-started guide is blocked at step 1.\n\n### Reproduction\n\n```powershell\ngit clone https://github.com/xeprotocol/xe      # git for Windows defaults to core.autocrlf=true\ncd xe\ngo build -o xe.exe ./cmd/xe\n./xe.exe wallet create\n# error: derive wallet: unknown recovery phrase word at position 1\n\n# proof that the embedded wordlist is the cause\n$b = [IO.File]::ReadAllBytes(\"core/wordlist_english.txt\")\n\"CR=$((($b | ? { $_ -eq 13 }).Count)) LF=$((($b | ? { $_ -eq 10 }).Count))\"\n# CR=2048 LF=2048\n```\n\n### Root cause\n\n`core/wordlist_english.txt` is embedded verbatim (`//go:embed`, `core/recovery_phrase.go:22-26`) and is\nnever trimmed per line. `core.autocrlf=true` rewrites it to CRLF **at checkout time**, changing the content\nof an embedded asset — not just source files. `ValidatePhrase` (`core/recovery_phrase.go:76-80`) then fails\non word 1 even though the generated phrase is perfectly valid.\n\nThis also means the same commit built on Windows and on Linux are **not byte-identical** for this asset,\nso `make verify-repro`'s \"same commit produces the same bytes on any machine\" does not hold for Windows\ncheckouts of this file.\n\n### Verification that this is the cause\n\nForcing LF (`git config core.autocrlf false` + re-checkout, or rewriting the file as LF) and rebuilding with\nno other change makes it work immediately:\n\n```\n$ ./xe.exe wallet create\nWallet created!\n  Address:    802d4ce502a4f806b3a0abf78f9f8fa54a80bb0010f0ce2212641eab20e484ef\n```\n\n### Suggested fix (any one of these)\n\n1. Add `.gitattributes` (preferred, fixes every checkout):\n   ```\n   core/wordlist_english.txt text eol=lf\n   ```\n2. Defensive, trim CR when loading:\n   ```go\n   phraseWords = strings.Split(strings.ReplaceAll(strings.TrimSuffix(wordlistEnglish, \"\\n\"), \"\\r\\n\", \"\\n\"), \"\\n\")\n   ```\n3. Add a build-time assertion that `len(phraseWords) == 2048` — this would have caught it immediately.\n\n### Impact\n\n- Every Windows tester is blocked at step 1; not a fund or consensus issue.\n- Cross-platform build reproducibility is not achieved for this embedded asset.\n\n### Out of scope / already checked\n\nNot a duplicate of #3 (that is a genesis-hash mismatch on boot; this is the embedded BIP39 wordlist).\nI checked `autocrlf`, `wordlist`, `recovery phrase` and `wallet create` across this repo's issues before\nfiling — no existing report covers it.\n","patch_refs":[{"id":120,"repo":"xeprotocol/xe","kind":"pr","ref":"35","title":"fix(core): enforce LF on embedded BIP39 wordlist and strip CR when loading phraseWords","url":"https://github.com/xeprotocol/xe/pull/35","note":"","state":"open","author":"ocakciomursel-pixel","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":13,"source":"github","source_ref":"6397318400","author":"greenblood33333","team":false,"body":"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:\n\n```\n> xe.exe verify-genesis --genesis-dir .\\genesis\\testnet-0005 --expect-network-id testnet-0005\nerror: genesis: genesis\\testnet-0005\\statechain-genesis.json: genesis: hash mismatch:\n  got d01aabc1a29d...8f296d6, want f620d15b4371961fe92a48720d47e7e84fc997c9ba038d226729d9b50b0ac981\n```\n\n`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.\n\nEnvironment: Windows 11 (10.0.26200), git for Windows 2.56.0, Go 1.25.0 windows/amd64, `CGO_ENABLED=0`, master @ `9787859`.\n\nSuggestion 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`.","created_at":"2026-10-25T11:55:53+00:00"},{"id":14,"source":"github","source_ref":"6406567719","author":"kenmungeneskar","team":false,"body":"**Independent reproduction — with one correction to the causal explanation**\n\nSame root cause on the wordlist side (thanks, this is a useful extension), reproduced here on Windows 11 /\ngit-for-Windows / Go 1.25.0, master @ `9787859`:\n\n```\ngenesis/testnet-0005/statechain-genesis.json   CR=99   LF=99\ngenesis/testnet-0005/ledger-genesis.json       CR=18   LF=18\ngenesis/testnet-0001/statechain-genesis.json   CR=99   LF=99\ngenesis/testnet-0003/statechain-genesis.json   CR=99   LF=99\n```\n\nand the same failure, byte-for-byte the same hashes:\n\n```\nerror: genesis: genesis\\testnet-0005\\statechain-genesis.json: genesis: hash mismatch:\n  got d01aabc1a29dc64bc6bbc30031a716cd2e0ceb867e5479953cd5ad22c8f296d6,\n  want f620d15b4371961fe92a48720d47e7e84fc997c9ba038d226729d9b50b0ac981\n```\n\n**But the genesis hash does not cover raw file bytes.** I converted the bundle to LF in a scratch copy\n(`\\r\\n -> \\n`, so `statechain-genesis.json` goes from 99 CR to 0) and re-ran the same command:\n\n```\nGenesis: ledger     .../ledger-genesis.json      hash=3ff640410d7879821b544d09545dcfb8e96fe4fc717634e8bff4e53cacd1e150\nGenesis: statechain .../statechain-genesis.json  hash=d01aabc1a29dc64bc6bbc30031a716cd2e0ceb867e5479953cd5ad22c8f296d6\nerror: genesis: embedded statechain genesis: genesis: hash mismatch:\n  got 96a5ac54247f0609ac51cfd925287dbfb73144adbb34eeb658784b511751c212,\n  want bbe4444dcf6dda5f039c5bf4f13f7f6139adcb741bd76ac464c84436d0cbe809\n```\n\nThe statechain hash is **`d01aabc1…` in both the CRLF and the LF tree** — the file's sha256 obviously changes,\nthe *genesis* hash does not. So EOL is not what moves that number, and stripping CR cannot make it match\n`f620d15b…`. There are two separable problems here:\n\n1. the published `testnet-0005` bundle's statechain hash is `d01aabc1…` while the tool expects `f620d15b…`\n   — independent of line endings (this looks like the same family as #3), and\n2. once the directory check is out of the way, the next check compares the bundle against the binary's\n   **embedded** genesis (`96a5ac54…` vs `bbe4444d…`), i.e. the binary must be rebuilt from the very tree\n   whose bundle you are verifying. A CRLF checkout at build time bakes the wrong placeholder in, which is\n   exactly the second symptom you described.\n\nOne practical gotcha worth putting in the fix: `git config core.autocrlf false` in a **parent** repo does not\nreach a nested clone. `third_party/xe` here is its own repository, so the top-level setting did nothing and\n`git ls-files --eol genesis/` still reports `w/crlf`. That is another argument for doing it in `.gitattributes`\ninside the XE repo (#35 does exactly that) rather than relying on local config.\n\nSo: +1 on `.gitattributes` covering `core/wordlist_english.txt` **and** `genesis/**`, and +1 on a Windows CI job\nthat runs `wallet create` and `verify-genesis --genesis-dir genesis/testnet-0005`; but note that (1) above\nstill fails on an LF tree, so the bundle hash expectation needs looking at separately.","created_at":"2026-10-26T02:01:30+00:00"},{"id":97,"source":"github","source_ref":"6567315979","author":"kenmungeneskar","team":false,"body":"**XE payout address for this report:** `b68f2b4d8a062d9219590f0c2d7753d783ec9f5d43d85a125230bb0f7a41a86e`\n\nLocally held key; the address is `sha256(\"xe/account/v1\" ‖ pubkey)` and does not depend on the network id, so the\nsame key yields the same address after a testnet wipe and at mainnet genesis.\n\nOne note on provenance, for the record while this is being triaged: PR #35 (\"Fixes #31\") is a third-party patch\nsubmitted against this report — I did not write it. Per the programme rules (\"One report per bug … Duplicate\nreports go to the first verifiable submission\"), the report is the submission, and the patch is welcome on its\nown merits; I'm flagging it only so the beneficiary for this finding is unambiguous, as happened in #101.","created_at":"2026-11-02T02:03:41+00:00"},{"id":659,"source":"github","source_ref":"6696108873","author":"Joseph Denne","team":true,"body":"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.","created_at":"2026-11-06T21:29:17+00:00"},{"id":1541,"source":"github","source_ref":"6730473503","author":"kenmungeneskar","team":false,"body":"Done — the payout address is now in the report body, at the top:\n\n`Payout address: b68f2b4d8a062d9219590f0c2d7753d783ec9f5d43d85a125230bb0f7a41a86e`\n\nOne clarification in case the desk wants a different representation: that is the full XE address as the protocol\nderives it, `sha256(\"xe/account/v1\" ‖ pubkey)` (64 hex chars, the same form the API returns from\n`/accounts/{address}/balance`). If the desk expects it written as `xe_…` (or as a desk key identity such as\n`xe:xxxxxxxx`), tell me the exact form and I will put that in the body instead — I would rather ask than guess at\na payout field. Same line has been added to my other two accepted reports (#30, #33) so they do not hit the same\nround trip when they reach this stage.","created_at":"2026-11-09T02:02:42+00:00"}]}