@cogcoin/client 1.0.2 → 1.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/README.md +3 -2
- package/dist/bitcoind/client/factory.d.ts +0 -8
- package/dist/bitcoind/client/factory.js +1 -59
- package/dist/bitcoind/client/managed-client.d.ts +1 -3
- package/dist/bitcoind/client/managed-client.js +3 -47
- package/dist/bitcoind/indexer-daemon-main.js +173 -28
- package/dist/bitcoind/indexer-daemon.d.ts +11 -3
- package/dist/bitcoind/indexer-daemon.js +123 -57
- package/dist/bitcoind/indexer-monitor.d.ts +12 -0
- package/dist/bitcoind/indexer-monitor.js +89 -0
- package/dist/bitcoind/progress/follow-scene.d.ts +7 -1
- package/dist/bitcoind/progress/follow-scene.js +87 -4
- package/dist/bitcoind/progress/tty-renderer.d.ts +2 -0
- package/dist/bitcoind/progress/tty-renderer.js +2 -0
- package/dist/bitcoind/testing.d.ts +0 -1
- package/dist/bitcoind/testing.js +0 -1
- package/dist/bitcoind/types.d.ts +5 -2
- package/dist/cli/commands/follow.js +44 -49
- package/dist/cli/commands/mining-admin.js +56 -2
- package/dist/cli/commands/mining-read.js +43 -3
- package/dist/cli/commands/mining-runtime.js +91 -73
- package/dist/cli/commands/service-runtime.js +42 -2
- package/dist/cli/commands/status.js +3 -1
- package/dist/cli/commands/sync.js +50 -90
- package/dist/cli/commands/wallet-admin.js +21 -3
- package/dist/cli/commands/wallet-read.js +2 -0
- package/dist/cli/context.js +5 -1
- package/dist/cli/managed-indexer-observer.d.ts +33 -0
- package/dist/cli/managed-indexer-observer.js +163 -0
- package/dist/cli/mining-format.d.ts +3 -1
- package/dist/cli/mining-format.js +35 -0
- package/dist/cli/mining-json.d.ts +11 -1
- package/dist/cli/mining-json.js +9 -0
- package/dist/cli/output.js +24 -0
- package/dist/cli/parse.d.ts +1 -1
- package/dist/cli/parse.js +23 -0
- package/dist/cli/read-json.d.ts +13 -1
- package/dist/cli/read-json.js +31 -0
- package/dist/cli/runner.js +4 -2
- package/dist/cli/signals.d.ts +12 -0
- package/dist/cli/signals.js +31 -13
- package/dist/cli/types.d.ts +8 -4
- package/dist/cli/update-service.d.ts +2 -12
- package/dist/cli/update-service.js +2 -68
- package/dist/semver.d.ts +12 -0
- package/dist/semver.js +68 -0
- package/dist/wallet/lifecycle.js +0 -6
- package/dist/wallet/mining/config.js +54 -3
- package/dist/wallet/mining/control.d.ts +5 -2
- package/dist/wallet/mining/control.js +153 -34
- package/dist/wallet/mining/domain-prompts.d.ts +17 -0
- package/dist/wallet/mining/domain-prompts.js +130 -0
- package/dist/wallet/mining/index.d.ts +2 -1
- package/dist/wallet/mining/index.js +1 -0
- package/dist/wallet/mining/runner.d.ts +58 -2
- package/dist/wallet/mining/runner.js +553 -331
- package/dist/wallet/mining/sentence-protocol.d.ts +1 -0
- package/dist/wallet/mining/sentences.js +7 -4
- package/dist/wallet/mining/types.d.ts +26 -0
- package/dist/wallet/mining/visualizer.d.ts +3 -0
- package/dist/wallet/mining/visualizer.js +106 -12
- package/dist/wallet/read/context.d.ts +1 -0
- package/dist/wallet/read/context.js +15 -10
- package/dist/wallet/reset.js +0 -1
- package/dist/wallet/state/client-password-agent.js +4 -1
- package/dist/wallet/state/client-password.js +15 -8
- package/dist/wallet/tx/anchor.js +0 -1
- package/dist/wallet/tx/bitcoin-transfer.js +0 -1
- package/dist/wallet/tx/cog.js +0 -3
- package/dist/wallet/tx/common.js +1 -1
- package/dist/wallet/tx/domain-admin.js +0 -1
- package/dist/wallet/tx/domain-market.js +0 -3
- package/dist/wallet/tx/field.js +0 -1
- package/dist/wallet/tx/register.js +0 -1
- package/dist/wallet/tx/reputation.js +0 -1
- package/package.json +1 -1
package/dist/cli/parse.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ParsedCliArgs } from "./types.js";
|
|
2
|
-
export declare const HELP_TEXT = "Usage: cogcoin <command> [options]\n\nCommands:\n status Show wallet-aware local service and chain status\n status --output json Emit the stable v1 machine-readable status envelope\n update Show the current and latest client versions and install updates\n update --output json Emit the stable v1 machine-readable update result envelope\n client unlock Unlock password-protected local wallet secrets for a limited time\n client lock Flush the cached client password unlock session\n client change-password Rotate the client password that protects local wallet secrets\n bitcoin start Start the managed Bitcoin daemon\n bitcoin stop Stop the managed Bitcoin daemon and paired indexer\n bitcoin status Show managed Bitcoin daemon status without starting it\n bitcoin transfer <sats> --to <address>\n Send plain BTC from the wallet address\n indexer start Start the managed Cogcoin indexer (and bitcoind if needed)\n indexer stop Stop the managed Cogcoin indexer only\n indexer status Show managed Cogcoin indexer status without starting it\n init Initialize a new local wallet root\n init --output json Emit the stable v1 machine-readable init result envelope\n restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n reset Factory-reset local Cogcoin state with interactive retention prompts\n repair Recover bounded wallet/indexer/runtime state\n wallet address Alias for address\n wallet ids Alias for ids\n mine Run the miner in the foreground\n mine start Start the miner as a background worker\n mine stop Stop the active background miner\n mine setup Configure the built-in mining provider\n mine setup --output json\n Emit the stable v1 machine-readable mine setup result envelope\n mine status Show mining control-plane health and readiness\n mine log Show recent mining control-plane events\n anchor <domain> Anchor an owned unanchored domain with the wallet address\n register <domain>\n Register a root domain or subdomain\n transfer <domain> --to <btc-target>\n Transfer an unanchored domain to another BTC address or script\n sell <domain> <price> List an unanchored domain for sale in COG\n unsell <domain> Clear an active domain listing\n buy <domain>\n Buy an unanchored listed domain in COG\n send <amount> --to <btc-target>\n Send COG from the wallet address to another BTC target\n claim <lock-id> --preimage <32-byte-hex>\n Claim an active COG lock before timeout\n reclaim <lock-id> Reclaim an expired COG lock as the original locker\n cog lock <amount> --to-domain <domain> (--for <blocks-or-duration> | --until-height <height>) --condition <sha256hex>\n Lock COG to an anchored recipient domain\n wallet status Show detailed wallet-local status and service health\n wallet init Initialize a new local wallet root\n wallet restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n wallet delete Delete one imported named seed without affecting main\n wallet show-mnemonic Reveal the initialized wallet recovery phrase after typed confirmation\n address Show the BTC wallet address for this wallet\n ids Show the local wallet address\n balance Show local wallet COG balances\n locks Show locally related active COG locks\n domain list Alias for domains\n domain show <domain> Alias for show <domain>\n domains [--anchored] [--listed] [--mineable]\n Show locally related domains\n show <domain> Show one domain and its local-wallet relationship\n fields <domain> List current fields on a domain\n field <domain> <field> Show one current field value\n field create <domain> <field>\n Create a new empty anchored field\n field set <domain> <field>\n Update an existing anchored field value\n field clear <domain> <field>\n Clear an existing anchored field value\n rep give <source-domain> <target-domain> <amount>\n Burn COG as anchored-domain reputation support\n rep revoke <source-domain> <target-domain> <amount>\n Revoke visible support without refunding burned COG\n\nOptions:\n --db <path> Override the SQLite database path\n --data-dir <path> Override the managed bitcoin datadir\n --for <duration> Relative timeout for cog lock, like 15m, 2h, or 1d\n --message <text> Founding message text for anchor\n --to <btc-target> Transfer or send target as an address or spk:<hex>\n --to-domain <domain>\n Recipient domain for cog lock\n --condition <sha256hex>\n 32-byte lock condition hash\n --until-height <height>\n Absolute timeout height for cog lock\n --preimage <32-byte-hex>\n Claim preimage for an active lock\n --review <text> Optional public review text for reputation operations\n --satvb <n> Override the mutation fee rate in sat/vB\n --text <utf8> UTF-8 payload text for endpoint or field writes\n --json <json> UTF-8 payload JSON text for endpoint or field writes\n --bytes <spec> Payload bytes as hex:<hex> or @<path>\n --permanent Create the field as permanent\n --format <spec> Advanced field format as raw:<u8>\n --value <spec> Advanced field value as hex:<hex>, @<path>, or utf8:<text>\n --claimable Show only currently claimable locks\n --reclaimable Show only currently reclaimable locks\n --anchored Show only anchored domains\n --listed Show only currently listed domains\n --mineable Show only locally mineable root domains\n --limit <n> Limit list rows (1..1000)\n --all Show all rows for list commands\n --follow Follow mining log output\n --output <mode> Output mode: text, json, or preview-json\n --progress <mode> Progress output mode: auto, tty, or none\n --seed <name> Select an imported wallet seed for wallet-aware commands\n --force Reserved for future use\n --force-race Allow a visible root registration race\n --yes Approve eligible plain yes/no mutation confirmations non-interactively\n --help Show help\n --version Show package version\n\nQuickstart:\n 1. Run `cogcoin init` to create the wallet.\n 2. Run `cogcoin sync` to bootstrap assumeutxo and the managed Bitcoin/indexer state.\n 3. Run `cogcoin address`, then fund the wallet with about 0.0015 BTC so you can buy a 6+ character domain to start mining and still keep BTC available for mining transaction fees.\n\nExamples:\n cogcoin status --output json\n cogcoin bitcoin status\n cogcoin indexer status\n cogcoin init --output json\n cogcoin restore --seed trading\n cogcoin wallet address\n cogcoin domain list --mineable\n cogcoin register alpha-child\n cogcoin anchor alpha\n cogcoin register alpha --satvb 12.5\n cogcoin buy alpha\n cogcoin field set alpha bio --text \"hello\"\n cogcoin rep give alpha beta 10 --review \"great operator\"\n cogcoin mine setup --output json\n cogcoin register alpha-child --output preview-json\n cogcoin mine status\n";
|
|
2
|
+
export declare const HELP_TEXT = "Usage: cogcoin <command> [options]\n\nCommands:\n status Show wallet-aware local service and chain status\n status --output json Emit the stable v1 machine-readable status envelope\n update Show the current and latest client versions and install updates\n update --output json Emit the stable v1 machine-readable update result envelope\n client unlock Unlock password-protected local wallet secrets for a limited time\n client lock Flush the cached client password unlock session\n client change-password Rotate the client password that protects local wallet secrets\n bitcoin start Start the managed Bitcoin daemon\n bitcoin stop Stop the managed Bitcoin daemon and paired indexer\n bitcoin status Show managed Bitcoin daemon status without starting it\n bitcoin transfer <sats> --to <address>\n Send plain BTC from the wallet address\n indexer start Start the managed Cogcoin indexer (and bitcoind if needed)\n indexer stop Stop the managed Cogcoin indexer only\n indexer status Show managed Cogcoin indexer status without starting it\n init Initialize a new local wallet root\n init --output json Emit the stable v1 machine-readable init result envelope\n restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n reset Factory-reset local Cogcoin state with interactive retention prompts\n repair Recover bounded wallet/indexer/runtime state\n wallet address Alias for address\n wallet ids Alias for ids\n mine Run the miner in the foreground\n mine start Start the miner as a background worker\n mine stop Stop the active background miner\n mine setup Configure the built-in mining provider\n mine setup --output json\n Emit the stable v1 machine-readable mine setup result envelope\n mine prompt Show per-domain mining prompt state\n mine prompt --output json\n Emit the stable v1 machine-readable mine prompt list envelope\n mine prompt <domain> Configure a per-domain mining prompt override\n mine prompt <domain> --output json\n Emit the stable v1 machine-readable mine prompt result envelope\n mine prompt list Alias for mine prompt\n mine status Show mining control-plane health and readiness\n mine log Show recent mining control-plane events\n anchor <domain> Anchor an owned unanchored domain with the wallet address\n register <domain>\n Register a root domain or subdomain\n transfer <domain> --to <btc-target>\n Transfer an unanchored domain to another BTC address or script\n sell <domain> <price> List an unanchored domain for sale in COG\n unsell <domain> Clear an active domain listing\n buy <domain>\n Buy an unanchored listed domain in COG\n send <amount> --to <btc-target>\n Send COG from the wallet address to another BTC target\n claim <lock-id> --preimage <32-byte-hex>\n Claim an active COG lock before timeout\n reclaim <lock-id> Reclaim an expired COG lock as the original locker\n cog lock <amount> --to-domain <domain> (--for <blocks-or-duration> | --until-height <height>) --condition <sha256hex>\n Lock COG to an anchored recipient domain\n wallet status Show detailed wallet-local status and service health\n wallet init Initialize a new local wallet root\n wallet restore Restore an imported named seed from a 24-word mnemonic; run sync afterward\n wallet delete Delete one imported named seed without affecting main\n wallet show-mnemonic Reveal the initialized wallet recovery phrase after typed confirmation\n address Show the BTC wallet address for this wallet\n ids Show the local wallet address\n balance Show local wallet COG balances\n locks Show locally related active COG locks\n domain list Alias for domains\n domain show <domain> Alias for show <domain>\n domains [--anchored] [--listed] [--mineable]\n Show locally related domains\n show <domain> Show one domain and its local-wallet relationship\n fields <domain> List current fields on a domain\n field <domain> <field> Show one current field value\n field create <domain> <field>\n Create a new empty anchored field\n field set <domain> <field>\n Update an existing anchored field value\n field clear <domain> <field>\n Clear an existing anchored field value\n rep give <source-domain> <target-domain> <amount>\n Burn COG as anchored-domain reputation support\n rep revoke <source-domain> <target-domain> <amount>\n Revoke visible support without refunding burned COG\n\nOptions:\n --db <path> Override the SQLite database path\n --data-dir <path> Override the managed bitcoin datadir\n --for <duration> Relative timeout for cog lock, like 15m, 2h, or 1d\n --message <text> Founding message text for anchor\n --to <btc-target> Transfer or send target as an address or spk:<hex>\n --to-domain <domain>\n Recipient domain for cog lock\n --condition <sha256hex>\n 32-byte lock condition hash\n --until-height <height>\n Absolute timeout height for cog lock\n --preimage <32-byte-hex>\n Claim preimage for an active lock\n --review <text> Optional public review text for reputation operations\n --satvb <n> Override the mutation fee rate in sat/vB\n --text <utf8> UTF-8 payload text for endpoint or field writes\n --json <json> UTF-8 payload JSON text for endpoint or field writes\n --bytes <spec> Payload bytes as hex:<hex> or @<path>\n --permanent Create the field as permanent\n --format <spec> Advanced field format as raw:<u8>\n --value <spec> Advanced field value as hex:<hex>, @<path>, or utf8:<text>\n --claimable Show only currently claimable locks\n --reclaimable Show only currently reclaimable locks\n --anchored Show only anchored domains\n --listed Show only currently listed domains\n --mineable Show only locally mineable root domains\n --limit <n> Limit list rows (1..1000)\n --all Show all rows for list commands\n --follow Follow mining log output\n --output <mode> Output mode: text, json, or preview-json\n --progress <mode> Progress output mode: auto, tty, or none\n --seed <name> Select an imported wallet seed for wallet-aware commands\n --force Reserved for future use\n --force-race Allow a visible root registration race\n --yes Approve eligible plain yes/no mutation confirmations non-interactively\n --help Show help\n --version Show package version\n\nQuickstart:\n 1. Run `cogcoin init` to create the wallet.\n 2. Run `cogcoin sync` to bootstrap assumeutxo and the managed Bitcoin/indexer state.\n 3. Run `cogcoin address`, then fund the wallet with about 0.0015 BTC so you can buy a 6+ character domain to start mining and still keep BTC available for mining transaction fees.\n\nExamples:\n cogcoin status --output json\n cogcoin bitcoin status\n cogcoin indexer status\n cogcoin init --output json\n cogcoin restore --seed trading\n cogcoin wallet address\n cogcoin domain list --mineable\n cogcoin register alpha-child\n cogcoin anchor alpha\n cogcoin register alpha --satvb 12.5\n cogcoin buy alpha\n cogcoin field set alpha bio --text \"hello\"\n cogcoin rep give alpha beta 10 --review \"great operator\"\n cogcoin mine setup --output json\n cogcoin mine prompt\n cogcoin mine prompt alpha\n cogcoin register alpha-child --output preview-json\n cogcoin mine status\n";
|
|
3
3
|
export declare function parseCliArgs(argv: string[]): ParsedCliArgs;
|
package/dist/cli/parse.js
CHANGED
|
@@ -31,6 +31,13 @@ Commands:
|
|
|
31
31
|
mine setup Configure the built-in mining provider
|
|
32
32
|
mine setup --output json
|
|
33
33
|
Emit the stable v1 machine-readable mine setup result envelope
|
|
34
|
+
mine prompt Show per-domain mining prompt state
|
|
35
|
+
mine prompt --output json
|
|
36
|
+
Emit the stable v1 machine-readable mine prompt list envelope
|
|
37
|
+
mine prompt <domain> Configure a per-domain mining prompt override
|
|
38
|
+
mine prompt <domain> --output json
|
|
39
|
+
Emit the stable v1 machine-readable mine prompt result envelope
|
|
40
|
+
mine prompt list Alias for mine prompt
|
|
34
41
|
mine status Show mining control-plane health and readiness
|
|
35
42
|
mine log Show recent mining control-plane events
|
|
36
43
|
anchor <domain> Anchor an owned unanchored domain with the wallet address
|
|
@@ -135,6 +142,8 @@ Examples:
|
|
|
135
142
|
cogcoin field set alpha bio --text "hello"
|
|
136
143
|
cogcoin rep give alpha beta 10 --review "great operator"
|
|
137
144
|
cogcoin mine setup --output json
|
|
145
|
+
cogcoin mine prompt
|
|
146
|
+
cogcoin mine prompt alpha
|
|
138
147
|
cogcoin register alpha-child --output preview-json
|
|
139
148
|
cogcoin mine status
|
|
140
149
|
`;
|
|
@@ -223,6 +232,8 @@ function supportsSeedFlag(command) {
|
|
|
223
232
|
case "mine-start":
|
|
224
233
|
case "mine-stop":
|
|
225
234
|
case "mine-setup":
|
|
235
|
+
case "mine-prompt":
|
|
236
|
+
case "mine-prompt-list":
|
|
226
237
|
case "mine-status":
|
|
227
238
|
case "mine-log":
|
|
228
239
|
case "wallet-delete":
|
|
@@ -648,6 +659,14 @@ export function parseCliArgs(argv) {
|
|
|
648
659
|
index += 1;
|
|
649
660
|
continue;
|
|
650
661
|
}
|
|
662
|
+
if (subcommand === "prompt") {
|
|
663
|
+
const action = argv[index + 2] ?? null;
|
|
664
|
+
command = action === null || action.startsWith("--") || action === "list"
|
|
665
|
+
? "mine-prompt-list"
|
|
666
|
+
: "mine-prompt";
|
|
667
|
+
index += action === "list" ? 2 : 1;
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
651
670
|
if (subcommand === "status") {
|
|
652
671
|
command = "mine-status";
|
|
653
672
|
index += 1;
|
|
@@ -889,6 +908,7 @@ export function parseCliArgs(argv) {
|
|
|
889
908
|
|| command === "mine-start"
|
|
890
909
|
|| command === "mine-stop"
|
|
891
910
|
|| command === "mine-setup"
|
|
911
|
+
|| command === "mine-prompt-list"
|
|
892
912
|
|| command === "mine-status"
|
|
893
913
|
|| command === "mine-log"
|
|
894
914
|
|| command === "wallet-address"
|
|
@@ -912,6 +932,9 @@ export function parseCliArgs(argv) {
|
|
|
912
932
|
&& args.length !== 1) {
|
|
913
933
|
throw new Error("cli_missing_domain_argument");
|
|
914
934
|
}
|
|
935
|
+
if (command === "mine-prompt" && args.length !== 1) {
|
|
936
|
+
throw new Error("cli_missing_domain_argument");
|
|
937
|
+
}
|
|
915
938
|
if ((command === "domain-endpoint-set"
|
|
916
939
|
|| command === "domain-endpoint-clear"
|
|
917
940
|
|| command === "domain-delegate-clear"
|
package/dist/cli/read-json.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WalletDomainView, WalletFieldView, WalletLockView, WalletReadContext } from "../wallet/read/index.js";
|
|
2
|
-
import type { MiningControlPlaneView, MiningEventRecord } from "../wallet/mining/index.js";
|
|
2
|
+
import type { MiningControlPlaneView, MiningDomainPromptListResult, MiningEventRecord } from "../wallet/mining/index.js";
|
|
3
3
|
import type { PendingMutationRecord } from "../wallet/types.js";
|
|
4
4
|
import type { JsonAvailabilityEntry, JsonPage } from "./output.js";
|
|
5
5
|
export interface ReadJsonResult<T> {
|
|
@@ -137,6 +137,18 @@ export declare function buildMineLogJson(events: MiningEventRecord[], page: Json
|
|
|
137
137
|
rotation: number[];
|
|
138
138
|
page: JsonPage;
|
|
139
139
|
}>;
|
|
140
|
+
export declare function buildMinePromptListJson(result: MiningDomainPromptListResult): ReadJsonResult<{
|
|
141
|
+
fallbackPromptConfigured: boolean;
|
|
142
|
+
prompts: Array<{
|
|
143
|
+
domain: {
|
|
144
|
+
name: string;
|
|
145
|
+
domainId: number | null;
|
|
146
|
+
};
|
|
147
|
+
mineable: boolean;
|
|
148
|
+
prompt: string | null;
|
|
149
|
+
effectivePromptSource: "domain" | "global-fallback" | "none";
|
|
150
|
+
}>;
|
|
151
|
+
}>;
|
|
140
152
|
export declare function buildBalanceJson(context: WalletReadContext): ReadJsonResult<{
|
|
141
153
|
assetLabel: string;
|
|
142
154
|
totalCogtoshi: string | null;
|
package/dist/cli/read-json.js
CHANGED
|
@@ -410,6 +410,9 @@ export function buildMineStatusJson(mining) {
|
|
|
410
410
|
? "Run `cogcoin mine setup` and clear or correct the provider model."
|
|
411
411
|
: "Run `cogcoin mine setup` and choose a valid provider model.");
|
|
412
412
|
}
|
|
413
|
+
else if (mining.runtime.currentPublishDecision === "publish-paused-insufficient-funds") {
|
|
414
|
+
nextSteps.push("Wait for enough safe BTC funding to become spendable for the next publish; mining resumes automatically.");
|
|
415
|
+
}
|
|
413
416
|
else if (mining.runtime.pauseReason === "zero-reward") {
|
|
414
417
|
nextSteps.push("Wait for the next positive-reward target height; mining resumes automatically.");
|
|
415
418
|
}
|
|
@@ -489,6 +492,34 @@ export function buildMineLogJson(events, page, rotation) {
|
|
|
489
492
|
},
|
|
490
493
|
};
|
|
491
494
|
}
|
|
495
|
+
export function buildMinePromptListJson(result) {
|
|
496
|
+
const explanations = [];
|
|
497
|
+
const nextSteps = [];
|
|
498
|
+
if (result.prompts.length === 0) {
|
|
499
|
+
explanations.push("No mineable root domains or stored per-domain mining prompts are configured.");
|
|
500
|
+
nextSteps.push("Run `cogcoin domains --mineable` to see eligible mining domains.");
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
const nextDomainPrompt = result.prompts.find((entry) => entry.mineable && entry.prompt === null);
|
|
504
|
+
if (nextDomainPrompt !== undefined) {
|
|
505
|
+
nextSteps.push(`cogcoin mine prompt ${nextDomainPrompt.domain.name}`);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return {
|
|
509
|
+
warnings: [],
|
|
510
|
+
explanations,
|
|
511
|
+
nextSteps,
|
|
512
|
+
data: {
|
|
513
|
+
fallbackPromptConfigured: result.fallbackPromptConfigured,
|
|
514
|
+
prompts: result.prompts.map((entry) => ({
|
|
515
|
+
domain: entry.domain,
|
|
516
|
+
mineable: entry.mineable,
|
|
517
|
+
prompt: entry.prompt,
|
|
518
|
+
effectivePromptSource: entry.effectivePromptSource,
|
|
519
|
+
})),
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
}
|
|
492
523
|
export function buildBalanceJson(context) {
|
|
493
524
|
const messages = createBaseMessages(context);
|
|
494
525
|
const total = walletCogBalance(context);
|
package/dist/cli/runner.js
CHANGED
|
@@ -92,7 +92,8 @@ export async function runCli(argv, contextOverrides = {}) {
|
|
|
92
92
|
|| parsed.command === "mine-stop") {
|
|
93
93
|
return runMiningRuntimeCommand(parsed, context);
|
|
94
94
|
}
|
|
95
|
-
if (parsed.command === "mine-setup"
|
|
95
|
+
if (parsed.command === "mine-setup"
|
|
96
|
+
|| parsed.command === "mine-prompt") {
|
|
96
97
|
return runMiningAdminCommand(parsed, context);
|
|
97
98
|
}
|
|
98
99
|
if (parsed.command === "init"
|
|
@@ -139,7 +140,8 @@ export async function runCli(argv, contextOverrides = {}) {
|
|
|
139
140
|
|| parsed.command === "rep-revoke") {
|
|
140
141
|
return runWalletMutationCommand(parsed, context);
|
|
141
142
|
}
|
|
142
|
-
if (parsed.command === "mine-
|
|
143
|
+
if (parsed.command === "mine-prompt-list"
|
|
144
|
+
|| parsed.command === "mine-status"
|
|
143
145
|
|| parsed.command === "mine-log") {
|
|
144
146
|
return runMiningReadCommand(parsed, context);
|
|
145
147
|
}
|
package/dist/cli/signals.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { InterruptibleOutcome, ManagedClientLike, SignalSource, StopSignalWatcher, WritableLike } from "./types.js";
|
|
2
|
+
export declare function createCloseSignalWatcher(options: {
|
|
3
|
+
signalSource: SignalSource;
|
|
4
|
+
stderr: WritableLike;
|
|
5
|
+
closeable: {
|
|
6
|
+
close(): Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
forceExit: (code: number) => never | void;
|
|
9
|
+
lockPaths?: readonly string[];
|
|
10
|
+
firstMessage?: string | null;
|
|
11
|
+
successMessage?: string | null;
|
|
12
|
+
failureMessage?: string | null;
|
|
13
|
+
}): StopSignalWatcher;
|
|
2
14
|
export declare function createStopSignalWatcher(signalSource: SignalSource, stderr: WritableLike, client: ManagedClientLike, forceExit: (code: number) => never | void, lockPaths?: readonly string[]): StopSignalWatcher;
|
|
3
15
|
export declare function createOwnedLockCleanupSignalWatcher(signalSource: SignalSource, forceExit: (code: number) => never | void, lockPaths: readonly string[]): StopSignalWatcher;
|
|
4
16
|
export declare function waitForCompletionOrStop<T>(promise: Promise<T>, stopWatcher: StopSignalWatcher): Promise<InterruptibleOutcome<T>>;
|
package/dist/cli/signals.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { writeLine } from "./io.js";
|
|
2
2
|
import { clearLockIfOwnedByCurrentProcess } from "../wallet/fs/lock.js";
|
|
3
|
-
export function
|
|
3
|
+
export function createCloseSignalWatcher(options) {
|
|
4
4
|
let closing = false;
|
|
5
5
|
let resolved = false;
|
|
6
6
|
let onSignal = () => { };
|
|
7
7
|
const cleanup = () => {
|
|
8
|
-
signalSource.off("SIGINT", onSignal);
|
|
9
|
-
signalSource.off("SIGTERM", onSignal);
|
|
8
|
+
options.signalSource.off("SIGINT", onSignal);
|
|
9
|
+
options.signalSource.off("SIGTERM", onSignal);
|
|
10
10
|
};
|
|
11
11
|
const promise = new Promise((resolve) => {
|
|
12
12
|
const settle = (code) => {
|
|
@@ -18,26 +18,32 @@ export function createStopSignalWatcher(signalSource, stderr, client, forceExit,
|
|
|
18
18
|
resolve(code);
|
|
19
19
|
};
|
|
20
20
|
const releaseOwnedLocks = async () => {
|
|
21
|
-
await Promise.allSettled([...new Set(lockPaths)].map(async (lockPath) => {
|
|
21
|
+
await Promise.allSettled([...new Set(options.lockPaths ?? [])].map(async (lockPath) => {
|
|
22
22
|
await clearLockIfOwnedByCurrentProcess(lockPath);
|
|
23
23
|
}));
|
|
24
24
|
};
|
|
25
25
|
const onFirstSignal = () => {
|
|
26
26
|
closing = true;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
if (options.firstMessage !== null && options.firstMessage !== undefined) {
|
|
28
|
+
writeLine(options.stderr, options.firstMessage);
|
|
29
|
+
}
|
|
30
|
+
void options.closeable.close().then(async () => {
|
|
29
31
|
await releaseOwnedLocks();
|
|
30
32
|
if (resolved) {
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
|
-
|
|
35
|
+
if (options.successMessage !== null && options.successMessage !== undefined) {
|
|
36
|
+
writeLine(options.stderr, options.successMessage);
|
|
37
|
+
}
|
|
34
38
|
settle(0);
|
|
35
39
|
}, async () => {
|
|
36
40
|
await releaseOwnedLocks();
|
|
37
41
|
if (resolved) {
|
|
38
42
|
return;
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
if (options.failureMessage !== null && options.failureMessage !== undefined) {
|
|
45
|
+
writeLine(options.stderr, options.failureMessage);
|
|
46
|
+
}
|
|
41
47
|
settle(1);
|
|
42
48
|
});
|
|
43
49
|
};
|
|
@@ -47,23 +53,35 @@ export function createStopSignalWatcher(signalSource, stderr, client, forceExit,
|
|
|
47
53
|
return;
|
|
48
54
|
}
|
|
49
55
|
settle(130);
|
|
50
|
-
if (lockPaths.length === 0) {
|
|
51
|
-
forceExit(130);
|
|
56
|
+
if ((options.lockPaths ?? []).length === 0) {
|
|
57
|
+
options.forceExit(130);
|
|
52
58
|
return;
|
|
53
59
|
}
|
|
54
60
|
void releaseOwnedLocks().finally(() => {
|
|
55
|
-
forceExit(130);
|
|
61
|
+
options.forceExit(130);
|
|
56
62
|
});
|
|
57
63
|
};
|
|
58
64
|
});
|
|
59
|
-
signalSource.on("SIGINT", onSignal);
|
|
60
|
-
signalSource.on("SIGTERM", onSignal);
|
|
65
|
+
options.signalSource.on("SIGINT", onSignal);
|
|
66
|
+
options.signalSource.on("SIGTERM", onSignal);
|
|
61
67
|
return {
|
|
62
68
|
cleanup,
|
|
63
69
|
isStopping: () => closing,
|
|
64
70
|
promise,
|
|
65
71
|
};
|
|
66
72
|
}
|
|
73
|
+
export function createStopSignalWatcher(signalSource, stderr, client, forceExit, lockPaths = []) {
|
|
74
|
+
return createCloseSignalWatcher({
|
|
75
|
+
signalSource,
|
|
76
|
+
stderr,
|
|
77
|
+
closeable: client,
|
|
78
|
+
forceExit,
|
|
79
|
+
lockPaths,
|
|
80
|
+
firstMessage: "Detaching from managed Cogcoin client and resuming background indexer follow...",
|
|
81
|
+
successMessage: "Detached cleanly; background indexer follow resumed.",
|
|
82
|
+
failureMessage: "Detach failed before background indexer follow was confirmed.",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
67
85
|
export function createOwnedLockCleanupSignalWatcher(signalSource, forceExit, lockPaths) {
|
|
68
86
|
let stopping = false;
|
|
69
87
|
let resolved = false;
|
package/dist/cli/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { inspectPassiveClientStatus } from "../passive-status.js";
|
|
2
|
+
import type { ManagedIndexerMonitor, openManagedIndexerMonitor } from "../bitcoind/indexer-monitor.js";
|
|
2
3
|
import { createRpcClient } from "../bitcoind/node.js";
|
|
3
4
|
import type { ManagedBitcoindProgressEvent } from "../bitcoind/types.js";
|
|
4
5
|
import { attachOrStartIndexerDaemon, probeIndexerDaemon, readObservedIndexerDaemonStatus, stopIndexerDaemonService } from "../bitcoind/indexer-daemon.js";
|
|
@@ -10,11 +11,11 @@ import type { WalletPrompter, initializeWallet, deleteImportedWalletSeed, previe
|
|
|
10
11
|
import type { openWalletReadContext } from "../wallet/read/index.js";
|
|
11
12
|
import { loadRawWalletStateEnvelope, loadWalletState } from "../wallet/state/storage.js";
|
|
12
13
|
import type { WalletSecretProvider } from "../wallet/state/provider.js";
|
|
13
|
-
import type { ensureBuiltInMiningSetupIfNeeded, followMiningLog, inspectMiningControlPlane, readMiningLog, runForegroundMining, setupBuiltInMining, startBackgroundMining, stopBackgroundMining } from "../wallet/mining/index.js";
|
|
14
|
+
import type { ensureBuiltInMiningSetupIfNeeded, followMiningLog, inspectMiningControlPlane, inspectMiningDomainPromptState, readMiningLog, runForegroundMining, setupBuiltInMining, startBackgroundMining, stopBackgroundMining, updateMiningDomainPrompt } from "../wallet/mining/index.js";
|
|
14
15
|
import type { anchorDomain, transferBitcoin, buyDomain, claimCogLock, clearDomainDelegate, clearDomainEndpoint, clearDomainMiner, clearField, createField, giveReputation, lockCogToDomain, registerDomain, reclaimCogLock, revokeReputation, sendCog, setField, setDomainCanonical, setDomainDelegate, setDomainEndpoint, setDomainMiner, sellDomain, transferDomain } from "../wallet/tx/index.js";
|
|
15
16
|
export type ProgressOutput = "auto" | "tty" | "none";
|
|
16
17
|
export type OutputMode = "text" | "json" | "preview-json";
|
|
17
|
-
export type CommandName = "init" | "restore" | "reset" | "repair" | "update" | "sync" | "status" | "client-lock" | "client-change-password" | "client-unlock" | "follow" | "bitcoin-start" | "bitcoin-stop" | "bitcoin-status" | "bitcoin-transfer" | "indexer-start" | "indexer-stop" | "indexer-status" | "anchor" | "domain-anchor" | "register" | "domain-register" | "transfer" | "domain-transfer" | "sell" | "domain-sell" | "unsell" | "domain-unsell" | "buy" | "domain-buy" | "domain-endpoint-set" | "domain-endpoint-clear" | "domain-delegate-set" | "domain-delegate-clear" | "domain-miner-set" | "domain-miner-clear" | "domain-canonical" | "field-list" | "field-show" | "field-create" | "field-set" | "field-clear" | "send" | "claim" | "reclaim" | "cog-send" | "cog-claim" | "cog-reclaim" | "cog-lock" | "rep-give" | "rep-revoke" | "cog-balance" | "cog-locks" | "mine" | "mine-start" | "mine-stop" | "mine-setup" | "mine-status" | "mine-log" | "wallet-init" | "wallet-delete" | "wallet-restore" | "wallet-show-mnemonic" | "wallet-status" | "wallet-address" | "wallet-ids" | "address" | "ids" | "balance" | "locks" | "domain-list" | "domains" | "domain-show" | "show" | "fields" | "field";
|
|
18
|
+
export type CommandName = "init" | "restore" | "reset" | "repair" | "update" | "sync" | "status" | "client-lock" | "client-change-password" | "client-unlock" | "follow" | "bitcoin-start" | "bitcoin-stop" | "bitcoin-status" | "bitcoin-transfer" | "indexer-start" | "indexer-stop" | "indexer-status" | "anchor" | "domain-anchor" | "register" | "domain-register" | "transfer" | "domain-transfer" | "sell" | "domain-sell" | "unsell" | "domain-unsell" | "buy" | "domain-buy" | "domain-endpoint-set" | "domain-endpoint-clear" | "domain-delegate-set" | "domain-delegate-clear" | "domain-miner-set" | "domain-miner-clear" | "domain-canonical" | "field-list" | "field-show" | "field-create" | "field-set" | "field-clear" | "send" | "claim" | "reclaim" | "cog-send" | "cog-claim" | "cog-reclaim" | "cog-lock" | "rep-give" | "rep-revoke" | "cog-balance" | "cog-locks" | "mine" | "mine-start" | "mine-stop" | "mine-setup" | "mine-prompt" | "mine-prompt-list" | "mine-status" | "mine-log" | "wallet-init" | "wallet-delete" | "wallet-restore" | "wallet-show-mnemonic" | "wallet-status" | "wallet-address" | "wallet-ids" | "address" | "ids" | "balance" | "locks" | "domain-list" | "domains" | "domain-show" | "show" | "fields" | "field";
|
|
18
19
|
export interface WritableLike {
|
|
19
20
|
isTTY?: boolean;
|
|
20
21
|
write(chunk: string): void;
|
|
@@ -71,7 +72,6 @@ export interface ManagedClientLike {
|
|
|
71
72
|
bestHeight: number;
|
|
72
73
|
}>;
|
|
73
74
|
playSyncCompletionScene?(): Promise<void>;
|
|
74
|
-
detachToBackgroundFollow?(): Promise<void>;
|
|
75
75
|
startFollowingTip(): Promise<void>;
|
|
76
76
|
getNodeStatus(): Promise<{
|
|
77
77
|
indexedTip: {
|
|
@@ -83,6 +83,8 @@ export interface ManagedClientLike {
|
|
|
83
83
|
}>;
|
|
84
84
|
close(): Promise<void>;
|
|
85
85
|
}
|
|
86
|
+
export interface ManagedIndexerMonitorLike extends ManagedIndexerMonitor {
|
|
87
|
+
}
|
|
86
88
|
export interface CliRunnerContext {
|
|
87
89
|
stdout?: WritableLike;
|
|
88
90
|
stderr?: WritableLike;
|
|
@@ -100,7 +102,6 @@ export interface CliRunnerContext {
|
|
|
100
102
|
openSqliteStore?: typeof openSqliteStore;
|
|
101
103
|
openManagedBitcoindClient?: (options: {
|
|
102
104
|
store: ClientStoreAdapter;
|
|
103
|
-
databasePath?: string;
|
|
104
105
|
dataDir?: string;
|
|
105
106
|
walletRootId?: string;
|
|
106
107
|
progressOutput?: ProgressOutput;
|
|
@@ -110,6 +111,7 @@ export interface CliRunnerContext {
|
|
|
110
111
|
nextArchiveEndHeight: number;
|
|
111
112
|
}) => Promise<boolean>;
|
|
112
113
|
}) => Promise<ManagedClientLike>;
|
|
114
|
+
openManagedIndexerMonitor?: typeof openManagedIndexerMonitor;
|
|
113
115
|
attachManagedBitcoindService?: typeof attachOrStartManagedBitcoindService;
|
|
114
116
|
probeManagedBitcoindService?: typeof probeManagedBitcoindService;
|
|
115
117
|
stopManagedBitcoindService?: typeof stopManagedBitcoindService;
|
|
@@ -150,11 +152,13 @@ export interface CliRunnerContext {
|
|
|
150
152
|
giveReputation?: typeof giveReputation;
|
|
151
153
|
revokeReputation?: typeof revokeReputation;
|
|
152
154
|
inspectMiningControlPlane?: typeof inspectMiningControlPlane;
|
|
155
|
+
inspectMiningDomainPromptState?: typeof inspectMiningDomainPromptState;
|
|
153
156
|
ensureBuiltInMiningSetupIfNeeded?: typeof ensureBuiltInMiningSetupIfNeeded;
|
|
154
157
|
runForegroundMining?: typeof runForegroundMining;
|
|
155
158
|
startBackgroundMining?: typeof startBackgroundMining;
|
|
156
159
|
stopBackgroundMining?: typeof stopBackgroundMining;
|
|
157
160
|
setupBuiltInMining?: typeof setupBuiltInMining;
|
|
161
|
+
updateMiningDomainPrompt?: typeof updateMiningDomainPrompt;
|
|
158
162
|
readMiningLog?: typeof readMiningLog;
|
|
159
163
|
followMiningLog?: typeof followMiningLog;
|
|
160
164
|
repairWallet?: typeof repairWallet;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
+
import { compareSemver, parseSemver, type ParsedSemver } from "../semver.js";
|
|
1
2
|
export declare const UPDATE_CHECK_CACHE_SCHEMA_VERSION = 1;
|
|
2
3
|
export declare const UPDATE_CHECK_MAX_AGE_MS: number;
|
|
3
4
|
export declare const PASSIVE_UPDATE_CHECK_TIMEOUT_MS = 500;
|
|
4
5
|
export declare const EXPLICIT_UPDATE_CHECK_TIMEOUT_MS = 5000;
|
|
5
6
|
export declare const UPDATE_CHECK_URL = "https://registry.npmjs.org/@cogcoin/client/latest";
|
|
6
7
|
export declare const CLI_INSTALL_COMMAND = "npm install -g @cogcoin/client";
|
|
7
|
-
export interface ParsedSemver {
|
|
8
|
-
major: number;
|
|
9
|
-
minor: number;
|
|
10
|
-
patch: number;
|
|
11
|
-
prerelease: Array<{
|
|
12
|
-
raw: string;
|
|
13
|
-
numeric: boolean;
|
|
14
|
-
numericValue: number | null;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
8
|
export interface UpdateCheckCache {
|
|
18
9
|
schemaVersion: typeof UPDATE_CHECK_CACHE_SCHEMA_VERSION;
|
|
19
10
|
lastCheckedAtUnixMs: number;
|
|
@@ -31,8 +22,7 @@ export type UpdateCheckResult = {
|
|
|
31
22
|
errorKind: string;
|
|
32
23
|
};
|
|
33
24
|
export declare function createEmptyUpdateCheckCache(): UpdateCheckCache;
|
|
34
|
-
export
|
|
35
|
-
export declare function compareSemver(left: string, right: string): number | null;
|
|
25
|
+
export { compareSemver, parseSemver, type ParsedSemver };
|
|
36
26
|
export declare function isUpdateCheckDisabled(env: NodeJS.ProcessEnv): boolean;
|
|
37
27
|
export declare function loadUpdateCheckCache(cachePath: string): Promise<UpdateCheckCache | null>;
|
|
38
28
|
export declare function shouldRefreshUpdateCheck(cache: UpdateCheckCache, now: number): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { compareSemver, parseSemver, } from "../semver.js";
|
|
2
3
|
import { writeJsonFileAtomic } from "../wallet/fs/atomic.js";
|
|
3
4
|
export const UPDATE_CHECK_CACHE_SCHEMA_VERSION = 1;
|
|
4
5
|
export const UPDATE_CHECK_MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
@@ -16,74 +17,7 @@ export function createEmptyUpdateCheckCache() {
|
|
|
16
17
|
lastNotifiedAtUnixMs: null,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
export
|
|
20
|
-
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(version.trim());
|
|
21
|
-
if (match === null) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
const prerelease = match[4] === undefined
|
|
25
|
-
? []
|
|
26
|
-
: match[4].split(".").map((raw) => ({
|
|
27
|
-
raw,
|
|
28
|
-
numeric: /^(0|[1-9]\d*)$/.test(raw),
|
|
29
|
-
numericValue: /^(0|[1-9]\d*)$/.test(raw) ? Number(raw) : null,
|
|
30
|
-
}));
|
|
31
|
-
return {
|
|
32
|
-
major: Number(match[1]),
|
|
33
|
-
minor: Number(match[2]),
|
|
34
|
-
patch: Number(match[3]),
|
|
35
|
-
prerelease,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export function compareSemver(left, right) {
|
|
39
|
-
const leftParsed = parseSemver(left);
|
|
40
|
-
const rightParsed = parseSemver(right);
|
|
41
|
-
if (leftParsed === null || rightParsed === null) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
if (leftParsed.major !== rightParsed.major) {
|
|
45
|
-
return leftParsed.major > rightParsed.major ? 1 : -1;
|
|
46
|
-
}
|
|
47
|
-
if (leftParsed.minor !== rightParsed.minor) {
|
|
48
|
-
return leftParsed.minor > rightParsed.minor ? 1 : -1;
|
|
49
|
-
}
|
|
50
|
-
if (leftParsed.patch !== rightParsed.patch) {
|
|
51
|
-
return leftParsed.patch > rightParsed.patch ? 1 : -1;
|
|
52
|
-
}
|
|
53
|
-
if (leftParsed.prerelease.length === 0 && rightParsed.prerelease.length === 0) {
|
|
54
|
-
return 0;
|
|
55
|
-
}
|
|
56
|
-
if (leftParsed.prerelease.length === 0) {
|
|
57
|
-
return 1;
|
|
58
|
-
}
|
|
59
|
-
if (rightParsed.prerelease.length === 0) {
|
|
60
|
-
return -1;
|
|
61
|
-
}
|
|
62
|
-
const maxLength = Math.max(leftParsed.prerelease.length, rightParsed.prerelease.length);
|
|
63
|
-
for (let index = 0; index < maxLength; index += 1) {
|
|
64
|
-
const leftIdentifier = leftParsed.prerelease[index];
|
|
65
|
-
const rightIdentifier = rightParsed.prerelease[index];
|
|
66
|
-
if (leftIdentifier === undefined) {
|
|
67
|
-
return -1;
|
|
68
|
-
}
|
|
69
|
-
if (rightIdentifier === undefined) {
|
|
70
|
-
return 1;
|
|
71
|
-
}
|
|
72
|
-
if (leftIdentifier.numeric && rightIdentifier.numeric) {
|
|
73
|
-
if (leftIdentifier.numericValue !== rightIdentifier.numericValue) {
|
|
74
|
-
return leftIdentifier.numericValue > rightIdentifier.numericValue ? 1 : -1;
|
|
75
|
-
}
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (leftIdentifier.numeric !== rightIdentifier.numeric) {
|
|
79
|
-
return leftIdentifier.numeric ? -1 : 1;
|
|
80
|
-
}
|
|
81
|
-
if (leftIdentifier.raw !== rightIdentifier.raw) {
|
|
82
|
-
return leftIdentifier.raw > rightIdentifier.raw ? 1 : -1;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
20
|
+
export { compareSemver, parseSemver };
|
|
87
21
|
export function isUpdateCheckDisabled(env) {
|
|
88
22
|
const raw = env.COGCOIN_DISABLE_UPDATE_CHECK;
|
|
89
23
|
if (raw === undefined) {
|
package/dist/semver.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ParsedSemver {
|
|
2
|
+
major: number;
|
|
3
|
+
minor: number;
|
|
4
|
+
patch: number;
|
|
5
|
+
prerelease: Array<{
|
|
6
|
+
raw: string;
|
|
7
|
+
numeric: boolean;
|
|
8
|
+
numericValue: number | null;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseSemver(version: string): ParsedSemver | null;
|
|
12
|
+
export declare function compareSemver(left: string, right: string): number | null;
|
package/dist/semver.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export function parseSemver(version) {
|
|
2
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(version.trim());
|
|
3
|
+
if (match === null) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const prerelease = match[4] === undefined
|
|
7
|
+
? []
|
|
8
|
+
: match[4].split(".").map((raw) => ({
|
|
9
|
+
raw,
|
|
10
|
+
numeric: /^(0|[1-9]\d*)$/.test(raw),
|
|
11
|
+
numericValue: /^(0|[1-9]\d*)$/.test(raw) ? Number(raw) : null,
|
|
12
|
+
}));
|
|
13
|
+
return {
|
|
14
|
+
major: Number(match[1]),
|
|
15
|
+
minor: Number(match[2]),
|
|
16
|
+
patch: Number(match[3]),
|
|
17
|
+
prerelease,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function compareSemver(left, right) {
|
|
21
|
+
const leftParsed = parseSemver(left);
|
|
22
|
+
const rightParsed = parseSemver(right);
|
|
23
|
+
if (leftParsed === null || rightParsed === null) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (leftParsed.major !== rightParsed.major) {
|
|
27
|
+
return leftParsed.major > rightParsed.major ? 1 : -1;
|
|
28
|
+
}
|
|
29
|
+
if (leftParsed.minor !== rightParsed.minor) {
|
|
30
|
+
return leftParsed.minor > rightParsed.minor ? 1 : -1;
|
|
31
|
+
}
|
|
32
|
+
if (leftParsed.patch !== rightParsed.patch) {
|
|
33
|
+
return leftParsed.patch > rightParsed.patch ? 1 : -1;
|
|
34
|
+
}
|
|
35
|
+
if (leftParsed.prerelease.length === 0 && rightParsed.prerelease.length === 0) {
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
if (leftParsed.prerelease.length === 0) {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
if (rightParsed.prerelease.length === 0) {
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
const maxLength = Math.max(leftParsed.prerelease.length, rightParsed.prerelease.length);
|
|
45
|
+
for (let index = 0; index < maxLength; index += 1) {
|
|
46
|
+
const leftIdentifier = leftParsed.prerelease[index];
|
|
47
|
+
const rightIdentifier = rightParsed.prerelease[index];
|
|
48
|
+
if (leftIdentifier === undefined) {
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
if (rightIdentifier === undefined) {
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
if (leftIdentifier.numeric && rightIdentifier.numeric) {
|
|
55
|
+
if (leftIdentifier.numericValue !== rightIdentifier.numericValue) {
|
|
56
|
+
return leftIdentifier.numericValue > rightIdentifier.numericValue ? 1 : -1;
|
|
57
|
+
}
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (leftIdentifier.numeric !== rightIdentifier.numeric) {
|
|
61
|
+
return leftIdentifier.numeric ? -1 : 1;
|
|
62
|
+
}
|
|
63
|
+
if (leftIdentifier.raw !== rightIdentifier.raw) {
|
|
64
|
+
return leftIdentifier.raw > rightIdentifier.raw ? 1 : -1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
package/dist/wallet/lifecycle.js
CHANGED
|
@@ -174,7 +174,6 @@ async function normalizeLoadedWalletStateIfNeeded(options) {
|
|
|
174
174
|
dataDir: options.dataDir,
|
|
175
175
|
chain: "main",
|
|
176
176
|
startHeight: 0,
|
|
177
|
-
serviceLifetime: "ephemeral",
|
|
178
177
|
walletRootId: state.walletRootId,
|
|
179
178
|
});
|
|
180
179
|
try {
|
|
@@ -271,7 +270,6 @@ async function recreateManagedCoreWalletReplica(state, provider, paths, dataDir,
|
|
|
271
270
|
dataDir,
|
|
272
271
|
chain: "main",
|
|
273
272
|
startHeight: 0,
|
|
274
|
-
serviceLifetime: "ephemeral",
|
|
275
273
|
walletRootId: state.walletRootId,
|
|
276
274
|
managedWalletPassphrase: state.managedCoreWallet.internalPassphrase,
|
|
277
275
|
});
|
|
@@ -804,7 +802,6 @@ async function importDescriptorIntoManagedCoreWallet(state, provider, paths, dat
|
|
|
804
802
|
dataDir,
|
|
805
803
|
chain: "main",
|
|
806
804
|
startHeight: 0,
|
|
807
|
-
serviceLifetime: "ephemeral",
|
|
808
805
|
walletRootId: state.walletRootId,
|
|
809
806
|
managedWalletPassphrase: state.managedCoreWallet.internalPassphrase,
|
|
810
807
|
});
|
|
@@ -890,7 +887,6 @@ export async function verifyManagedCoreWalletReplica(state, dataDir, dependencie
|
|
|
890
887
|
dataDir,
|
|
891
888
|
chain: "main",
|
|
892
889
|
startHeight: 0,
|
|
893
|
-
serviceLifetime: "ephemeral",
|
|
894
890
|
walletRootId: state.walletRootId,
|
|
895
891
|
});
|
|
896
892
|
const rpc = (dependencies.rpcFactory ?? createRpcClient)(node.rpc);
|
|
@@ -1260,7 +1256,6 @@ export async function deleteImportedWalletSeed(options) {
|
|
|
1260
1256
|
dataDir: options.dataDir,
|
|
1261
1257
|
chain: "main",
|
|
1262
1258
|
startHeight: 0,
|
|
1263
|
-
serviceLifetime: "ephemeral",
|
|
1264
1259
|
});
|
|
1265
1260
|
const rpc = (options.rpcFactory ?? createRpcClient)(node.rpc);
|
|
1266
1261
|
const walletName = sanitizeWalletName(seedRecord.walletRootId);
|
|
@@ -1423,7 +1418,6 @@ export async function repairWallet(options) {
|
|
|
1423
1418
|
dataDir: options.dataDir,
|
|
1424
1419
|
chain: "main",
|
|
1425
1420
|
startHeight: 0,
|
|
1426
|
-
serviceLifetime: "ephemeral",
|
|
1427
1421
|
walletRootId: repairedState.walletRootId,
|
|
1428
1422
|
});
|
|
1429
1423
|
const bitcoindRpc = (options.rpcFactory ?? createRpcClient)(bitcoindHandle.rpc);
|