diff options
| author | Bitflash <btf01@proton.me> | 2026-07-30 12:06:08 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-30 12:06:08 -0300 |
| commit | b539d776bd86df9224d97048f26f33d2750d1c92 (patch) | |
| tree | 4a246ca7c8680e0b2d32613e388116a5d39247cf /README.md | |
| parent | daac46893448e49a21244d9646acf0ec47518537 (diff) | |
wallet: export and import keys as text (#49)
The last door out. Everything else assumes Berkeley DB will
cooperate. When it will not -- a build that cannot read the
file, a truncation, an environment past recovering -- the keys
are usually still perfectly intact and were unreachable
anyway. #40 is one person's account of exactly that, and #46
only rescues the cases where BDB still opens the file at all.
bitflash -dumpwallet=keys.txt
bitflash -importwallet=keys.txt
One key per line with its address and label. No database, no
environment, no version coupling: anything that can read a
line can recover from it.
The format is the DER private key in hex, which round-trips
exactly through SetPrivKey. Not interchangeable with other
wallets -- worth having eventually, but a WIF encoder I got
subtly wrong would be worse than no encoder at all, and this
file exists for the case where nothing else works.
Care taken, because the failure modes here cost money:
- Refuses to overwrite an existing file. A mistyped path
must not eat the only copy of something irreplaceable.
- Written owner-only on POSIX, before any key reaches it.
Windows inherits the folder's ACL; the README says so
rather than pretending otherwise.
- Newlines in labels are flattened, so a label cannot forge
an extra entry on read-back.
- Import skips keys already present, so running it twice
does nothing, and one unreadable line is reported and
stepped over instead of costing the reader every other key
in the file.
Verified on Linux and Windows: a key exported from one wallet
imports into a different one and its address then appears
there; re-importing adds nothing; a corrupted line is skipped
while the rest still load; the dump is 0600 and refuses to
overwrite.
This does not solve #47. Keys still are not derived from a
seed, so a dump is as much a snapshot as any other backup.
What it does is make the keys reachable no matter what state
the database is in.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 24 |
1 files changed, 24 insertions, 0 deletions
| @@ -98,6 +98,30 @@ The second point is the pre-BIP32 problem that deterministic wallets were | |||
| 98 | invented to solve; see [#47](https://github.com/Bitflash-sh/bitflash/issues/47). | 98 | invented to solve; see [#47](https://github.com/Bitflash-sh/bitflash/issues/47). |
| 99 | Until that lands, repetition is the only defence. | 99 | Until that lands, repetition is the only defence. |
| 100 | 100 | ||
| 101 | ### When wallet.dat itself will not open | ||
| 102 | |||
| 103 | Everything above still runs through Berkeley DB. If the database is the thing | ||
| 104 | that is broken — a build that will not read it, a file truncated by a bad copy, | ||
| 105 | an environment beyond recovery — the keys are usually still fine, and you can | ||
| 106 | take them out as text: | ||
| 107 | |||
| 108 | ``` | ||
| 109 | bitflash -dumpwallet=/path/to/keys.txt | ||
| 110 | bitflash -importwallet=/path/to/keys.txt # into any wallet, on any machine | ||
| 111 | ``` | ||
| 112 | |||
| 113 | One key per line with its address and label, no database and no environment. | ||
| 114 | Importing skips keys the wallet already holds, so running it twice is safe, and | ||
| 115 | an unreadable line is reported and stepped over rather than abandoning the rest. | ||
| 116 | Restart the node afterwards so it scans the chain for transactions belonging to | ||
| 117 | the new keys. | ||
| 118 | |||
| 119 | **The dump is your private keys in the clear.** Anyone who reads that file can | ||
| 120 | spend those coins. It is written owner-only on Linux and macOS; on Windows it | ||
| 121 | inherits whatever the containing folder allows, so choose the folder carefully. | ||
| 122 | Move it somewhere safe and delete the copy. `-dumpwallet` will not overwrite an | ||
| 123 | existing file. | ||
| 124 | |||
| 101 | --- | 125 | --- |
| 102 | 126 | ||
| 103 | ## Mining | 127 | ## Mining |