@cogcoin/client 0.5.14 → 1.0.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.
Files changed (172) hide show
  1. package/README.md +80 -25
  2. package/dist/app-paths.d.ts +5 -6
  3. package/dist/app-paths.js +8 -16
  4. package/dist/art/balance.txt +10 -0
  5. package/dist/art/welcome.txt +16 -0
  6. package/dist/bitcoind/bootstrap/controller.d.ts +1 -0
  7. package/dist/bitcoind/bootstrap/controller.js +53 -1
  8. package/dist/bitcoind/client/follow-block-times.d.ts +1 -0
  9. package/dist/bitcoind/client/follow-block-times.js +1 -1
  10. package/dist/bitcoind/client/internal-types.d.ts +7 -3
  11. package/dist/bitcoind/client/managed-client.d.ts +4 -2
  12. package/dist/bitcoind/client/managed-client.js +14 -0
  13. package/dist/bitcoind/client/sync-engine.js +72 -11
  14. package/dist/bitcoind/hash-order.d.ts +4 -0
  15. package/dist/bitcoind/hash-order.js +13 -0
  16. package/dist/bitcoind/indexer-daemon-main.js +11 -3
  17. package/dist/bitcoind/normalize.js +3 -2
  18. package/dist/bitcoind/processing-start-height.d.ts +5 -0
  19. package/dist/bitcoind/processing-start-height.js +7 -0
  20. package/dist/bitcoind/progress/constants.d.ts +4 -0
  21. package/dist/bitcoind/progress/constants.js +4 -0
  22. package/dist/bitcoind/progress/controller.d.ts +2 -1
  23. package/dist/bitcoind/progress/controller.js +3 -3
  24. package/dist/bitcoind/progress/follow-scene.d.ts +6 -2
  25. package/dist/bitcoind/progress/follow-scene.js +29 -6
  26. package/dist/bitcoind/progress/formatting.d.ts +1 -0
  27. package/dist/bitcoind/progress/formatting.js +6 -0
  28. package/dist/bitcoind/progress/train-scene.js +37 -18
  29. package/dist/bitcoind/progress/tty-renderer.d.ts +6 -1
  30. package/dist/bitcoind/progress/tty-renderer.js +8 -4
  31. package/dist/bitcoind/rpc.d.ts +2 -1
  32. package/dist/bitcoind/rpc.js +3 -0
  33. package/dist/bitcoind/types.d.ts +16 -0
  34. package/dist/bytes.d.ts +1 -0
  35. package/dist/bytes.js +3 -0
  36. package/dist/cli/art.d.ts +2 -0
  37. package/dist/cli/art.js +37 -0
  38. package/dist/cli/commands/client-admin.d.ts +2 -0
  39. package/dist/cli/commands/client-admin.js +91 -0
  40. package/dist/cli/commands/follow.js +0 -2
  41. package/dist/cli/commands/mining-admin.js +6 -47
  42. package/dist/cli/commands/mining-read.js +11 -50
  43. package/dist/cli/commands/mining-runtime.js +38 -3
  44. package/dist/cli/commands/service-runtime.js +0 -2
  45. package/dist/cli/commands/status.js +8 -2
  46. package/dist/cli/commands/sync.js +51 -4
  47. package/dist/cli/commands/wallet-admin.js +142 -136
  48. package/dist/cli/commands/wallet-mutation.js +91 -79
  49. package/dist/cli/commands/wallet-read.js +15 -18
  50. package/dist/cli/context.js +4 -14
  51. package/dist/cli/mining-format.d.ts +0 -1
  52. package/dist/cli/mining-format.js +5 -37
  53. package/dist/cli/mining-json.d.ts +0 -18
  54. package/dist/cli/mining-json.js +0 -35
  55. package/dist/cli/mutation-command-groups.d.ts +1 -2
  56. package/dist/cli/mutation-command-groups.js +0 -5
  57. package/dist/cli/mutation-json.d.ts +24 -145
  58. package/dist/cli/mutation-json.js +30 -136
  59. package/dist/cli/mutation-resolved-json.d.ts +0 -7
  60. package/dist/cli/mutation-resolved-json.js +4 -10
  61. package/dist/cli/mutation-success.d.ts +2 -0
  62. package/dist/cli/mutation-success.js +11 -1
  63. package/dist/cli/mutation-text-format.js +1 -3
  64. package/dist/cli/output.d.ts +1 -1
  65. package/dist/cli/output.js +254 -231
  66. package/dist/cli/parse.d.ts +1 -1
  67. package/dist/cli/parse.js +93 -122
  68. package/dist/cli/preview-json.d.ts +17 -120
  69. package/dist/cli/preview-json.js +14 -97
  70. package/dist/cli/prompt.js +8 -13
  71. package/dist/cli/read-json.d.ts +15 -37
  72. package/dist/cli/read-json.js +44 -140
  73. package/dist/cli/runner.js +10 -13
  74. package/dist/cli/types.d.ts +8 -17
  75. package/dist/cli/types.js +0 -2
  76. package/dist/cli/wallet-format.d.ts +1 -0
  77. package/dist/cli/wallet-format.js +205 -144
  78. package/dist/cli/workflow-hints.d.ts +3 -3
  79. package/dist/cli/workflow-hints.js +11 -8
  80. package/dist/client/default-client.d.ts +3 -1
  81. package/dist/client/default-client.js +45 -2
  82. package/dist/client/factory.js +1 -1
  83. package/dist/client/initialization.js +23 -0
  84. package/dist/client/persistence.js +5 -5
  85. package/dist/client/store-adapter.js +1 -0
  86. package/dist/sqlite/checkpoints.d.ts +1 -0
  87. package/dist/sqlite/checkpoints.js +7 -0
  88. package/dist/sqlite/store.js +14 -1
  89. package/dist/types.d.ts +1 -0
  90. package/dist/wallet/coin-control.d.ts +41 -11
  91. package/dist/wallet/coin-control.js +100 -357
  92. package/dist/wallet/descriptor-normalization.d.ts +1 -3
  93. package/dist/wallet/descriptor-normalization.js +0 -16
  94. package/dist/wallet/lifecycle.d.ts +7 -99
  95. package/dist/wallet/lifecycle.js +513 -968
  96. package/dist/wallet/managed-core-wallet.d.ts +13 -0
  97. package/dist/wallet/managed-core-wallet.js +20 -0
  98. package/dist/wallet/mining/constants.d.ts +5 -12
  99. package/dist/wallet/mining/constants.js +5 -12
  100. package/dist/wallet/mining/control.d.ts +1 -13
  101. package/dist/wallet/mining/control.js +45 -349
  102. package/dist/wallet/mining/index.d.ts +3 -4
  103. package/dist/wallet/mining/index.js +1 -2
  104. package/dist/wallet/mining/runner.d.ts +179 -6
  105. package/dist/wallet/mining/runner.js +891 -501
  106. package/dist/wallet/mining/runtime-artifacts.js +23 -3
  107. package/dist/wallet/mining/sentence-protocol.d.ts +44 -0
  108. package/dist/wallet/mining/sentence-protocol.js +123 -0
  109. package/dist/wallet/mining/sentences.d.ts +4 -8
  110. package/dist/wallet/mining/sentences.js +3 -52
  111. package/dist/wallet/mining/state.d.ts +11 -6
  112. package/dist/wallet/mining/state.js +7 -6
  113. package/dist/wallet/mining/types.d.ts +2 -30
  114. package/dist/wallet/mining/visualizer.d.ts +31 -3
  115. package/dist/wallet/mining/visualizer.js +135 -13
  116. package/dist/wallet/read/context.d.ts +0 -2
  117. package/dist/wallet/read/context.js +119 -140
  118. package/dist/wallet/read/filter.js +2 -11
  119. package/dist/wallet/read/index.d.ts +1 -1
  120. package/dist/wallet/read/project.js +24 -77
  121. package/dist/wallet/read/types.d.ts +10 -25
  122. package/dist/wallet/reset.d.ts +0 -1
  123. package/dist/wallet/reset.js +60 -138
  124. package/dist/wallet/root-resolution.d.ts +1 -5
  125. package/dist/wallet/root-resolution.js +0 -18
  126. package/dist/wallet/runtime.d.ts +0 -6
  127. package/dist/wallet/runtime.js +0 -8
  128. package/dist/wallet/state/client-password-agent.js +208 -0
  129. package/dist/wallet/state/client-password.d.ts +65 -0
  130. package/dist/wallet/state/client-password.js +952 -0
  131. package/dist/wallet/state/crypto.d.ts +1 -20
  132. package/dist/wallet/state/crypto.js +0 -63
  133. package/dist/wallet/state/provider.d.ts +23 -11
  134. package/dist/wallet/state/provider.js +248 -290
  135. package/dist/wallet/state/storage.d.ts +2 -2
  136. package/dist/wallet/state/storage.js +48 -16
  137. package/dist/wallet/tx/anchor.d.ts +3 -28
  138. package/dist/wallet/tx/anchor.js +349 -1240
  139. package/dist/wallet/tx/bitcoin-transfer.d.ts +35 -0
  140. package/dist/wallet/tx/bitcoin-transfer.js +200 -0
  141. package/dist/wallet/tx/cog.d.ts +5 -1
  142. package/dist/wallet/tx/cog.js +149 -185
  143. package/dist/wallet/tx/common.d.ts +74 -10
  144. package/dist/wallet/tx/common.js +315 -138
  145. package/dist/wallet/tx/domain-admin.d.ts +3 -1
  146. package/dist/wallet/tx/domain-admin.js +61 -99
  147. package/dist/wallet/tx/domain-market.d.ts +5 -1
  148. package/dist/wallet/tx/domain-market.js +221 -228
  149. package/dist/wallet/tx/field.d.ts +4 -10
  150. package/dist/wallet/tx/field.js +84 -914
  151. package/dist/wallet/tx/identity-selector.d.ts +9 -3
  152. package/dist/wallet/tx/identity-selector.js +17 -35
  153. package/dist/wallet/tx/index.d.ts +3 -1
  154. package/dist/wallet/tx/index.js +2 -1
  155. package/dist/wallet/tx/register.d.ts +3 -1
  156. package/dist/wallet/tx/register.js +62 -220
  157. package/dist/wallet/tx/reputation.d.ts +3 -1
  158. package/dist/wallet/tx/reputation.js +58 -95
  159. package/dist/wallet/types.d.ts +8 -122
  160. package/package.json +5 -5
  161. package/dist/wallet/archive.d.ts +0 -4
  162. package/dist/wallet/archive.js +0 -41
  163. package/dist/wallet/mining/hook-protocol.d.ts +0 -47
  164. package/dist/wallet/mining/hook-protocol.js +0 -161
  165. package/dist/wallet/mining/hook-runner.js +0 -52
  166. package/dist/wallet/mining/hooks.d.ts +0 -38
  167. package/dist/wallet/mining/hooks.js +0 -520
  168. package/dist/wallet/state/explicit-lock.d.ts +0 -4
  169. package/dist/wallet/state/explicit-lock.js +0 -19
  170. package/dist/wallet/state/session.d.ts +0 -12
  171. package/dist/wallet/state/session.js +0 -23
  172. /package/dist/wallet/{mining/hook-runner.d.ts → state/client-password-agent.d.ts} +0 -0
