@cogcoin/client 0.5.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 +21 -0
- package/README.md +136 -0
- package/dist/app-paths.d.ts +38 -0
- package/dist/app-paths.js +121 -0
- package/dist/art/banner.txt +13 -0
- package/dist/art/scroll.txt +13 -0
- package/dist/art/train-car.txt +6 -0
- package/dist/art/train-smoke.txt +6 -0
- package/dist/art/train.txt +6 -0
- package/dist/bitcoind/bootstrap/chainstate.d.ts +4 -0
- package/dist/bitcoind/bootstrap/chainstate.js +13 -0
- package/dist/bitcoind/bootstrap/constants.d.ts +7 -0
- package/dist/bitcoind/bootstrap/constants.js +12 -0
- package/dist/bitcoind/bootstrap/controller.d.ts +29 -0
- package/dist/bitcoind/bootstrap/controller.js +101 -0
- package/dist/bitcoind/bootstrap/download.d.ts +2 -0
- package/dist/bitcoind/bootstrap/download.js +196 -0
- package/dist/bitcoind/bootstrap/headers.d.ts +13 -0
- package/dist/bitcoind/bootstrap/headers.js +61 -0
- package/dist/bitcoind/bootstrap/paths.d.ts +4 -0
- package/dist/bitcoind/bootstrap/paths.js +15 -0
- package/dist/bitcoind/bootstrap/snapshot-file.d.ts +7 -0
- package/dist/bitcoind/bootstrap/snapshot-file.js +42 -0
- package/dist/bitcoind/bootstrap/state.d.ts +40 -0
- package/dist/bitcoind/bootstrap/state.js +70 -0
- package/dist/bitcoind/bootstrap/types.d.ts +28 -0
- package/dist/bitcoind/bootstrap/types.js +1 -0
- package/dist/bitcoind/bootstrap.d.ts +8 -0
- package/dist/bitcoind/bootstrap.js +7 -0
- package/dist/bitcoind/client/factory.d.ts +3 -0
- package/dist/bitcoind/client/factory.js +57 -0
- package/dist/bitcoind/client/follow-block-times.d.ts +8 -0
- package/dist/bitcoind/client/follow-block-times.js +25 -0
- package/dist/bitcoind/client/follow-loop.d.ts +10 -0
- package/dist/bitcoind/client/follow-loop.js +57 -0
- package/dist/bitcoind/client/internal-types.d.ts +63 -0
- package/dist/bitcoind/client/internal-types.js +18 -0
- package/dist/bitcoind/client/managed-client.d.ts +20 -0
- package/dist/bitcoind/client/managed-client.js +197 -0
- package/dist/bitcoind/client/rate-tracker.d.ts +2 -0
- package/dist/bitcoind/client/rate-tracker.js +24 -0
- package/dist/bitcoind/client/sync-engine.d.ts +3 -0
- package/dist/bitcoind/client/sync-engine.js +143 -0
- package/dist/bitcoind/client.d.ts +1 -0
- package/dist/bitcoind/client.js +1 -0
- package/dist/bitcoind/errors.d.ts +1 -0
- package/dist/bitcoind/errors.js +49 -0
- package/dist/bitcoind/index.d.ts +2 -0
- package/dist/bitcoind/index.js +1 -0
- package/dist/bitcoind/indexer-daemon-main.d.ts +1 -0
- package/dist/bitcoind/indexer-daemon-main.js +472 -0
- package/dist/bitcoind/indexer-daemon.d.ts +107 -0
- package/dist/bitcoind/indexer-daemon.js +391 -0
- package/dist/bitcoind/node.d.ts +8 -0
- package/dist/bitcoind/node.js +219 -0
- package/dist/bitcoind/normalize.d.ts +3 -0
- package/dist/bitcoind/normalize.js +47 -0
- package/dist/bitcoind/progress/assets.d.ts +10 -0
- package/dist/bitcoind/progress/assets.js +90 -0
- package/dist/bitcoind/progress/constants.d.ts +48 -0
- package/dist/bitcoind/progress/constants.js +53 -0
- package/dist/bitcoind/progress/controller.d.ts +28 -0
- package/dist/bitcoind/progress/controller.js +188 -0
- package/dist/bitcoind/progress/follow-scene.d.ts +40 -0
- package/dist/bitcoind/progress/follow-scene.js +367 -0
- package/dist/bitcoind/progress/formatting.d.ts +23 -0
- package/dist/bitcoind/progress/formatting.js +227 -0
- package/dist/bitcoind/progress/quote-scene.d.ts +4 -0
- package/dist/bitcoind/progress/quote-scene.js +137 -0
- package/dist/bitcoind/progress/train-scene.d.ts +9 -0
- package/dist/bitcoind/progress/train-scene.js +92 -0
- package/dist/bitcoind/progress/tty-renderer.d.ts +18 -0
- package/dist/bitcoind/progress/tty-renderer.js +150 -0
- package/dist/bitcoind/progress.d.ts +7 -0
- package/dist/bitcoind/progress.js +7 -0
- package/dist/bitcoind/quotes.d.ts +24 -0
- package/dist/bitcoind/quotes.js +195 -0
- package/dist/bitcoind/rpc.d.ts +71 -0
- package/dist/bitcoind/rpc.js +322 -0
- package/dist/bitcoind/service-paths.d.ts +19 -0
- package/dist/bitcoind/service-paths.js +49 -0
- package/dist/bitcoind/service.d.ts +40 -0
- package/dist/bitcoind/service.js +735 -0
- package/dist/bitcoind/testing.d.ts +9 -0
- package/dist/bitcoind/testing.js +9 -0
- package/dist/bitcoind/types.d.ts +396 -0
- package/dist/bitcoind/types.js +3 -0
- package/dist/bytes.d.ts +9 -0
- package/dist/bytes.js +36 -0
- package/dist/cli/commands/follow.d.ts +2 -0
- package/dist/cli/commands/follow.js +43 -0
- package/dist/cli/commands/mining-admin.d.ts +2 -0
- package/dist/cli/commands/mining-admin.js +92 -0
- package/dist/cli/commands/mining-read.d.ts +2 -0
- package/dist/cli/commands/mining-read.js +173 -0
- package/dist/cli/commands/mining-runtime.d.ts +2 -0
- package/dist/cli/commands/mining-runtime.js +108 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.js +31 -0
- package/dist/cli/commands/sync.d.ts +2 -0
- package/dist/cli/commands/sync.js +52 -0
- package/dist/cli/commands/wallet-admin.d.ts +2 -0
- package/dist/cli/commands/wallet-admin.js +175 -0
- package/dist/cli/commands/wallet-mutation.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation.js +681 -0
- package/dist/cli/commands/wallet-read.d.ts +2 -0
- package/dist/cli/commands/wallet-read.js +265 -0
- package/dist/cli/context.d.ts +3 -0
- package/dist/cli/context.js +75 -0
- package/dist/cli/io.d.ts +3 -0
- package/dist/cli/io.js +12 -0
- package/dist/cli/mining-format.d.ts +5 -0
- package/dist/cli/mining-format.js +156 -0
- package/dist/cli/mining-json.d.ts +49 -0
- package/dist/cli/mining-json.js +89 -0
- package/dist/cli/mutation-command-groups.d.ts +15 -0
- package/dist/cli/mutation-command-groups.js +71 -0
- package/dist/cli/mutation-json.d.ts +430 -0
- package/dist/cli/mutation-json.js +311 -0
- package/dist/cli/mutation-resolved-json.d.ts +124 -0
- package/dist/cli/mutation-resolved-json.js +129 -0
- package/dist/cli/mutation-success.d.ts +20 -0
- package/dist/cli/mutation-success.js +47 -0
- package/dist/cli/mutation-text-format.d.ts +22 -0
- package/dist/cli/mutation-text-format.js +171 -0
- package/dist/cli/mutation-text-write.d.ts +13 -0
- package/dist/cli/mutation-text-write.js +16 -0
- package/dist/cli/output.d.ts +185 -0
- package/dist/cli/output.js +1085 -0
- package/dist/cli/parse.d.ts +3 -0
- package/dist/cli/parse.js +971 -0
- package/dist/cli/preview-json.d.ts +416 -0
- package/dist/cli/preview-json.js +293 -0
- package/dist/cli/prompt.d.ts +3 -0
- package/dist/cli/prompt.js +33 -0
- package/dist/cli/read-json.d.ts +187 -0
- package/dist/cli/read-json.js +675 -0
- package/dist/cli/runner.d.ts +2 -0
- package/dist/cli/runner.js +129 -0
- package/dist/cli/signals.d.ts +3 -0
- package/dist/cli/signals.js +63 -0
- package/dist/cli/status-format.d.ts +2 -0
- package/dist/cli/status-format.js +48 -0
- package/dist/cli/types.d.ts +148 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/wallet-format.d.ts +29 -0
- package/dist/cli/wallet-format.js +637 -0
- package/dist/cli/workflow-hints.d.ts +13 -0
- package/dist/cli/workflow-hints.js +94 -0
- package/dist/cli-runner.d.ts +3 -0
- package/dist/cli-runner.js +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6 -0
- package/dist/client/default-client.d.ts +11 -0
- package/dist/client/default-client.js +118 -0
- package/dist/client/factory.d.ts +2 -0
- package/dist/client/factory.js +15 -0
- package/dist/client/initialization.d.ts +6 -0
- package/dist/client/initialization.js +30 -0
- package/dist/client/persistence.d.ts +5 -0
- package/dist/client/persistence.js +28 -0
- package/dist/client/store-adapter.d.ts +3 -0
- package/dist/client/store-adapter.js +20 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/passive-status.d.ts +36 -0
- package/dist/passive-status.js +100 -0
- package/dist/sqlite/better-sqlite3.d.ts +26 -0
- package/dist/sqlite/better-sqlite3.js +4 -0
- package/dist/sqlite/checkpoints.d.ts +11 -0
- package/dist/sqlite/checkpoints.js +27 -0
- package/dist/sqlite/driver.d.ts +17 -0
- package/dist/sqlite/driver.js +98 -0
- package/dist/sqlite/index.d.ts +4 -0
- package/dist/sqlite/index.js +9 -0
- package/dist/sqlite/migrate.d.ts +2 -0
- package/dist/sqlite/migrate.js +37 -0
- package/dist/sqlite/store.d.ts +3 -0
- package/dist/sqlite/store.js +122 -0
- package/dist/sqlite/tip-meta.d.ts +26 -0
- package/dist/sqlite/tip-meta.js +97 -0
- package/dist/sqlite/types.d.ts +10 -0
- package/dist/sqlite/types.js +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.js +1 -0
- package/dist/wallet/archive.d.ts +4 -0
- package/dist/wallet/archive.js +39 -0
- package/dist/wallet/cogop/constants.d.ts +32 -0
- package/dist/wallet/cogop/constants.js +32 -0
- package/dist/wallet/cogop/index.d.ts +32 -0
- package/dist/wallet/cogop/index.js +213 -0
- package/dist/wallet/cogop/numeric.d.ts +3 -0
- package/dist/wallet/cogop/numeric.js +24 -0
- package/dist/wallet/cogop/scriptpubkey.d.ts +2 -0
- package/dist/wallet/cogop/scriptpubkey.js +13 -0
- package/dist/wallet/cogop/validate-name.d.ts +2 -0
- package/dist/wallet/cogop/validate-name.js +18 -0
- package/dist/wallet/fs/atomic.d.ts +6 -0
- package/dist/wallet/fs/atomic.js +46 -0
- package/dist/wallet/fs/lock.d.ts +19 -0
- package/dist/wallet/fs/lock.js +61 -0
- package/dist/wallet/fs/status-file.d.ts +1 -0
- package/dist/wallet/fs/status-file.js +4 -0
- package/dist/wallet/lifecycle.d.ts +193 -0
- package/dist/wallet/lifecycle.js +1475 -0
- package/dist/wallet/material.d.ts +45 -0
- package/dist/wallet/material.js +118 -0
- package/dist/wallet/mining/config.d.ts +18 -0
- package/dist/wallet/mining/config.js +44 -0
- package/dist/wallet/mining/constants.d.ts +24 -0
- package/dist/wallet/mining/constants.js +24 -0
- package/dist/wallet/mining/control.d.ts +53 -0
- package/dist/wallet/mining/control.js +758 -0
- package/dist/wallet/mining/coordination.d.ts +40 -0
- package/dist/wallet/mining/coordination.js +121 -0
- package/dist/wallet/mining/hook-protocol.d.ts +47 -0
- package/dist/wallet/mining/hook-protocol.js +161 -0
- package/dist/wallet/mining/hook-runner.d.ts +1 -0
- package/dist/wallet/mining/hook-runner.js +52 -0
- package/dist/wallet/mining/hooks.d.ts +38 -0
- package/dist/wallet/mining/hooks.js +520 -0
- package/dist/wallet/mining/index.d.ts +8 -0
- package/dist/wallet/mining/index.js +6 -0
- package/dist/wallet/mining/runner.d.ts +155 -0
- package/dist/wallet/mining/runner.js +2574 -0
- package/dist/wallet/mining/runtime-artifacts.d.ts +17 -0
- package/dist/wallet/mining/runtime-artifacts.js +166 -0
- package/dist/wallet/mining/sentences.d.ts +23 -0
- package/dist/wallet/mining/sentences.js +281 -0
- package/dist/wallet/mining/state.d.ts +9 -0
- package/dist/wallet/mining/state.js +75 -0
- package/dist/wallet/mining/types.d.ts +141 -0
- package/dist/wallet/mining/types.js +1 -0
- package/dist/wallet/mining/visualizer.d.ts +19 -0
- package/dist/wallet/mining/visualizer.js +134 -0
- package/dist/wallet/mining/worker-main.d.ts +1 -0
- package/dist/wallet/mining/worker-main.js +17 -0
- package/dist/wallet/read/context.d.ts +20 -0
- package/dist/wallet/read/context.js +532 -0
- package/dist/wallet/read/filter.d.ts +9 -0
- package/dist/wallet/read/filter.js +42 -0
- package/dist/wallet/read/index.d.ts +4 -0
- package/dist/wallet/read/index.js +3 -0
- package/dist/wallet/read/project.d.ts +11 -0
- package/dist/wallet/read/project.js +300 -0
- package/dist/wallet/read/types.d.ts +144 -0
- package/dist/wallet/read/types.js +1 -0
- package/dist/wallet/runtime.d.ts +26 -0
- package/dist/wallet/runtime.js +28 -0
- package/dist/wallet/state/crypto.d.ts +31 -0
- package/dist/wallet/state/crypto.js +127 -0
- package/dist/wallet/state/provider.d.ts +37 -0
- package/dist/wallet/state/provider.js +312 -0
- package/dist/wallet/state/session.d.ts +12 -0
- package/dist/wallet/state/session.js +23 -0
- package/dist/wallet/state/storage.d.ts +19 -0
- package/dist/wallet/state/storage.js +55 -0
- package/dist/wallet/tx/anchor.d.ts +40 -0
- package/dist/wallet/tx/anchor.js +1210 -0
- package/dist/wallet/tx/cog.d.ts +92 -0
- package/dist/wallet/tx/cog.js +1055 -0
- package/dist/wallet/tx/common.d.ts +89 -0
- package/dist/wallet/tx/common.js +156 -0
- package/dist/wallet/tx/confirm.d.ts +15 -0
- package/dist/wallet/tx/confirm.js +24 -0
- package/dist/wallet/tx/domain-admin.d.ts +105 -0
- package/dist/wallet/tx/domain-admin.js +869 -0
- package/dist/wallet/tx/domain-market.d.ts +112 -0
- package/dist/wallet/tx/domain-market.js +1365 -0
- package/dist/wallet/tx/field.d.ts +101 -0
- package/dist/wallet/tx/field.js +1853 -0
- package/dist/wallet/tx/identity-selector.d.ts +12 -0
- package/dist/wallet/tx/identity-selector.js +52 -0
- package/dist/wallet/tx/index.d.ts +7 -0
- package/dist/wallet/tx/index.js +7 -0
- package/dist/wallet/tx/journal.d.ts +5 -0
- package/dist/wallet/tx/journal.js +31 -0
- package/dist/wallet/tx/register.d.ts +68 -0
- package/dist/wallet/tx/register.js +952 -0
- package/dist/wallet/tx/reputation.d.ts +72 -0
- package/dist/wallet/tx/reputation.js +693 -0
- package/dist/wallet/tx/targets.d.ts +7 -0
- package/dist/wallet/tx/targets.js +122 -0
- package/dist/wallet/types.d.ts +249 -0
- package/dist/wallet/types.js +1 -0
- package/dist/writing_quotes.json +1654 -0
- package/package.json +78 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface NormalizedBtcTarget {
|
|
2
|
+
scriptPubKeyHex: string;
|
|
3
|
+
address: string | null;
|
|
4
|
+
opaque: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function renderScriptPubKeyAsAddress(scriptPubKeyHex: string): string | null;
|
|
7
|
+
export declare function normalizeBtcTarget(target: string): NormalizedBtcTarget;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { base58, bech32, bech32m } from "@scure/base";
|
|
3
|
+
import { validateExternalScriptPubKey } from "../cogop/index.js";
|
|
4
|
+
const BASE58CHECK_P2PKH_MAINNET = 0x00;
|
|
5
|
+
const BASE58CHECK_P2SH_MAINNET = 0x05;
|
|
6
|
+
const BECH32_HRP_MAINNET = "bc";
|
|
7
|
+
function sha256(value) {
|
|
8
|
+
return createHash("sha256").update(value).digest();
|
|
9
|
+
}
|
|
10
|
+
function checksum4(value) {
|
|
11
|
+
return sha256(sha256(value)).subarray(0, 4);
|
|
12
|
+
}
|
|
13
|
+
function encodeBase58Check(version, payload) {
|
|
14
|
+
const body = Buffer.concat([Buffer.from([version]), Buffer.from(payload)]);
|
|
15
|
+
return base58.encode(Buffer.concat([body, Buffer.from(checksum4(body))]));
|
|
16
|
+
}
|
|
17
|
+
function decodeBase58Check(value) {
|
|
18
|
+
const decoded = Buffer.from(base58.decode(value));
|
|
19
|
+
if (decoded.length < 5) {
|
|
20
|
+
throw new Error("wallet_target_invalid_address");
|
|
21
|
+
}
|
|
22
|
+
const body = decoded.subarray(0, decoded.length - 4);
|
|
23
|
+
const actualChecksum = decoded.subarray(decoded.length - 4);
|
|
24
|
+
const expectedChecksum = checksum4(body);
|
|
25
|
+
if (!Buffer.from(expectedChecksum).equals(actualChecksum)) {
|
|
26
|
+
throw new Error("wallet_target_invalid_address");
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
version: body[0],
|
|
30
|
+
payload: body.subarray(1),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function encodeWitnessAddress(version, program) {
|
|
34
|
+
const words = [version, ...bech32.toWords(program)];
|
|
35
|
+
return version === 0
|
|
36
|
+
? bech32.encode(BECH32_HRP_MAINNET, words)
|
|
37
|
+
: bech32m.encode(BECH32_HRP_MAINNET, words);
|
|
38
|
+
}
|
|
39
|
+
function buildWitnessScript(version, program) {
|
|
40
|
+
const versionOpcode = version === 0 ? 0x00 : 0x50 + version;
|
|
41
|
+
return Buffer.concat([Buffer.from([versionOpcode, program.length]), Buffer.from(program)]).toString("hex");
|
|
42
|
+
}
|
|
43
|
+
function tryDecodeWitnessAddress(value) {
|
|
44
|
+
for (const codec of [bech32, bech32m]) {
|
|
45
|
+
try {
|
|
46
|
+
const decoded = codec.decode(value);
|
|
47
|
+
if (decoded.prefix !== BECH32_HRP_MAINNET || decoded.words.length === 0) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const version = decoded.words[0];
|
|
51
|
+
const program = Buffer.from(codec.fromWords(decoded.words.slice(1)));
|
|
52
|
+
if (version < 0 || version > 16 || program.length < 2 || program.length > 40) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (version === 0 && program.length !== 20 && program.length !== 32) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
return buildWitnessScript(version, program);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
function decodeAddressToScriptPubKeyHex(address) {
|
|
67
|
+
const witnessScriptHex = tryDecodeWitnessAddress(address);
|
|
68
|
+
if (witnessScriptHex !== null) {
|
|
69
|
+
return witnessScriptHex;
|
|
70
|
+
}
|
|
71
|
+
const decoded = decodeBase58Check(address);
|
|
72
|
+
if (decoded.version === BASE58CHECK_P2PKH_MAINNET && decoded.payload.length === 20) {
|
|
73
|
+
return `76a914${Buffer.from(decoded.payload).toString("hex")}88ac`;
|
|
74
|
+
}
|
|
75
|
+
if (decoded.version === BASE58CHECK_P2SH_MAINNET && decoded.payload.length === 20) {
|
|
76
|
+
return `a914${Buffer.from(decoded.payload).toString("hex")}87`;
|
|
77
|
+
}
|
|
78
|
+
throw new Error("wallet_target_invalid_address");
|
|
79
|
+
}
|
|
80
|
+
export function renderScriptPubKeyAsAddress(scriptPubKeyHex) {
|
|
81
|
+
if (/^0014[0-9a-f]{40}$/i.test(scriptPubKeyHex)) {
|
|
82
|
+
return encodeWitnessAddress(0, Buffer.from(scriptPubKeyHex.slice(4), "hex"));
|
|
83
|
+
}
|
|
84
|
+
if (/^0020[0-9a-f]{64}$/i.test(scriptPubKeyHex)) {
|
|
85
|
+
return encodeWitnessAddress(0, Buffer.from(scriptPubKeyHex.slice(4), "hex"));
|
|
86
|
+
}
|
|
87
|
+
if (/^5120[0-9a-f]{64}$/i.test(scriptPubKeyHex)) {
|
|
88
|
+
return encodeWitnessAddress(1, Buffer.from(scriptPubKeyHex.slice(4), "hex"));
|
|
89
|
+
}
|
|
90
|
+
if (/^76a914[0-9a-f]{40}88ac$/i.test(scriptPubKeyHex)) {
|
|
91
|
+
return encodeBase58Check(BASE58CHECK_P2PKH_MAINNET, Buffer.from(scriptPubKeyHex.slice(6, -4), "hex"));
|
|
92
|
+
}
|
|
93
|
+
if (/^a914[0-9a-f]{40}87$/i.test(scriptPubKeyHex)) {
|
|
94
|
+
return encodeBase58Check(BASE58CHECK_P2SH_MAINNET, Buffer.from(scriptPubKeyHex.slice(4, -2), "hex"));
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
export function normalizeBtcTarget(target) {
|
|
99
|
+
const trimmed = target.trim();
|
|
100
|
+
if (trimmed === "") {
|
|
101
|
+
throw new Error("wallet_target_missing");
|
|
102
|
+
}
|
|
103
|
+
if (trimmed.startsWith("spk:")) {
|
|
104
|
+
const scriptPubKeyHex = trimmed.slice(4).toLowerCase();
|
|
105
|
+
if (!/^[0-9a-f]+$/.test(scriptPubKeyHex) || scriptPubKeyHex.length % 2 !== 0) {
|
|
106
|
+
throw new Error("wallet_target_invalid_script");
|
|
107
|
+
}
|
|
108
|
+
validateExternalScriptPubKey(Buffer.from(scriptPubKeyHex, "hex"));
|
|
109
|
+
return {
|
|
110
|
+
scriptPubKeyHex,
|
|
111
|
+
address: renderScriptPubKeyAsAddress(scriptPubKeyHex),
|
|
112
|
+
opaque: renderScriptPubKeyAsAddress(scriptPubKeyHex) === null,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const scriptPubKeyHex = decodeAddressToScriptPubKeyHex(trimmed).toLowerCase();
|
|
116
|
+
validateExternalScriptPubKey(Buffer.from(scriptPubKeyHex, "hex"));
|
|
117
|
+
return {
|
|
118
|
+
scriptPubKeyHex,
|
|
119
|
+
address: trimmed,
|
|
120
|
+
opaque: false,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
export type WalletNetwork = "mainnet";
|
|
2
|
+
export type ScriptPubKeyHex = string;
|
|
3
|
+
export type WalletMnemonicLanguage = "english";
|
|
4
|
+
export interface OutpointRecord {
|
|
5
|
+
txid: string;
|
|
6
|
+
vout: number;
|
|
7
|
+
}
|
|
8
|
+
export type PendingMutationStatus = "draft" | "broadcasting" | "broadcast-unknown" | "live" | "confirmed" | "canceled" | "repair-required";
|
|
9
|
+
export interface PendingMutationRecord {
|
|
10
|
+
mutationId: string;
|
|
11
|
+
kind: "register" | "transfer" | "sell" | "buy" | "rep-give" | "rep-revoke" | "send" | "lock" | "claim" | "field-create" | "field-set" | "field-clear" | "endpoint" | "delegate" | "miner" | "canonical";
|
|
12
|
+
registerKind?: "root" | "subdomain";
|
|
13
|
+
domainName: string;
|
|
14
|
+
parentDomainName: string | null;
|
|
15
|
+
senderScriptPubKeyHex: ScriptPubKeyHex;
|
|
16
|
+
senderLocalIndex: number | null;
|
|
17
|
+
recipientScriptPubKeyHex?: ScriptPubKeyHex | null;
|
|
18
|
+
endpointValueHex?: string | null;
|
|
19
|
+
priceCogtoshi?: bigint | null;
|
|
20
|
+
amountCogtoshi?: bigint | null;
|
|
21
|
+
recipientDomainName?: string | null;
|
|
22
|
+
reviewPayloadHex?: string | null;
|
|
23
|
+
timeoutHeight?: number | null;
|
|
24
|
+
conditionHex?: string | null;
|
|
25
|
+
lockId?: number | null;
|
|
26
|
+
preimageHex?: string | null;
|
|
27
|
+
fieldName?: string | null;
|
|
28
|
+
fieldId?: number | null;
|
|
29
|
+
fieldPermanent?: boolean | null;
|
|
30
|
+
fieldFormat?: number | null;
|
|
31
|
+
fieldValueHex?: string | null;
|
|
32
|
+
intentFingerprintHex: string;
|
|
33
|
+
status: PendingMutationStatus;
|
|
34
|
+
createdAtUnixMs: number;
|
|
35
|
+
lastUpdatedAtUnixMs: number;
|
|
36
|
+
attemptedTxid: string | null;
|
|
37
|
+
attemptedWtxid: string | null;
|
|
38
|
+
temporaryBuilderLockedOutpoints: OutpointRecord[];
|
|
39
|
+
}
|
|
40
|
+
export interface LocalIdentityRecord {
|
|
41
|
+
index: number;
|
|
42
|
+
scriptPubKeyHex: ScriptPubKeyHex;
|
|
43
|
+
address: string | null;
|
|
44
|
+
status: "funding" | "dedicated" | "read-only";
|
|
45
|
+
assignedDomainNames: string[];
|
|
46
|
+
}
|
|
47
|
+
export interface DomainRecord {
|
|
48
|
+
name: string;
|
|
49
|
+
domainId: number | null;
|
|
50
|
+
dedicatedIndex: number | null;
|
|
51
|
+
currentOwnerScriptPubKeyHex: ScriptPubKeyHex | null;
|
|
52
|
+
currentOwnerLocalIndex: number | null;
|
|
53
|
+
canonicalChainStatus: "unknown" | "registered-unanchored" | "anchored";
|
|
54
|
+
localAnchorIntent: "none" | "reserved" | "tx1-live" | "tx2-live" | "repair-required";
|
|
55
|
+
currentCanonicalAnchorOutpoint: {
|
|
56
|
+
txid: string;
|
|
57
|
+
vout: number;
|
|
58
|
+
valueSats: number;
|
|
59
|
+
} | null;
|
|
60
|
+
foundingMessageText: string | null;
|
|
61
|
+
birthTime: number | null;
|
|
62
|
+
}
|
|
63
|
+
export interface HookClientStateRecord {
|
|
64
|
+
mode: "builtin" | "custom" | "disabled";
|
|
65
|
+
validationState: "unknown" | "validated" | "stale" | "failed" | "never" | "current";
|
|
66
|
+
lastValidationAtUnixMs: number | null;
|
|
67
|
+
lastValidationError: string | null;
|
|
68
|
+
validatedLaunchFingerprint: string | null;
|
|
69
|
+
validatedFullFingerprint: string | null;
|
|
70
|
+
fullTrustWarningAcknowledgedAtUnixMs: number | null;
|
|
71
|
+
consecutiveFailureCount: number;
|
|
72
|
+
cooldownUntilUnixMs: number | null;
|
|
73
|
+
}
|
|
74
|
+
export interface MiningStateRecord {
|
|
75
|
+
runMode: "stopped" | "foreground" | "background";
|
|
76
|
+
state: "idle" | "live" | "paused" | "paused-stale" | "repair-required";
|
|
77
|
+
pauseReason: string | null;
|
|
78
|
+
currentPublishState: "none" | "broadcasting" | "broadcast-unknown" | "in-mempool";
|
|
79
|
+
currentDomain: string | null;
|
|
80
|
+
currentDomainId: number | null;
|
|
81
|
+
currentDomainIndex: number | null;
|
|
82
|
+
currentSenderScriptPubKeyHex: ScriptPubKeyHex | null;
|
|
83
|
+
currentTxid: string | null;
|
|
84
|
+
currentWtxid: string | null;
|
|
85
|
+
currentFeeRateSatVb: number | null;
|
|
86
|
+
currentAbsoluteFeeSats: number | null;
|
|
87
|
+
currentScore: string | null;
|
|
88
|
+
currentSentence: string | null;
|
|
89
|
+
currentEncodedSentenceBytesHex: string | null;
|
|
90
|
+
currentBip39WordIndices: number[] | null;
|
|
91
|
+
currentBlendSeedHex: string | null;
|
|
92
|
+
currentBlockTargetHeight: number | null;
|
|
93
|
+
currentReferencedBlockHashDisplay: string | null;
|
|
94
|
+
currentIntentFingerprintHex: string | null;
|
|
95
|
+
liveMiningFamilyInMempool: boolean | null;
|
|
96
|
+
currentPublishDecision: string | null;
|
|
97
|
+
replacementCount: number;
|
|
98
|
+
currentBlockFeeSpentSats: string;
|
|
99
|
+
sessionFeeSpentSats: string;
|
|
100
|
+
lifetimeFeeSpentSats: string;
|
|
101
|
+
sharedMiningConflictOutpoint: {
|
|
102
|
+
txid: string;
|
|
103
|
+
vout: number;
|
|
104
|
+
} | null;
|
|
105
|
+
}
|
|
106
|
+
export interface ProactiveFamilyTransactionRecord {
|
|
107
|
+
status: "draft" | "broadcasting" | "broadcast-unknown" | "live" | "confirmed" | "canceled" | "repair-required";
|
|
108
|
+
attemptedTxid: string | null;
|
|
109
|
+
attemptedWtxid: string | null;
|
|
110
|
+
temporaryBuilderLockedOutpoints: OutpointRecord[];
|
|
111
|
+
rawHex: string | null;
|
|
112
|
+
}
|
|
113
|
+
export interface ProactiveFamilyStateRecord {
|
|
114
|
+
familyId: string;
|
|
115
|
+
type: "anchor" | "field" | string;
|
|
116
|
+
status: "draft" | "broadcasting" | "broadcast-unknown" | "live" | "confirmed" | "canceled" | "repair-required";
|
|
117
|
+
intentFingerprintHex: string;
|
|
118
|
+
createdAtUnixMs: number;
|
|
119
|
+
lastUpdatedAtUnixMs?: number;
|
|
120
|
+
domainName?: string | null;
|
|
121
|
+
domainId?: number | null;
|
|
122
|
+
sourceSenderLocalIndex?: number | null;
|
|
123
|
+
sourceSenderScriptPubKeyHex?: ScriptPubKeyHex | null;
|
|
124
|
+
reservedDedicatedIndex?: number | null;
|
|
125
|
+
reservedScriptPubKeyHex?: ScriptPubKeyHex | null;
|
|
126
|
+
foundingMessageText?: string | null;
|
|
127
|
+
foundingMessagePayloadHex?: string | null;
|
|
128
|
+
listingCancelCommitted?: boolean;
|
|
129
|
+
fieldName?: string | null;
|
|
130
|
+
expectedFieldId?: number | null;
|
|
131
|
+
fieldPermanent?: boolean | null;
|
|
132
|
+
fieldFormat?: number | null;
|
|
133
|
+
fieldValueHex?: string | null;
|
|
134
|
+
currentStep?: "reserved" | "tx1" | "tx2" | null;
|
|
135
|
+
tx1?: ProactiveFamilyTransactionRecord | null;
|
|
136
|
+
tx2?: ProactiveFamilyTransactionRecord | null;
|
|
137
|
+
}
|
|
138
|
+
export interface WalletStateV1 {
|
|
139
|
+
schemaVersion: 1;
|
|
140
|
+
stateRevision: number;
|
|
141
|
+
lastWrittenAtUnixMs: number;
|
|
142
|
+
walletRootId: string;
|
|
143
|
+
network: WalletNetwork;
|
|
144
|
+
anchorValueSats: number;
|
|
145
|
+
nextDedicatedIndex: number;
|
|
146
|
+
fundingIndex: 0;
|
|
147
|
+
mnemonic: {
|
|
148
|
+
phrase: string;
|
|
149
|
+
language: WalletMnemonicLanguage;
|
|
150
|
+
};
|
|
151
|
+
keys: {
|
|
152
|
+
masterFingerprintHex: string;
|
|
153
|
+
accountPath: string;
|
|
154
|
+
accountXprv: string;
|
|
155
|
+
accountXpub: string;
|
|
156
|
+
};
|
|
157
|
+
descriptor: {
|
|
158
|
+
privateExternal: string;
|
|
159
|
+
publicExternal: string;
|
|
160
|
+
checksum: string | null;
|
|
161
|
+
rangeEnd: number;
|
|
162
|
+
safetyMargin: number;
|
|
163
|
+
};
|
|
164
|
+
funding: {
|
|
165
|
+
address: string;
|
|
166
|
+
scriptPubKeyHex: ScriptPubKeyHex;
|
|
167
|
+
};
|
|
168
|
+
walletBirthTime: number;
|
|
169
|
+
managedCoreWallet: {
|
|
170
|
+
walletName: string;
|
|
171
|
+
internalPassphrase: string;
|
|
172
|
+
descriptorChecksum: string | null;
|
|
173
|
+
fundingAddress0: string | null;
|
|
174
|
+
fundingScriptPubKeyHex0: ScriptPubKeyHex | null;
|
|
175
|
+
proofStatus: "not-proven" | "ready" | "missing" | "mismatch";
|
|
176
|
+
lastImportedAtUnixMs: number | null;
|
|
177
|
+
lastVerifiedAtUnixMs: number | null;
|
|
178
|
+
};
|
|
179
|
+
identities: LocalIdentityRecord[];
|
|
180
|
+
domains: DomainRecord[];
|
|
181
|
+
miningState: MiningStateRecord;
|
|
182
|
+
hookClientState: {
|
|
183
|
+
mining: HookClientStateRecord;
|
|
184
|
+
};
|
|
185
|
+
proactiveFamilies: ProactiveFamilyStateRecord[];
|
|
186
|
+
pendingMutations?: PendingMutationRecord[];
|
|
187
|
+
}
|
|
188
|
+
export interface PortableWalletArchivePayloadV1 {
|
|
189
|
+
schemaVersion: 1;
|
|
190
|
+
exportedAtUnixMs: number;
|
|
191
|
+
walletRootId: string;
|
|
192
|
+
network: WalletNetwork;
|
|
193
|
+
anchorValueSats: number;
|
|
194
|
+
nextDedicatedIndex: number;
|
|
195
|
+
fundingIndex: 0;
|
|
196
|
+
mnemonic: {
|
|
197
|
+
phrase: string;
|
|
198
|
+
language: WalletMnemonicLanguage;
|
|
199
|
+
};
|
|
200
|
+
expected: {
|
|
201
|
+
masterFingerprintHex: string;
|
|
202
|
+
accountPath: string;
|
|
203
|
+
accountXpub: string;
|
|
204
|
+
publicExternalDescriptor: string;
|
|
205
|
+
descriptorChecksum: string | null;
|
|
206
|
+
rangeEnd: number;
|
|
207
|
+
safetyMargin: number;
|
|
208
|
+
fundingAddress0: string;
|
|
209
|
+
fundingScriptPubKeyHex0: ScriptPubKeyHex;
|
|
210
|
+
walletBirthTime: number;
|
|
211
|
+
};
|
|
212
|
+
identities: LocalIdentityRecord[];
|
|
213
|
+
domains: DomainRecord[];
|
|
214
|
+
miningState: MiningStateRecord;
|
|
215
|
+
hookClientState: {
|
|
216
|
+
mining: HookClientStateRecord;
|
|
217
|
+
};
|
|
218
|
+
proactiveFamilies: ProactiveFamilyStateRecord[];
|
|
219
|
+
}
|
|
220
|
+
export interface Argon2EnvelopeParams {
|
|
221
|
+
name: "argon2id";
|
|
222
|
+
memoryKib: number;
|
|
223
|
+
iterations: number;
|
|
224
|
+
parallelism: number;
|
|
225
|
+
salt: string;
|
|
226
|
+
}
|
|
227
|
+
export interface EncryptedEnvelopeV1 {
|
|
228
|
+
format: string;
|
|
229
|
+
version: 1;
|
|
230
|
+
cipher: "aes-256-gcm";
|
|
231
|
+
wrappedBy: string;
|
|
232
|
+
argon2id?: Argon2EnvelopeParams | null;
|
|
233
|
+
secretProvider?: {
|
|
234
|
+
kind: string;
|
|
235
|
+
keyId: string;
|
|
236
|
+
} | null;
|
|
237
|
+
nonce: string;
|
|
238
|
+
tag: string;
|
|
239
|
+
ciphertext: string;
|
|
240
|
+
}
|
|
241
|
+
export interface UnlockSessionStateV1 {
|
|
242
|
+
schemaVersion: 1;
|
|
243
|
+
walletRootId: string;
|
|
244
|
+
sessionId: string;
|
|
245
|
+
createdAtUnixMs: number;
|
|
246
|
+
unlockUntilUnixMs: number;
|
|
247
|
+
sourceStateRevision: number;
|
|
248
|
+
wrappedSessionKeyMaterial: string;
|
|
249
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|