Skip to content

Commit 7ab8a01

Browse files
committed
Refactor BIP-39 wordlist scripts.
1 parent 1633a0e commit 7ab8a01

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

db/export-bip39-en.mjs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { readFileSync, writeFileSync } from "fs";
2+
import { resolve } from "./utils.mjs";
3+
4+
const words = readFileSync(resolve("lang-en.txt")).toString().trim().split("\n");
5+
if (words.length !== 2048) { throw new Error("bad list!"); }
6+
7+
const lines = [ ];
8+
lines.push("#ifndef __BIP39_EN_H__");
9+
lines.push("#define __BIP39_EN_H__");
10+
lines.push("");
11+
lines.push("#ifdef __cplusplus");
12+
lines.push('extern "C" {');
13+
lines.push("#endif /* __cplusplus */");
14+
lines.push("");
15+
16+
lines.push("const char* wordlist_en = ");
17+
for (let i = 0; i < words.length; i++) {
18+
lines.push(` "${ words[i] }\\0"`);
19+
}
20+
lines.push(" ;");
21+
22+
lines.push("");
23+
lines.push("#ifdef __cplusplus");
24+
lines.push("}");
25+
lines.push("#endif /* __cplusplus */");
26+
lines.push("");
27+
lines.push("#endif /* __BIP39_EN_H__ */");
28+
29+
writeFileSync(resolve("../src/bip39-en.h"), lines.join("\n"));
File renamed without changes.

src/bip39-en.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2060,4 +2060,4 @@ const char* wordlist_en =
20602060
}
20612061
#endif /* __cplusplus */
20622062

2063-
#endif /* __BIP39_EN_H__ */
2063+
#endif /* __BIP39_EN_H__ */

tools/generate-bip39-wordlist.mjs

-31
This file was deleted.

0 commit comments

Comments
 (0)