@@ -6,7 +6,13 @@ type ReadyWalletMutationContext = WalletReadContext & {
6
6
  snapshot: NonNullable<WalletReadContext["snapshot"]>;
7
7
  model: NonNullable<WalletReadContext["model"]>;
8
8
  };
9
- type ResolvedIdentity = ReadyWalletMutationContext["model"]["identities"][number];
10
- export declare function getCanonicalIdentitySelector(identity: ResolvedIdentity): string;
11
- export declare function resolveIdentityBySelector(context: ReadyWalletMutationContext, selector: string, errorPrefix: string): ResolvedIdentity;
9
+ export interface ResolvedWalletIdentity {
10
+ index: 0;
11
+ scriptPubKeyHex: string;
12
+ address: string | null;
13
+ observedCogBalance: bigint | null;
14
+ readOnly: false;
15
+ }
16
+ export declare function getCanonicalIdentitySelector(identity: ResolvedWalletIdentity): string;
17
+ export declare function resolveIdentityBySelector(context: ReadyWalletMutationContext, selector: string, errorPrefix: string): ResolvedWalletIdentity;
12
18
  export {};
@@ -1,4 +1,14 @@
1
+ import { getBalance } from "@cogcoin/indexer/queries";
1
2
  import { serializeDomainReg } from "../cogop/index.js";
