btc-quantum-check 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 btc-quantum-check contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,100 @@
1
- # Temporary Holding Version
1
+ # btc-quantum-check
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Check whether a Bitcoin address has its **public key exposed on-chain**.
4
+
5
+ A quantum computer running Shor's algorithm would need an address's public key to derive its private key. Most Bitcoin address types publish only a *hash* of the key, and the key itself appears on the blockchain the first time the address spends. This tool tells you which of your addresses are in which state.
6
+
7
+ **Try it in the browser: https://4slow.github.io/btc-quantum-check/**
8
+
9
+ It needs public addresses only. **Never enter a seed phrase or private key, here or anywhere.**
10
+
11
+ ## What it reports
12
+
13
+ | Result | Meaning |
14
+ |---|---|
15
+ | **Hidden** | Holds coins and has never spent. The public key is not on-chain. |
16
+ | **Exposed** | Has spent before and still holds coins (address reuse). The key is public. Move the coins to a fresh receive address. |
17
+ | **Exposed (spending now)** | The first spend is unconfirmed in the mempool, which already reveals the key. |
18
+ | **Exposed (Taproot)** | `bc1p…` addresses contain the public key itself. |
19
+ | **Empty** | Holds nothing now. Nothing to steal, whether or not the key was revealed. |
20
+ | **Never used** | No transactions at all. |
21
+
22
+ ## Use it
23
+
24
+ ### Web page
25
+
26
+ ```
27
+ npm start
28
+ ```
29
+
30
+ The hosted version is at https://4slow.github.io/btc-quantum-check/. To run it yourself, use the command above and open http://localhost:4173. The page is static (`index.html` plus `src/`) and has English and Hebrew.
31
+
32
+ ### Command line
33
+
34
+ Requires Node.js 20 or newer. No dependencies to install.
35
+
36
+ ```
37
+ node cli.js bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
38
+ node cli.js <address> <address> --json
39
+ node cli.js <address> --lang he
40
+ node cli.js <address> --api https://blockstream.info/api
41
+ ```
42
+
43
+ ### As a library
44
+
45
+ Not on npm yet. Until it is, install straight from GitHub:
46
+
47
+ ```
48
+ npm install github:4slow/btc-quantum-check
49
+ ```
50
+
51
+ ```js
52
+ import { checkAddress, checkAddresses, isExposed } from 'btc-quantum-check';
53
+
54
+ const result = await checkAddress('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');
55
+ // { ok: true, address, type: 'p2wpkh', status: 'empty', balanceSat: 0, txCount: 249, keyRevealed: true }
56
+
57
+ const results = await checkAddresses(myAddresses, { concurrency: 4 });
58
+ const atRisk = results.filter(isExposed);
59
+ ```
60
+
61
+ | Export | What it does |
62
+ |---|---|
63
+ | `checkAddress(address, options?)` | Looks one address up and classifies it. Never throws for bad input or network errors; check `result.ok`. |
64
+ | `checkAddresses(addresses, options?)` | Same for many addresses, in input order, with a `concurrency` limit. |
65
+ | `isExposed(result)` | `true` when coins sit behind an already-visible public key. |
66
+ | `parseAddress(address)` | Offline validation (Base58Check, Bech32, Bech32m) and address type. |
67
+ | `classify(type, stats)` | The pure rule: address type plus Esplora stats in, status out. Use it if you already have the data. |
68
+ | `MESSAGES` | English and Hebrew text for each status. |
69
+
70
+ Options: `apiBase` (any Esplora-compatible API, default mempool.space) and `fetchImpl`. TypeScript types are included. Works in Node 20+ and in browsers.
71
+
72
+ ## Limits you should know
73
+
74
+ - **"Hidden" is not "quantum-proof".** The key becomes visible the moment you spend, until the transaction confirms. No Bitcoin address is fully quantum-resistant until the network adopts post-quantum signatures.
75
+ - **It only sees this address's own history.** If the same key was revealed elsewhere (used in another address type, in an old pay-to-public-key output, or in a published signed message), the tool still says "Hidden". The genesis address `1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa` is an example: its key is public through the genesis block's pay-to-public-key output.
76
+ - **Script addresses** (`3…`, `bc1q…` with 62 characters) are treated like single-key addresses: revealed once spent. For multisig this is a simplification.
77
+ - **It checks addresses, not wallets.** A wallet spreads its balance over many addresses. Check each address that holds coins.
78
+ - **Mainnet only.**
79
+ - This is an educational tool, not financial or security advice.
80
+
81
+ ## Privacy
82
+
83
+ Each address you check is sent to a block explorer API to fetch its transaction counts. The default is [mempool.space](https://mempool.space); the operator can see which addresses you looked up, together with your IP address. To avoid that, point `--api` at your own [Esplora](https://github.com/Blockstream/esplora) or mempool instance. Nothing is stored by the tool.
84
+
85
+ ## How it decides
86
+
87
+ 1. Validate the address (Base58Check, Bech32, Bech32m) and read its type.
88
+ 2. Fetch `GET /address/<address>` from an Esplora-compatible API.
89
+ 3. Balance = funded − spent, confirmed plus mempool.
90
+ 4. Taproot with a balance is exposed. Otherwise, any spend (confirmed or pending) means the key is revealed; a balance on top of that means exposed.
91
+
92
+ The logic lives in [`src/exposure.js`](src/exposure.js) and is covered by `npm test`.
93
+
94
+ ## Contributing
95
+
96
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
97
+
98
+ ## License
99
+
100
+ MIT
package/cli.js ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ import { checkAddress, formatBtc, DEFAULT_API } from './src/exposure.js';
3
+ import { MESSAGES, EXPOSED } from './src/messages.js';
4
+
5
+ const HELP = `btc-quantum-check - is the public key of a Bitcoin address exposed on-chain?
6
+
7
+ Usage:
8
+ node cli.js <address> [address ...] [options]
9
+
10
+ Options:
11
+ --api <url> Esplora-compatible API base (default: ${DEFAULT_API})
12
+ --lang <en|he>
13
+ --json Machine-readable output
14
+ -h, --help
15
+
16
+ Only public addresses are ever needed. Never enter a seed phrase or private key.`;
17
+
18
+ const args = process.argv.slice(2);
19
+ const addresses = [];
20
+ let apiBase = DEFAULT_API, lang = 'en', json = false;
21
+
22
+ for (let i = 0; i < args.length; i++) {
23
+ const a = args[i];
24
+ if (a === '-h' || a === '--help') { console.log(HELP); process.exit(0); }
25
+ else if (a === '--json') json = true;
26
+ else if (a === '--api' || a === '--lang') {
27
+ const value = args[++i];
28
+ if (!value) { console.error(`${a} needs a value`); process.exit(1); }
29
+ if (a === '--api') apiBase = value; else lang = value;
30
+ }
31
+ else if (a.startsWith('-')) { console.error(`Unknown option: ${a}`); process.exit(1); }
32
+ else addresses.push(a);
33
+ }
34
+
35
+ if (addresses.length === 0) { console.log(HELP); process.exit(1); }
36
+ const t = MESSAGES[lang];
37
+ if (!t) { console.error(`Unknown language: ${lang}`); process.exit(1); }
38
+
39
+ const results = [];
40
+ for (const address of addresses) results.push(await checkAddress(address, { apiBase }));
41
+
42
+ if (json) {
43
+ console.log(JSON.stringify(results, null, 2));
44
+ } else {
45
+ for (const r of results) {
46
+ console.log(`\n${r.address}`);
47
+ if (!r.ok) {
48
+ console.log(` ! ${t.error[r.error] ?? r.error}${r.detail ? ` (${r.detail})` : ''}`);
49
+ continue;
50
+ }
51
+ const [title, text] = t.status[r.status];
52
+ const mark = EXPOSED.has(r.status) ? '[!!]' : r.status === 'hidden' ? '[ok]' : '[--]';
53
+ console.log(` ${mark} ${title} - ${t.type[r.type]}`);
54
+ console.log(` ${text}`);
55
+ if (r.status === 'empty' && r.keyRevealed) console.log(` ${t.keyWasRevealed}`);
56
+ console.log(` ${t.balance}: ${formatBtc(r.balanceSat)} BTC ${t.transactions}: ${r.txCount}`);
57
+ }
58
+ console.log('');
59
+ }
60
+
61
+ process.exitCode = results.some((r) => !r.ok) ? 1 : 0;
package/index.d.ts ADDED
@@ -0,0 +1,88 @@
1
+ export type AddressType = 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2wsh' | 'p2tr' | 'witness_unknown';
2
+
3
+ export type ExposureStatus =
4
+ | 'unused'
5
+ | 'empty'
6
+ | 'hidden'
7
+ | 'exposed_reused'
8
+ | 'exposed_pending'
9
+ | 'exposed_taproot'
10
+ | 'unknown_type';
11
+
12
+ export type AddressError = 'empty' | 'invalid_checksum' | 'unsupported' | 'api_error' | 'network_error';
13
+
14
+ export interface ParsedAddress {
15
+ ok: true;
16
+ /** Normalised address (bech32 is lowercased). */
17
+ address: string;
18
+ type: AddressType;
19
+ }
20
+
21
+ export interface FailedResult {
22
+ ok: false;
23
+ address: string;
24
+ error: AddressError;
25
+ detail?: string;
26
+ }
27
+
28
+ export interface Classification {
29
+ status: ExposureStatus;
30
+ /** Confirmed plus unconfirmed balance, in satoshis. */
31
+ balanceSat: number;
32
+ txCount: number;
33
+ /** Whether the public key is visible on-chain or in the mempool. */
34
+ keyRevealed: boolean;
35
+ }
36
+
37
+ export interface ExposureResult extends ParsedAddress, Classification {}
38
+
39
+ /** The `chain_stats` / `mempool_stats` object of an Esplora address response. */
40
+ export interface TxoStats {
41
+ funded_txo_count?: number;
42
+ funded_txo_sum?: number;
43
+ spent_txo_count?: number;
44
+ spent_txo_sum?: number;
45
+ tx_count?: number;
46
+ }
47
+
48
+ export interface AddressStats {
49
+ chain_stats?: TxoStats;
50
+ mempool_stats?: TxoStats;
51
+ }
52
+
53
+ export interface CheckOptions {
54
+ /** Esplora-compatible API base. Defaults to mempool.space. */
55
+ apiBase?: string;
56
+ fetchImpl?: typeof fetch;
57
+ }
58
+
59
+ export const DEFAULT_API: string;
60
+
61
+ /** Validate a mainnet address offline and report its type. */
62
+ export function parseAddress(raw: string): Promise<ParsedAddress | FailedResult>;
63
+
64
+ /** Classify from an address type and Esplora stats. No network access. */
65
+ export function classify(type: AddressType, stats: AddressStats | undefined): Classification;
66
+
67
+ /** Look an address up and classify it. Never throws for bad input or network errors. */
68
+ export function checkAddress(raw: string, options?: CheckOptions): Promise<ExposureResult | FailedResult>;
69
+
70
+ /** Check several addresses; results are in input order. */
71
+ export function checkAddresses(
72
+ addresses: Iterable<string>,
73
+ options?: CheckOptions & { concurrency?: number },
74
+ ): Promise<Array<ExposureResult | FailedResult>>;
75
+
76
+ /** True when coins sit behind a public key that is already visible. */
77
+ export function isExposed(result: ExposureResult | FailedResult | null | undefined): boolean;
78
+
79
+ export function formatBtc(sat: number): string;
80
+
81
+ export const MESSAGES: Record<'en' | 'he', {
82
+ status: Record<ExposureStatus, [title: string, text: string]>;
83
+ error: Record<AddressError, string>;
84
+ type: Record<AddressType, string>;
85
+ keyWasRevealed: string;
86
+ balance: string;
87
+ transactions: string;
88
+ }>;
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export {
2
+ DEFAULT_API,
3
+ parseAddress,
4
+ classify,
5
+ checkAddress,
6
+ checkAddresses,
7
+ isExposed,
8
+ formatBtc,
9
+ } from './src/exposure.js';
10
+ export { MESSAGES } from './src/messages.js';
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "btc-quantum-check",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Check whether a Bitcoin address has its public key exposed on-chain (quantum exposure). Library, CLI and web page. No dependencies.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "main": "./index.js",
8
+ "types": "./index.d.ts",
9
+ "exports": {
10
+ ".": { "types": "./index.d.ts", "default": "./index.js" }
11
+ },
12
+ "bin": { "btc-quantum-check": "cli.js" },
13
+ "files": ["index.js", "index.d.ts", "cli.js", "src"],
14
+ "sideEffects": false,
15
+ "engines": { "node": ">=20" },
16
+ "repository": { "type": "git", "url": "git+https://github.com/4slow/btc-quantum-check.git" },
17
+ "homepage": "https://4slow.github.io/btc-quantum-check/",
18
+ "bugs": "https://github.com/4slow/btc-quantum-check/issues",
19
+ "keywords": ["bitcoin", "quantum", "post-quantum", "address", "public-key", "p2pkh", "segwit", "taproot", "wallet", "security"],
20
+ "scripts": {
21
+ "test": "node --test",
22
+ "start": "node serve.js"
23
+ }
24
+ }
@@ -0,0 +1,188 @@
1
+ // Core logic: decide whether a Bitcoin address has its public key exposed on-chain.
2
+ // Works in Node 20+ and in browsers. No dependencies.
3
+
4
+ export const DEFAULT_API = 'https://mempool.space/api';
5
+
6
+ const BECH32_CHARSET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';
7
+ const BECH32_GEN = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3];
8
+ const BECH32_CONST = 1;
9
+ const BECH32M_CONST = 0x2bc830a3;
10
+ const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
11
+
12
+ function bech32Polymod(values) {
13
+ let chk = 1;
14
+ for (const v of values) {
15
+ const top = chk >>> 25;
16
+ chk = ((chk & 0x1ffffff) << 5) ^ v;
17
+ for (let i = 0; i < 5; i++) if ((top >>> i) & 1) chk ^= BECH32_GEN[i];
18
+ }
19
+ return chk >>> 0;
20
+ }
21
+
22
+ function decodeSegwit(input) {
23
+ if (input !== input.toLowerCase() && input !== input.toUpperCase()) return null;
24
+ const addr = input.toLowerCase();
25
+ if (!addr.startsWith('bc1') || addr.length < 14 || addr.length > 90) return null;
26
+ const data = [];
27
+ for (const ch of addr.slice(3)) {
28
+ const v = BECH32_CHARSET.indexOf(ch);
29
+ if (v === -1) return null;
30
+ data.push(v);
31
+ }
32
+ if (data.length < 7) return null;
33
+ // hrp "bc" expanded: high bits, separator, low bits
34
+ const check = bech32Polymod([3, 3, 0, 2, 3, ...data]);
35
+ const version = data[0];
36
+ const expected = version === 0 ? BECH32_CONST : BECH32M_CONST;
37
+ if (check !== expected || version > 16) return null;
38
+
39
+ // Convert the 5-bit groups (without version and checksum) to bytes.
40
+ let acc = 0, bits = 0, programLength = 0;
41
+ for (const v of data.slice(1, -6)) {
42
+ acc = (acc << 5) | v;
43
+ bits += 5;
44
+ while (bits >= 8) { bits -= 8; programLength++; acc &= (1 << bits) - 1; }
45
+ }
46
+ if (bits >= 5 || acc !== 0) return null;
47
+ if (programLength < 2 || programLength > 40) return null;
48
+ if (version === 0 && programLength !== 20 && programLength !== 32) return null;
49
+ return { version, programLength, normalized: addr };
50
+ }
51
+
52
+ async function sha256(bytes) {
53
+ return new Uint8Array(await globalThis.crypto.subtle.digest('SHA-256', bytes));
54
+ }
55
+
56
+ async function decodeBase58Check(addr) {
57
+ let n = 0n;
58
+ for (const ch of addr) {
59
+ const v = BASE58_ALPHABET.indexOf(ch);
60
+ if (v === -1) return null;
61
+ n = n * 58n + BigInt(v);
62
+ }
63
+ const bytes = [];
64
+ while (n > 0n) { bytes.unshift(Number(n & 0xffn)); n >>= 8n; }
65
+ for (const ch of addr) { if (ch === '1') bytes.unshift(0); else break; }
66
+ if (bytes.length !== 25) return null;
67
+ const payload = Uint8Array.from(bytes.slice(0, 21));
68
+ const digest = await sha256(await sha256(payload));
69
+ for (let i = 0; i < 4; i++) if (digest[i] !== bytes[21 + i]) return null;
70
+ return { versionByte: bytes[0] };
71
+ }
72
+
73
+ /**
74
+ * Validate a mainnet address and report its type.
75
+ * Returns { ok: true, address, type } or { ok: false, address, error }.
76
+ * Types: p2pkh, p2sh, p2wpkh, p2wsh, p2tr, witness_unknown.
77
+ */
78
+ export async function parseAddress(raw) {
79
+ const address = String(raw ?? '').trim();
80
+ if (!address) return { ok: false, address, error: 'empty' };
81
+
82
+ if (/^bc1/i.test(address)) {
83
+ const seg = decodeSegwit(address);
84
+ if (!seg) return { ok: false, address, error: 'invalid_checksum' };
85
+ let type = 'witness_unknown';
86
+ if (seg.version === 0) type = seg.programLength === 20 ? 'p2wpkh' : 'p2wsh';
87
+ else if (seg.version === 1 && seg.programLength === 32) type = 'p2tr';
88
+ return { ok: true, address: seg.normalized, type };
89
+ }
90
+
91
+ if (/^[13]/.test(address)) {
92
+ const decoded = await decodeBase58Check(address);
93
+ if (!decoded) return { ok: false, address, error: 'invalid_checksum' };
94
+ if (decoded.versionByte === 0x00) return { ok: true, address, type: 'p2pkh' };
95
+ if (decoded.versionByte === 0x05) return { ok: true, address, type: 'p2sh' };
96
+ return { ok: false, address, error: 'unsupported' };
97
+ }
98
+
99
+ return { ok: false, address, error: 'unsupported' };
100
+ }
101
+
102
+ /**
103
+ * Pure classification from address type + Esplora address stats.
104
+ *
105
+ * status:
106
+ * unused never received anything
107
+ * empty had activity, holds nothing now
108
+ * hidden holds coins, public key never revealed on-chain
109
+ * exposed_reused holds coins, and the address has spent before (key revealed)
110
+ * exposed_pending holds coins, first spend is waiting in the mempool (key revealed now)
111
+ * exposed_taproot holds coins in a Taproot output (key is in the address itself)
112
+ * unknown_type holds coins in a witness version this tool does not understand
113
+ */
114
+ export function classify(type, stats) {
115
+ const chain = stats?.chain_stats ?? {};
116
+ const mem = stats?.mempool_stats ?? {};
117
+ const num = (v) => (Number.isFinite(v) ? v : 0);
118
+
119
+ const balanceSat =
120
+ num(chain.funded_txo_sum) - num(chain.spent_txo_sum) +
121
+ num(mem.funded_txo_sum) - num(mem.spent_txo_sum);
122
+ const txCount = num(chain.tx_count) + num(mem.tx_count);
123
+ const spentConfirmed = num(chain.spent_txo_count) > 0;
124
+ const spentPending = num(mem.spent_txo_count) > 0;
125
+ const keyRevealed = type === 'p2tr' || spentConfirmed || spentPending;
126
+
127
+ let status;
128
+ if (txCount === 0) status = 'unused';
129
+ else if (balanceSat <= 0) status = 'empty';
130
+ else if (type === 'p2tr') status = 'exposed_taproot';
131
+ else if (type === 'witness_unknown') status = 'unknown_type';
132
+ else if (spentConfirmed) status = 'exposed_reused';
133
+ else if (spentPending) status = 'exposed_pending';
134
+ else status = 'hidden';
135
+
136
+ return { status, balanceSat, txCount, keyRevealed };
137
+ }
138
+
139
+ /**
140
+ * Look one address up on an Esplora-compatible API (mempool.space, blockstream.info,
141
+ * or your own node) and classify it.
142
+ */
143
+ export async function checkAddress(raw, { apiBase = DEFAULT_API, fetchImpl = globalThis.fetch } = {}) {
144
+ const parsed = await parseAddress(raw);
145
+ if (!parsed.ok) return parsed;
146
+
147
+ const url = `${apiBase.replace(/\/+$/, '')}/address/${parsed.address}`;
148
+ let stats;
149
+ try {
150
+ const res = await fetchImpl(url, { headers: { Accept: 'application/json' } });
151
+ if (!res.ok) return { ok: false, address: parsed.address, error: 'api_error', detail: `HTTP ${res.status}` };
152
+ stats = await res.json();
153
+ } catch (err) {
154
+ return { ok: false, address: parsed.address, error: 'network_error', detail: String(err?.message ?? err) };
155
+ }
156
+ return { ok: true, address: parsed.address, type: parsed.type, ...classify(parsed.type, stats) };
157
+ }
158
+
159
+ export function formatBtc(sat) {
160
+ const sign = sat < 0 ? '-' : '';
161
+ const abs = Math.abs(sat);
162
+ return `${sign}${Math.floor(abs / 1e8)}.${String(abs % 1e8).padStart(8, '0')}`;
163
+ }
164
+
165
+ /**
166
+ * Check several addresses, a few at a time. Results come back in input order.
167
+ * Duplicates are looked up once.
168
+ */
169
+ export async function checkAddresses(addresses, { concurrency = 4, ...options } = {}) {
170
+ const list = [...addresses];
171
+ const unique = [...new Set(list.map((a) => String(a ?? '').trim()))];
172
+ const byAddress = new Map();
173
+ let next = 0;
174
+ const worker = async () => {
175
+ while (next < unique.length) {
176
+ const address = unique[next++];
177
+ byAddress.set(address, await checkAddress(address, options));
178
+ }
179
+ };
180
+ const workers = Math.max(1, Math.min(concurrency, unique.length));
181
+ await Promise.all(Array.from({ length: workers }, worker));
182
+ return list.map((a) => byAddress.get(String(a ?? '').trim()));
183
+ }
184
+
185
+ /** True when the result means coins sit behind a public key that is already visible. */
186
+ export function isExposed(result) {
187
+ return Boolean(result?.ok) && ['exposed_reused', 'exposed_pending', 'exposed_taproot'].includes(result.status);
188
+ }
@@ -0,0 +1,50 @@
1
+ // User-facing text for each result, in English and Hebrew.
2
+
3
+ export const MESSAGES = {
4
+ en: {
5
+ status: {
6
+ unused: ['Never used', 'This address has never received anything. Nothing to protect.'],
7
+ empty: ['Empty', 'This address holds nothing now, so there is nothing to steal from it.'],
8
+ hidden: ['Hidden', 'The public key has never been revealed on-chain. It stays hidden until you spend from this address.'],
9
+ exposed_reused: ['Exposed', 'This address has spent before, so its public key is public, and it still holds coins. Move them to a fresh receive address.'],
10
+ exposed_pending: ['Exposed (spending now)', 'A spend from this address is waiting for confirmation, which reveals the public key. Any coins left here should go to a fresh address.'],
11
+ exposed_taproot: ['Exposed (Taproot)', 'Taproot addresses contain the public key itself, so it is visible even before any spend.'],
12
+ unknown_type: ['Unknown address type', 'This tool does not know how this address type handles its keys.'],
13
+ },
14
+ error: {
15
+ empty: 'No address given.',
16
+ invalid_checksum: 'Not a valid address. Check for a typo.',
17
+ unsupported: 'Only Bitcoin mainnet addresses (1…, 3…, bc1…) are supported.',
18
+ api_error: 'The block explorer returned an error.',
19
+ network_error: 'Could not reach the block explorer.',
20
+ },
21
+ type: { p2pkh: 'P2PKH (legacy)', p2sh: 'P2SH (script)', p2wpkh: 'P2WPKH (SegWit)', p2wsh: 'P2WSH (SegWit script)', p2tr: 'P2TR (Taproot)', witness_unknown: 'unknown witness version' },
22
+ keyWasRevealed: 'Its public key was revealed when it spent.',
23
+ balance: 'Balance',
24
+ transactions: 'Transactions',
25
+ },
26
+ he: {
27
+ status: {
28
+ unused: ['לא בשימוש', 'הכתובת הזו מעולם לא קיבלה דבר. אין על מה להגן.'],
29
+ empty: ['ריקה', 'אין בכתובת הזו כלום כרגע, ולכן אין מה לגנוב ממנה.'],
30
+ hidden: ['מוסתר', 'המפתח הציבורי מעולם לא נחשף בבלוקצ\'יין. הוא נשאר מוסתר עד שתשלחו מהכתובת הזו.'],
31
+ exposed_reused: ['חשוף', 'מהכתובת הזו כבר שלחו בעבר, כך שהמפתח הציבורי שלה גלוי, ועדיין יש בה מטבעות. העבירו אותם לכתובת קבלה חדשה.'],
32
+ exposed_pending: ['חשוף (שליחה בתהליך)', 'שליחה מהכתובת הזו ממתינה לאישור, והיא חושפת את המפתח הציבורי. מטבעות שנשארו כאן כדאי להעביר לכתובת חדשה.'],
33
+ exposed_taproot: ['חשוף (Taproot)', 'כתובות Taproot מכילות את המפתח הציבורי עצמו, ולכן הוא גלוי גם לפני שליחה.'],
34
+ unknown_type: ['סוג כתובת לא מוכר', 'הכלי לא יודע איך סוג הכתובת הזה מטפל במפתחות.'],
35
+ },
36
+ error: {
37
+ empty: 'לא הוזנה כתובת.',
38
+ invalid_checksum: 'הכתובת לא תקינה. בדקו אם יש שגיאת הקלדה.',
39
+ unsupported: 'נתמכות רק כתובות של רשת הביטקוין הראשית (1…, 3…, bc1…).',
40
+ api_error: 'סייר הבלוקים החזיר שגיאה.',
41
+ network_error: 'לא הצלחתי להגיע לסייר הבלוקים.',
42
+ },
43
+ type: { p2pkh: 'P2PKH (ישן)', p2sh: 'P2SH (סקריפט)', p2wpkh: 'P2WPKH (SegWit)', p2wsh: 'P2WSH (סקריפט SegWit)', p2tr: 'P2TR (Taproot)', witness_unknown: 'גרסת witness לא מוכרת' },
44
+ keyWasRevealed: 'המפתח הציבורי שלה נחשף כששלחו ממנה.',
45
+ balance: 'יתרה',
46
+ transactions: 'עסקאות',
47
+ },
48
+ };
49
+
50
+ export const EXPOSED = new Set(['exposed_reused', 'exposed_pending', 'exposed_taproot']);