@cogcoin/client 0.5.15 → 1.0.1
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/README.md +80 -25
- package/dist/app-paths.d.ts +5 -6
- package/dist/app-paths.js +8 -16
- package/dist/art/balance.txt +10 -0
- package/dist/art/welcome.txt +16 -0
- package/dist/bitcoind/bootstrap/controller.d.ts +1 -0
- package/dist/bitcoind/bootstrap/controller.js +53 -1
- package/dist/bitcoind/client/follow-block-times.d.ts +1 -0
- package/dist/bitcoind/client/follow-block-times.js +1 -1
- package/dist/bitcoind/client/internal-types.d.ts +7 -3
- package/dist/bitcoind/client/managed-client.d.ts +4 -2
- package/dist/bitcoind/client/managed-client.js +14 -0
- package/dist/bitcoind/client/sync-engine.js +72 -11
- package/dist/bitcoind/hash-order.d.ts +4 -0
- package/dist/bitcoind/hash-order.js +13 -0
- package/dist/bitcoind/indexer-daemon-main.js +11 -3
- package/dist/bitcoind/normalize.js +3 -2
- package/dist/bitcoind/processing-start-height.d.ts +5 -0
- package/dist/bitcoind/processing-start-height.js +7 -0
- package/dist/bitcoind/progress/constants.d.ts +4 -0
- package/dist/bitcoind/progress/constants.js +4 -0
- package/dist/bitcoind/progress/controller.d.ts +2 -1
- package/dist/bitcoind/progress/controller.js +3 -3
- package/dist/bitcoind/progress/follow-scene.d.ts +6 -2
- package/dist/bitcoind/progress/follow-scene.js +29 -6
- package/dist/bitcoind/progress/formatting.d.ts +1 -0
- package/dist/bitcoind/progress/formatting.js +6 -0
- package/dist/bitcoind/progress/train-scene.js +37 -18
- package/dist/bitcoind/progress/tty-renderer.d.ts +6 -1
- package/dist/bitcoind/progress/tty-renderer.js +8 -4
- package/dist/bitcoind/rpc.d.ts +2 -1
- package/dist/bitcoind/rpc.js +3 -0
- package/dist/bitcoind/types.d.ts +6 -0
- package/dist/bytes.d.ts +1 -0
- package/dist/bytes.js +3 -0
- package/dist/cli/art.d.ts +2 -0
- package/dist/cli/art.js +37 -0
- package/dist/cli/commands/client-admin.d.ts +2 -0
- package/dist/cli/commands/client-admin.js +91 -0
- package/dist/cli/commands/follow.js +0 -2
- package/dist/cli/commands/mining-admin.js +6 -47
- package/dist/cli/commands/mining-read.js +11 -50
- package/dist/cli/commands/mining-runtime.js +142 -5
- package/dist/cli/commands/service-runtime.js +0 -2
- package/dist/cli/commands/status.js +8 -2
- package/dist/cli/commands/sync.js +49 -92
- package/dist/cli/commands/wallet-admin.js +142 -136
- package/dist/cli/commands/wallet-mutation.js +91 -79
- package/dist/cli/commands/wallet-read.js +15 -18
- package/dist/cli/context.js +5 -14
- package/dist/cli/mining-format.d.ts +0 -1
- package/dist/cli/mining-format.js +5 -37
- package/dist/cli/mining-json.d.ts +0 -18
- package/dist/cli/mining-json.js +0 -35
- package/dist/cli/mutation-command-groups.d.ts +1 -2
- package/dist/cli/mutation-command-groups.js +0 -5
- package/dist/cli/mutation-json.d.ts +24 -145
- package/dist/cli/mutation-json.js +30 -136
- package/dist/cli/mutation-resolved-json.d.ts +0 -7
- package/dist/cli/mutation-resolved-json.js +4 -10
- package/dist/cli/mutation-success.d.ts +2 -0
- package/dist/cli/mutation-success.js +11 -1
- package/dist/cli/mutation-text-format.js +1 -3
- package/dist/cli/output.d.ts +1 -1
- package/dist/cli/output.js +254 -231
- package/dist/cli/parse.d.ts +1 -1
- package/dist/cli/parse.js +93 -122
- package/dist/cli/preview-json.d.ts +17 -120
- package/dist/cli/preview-json.js +14 -97
- package/dist/cli/prompt.js +8 -13
- package/dist/cli/read-json.d.ts +15 -37
- package/dist/cli/read-json.js +44 -140
- package/dist/cli/runner.js +10 -13
- package/dist/cli/sync-progress.d.ts +6 -0
- package/dist/cli/sync-progress.js +91 -0
- package/dist/cli/types.d.ts +9 -17
- package/dist/cli/types.js +0 -2
- package/dist/cli/wallet-format.d.ts +1 -0
- package/dist/cli/wallet-format.js +208 -144
- package/dist/cli/workflow-hints.d.ts +3 -3
- package/dist/cli/workflow-hints.js +11 -8
- package/dist/client/default-client.d.ts +3 -1
- package/dist/client/default-client.js +45 -2
- package/dist/client/factory.js +1 -1
- package/dist/client/initialization.js +23 -0
- package/dist/client/persistence.js +5 -5
- package/dist/client/store-adapter.js +1 -0
- package/dist/sqlite/checkpoints.d.ts +1 -0
- package/dist/sqlite/checkpoints.js +7 -0
- package/dist/sqlite/store.js +14 -1
- package/dist/types.d.ts +1 -0
- package/dist/wallet/coin-control.d.ts +41 -12
- package/dist/wallet/coin-control.js +100 -428
- package/dist/wallet/descriptor-normalization.d.ts +1 -3
- package/dist/wallet/descriptor-normalization.js +0 -16
- package/dist/wallet/lifecycle.d.ts +7 -99
- package/dist/wallet/lifecycle.js +513 -968
- package/dist/wallet/managed-core-wallet.d.ts +13 -0
- package/dist/wallet/managed-core-wallet.js +20 -0
- package/dist/wallet/mining/constants.d.ts +5 -12
- package/dist/wallet/mining/constants.js +5 -12
- package/dist/wallet/mining/control.d.ts +1 -13
- package/dist/wallet/mining/control.js +45 -349
- package/dist/wallet/mining/index.d.ts +4 -5
- package/dist/wallet/mining/index.js +2 -3
- package/dist/wallet/mining/runner.d.ts +123 -13
- package/dist/wallet/mining/runner.js +899 -511
- package/dist/wallet/mining/runtime-artifacts.js +23 -3
- package/dist/wallet/mining/sentence-protocol.d.ts +44 -0
- package/dist/wallet/mining/sentence-protocol.js +123 -0
- package/dist/wallet/mining/sentences.d.ts +4 -8
- package/dist/wallet/mining/sentences.js +3 -52
- package/dist/wallet/mining/state.d.ts +11 -6
- package/dist/wallet/mining/state.js +7 -6
- package/dist/wallet/mining/types.d.ts +2 -30
- package/dist/wallet/mining/visualizer.d.ts +31 -3
- package/dist/wallet/mining/visualizer.js +135 -13
- package/dist/wallet/read/context.d.ts +0 -2
- package/dist/wallet/read/context.js +119 -140
- package/dist/wallet/read/filter.js +2 -11
- package/dist/wallet/read/index.d.ts +1 -1
- package/dist/wallet/read/project.js +24 -77
- package/dist/wallet/read/types.d.ts +10 -25
- package/dist/wallet/reset.d.ts +0 -1
- package/dist/wallet/reset.js +60 -138
- package/dist/wallet/root-resolution.d.ts +1 -5
- package/dist/wallet/root-resolution.js +0 -18
- package/dist/wallet/runtime.d.ts +0 -6
- package/dist/wallet/runtime.js +0 -8
- package/dist/wallet/state/client-password-agent.js +208 -0
- package/dist/wallet/state/client-password.d.ts +65 -0
- package/dist/wallet/state/client-password.js +952 -0
- package/dist/wallet/state/crypto.d.ts +1 -20
- package/dist/wallet/state/crypto.js +0 -63
- package/dist/wallet/state/provider.d.ts +23 -11
- package/dist/wallet/state/provider.js +248 -290
- package/dist/wallet/state/storage.d.ts +2 -2
- package/dist/wallet/state/storage.js +48 -16
- package/dist/wallet/tx/anchor.d.ts +3 -28
- package/dist/wallet/tx/anchor.js +349 -1250
- package/dist/wallet/tx/bitcoin-transfer.d.ts +35 -0
- package/dist/wallet/tx/bitcoin-transfer.js +200 -0
- package/dist/wallet/tx/cog.d.ts +5 -1
- package/dist/wallet/tx/cog.js +149 -185
- package/dist/wallet/tx/common.d.ts +61 -8
- package/dist/wallet/tx/common.js +266 -146
- package/dist/wallet/tx/domain-admin.d.ts +3 -1
- package/dist/wallet/tx/domain-admin.js +61 -99
- package/dist/wallet/tx/domain-market.d.ts +5 -1
- package/dist/wallet/tx/domain-market.js +221 -228
- package/dist/wallet/tx/field.d.ts +4 -10
- package/dist/wallet/tx/field.js +83 -924
- package/dist/wallet/tx/identity-selector.d.ts +9 -3
- package/dist/wallet/tx/identity-selector.js +17 -35
- package/dist/wallet/tx/index.d.ts +3 -1
- package/dist/wallet/tx/index.js +2 -1
- package/dist/wallet/tx/register.d.ts +3 -1
- package/dist/wallet/tx/register.js +62 -220
- package/dist/wallet/tx/reputation.d.ts +3 -1
- package/dist/wallet/tx/reputation.js +58 -95
- package/dist/wallet/types.d.ts +8 -122
- package/package.json +5 -5
- package/dist/wallet/archive.d.ts +0 -4
- package/dist/wallet/archive.js +0 -41
- package/dist/wallet/mining/hook-protocol.d.ts +0 -47
- package/dist/wallet/mining/hook-protocol.js +0 -161
- package/dist/wallet/mining/hook-runner.js +0 -52
- package/dist/wallet/mining/hooks.d.ts +0 -38
- package/dist/wallet/mining/hooks.js +0 -520
- package/dist/wallet/state/explicit-lock.d.ts +0 -4
- package/dist/wallet/state/explicit-lock.js +0 -19
- package/dist/wallet/state/session.d.ts +0 -12
- package/dist/wallet/state/session.js +0 -23
- /package/dist/wallet/{mining/hook-runner.d.ts → state/client-password-agent.d.ts} +0 -0
|
@@ -1,11 +1,46 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { writeJsonFileAtomic } from "../fs/atomic.js";
|
|
3
3
|
import { normalizeWalletStateRecord } from "../coin-control.js";
|
|
4
|
-
import {
|
|
4
|
+
import { decryptJsonWithSecretProvider, encryptJsonWithSecretProvider, } from "./crypto.js";
|
|
5
5
|
async function readEnvelope(path) {
|
|
6
6
|
const raw = await readFile(path, "utf8");
|
|
7
7
|
return JSON.parse(raw);
|
|
8
8
|
}
|
|
9
|
+
function serializeWalletState(state) {
|
|
10
|
+
return {
|
|
11
|
+
schemaVersion: 5,
|
|
12
|
+
stateRevision: state.stateRevision,
|
|
13
|
+
lastWrittenAtUnixMs: state.lastWrittenAtUnixMs,
|
|
14
|
+
walletRootId: state.walletRootId,
|
|
15
|
+
network: state.network,
|
|
16
|
+
localScriptPubKeyHexes: state.localScriptPubKeyHexes,
|
|
17
|
+
mnemonic: state.mnemonic,
|
|
18
|
+
keys: state.keys,
|
|
19
|
+
descriptor: state.descriptor,
|
|
20
|
+
funding: state.funding,
|
|
21
|
+
walletBirthTime: state.walletBirthTime,
|
|
22
|
+
managedCoreWallet: {
|
|
23
|
+
walletName: state.managedCoreWallet.walletName,
|
|
24
|
+
internalPassphrase: state.managedCoreWallet.internalPassphrase,
|
|
25
|
+
descriptorChecksum: state.managedCoreWallet.descriptorChecksum,
|
|
26
|
+
walletAddress: state.managedCoreWallet.walletAddress,
|
|
27
|
+
walletScriptPubKeyHex: state.managedCoreWallet.walletScriptPubKeyHex,
|
|
28
|
+
proofStatus: state.managedCoreWallet.proofStatus,
|
|
29
|
+
lastImportedAtUnixMs: state.managedCoreWallet.lastImportedAtUnixMs,
|
|
30
|
+
lastVerifiedAtUnixMs: state.managedCoreWallet.lastVerifiedAtUnixMs,
|
|
31
|
+
},
|
|
32
|
+
domains: state.domains.map((domain) => ({
|
|
33
|
+
name: domain.name,
|
|
34
|
+
domainId: domain.domainId,
|
|
35
|
+
currentOwnerScriptPubKeyHex: domain.currentOwnerScriptPubKeyHex,
|
|
36
|
+
canonicalChainStatus: domain.canonicalChainStatus,
|
|
37
|
+
foundingMessageText: domain.foundingMessageText,
|
|
38
|
+
birthTime: domain.birthTime,
|
|
39
|
+
})),
|
|
40
|
+
miningState: state.miningState,
|
|
41
|
+
pendingMutations: state.pendingMutations,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
9
44
|
export async function loadRawWalletStateEnvelope(paths) {
|
|
10
45
|
try {
|
|
11
46
|
return {
|
|
@@ -43,6 +78,12 @@ export function extractWalletRootIdHintFromWalletStateEnvelope(envelope) {
|
|
|
43
78
|
}
|
|
44
79
|
return keyId.slice(prefix.length);
|
|
45
80
|
}
|
|
81
|
+
async function loadWalletStateEnvelope(envelope, access) {
|
|
82
|
+
if (envelope.secretProvider == null) {
|
|
83
|
+
throw new Error("wallet_state_legacy_envelope_unsupported");
|
|
84
|
+
}
|
|
85
|
+
return normalizeWalletStateRecord(await decryptJsonWithSecretProvider(envelope, access.provider));
|
|
86
|
+
}
|
|
46
87
|
export async function saveWalletState(paths, state, access) {
|
|
47
88
|
let previousPrimary = null;
|
|
48
89
|
try {
|
|
@@ -56,15 +97,10 @@ export async function saveWalletState(paths, state, access) {
|
|
|
56
97
|
throw error;
|
|
57
98
|
}
|
|
58
99
|
}
|
|
59
|
-
const envelope =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
64
|
-
: await encryptJsonWithSecretProvider(state, access.provider, access.secretReference, {
|
|
65
|
-
format: "cogcoin-local-wallet-state",
|
|
66
|
-
walletRootIdHint: state.walletRootId,
|
|
67
|
-
});
|
|
100
|
+
const envelope = await encryptJsonWithSecretProvider(serializeWalletState(state), access.provider, access.secretReference, {
|
|
101
|
+
format: "cogcoin-local-wallet-state",
|
|
102
|
+
walletRootIdHint: state.walletRootId,
|
|
103
|
+
});
|
|
68
104
|
await writeJsonFileAtomic(paths.primaryPath, envelope, { mode: 0o600 });
|
|
69
105
|
if (previousPrimary !== null) {
|
|
70
106
|
await writeJsonFileAtomic(paths.backupPath, previousPrimary, { mode: 0o600 });
|
|
@@ -74,18 +110,14 @@ export async function loadWalletState(paths, access) {
|
|
|
74
110
|
try {
|
|
75
111
|
return {
|
|
76
112
|
source: "primary",
|
|
77
|
-
state:
|
|
78
|
-
? await decryptJsonWithPassphrase(await readEnvelope(paths.primaryPath), access)
|
|
79
|
-
: await decryptJsonWithSecretProvider(await readEnvelope(paths.primaryPath), access.provider)),
|
|
113
|
+
state: await loadWalletStateEnvelope(await readEnvelope(paths.primaryPath), access),
|
|
80
114
|
};
|
|
81
115
|
}
|
|
82
116
|
catch (primaryError) {
|
|
83
117
|
try {
|
|
84
118
|
return {
|
|
85
119
|
source: "backup",
|
|
86
|
-
state:
|
|
87
|
-
? await decryptJsonWithPassphrase(await readEnvelope(paths.backupPath), access)
|
|
88
|
-
: await decryptJsonWithSecretProvider(await readEnvelope(paths.backupPath), access.provider)),
|
|
120
|
+
state: await loadWalletStateEnvelope(await readEnvelope(paths.backupPath), access),
|
|
89
121
|
};
|
|
90
122
|
}
|
|
91
123
|
catch {
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { attachOrStartManagedBitcoindService } from "../../bitcoind/service.js";
|
|
2
2
|
import { createRpcClient } from "../../bitcoind/node.js";
|
|
3
|
-
import type { RpcTransaction } from "../../bitcoind/types.js";
|
|
4
3
|
import type { WalletPrompter } from "../lifecycle.js";
|
|
5
4
|
import { type WalletRuntimePaths } from "../runtime.js";
|
|
6
5
|
import { type WalletSecretProvider } from "../state/provider.js";
|
|
7
|
-
import type { ProactiveFamilyStateRecord } from "../types.js";
|
|
8
6
|
import { openWalletReadContext } from "../read/index.js";
|
|
9
|
-
import { type WalletMutationRpcClient } from "./common.js";
|
|
7
|
+
import { type WalletMutationFeeSummary, type WalletMutationRpcClient } from "./common.js";
|
|
10
8
|
interface WalletAnchorRpcClient extends WalletMutationRpcClient {
|
|
11
9
|
getBlockchainInfo(): Promise<{
|
|
12
10
|
blocks: number;
|
|
13
11
|
}>;
|
|
14
12
|
sendRawTransaction(hex: string): Promise<string>;
|
|
15
13
|
getRawMempool(): Promise<string[]>;
|
|
16
|
-
getRawTransaction(txid: string, verbose?: boolean): Promise<RpcTransaction>;
|
|
17
14
|
}
|
|
18
15
|
export interface AnchorDomainOptions {
|
|
19
16
|
domainName: string;
|
|
20
17
|
foundingMessageText?: string | null;
|
|
21
18
|
promptForFoundingMessageWhenMissing?: boolean;
|
|
19
|
+
feeRateSatVb?: number | null;
|
|
22
20
|
dataDir: string;
|
|
23
21
|
databasePath: string;
|
|
24
22
|
provider?: WalletSecretProvider;
|
|
@@ -32,33 +30,10 @@ export interface AnchorDomainOptions {
|
|
|
32
30
|
export interface AnchorDomainResult {
|
|
33
31
|
domainName: string;
|
|
34
32
|
txid: string;
|
|
35
|
-
tx1Txid: string;
|
|
36
|
-
tx2Txid: string;
|
|
37
|
-
dedicatedIndex: number;
|
|
38
33
|
status: "live" | "confirmed";
|
|
39
34
|
reusedExisting: boolean;
|
|
40
35
|
foundingMessageText?: string | null;
|
|
41
|
-
|
|
42
|
-
export interface ClearPendingAnchorOptions {
|
|
43
|
-
domainName: string;
|
|
44
|
-
dataDir: string;
|
|
45
|
-
databasePath: string;
|
|
46
|
-
provider?: WalletSecretProvider;
|
|
47
|
-
prompter: WalletPrompter;
|
|
48
|
-
assumeYes?: boolean;
|
|
49
|
-
nowUnixMs?: number;
|
|
50
|
-
paths?: WalletRuntimePaths;
|
|
51
|
-
openReadContext?: typeof openWalletReadContext;
|
|
52
|
-
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
53
|
-
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => WalletAnchorRpcClient;
|
|
54
|
-
}
|
|
55
|
-
export interface ClearPendingAnchorResult {
|
|
56
|
-
domainName: string;
|
|
57
|
-
cleared: boolean;
|
|
58
|
-
previousFamilyStatus: ProactiveFamilyStateRecord["status"] | null;
|
|
59
|
-
previousFamilyStep: ProactiveFamilyStateRecord["currentStep"] | null;
|
|
60
|
-
releasedDedicatedIndex: number | null;
|
|
36
|
+
fees: WalletMutationFeeSummary;
|
|
61
37
|
}
|
|
62
38
|
export declare function anchorDomain(options: AnchorDomainOptions): Promise<AnchorDomainResult>;
|
|
63
|
-
export declare function clearPendingAnchor(options: ClearPendingAnchorOptions): Promise<ClearPendingAnchorResult>;
|
|
64
39
|
export {};
|