3
+ function resolveWalletIdentity(context) {
4
+ return {
5
+ index: 0,
6
+ scriptPubKeyHex: context.model.walletScriptPubKeyHex,
7
+ address: context.model.walletAddress,
8
+ observedCogBalance: getBalance(context.snapshot.state, new Uint8Array(Buffer.from(context.model.walletScriptPubKeyHex, "hex"))),
9
+ readOnly: false,
10
+ };
11
+ }
2
12
  function normalizeDomainName(value, errorCode) {
3
13
  const normalized = value.trim().toLowerCase();
4
14
  if (normalized.length === 0) {
@@ -8,45 +18,17 @@ function normalizeDomainName(value, errorCode) {
8
18
  return normalized;
9
19
  }
10
20
  export function getCanonicalIdentitySelector(identity) {
11
- return identity.selectors.find((selector) => selector.startsWith("id:")) ?? `id:${identity.index}`;
21
+ return identity.address ?? `spk:${identity.scriptPubKeyHex}`;
12
22
  }
13
23
  export function resolveIdentityBySelector(context, selector, errorPrefix) {
24
+ const walletIdentity = resolveWalletIdentity(context);
25
+ if (walletIdentity.address === null && walletIdentity.scriptPubKeyHex.length === 0) {
26
+ throw new Error(`${errorPrefix}_sender_not_found`);
27
+ }
14
28
  const trimmed = selector.trim();
15
29
  if (trimmed === "") {
16
30
  throw new Error(`${errorPrefix}_sender_selector_missing`);
17
31
  }
18
- if (trimmed.startsWith("id:")) {
19
- const index = Number.parseInt(trimmed.slice(3), 10);
20
- const identity = context.model.identities.find((entry) => entry.index === index) ?? null;
21
- if (identity === null) {
22
- throw new Error(`${errorPrefix}_sender_not_found`);
23
- }
24
- return identity;
25
- }
26
- if (trimmed.startsWith("domain:")) {
27
- const domainName = normalizeDomainName(trimmed.slice(7), `${errorPrefix}_sender_selector_invalid_domain`);
28
- const domain = context.model.domains.find((entry) => entry.name === domainName) ?? null;
29
- if (domain === null || domain.ownerLocalIndex === null) {
30
- throw new Error(`${errorPrefix}_sender_not_found`);
31
- }
32
- const identity = context.model.identities.find((entry) => entry.index === domain.ownerLocalIndex) ?? null;
33
- if (identity === null) {
34
- throw new Error(`${errorPrefix}_sender_not_found`);
35
- }
36
- return identity;
37
- }
38
- if (trimmed.startsWith("spk:")) {
39
- const scriptPubKeyHex = trimmed.slice(4).toLowerCase();
40
- const identity = context.model.identities.find((entry) => entry.scriptPubKeyHex === scriptPubKeyHex) ?? null;
41
- if (identity === null) {
42
- throw new Error(`${errorPrefix}_sender_not_found`);
43
- }
44
- return identity;
45
- }
46
- const normalizedAddress = trimmed.toLowerCase();
47
- const identity = context.model.identities.find((entry) => entry.address?.toLowerCase() === normalizedAddress) ?? null;
48
- if (identity === null) {
49
- throw new Error(`${errorPrefix}_sender_not_found`);
50
- }
51
- return identity;
32
+ void normalizeDomainName;
33
+ return walletIdentity;
52
34
  }
@@ -1,7 +1,9 @@
1
+ export { transferBitcoin, type BitcoinTransferResult, } from "./bitcoin-transfer.js";
1
2
  export { extractOpReturnPayloadFromScriptHex, registerDomain, type RegisterDomainResult, } from "./register.js";
3
+ export type { WalletMutationFeeSelectionSource, WalletMutationFeeSummary, } from "./common.js";
2
4
  export { buyDomain, parseCogAmountToCogtoshi, sellDomain, transferDomain, type DomainMarketMutationResult, } from "./domain-market.js";
3
5
  export { claimCogLock, lockCogToDomain, reclaimCogLock, sendCog, type CogMutationResult, } from "./cog.js";
4
- export { anchorDomain, clearPendingAnchor, type AnchorDomainResult, type ClearPendingAnchorResult, } from "./anchor.js";
6
+ export { anchorDomain, type AnchorDomainResult, } from "./anchor.js";
5
7
  export { clearDomainDelegate, clearDomainEndpoint, clearDomainMiner, setDomainCanonical, setDomainDelegate, setDomainEndpoint, setDomainMiner, type DomainAdminMutationResult, } from "./domain-admin.js";
6
8
  export { clearField, createField, setField, type ClearFieldOptions, type CreateFieldOptions, type FieldMutationResult, type FieldValueInputSource, type SetFieldOptions, } from "./field.js";
7
9
  export { giveReputation, revokeReputation, type GiveReputationOptions, type ReputationMutationResult, type RevokeReputationOptions, } from "./reputation.js";
@@ -1,7 +1,8 @@
1
+ export { transferBitcoin, } from "./bitcoin-transfer.js";
1
2
  export { extractOpReturnPayloadFromScriptHex, registerDomain, } from "./register.js";
2
3
  export { buyDomain, parseCogAmountToCogtoshi, sellDomain, transferDomain, } from "./domain-market.js";
3
4
  export { claimCogLock, lockCogToDomain, reclaimCogLock, sendCog, } from "./cog.js";
4
- export { anchorDomain, clearPendingAnchor, } from "./anchor.js";
5
+ export { anchorDomain, } from "./anchor.js";
5
6
  export { clearDomainDelegate, clearDomainEndpoint, clearDomainMiner, setDomainCanonical, setDomainDelegate, setDomainEndpoint, setDomainMiner, } from "./domain-admin.js";
6
7
  export { clearField, createField, setField, } from "./field.js";
7
8
  export { giveReputation, revokeReputation, } from "./reputation.js";
@@ -6,7 +6,7 @@ import type { WalletPrompter } from "../lifecycle.js";
6
6
  import { type WalletRuntimePaths } from "../runtime.js";
7
7
  import { type WalletSecretProvider } from "../state/provider.js";
8
8
  import { openWalletReadContext } from "../read/index.js";
9
- import { type WalletMutationRpcClient } from "./common.js";
9
+ import { type WalletMutationFeeSummary, type WalletMutationRpcClient } from "./common.js";
10
10
  interface WalletRegisterRpcClient extends WalletMutationRpcClient {
11
11
  getBlockchainInfo(): Promise<{
12
12
  blocks: number;
@@ -46,10 +46,12 @@ export interface RegisterDomainResult {
46
46
  txid: string;
47
47
  status: "live" | "confirmed";
48
48
  reusedExisting: boolean;
49
+ fees: WalletMutationFeeSummary;
49
50
  }
50
51
  export interface RegisterDomainOptions {
51
52
  domainName: string;
52
53
  fromIdentity?: string | null;
54
+ feeRateSatVb?: number | null;
53
55
  dataDir: string;
54
56
  databasePath: string;
55
57
  forceRace?: boolean;