@cogcoin/client 1.1.7 → 1.1.9

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 (284) hide show
  1. package/README.md +1 -1
  2. package/dist/bitcoind/service.js +1 -1
  3. package/dist/cli/commands/mining-read.js +1 -1
  4. package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
  5. package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
  6. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
  7. package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
  8. package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
  9. package/dist/cli/commands/wallet-mutation/cog.js +131 -0
  10. package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
  11. package/dist/cli/commands/wallet-mutation/context.js +18 -0
  12. package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
  13. package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
  14. package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
  15. package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
  16. package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
  17. package/dist/cli/commands/wallet-mutation/field.js +125 -0
  18. package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
  19. package/dist/cli/commands/wallet-mutation/register.js +38 -0
  20. package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
  21. package/dist/cli/commands/wallet-mutation/registry.js +39 -0
  22. package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
  23. package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
  24. package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
  25. package/dist/cli/commands/wallet-mutation/types.js +1 -0
  26. package/dist/cli/commands/wallet-mutation.js +13 -765
  27. package/dist/cli/commands/wallet-read.js +4 -4
  28. package/dist/cli/mutation-success.d.ts +0 -2
  29. package/dist/cli/output/classify.d.ts +7 -0
  30. package/dist/cli/output/classify.js +94 -0
  31. package/dist/cli/output/render.d.ts +2 -0
  32. package/dist/cli/output/render.js +13 -0
  33. package/dist/cli/output/rules/cli-surface.d.ts +2 -0
  34. package/dist/cli/output/rules/cli-surface.js +110 -0
  35. package/dist/cli/output/rules/generic.d.ts +2 -0
  36. package/dist/cli/output/rules/generic.js +13 -0
  37. package/dist/cli/output/rules/index.d.ts +2 -0
  38. package/dist/cli/output/rules/index.js +24 -0
  39. package/dist/cli/output/rules/mining-update.d.ts +2 -0
  40. package/dist/cli/output/rules/mining-update.js +68 -0
  41. package/dist/cli/output/rules/services.d.ts +2 -0
  42. package/dist/cli/output/rules/services.js +110 -0
  43. package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
  44. package/dist/cli/output/rules/wallet-admin.js +224 -0
  45. package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
  46. package/dist/cli/output/rules/wallet-mutations.js +274 -0
  47. package/dist/cli/output/types.d.ts +16 -0
  48. package/dist/cli/output/types.js +1 -0
  49. package/dist/cli/output.d.ts +2 -168
  50. package/dist/cli/output.js +6 -989
  51. package/dist/cli/pagination.d.ts +15 -0
  52. package/dist/cli/pagination.js +16 -0
  53. package/dist/cli/recommendations.d.ts +4 -0
  54. package/dist/cli/recommendations.js +108 -0
  55. package/dist/cli/wallet-format/availability.d.ts +5 -0
  56. package/dist/cli/wallet-format/availability.js +96 -0
  57. package/dist/cli/wallet-format/balance.d.ts +2 -0
  58. package/dist/cli/wallet-format/balance.js +162 -0
  59. package/dist/cli/wallet-format/domains.d.ts +8 -0
  60. package/dist/cli/wallet-format/domains.js +84 -0
  61. package/dist/cli/wallet-format/fields.d.ts +6 -0
  62. package/dist/cli/wallet-format/fields.js +61 -0
  63. package/dist/cli/wallet-format/identity.d.ts +5 -0
  64. package/dist/cli/wallet-format/identity.js +19 -0
  65. package/dist/cli/wallet-format/locks.d.ts +7 -0
  66. package/dist/cli/wallet-format/locks.js +52 -0
  67. package/dist/cli/wallet-format/overview.d.ts +2 -0
  68. package/dist/cli/wallet-format/overview.js +122 -0
  69. package/dist/cli/wallet-format/pending.d.ts +13 -0
  70. package/dist/cli/wallet-format/pending.js +101 -0
  71. package/dist/cli/wallet-format/shared.d.ts +7 -0
  72. package/dist/cli/wallet-format/shared.js +31 -0
  73. package/dist/cli/wallet-format/status.d.ts +3 -0
  74. package/dist/cli/wallet-format/status.js +27 -0
  75. package/dist/cli/wallet-format.d.ts +8 -30
  76. package/dist/cli/wallet-format.js +8 -830
  77. package/dist/cli/wallet-read-helpers.d.ts +6 -0
  78. package/dist/cli/wallet-read-helpers.js +17 -0
  79. package/dist/wallet/mining/candidate.d.ts +1 -1
  80. package/dist/wallet/mining/candidate.js +3 -3
  81. package/dist/wallet/mining/constants.d.ts +2 -2
  82. package/dist/wallet/mining/constants.js +2 -2
  83. package/dist/wallet/mining/engine-state.js +10 -0
  84. package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
  85. package/dist/wallet/mining/sentences.js +8 -8
  86. package/dist/wallet/mining/visualizer-sync.js +79 -15
  87. package/dist/wallet/read/context.js +1 -1
  88. package/dist/wallet/reset/artifacts.d.ts +16 -0
  89. package/dist/wallet/reset/artifacts.js +141 -0
  90. package/dist/wallet/reset/execution.d.ts +38 -0
  91. package/dist/wallet/reset/execution.js +458 -0
  92. package/dist/wallet/reset/preflight.d.ts +7 -0
  93. package/dist/wallet/reset/preflight.js +116 -0
  94. package/dist/wallet/reset/preview.d.ts +2 -0
  95. package/dist/wallet/reset/preview.js +50 -0
  96. package/dist/wallet/reset/process-cleanup.d.ts +12 -0
  97. package/dist/wallet/reset/process-cleanup.js +179 -0
  98. package/dist/wallet/reset/types.d.ts +189 -0
  99. package/dist/wallet/reset/types.js +1 -0
  100. package/dist/wallet/reset.d.ts +4 -119
  101. package/dist/wallet/reset.js +4 -882
  102. package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
  103. package/dist/wallet/tx/anchor/confirm.js +60 -0
  104. package/dist/wallet/tx/anchor/draft.d.ts +39 -0
  105. package/dist/wallet/tx/anchor/draft.js +167 -0
  106. package/dist/wallet/tx/anchor/index.d.ts +5 -0
  107. package/dist/wallet/tx/anchor/index.js +148 -0
  108. package/dist/wallet/tx/anchor/intent.d.ts +61 -0
  109. package/dist/wallet/tx/anchor/intent.js +101 -0
  110. package/dist/wallet/tx/anchor/plan.d.ts +3 -0
  111. package/dist/wallet/tx/anchor/plan.js +18 -0
  112. package/dist/wallet/tx/anchor/result.d.ts +25 -0
  113. package/dist/wallet/tx/anchor/result.js +20 -0
  114. package/dist/wallet/tx/anchor.d.ts +1 -39
  115. package/dist/wallet/tx/anchor.js +1 -494
  116. package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
  117. package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
  118. package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
  119. package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
  120. package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
  121. package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
  122. package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
  123. package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
  124. package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
  125. package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
  126. package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
  127. package/dist/wallet/tx/bitcoin-transfer.js +1 -200
  128. package/dist/wallet/tx/cog/confirm.d.ts +13 -0
  129. package/dist/wallet/tx/cog/confirm.js +59 -0
  130. package/dist/wallet/tx/cog/draft.d.ts +20 -0
  131. package/dist/wallet/tx/cog/draft.js +114 -0
  132. package/dist/wallet/tx/cog/index.d.ts +6 -0
  133. package/dist/wallet/tx/cog/index.js +117 -0
  134. package/dist/wallet/tx/cog/intent.d.ts +30 -0
  135. package/dist/wallet/tx/cog/intent.js +169 -0
  136. package/dist/wallet/tx/cog/plan.d.ts +19 -0
  137. package/dist/wallet/tx/cog/plan.js +65 -0
  138. package/dist/wallet/tx/cog/result.d.ts +27 -0
  139. package/dist/wallet/tx/cog/result.js +28 -0
  140. package/dist/wallet/tx/cog/types.d.ts +186 -0
  141. package/dist/wallet/tx/cog/types.js +2 -0
  142. package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
  143. package/dist/wallet/tx/cog/variants/claim.js +92 -0
  144. package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
  145. package/dist/wallet/tx/cog/variants/lock.js +102 -0
  146. package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
  147. package/dist/wallet/tx/cog/variants/send.js +77 -0
  148. package/dist/wallet/tx/cog.d.ts +1 -96
  149. package/dist/wallet/tx/cog.js +1 -824
  150. package/dist/wallet/tx/common.d.ts +14 -199
  151. package/dist/wallet/tx/common.js +10 -493
  152. package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
  153. package/dist/wallet/tx/domain-admin/confirm.js +58 -0
  154. package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
  155. package/dist/wallet/tx/domain-admin/draft.js +161 -0
  156. package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
  157. package/dist/wallet/tx/domain-admin/index.js +150 -0
  158. package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
  159. package/dist/wallet/tx/domain-admin/intent.js +61 -0
  160. package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
  161. package/dist/wallet/tx/domain-admin/plan.js +64 -0
  162. package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
  163. package/dist/wallet/tx/domain-admin/result.js +33 -0
  164. package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
  165. package/dist/wallet/tx/domain-admin/types.js +1 -0
  166. package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
  167. package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
  168. package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
  169. package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
  170. package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
  171. package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
  172. package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
  173. package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
  174. package/dist/wallet/tx/domain-admin.d.ts +1 -107
  175. package/dist/wallet/tx/domain-admin.js +1 -729
  176. package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
  177. package/dist/wallet/tx/domain-market/confirm.js +52 -0
  178. package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
  179. package/dist/wallet/tx/domain-market/draft.js +286 -0
  180. package/dist/wallet/tx/domain-market/index.d.ts +6 -0
  181. package/dist/wallet/tx/domain-market/index.js +145 -0
  182. package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
  183. package/dist/wallet/tx/domain-market/intent.js +131 -0
  184. package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
  185. package/dist/wallet/tx/domain-market/plan.js +98 -0
  186. package/dist/wallet/tx/domain-market/result.d.ts +45 -0
  187. package/dist/wallet/tx/domain-market/result.js +88 -0
  188. package/dist/wallet/tx/domain-market/types.d.ts +221 -0
  189. package/dist/wallet/tx/domain-market/types.js +1 -0
  190. package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
  191. package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
  192. package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
  193. package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
  194. package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
  195. package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
  196. package/dist/wallet/tx/domain-market.d.ts +1 -116
  197. package/dist/wallet/tx/domain-market.js +1 -1078
  198. package/dist/wallet/tx/draft-build.d.ts +60 -0
  199. package/dist/wallet/tx/draft-build.js +127 -0
  200. package/dist/wallet/tx/executor.d.ts +6 -40
  201. package/dist/wallet/tx/executor.js +6 -100
  202. package/dist/wallet/tx/fee.d.ts +30 -0
  203. package/dist/wallet/tx/fee.js +98 -0
  204. package/dist/wallet/tx/field/confirm.d.ts +11 -0
  205. package/dist/wallet/tx/field/confirm.js +19 -0
  206. package/dist/wallet/tx/field/draft.d.ts +23 -0
  207. package/dist/wallet/tx/field/draft.js +202 -0
  208. package/dist/wallet/tx/field/index.d.ts +5 -0
  209. package/dist/wallet/tx/field/index.js +140 -0
  210. package/dist/wallet/tx/field/intent.d.ts +5 -0
  211. package/dist/wallet/tx/field/intent.js +50 -0
  212. package/dist/wallet/tx/field/plan.d.ts +20 -0
  213. package/dist/wallet/tx/field/plan.js +65 -0
  214. package/dist/wallet/tx/field/result.d.ts +29 -0
  215. package/dist/wallet/tx/field/result.js +103 -0
  216. package/dist/wallet/tx/field/types.d.ts +163 -0
  217. package/dist/wallet/tx/field/types.js +1 -0
  218. package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
  219. package/dist/wallet/tx/field/variants/clear.js +60 -0
  220. package/dist/wallet/tx/field/variants/create.d.ts +2 -0
  221. package/dist/wallet/tx/field/variants/create.js +67 -0
  222. package/dist/wallet/tx/field/variants/set.d.ts +2 -0
  223. package/dist/wallet/tx/field/variants/set.js +195 -0
  224. package/dist/wallet/tx/field.d.ts +1 -95
  225. package/dist/wallet/tx/field.js +1 -920
  226. package/dist/wallet/tx/mining-preemption.d.ts +6 -0
  227. package/dist/wallet/tx/mining-preemption.js +7 -0
  228. package/dist/wallet/tx/primitives.d.ts +13 -0
  229. package/dist/wallet/tx/primitives.js +42 -0
  230. package/dist/wallet/tx/psbt-assert.d.ts +14 -0
  231. package/dist/wallet/tx/psbt-assert.js +39 -0
  232. package/dist/wallet/tx/publish.d.ts +37 -0
  233. package/dist/wallet/tx/publish.js +88 -0
  234. package/dist/wallet/tx/readiness.d.ts +7 -0
  235. package/dist/wallet/tx/readiness.js +61 -0
  236. package/dist/wallet/tx/reconcile.d.ts +24 -0
  237. package/dist/wallet/tx/reconcile.js +72 -0
  238. package/dist/wallet/tx/register/confirm.d.ts +6 -0
  239. package/dist/wallet/tx/register/confirm.js +66 -0
  240. package/dist/wallet/tx/register/draft.d.ts +42 -0
  241. package/dist/wallet/tx/register/draft.js +181 -0
  242. package/dist/wallet/tx/register/index.d.ts +6 -0
  243. package/dist/wallet/tx/register/index.js +158 -0
  244. package/dist/wallet/tx/register/intent.d.ts +74 -0
  245. package/dist/wallet/tx/register/intent.js +119 -0
  246. package/dist/wallet/tx/register/plan.d.ts +43 -0
  247. package/dist/wallet/tx/register/plan.js +168 -0
  248. package/dist/wallet/tx/register/result.d.ts +78 -0
  249. package/dist/wallet/tx/register/result.js +41 -0
  250. package/dist/wallet/tx/register.d.ts +1 -70
  251. package/dist/wallet/tx/register.js +1 -681
  252. package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
  253. package/dist/wallet/tx/reputation/confirm.js +51 -0
  254. package/dist/wallet/tx/reputation/draft.d.ts +20 -0
  255. package/dist/wallet/tx/reputation/draft.js +130 -0
  256. package/dist/wallet/tx/reputation/index.d.ts +4 -0
  257. package/dist/wallet/tx/reputation/index.js +162 -0
  258. package/dist/wallet/tx/reputation/intent.d.ts +36 -0
  259. package/dist/wallet/tx/reputation/intent.js +157 -0
  260. package/dist/wallet/tx/reputation/plan.d.ts +19 -0
  261. package/dist/wallet/tx/reputation/plan.js +64 -0
  262. package/dist/wallet/tx/reputation/result.d.ts +21 -0
  263. package/dist/wallet/tx/reputation/result.js +31 -0
  264. package/dist/wallet/tx/reputation/types.d.ts +130 -0
  265. package/dist/wallet/tx/reputation/types.js +1 -0
  266. package/dist/wallet/tx/reputation.d.ts +1 -74
  267. package/dist/wallet/tx/reputation.js +1 -556
  268. package/dist/wallet/tx/signing.d.ts +18 -0
  269. package/dist/wallet/tx/signing.js +31 -0
  270. package/dist/wallet/tx/state-persist.d.ts +27 -0
  271. package/dist/wallet/tx/state-persist.js +54 -0
  272. package/dist/wallet/tx/types.d.ts +44 -0
  273. package/dist/wallet/tx/types.js +1 -0
  274. package/package.json +1 -1
  275. package/dist/cli/mining-json.d.ts +0 -20
  276. package/dist/cli/mining-json.js +0 -46
  277. package/dist/cli/mutation-json.d.ts +0 -325
  278. package/dist/cli/mutation-json.js +0 -269
  279. package/dist/cli/mutation-resolved-json.d.ts +0 -117
  280. package/dist/cli/mutation-resolved-json.js +0 -123
  281. package/dist/cli/preview-json.d.ts +0 -319
  282. package/dist/cli/preview-json.js +0 -254
  283. package/dist/cli/read-json.d.ts +0 -190
  284. package/dist/cli/read-json.js +0 -627
@@ -0,0 +1,6 @@
1
+ import type { WalletFieldView, WalletLockView, WalletReadContext } from "../wallet/read/index.js";
2
+ export declare function listVisibleWalletLocks(context: WalletReadContext, options: {
3
+ claimableOnly: boolean;
4
+ reclaimableOnly: boolean;
5
+ }): WalletLockView[] | null;
6
+ export declare function listVisibleDomainFields(context: WalletReadContext, domainName: string): WalletFieldView[] | null;
@@ -0,0 +1,17 @@
1
+ import { listDomainFields, listWalletLocks, } from "../wallet/read/index.js";
2
+ export function listVisibleWalletLocks(context, options) {
3
+ const locks = listWalletLocks(context);
4
+ if (locks === null) {
5
+ return null;
6
+ }
7
+ if (options.claimableOnly) {
8
+ return locks.filter((lock) => lock.claimableNow);
9
+ }
10
+ if (options.reclaimableOnly) {
11
+ return locks.filter((lock) => lock.reclaimableNow);
12
+ }
13
+ return locks;
14
+ }
15
+ export function listVisibleDomainFields(context, domainName) {
16
+ return listDomainFields(context, domainName);
17
+ }
@@ -45,7 +45,7 @@ export declare function buildMiningGenerationRequest(options: {
45
45
  requiredWords: [string, string, string, string, string];
46
46
  }>;
47
47
  domainExtraPrompts: Record<string, string>;
48
- extraPrompt: string | null;
48
+ fallbackInstruction: string | null;
49
49
  }): MiningSentenceGenerationRequest;
50
50
  export declare function generateCandidatesForDomains(options: {
51
51
  rpc: MiningRpcClient;
@@ -114,13 +114,13 @@ export function buildMiningGenerationRequest(options) {
114
114
  targetBlockHeight: options.targetBlockHeight,
115
115
  referencedBlockHashDisplay: options.referencedBlockHashDisplay,
116
116
  generatedAtUnixMs: options.generatedAtUnixMs ?? Date.now(),
117
- extraPrompt: options.extraPrompt,
117
+ fallbackInstruction: options.fallbackInstruction,
118
118
  limits: createMiningSentenceRequestLimits(),
119
119
  rootDomains: options.domains.map((domain) => ({
120
120
  domainId: domain.domainId,
121
121
  domainName: domain.domainName,
122
122
  requiredWords: domain.requiredWords,
123
- extraPrompt: options.domainExtraPrompts[domain.domainName.toLowerCase()] ?? null,
123
+ domainInstruction: options.domainExtraPrompts[domain.domainName.toLowerCase()] ?? null,
124
124
  })),
125
125
  };
126
126
  }
@@ -193,7 +193,7 @@ export async function generateCandidatesForDomains(options) {
193
193
  referencedBlockHashDisplay: bestBlockHash,
194
194
  domains: rootDomains,
195
195
  domainExtraPrompts: clientConfig?.mining.domainExtraPrompts ?? {},
196
- extraPrompt: clientConfig?.mining.builtIn?.extraPrompt ?? null,
196
+ fallbackInstruction: clientConfig?.mining.builtIn?.extraPrompt ?? null,
197
197
  });
198
198
  let generated;
199
199
  try {
@@ -10,8 +10,8 @@ export declare const MINING_LOOP_INTERVAL_MS = 2000;
10
10
  export declare const MINING_BUILTIN_TIMEOUT_MS = 30000;
11
11
  export declare const MINING_SENTENCE_SCHEMA_VERSION: 1;
12
12
  export declare const MINING_SENTENCE_MAX_CANDIDATE_SENTENCE_UTF8_BYTES = 512;
13
- export declare const MINING_SENTENCE_MAX_CANDIDATES_PER_ROOT_DOMAIN = 8;
14
- export declare const MINING_SENTENCE_MAX_CANDIDATES_TOTAL = 64;
13
+ export declare const MINING_SENTENCE_MAX_CANDIDATES_PER_ROOT_DOMAIN = 25;
14
+ export declare const MINING_SENTENCE_MAX_CANDIDATES_TOTAL = 500;
15
15
  export declare const MINING_SENTENCE_TIMEOUT_MS = 30000;
16
16
  export declare const MINING_SHUTDOWN_GRACE_MS = 15000;
17
17
  export declare const MINING_SETTLEMENT_DUMMY_REWARD = 100n;
@@ -10,8 +10,8 @@ export const MINING_LOOP_INTERVAL_MS = 2_000;
10
10
  export const MINING_BUILTIN_TIMEOUT_MS = 30_000;
11
11
  export const MINING_SENTENCE_SCHEMA_VERSION = 1;
12
12
  export const MINING_SENTENCE_MAX_CANDIDATE_SENTENCE_UTF8_BYTES = 512;
13
- export const MINING_SENTENCE_MAX_CANDIDATES_PER_ROOT_DOMAIN = 8;
14
- export const MINING_SENTENCE_MAX_CANDIDATES_TOTAL = 64;
13
+ export const MINING_SENTENCE_MAX_CANDIDATES_PER_ROOT_DOMAIN = 25;
14
+ export const MINING_SENTENCE_MAX_CANDIDATES_TOTAL = 500;
15
15
  export const MINING_SENTENCE_TIMEOUT_MS = 30_000;
16
16
  export const MINING_SHUTDOWN_GRACE_MS = 15_000;
17
17
  export const MINING_SETTLEMENT_DUMMY_REWARD = 100n;
@@ -135,13 +135,23 @@ export function buildMiningTipKey(bestBlockHash, targetBlockHeight) {
135
135
  }
136
136
  return `${bestBlockHash}:${targetBlockHeight}`;
137
137
  }
138
+ function cloneSettledBoardEntries(entries) {
139
+ return entries.map((entry) => ({
140
+ ...entry,
141
+ requiredWords: [...entry.requiredWords],
142
+ }));
143
+ }
138
144
  export function resetMiningUiForTip(loopState, _targetBlockHeight) {
139
145
  const preservedTxid = loopState.ui.latestTxid;
140
146
  const preservedFundingAddress = loopState.ui.fundingAddress;
147
+ const preservedSettledBlockHeight = loopState.ui.settledBlockHeight;
148
+ const preservedSettledBoardEntries = cloneSettledBoardEntries(loopState.ui.settledBoardEntries);
141
149
  loopState.ui = {
142
150
  ...createEmptyMiningFollowVisualizerState(),
143
151
  fundingAddress: preservedFundingAddress,
144
152
  latestTxid: preservedTxid,
153
+ settledBlockHeight: preservedSettledBlockHeight,
154
+ settledBoardEntries: preservedSettledBoardEntries,
145
155
  };
146
156
  loopState.selectedCandidateTipKey = null;
147
157
  loopState.selectedCandidate = null;
@@ -5,7 +5,7 @@ export interface MiningSentenceGenerationRequestV1 {
5
5
  targetBlockHeight: number;
6
6
  referencedBlockHashDisplay: string;
7
7
  generatedAtUnixMs: number;
8
- extraPrompt: string | null;
8
+ fallbackInstruction: string | null;
9
9
  limits: {
10
10
  maxCandidatesPerRootDomain: number;
11
11
  maxCandidatesTotal: number;
@@ -16,7 +16,7 @@ export interface MiningSentenceGenerationRequestV1 {
16
16
  domainId: number;
17
17
  domainName: string;
18
18
  requiredWords: [string, string, string, string, string];
19
- extraPrompt: string | null;
19
+ domainInstruction: string | null;
20
20
  }>;
21
21
  }
22
22
  export interface MiningSentenceCandidateV1 {
@@ -26,20 +26,20 @@ function createBuiltInProviderTimeoutError(options) {
26
26
  const unit = seconds === "1" ? "second" : "seconds";
27
27
  return new MiningProviderRequestError("unavailable", `The built-in ${providerName} mining provider timed out after ${seconds} ${unit}.`);
28
28
  }
29
- function buildSystemPrompt(extraPrompt) {
29
+ function buildSystemPrompt(fallbackInstruction) {
30
30
  const lines = [
31
31
  "You are helping generate candidate Cogcoin mining sentences.",
32
32
  "Return only JSON matching the requested response schema.",
33
33
  "Every sentence must be a single natural-language sentence.",
34
34
  "Do not add commentary, markdown, or code fences.",
35
35
  "Do not invent domain IDs or request IDs.",
36
- "Each rootDomains entry may include an extraPrompt that applies only to that domain.",
37
- "If rootDomains[i].extraPrompt is present, use it only for candidates for that domainId.",
38
- "If rootDomains[i].extraPrompt is null, fall back to the request-level extraPrompt when it is present.",
36
+ "Each rootDomains entry may include a domainInstruction that applies only to that domain.",
37
+ "If rootDomains[i].domainInstruction is present, use it only for candidates for that domainId.",
38
+ "If rootDomains[i].domainInstruction is null, fall back to the request-level fallbackInstruction when it is present.",
39
39
  "Never apply one domain's prompt to another domain's candidates.",
40
40
  ];
41
- if (extraPrompt !== null && extraPrompt.trim().length > 0) {
42
- lines.push(`Request-level fallback instruction: ${extraPrompt.trim()}`);
41
+ if (fallbackInstruction !== null && fallbackInstruction.trim().length > 0) {
42
+ lines.push(`Request-level fallback instruction: ${fallbackInstruction.trim()}`);
43
43
  }
44
44
  return lines.join("\n");
45
45
  }
@@ -162,7 +162,7 @@ async function requestBuiltInSentences(options) {
162
162
  input: [
163
163
  {
164
164
  role: "system",
165
- content: buildSystemPrompt(options.request.extraPrompt),
165
+ content: buildSystemPrompt(options.request.fallbackInstruction),
166
166
  },
167
167
  {
168
168
  role: "user",
@@ -209,7 +209,7 @@ async function requestBuiltInSentences(options) {
209
209
  body: JSON.stringify({
210
210
  model,
211
211
  max_tokens: 1_200,
212
- system: buildSystemPrompt(options.request.extraPrompt),
212
+ system: buildSystemPrompt(options.request.fallbackInstruction),
213
213
  messages: [
214
214
  {
215
215
  role: "user",
@@ -4,6 +4,12 @@ import { FOLLOW_VISIBLE_PRIOR_BLOCKS } from "../../bitcoind/client/follow-block-
4
4
  import { buildMiningTipKey, resetMiningUiForTip } from "./engine-state.js";
5
5
  import { deriveMiningWordIndices, numberToSats, resolveBip39WordsFromIndices, } from "./engine-utils.js";
6
6
  import { createEmptyMiningFollowVisualizerState } from "./visualizer.js";
7
+ function cloneSettledBoardEntries(entries) {
8
+ return entries.map((entry) => ({
9
+ ...entry,
10
+ requiredWords: [...entry.requiredWords],
11
+ }));
12
+ }
7
13
  function resolveSettledWinnerRequiredWords(options) {
8
14
  const storedWords = resolveBip39WordsFromIndices(options.bip39WordIndices);
9
15
  if (storedWords.length > 0) {
@@ -20,6 +26,46 @@ function resolveSettledWinnerRequiredWords(options) {
20
26
  function fallbackSettledWinnerDomainName(domainId) {
21
27
  return `domain-${domainId}`;
22
28
  }
29
+ function resolveSettledBoardEntriesForHeight(options) {
30
+ if (options.snapshotState === null || options.snapshotState === undefined) {
31
+ return null;
32
+ }
33
+ const winners = getBlockWinners(options.snapshotState, options.blockHeight);
34
+ if (winners === null) {
35
+ return null;
36
+ }
37
+ const snapshotState = options.snapshotState;
38
+ return winners
39
+ .slice()
40
+ .sort((left, right) => left.rank - right.rank || left.txIndex - right.txIndex)
41
+ .slice(0, 5)
42
+ .map((winner) => ({
43
+ rank: winner.rank,
44
+ domainName: lookupDomainById(snapshotState, winner.domainId)?.name ?? fallbackSettledWinnerDomainName(winner.domainId),
45
+ sentence: winner.sentenceText ?? "[unavailable]",
46
+ requiredWords: resolveSettledWinnerRequiredWords({
47
+ domainId: winner.domainId,
48
+ bip39WordIndices: winner.bip39WordIndices,
49
+ snapshotTipPreviousHashHex: options.blockPreviousHashHex,
50
+ }),
51
+ }));
52
+ }
53
+ function resolveLatestPriorNonEmptySettledBoard(options) {
54
+ for (let blockHeight = options.snapshotTipHeight - 1; blockHeight >= 0; blockHeight -= 1) {
55
+ const settledBoardEntries = resolveSettledBoardEntriesForHeight({
56
+ snapshotState: options.snapshotState,
57
+ blockHeight,
58
+ blockPreviousHashHex: null,
59
+ });
60
+ if (settledBoardEntries !== null && settledBoardEntries.length > 0) {
61
+ return {
62
+ settledBlockHeight: blockHeight,
63
+ settledBoardEntries,
64
+ };
65
+ }
66
+ }
67
+ return null;
68
+ }
23
69
  function resolveCurrentMinedBlockBoard(options) {
24
70
  const settledBlockHeight = options.snapshotTipHeight ?? null;
25
71
  if (settledBlockHeight === null) {
@@ -34,23 +80,37 @@ function resolveCurrentMinedBlockBoard(options) {
34
80
  settledBoardEntries: [],
35
81
  };
36
82
  }
37
- const settledBoardEntries = (getBlockWinners(options.snapshotState, settledBlockHeight) ?? [])
38
- .slice()
39
- .sort((left, right) => left.rank - right.rank || left.txIndex - right.txIndex)
40
- .slice(0, 5)
41
- .map((winner) => ({
42
- rank: winner.rank,
43
- domainName: lookupDomainById(options.snapshotState, winner.domainId)?.name ?? fallbackSettledWinnerDomainName(winner.domainId),
44
- sentence: winner.sentenceText ?? "[unavailable]",
45
- requiredWords: resolveSettledWinnerRequiredWords({
46
- domainId: winner.domainId,
47
- bip39WordIndices: winner.bip39WordIndices,
48
- snapshotTipPreviousHashHex: options.snapshotTipPreviousHashHex,
49
- }),
50
- }));
83
+ const settledBoardEntries = resolveSettledBoardEntriesForHeight({
84
+ snapshotState: options.snapshotState,
85
+ blockHeight: settledBlockHeight,
86
+ blockPreviousHashHex: options.snapshotTipPreviousHashHex,
87
+ });
88
+ if (settledBoardEntries !== null) {
89
+ return {
90
+ settledBlockHeight,
91
+ settledBoardEntries,
92
+ };
93
+ }
94
+ const currentDisplayedBlockHeight = options.currentDisplayedBoard?.settledBlockHeight ?? null;
95
+ const currentDisplayedEntries = options.currentDisplayedBoard?.settledBoardEntries ?? [];
96
+ if (currentDisplayedBlockHeight !== null
97
+ && currentDisplayedBlockHeight <= settledBlockHeight
98
+ && currentDisplayedEntries.length > 0) {
99
+ return {
100
+ settledBlockHeight: currentDisplayedBlockHeight,
101
+ settledBoardEntries: cloneSettledBoardEntries(currentDisplayedEntries),
102
+ };
103
+ }
104
+ const latestPriorNonEmptyBoard = resolveLatestPriorNonEmptySettledBoard({
105
+ snapshotState: options.snapshotState,
106
+ snapshotTipHeight: settledBlockHeight,
107
+ });
108
+ if (latestPriorNonEmptyBoard !== null) {
109
+ return latestPriorNonEmptyBoard;
110
+ }
51
111
  return {
52
112
  settledBlockHeight,
53
- settledBoardEntries,
113
+ settledBoardEntries: [],
54
114
  };
55
115
  }
56
116
  export function resolveSettledBoard(options) {
@@ -66,6 +126,10 @@ function syncMiningUiSettledBoard(loopState, snapshotState, snapshotTipHeight, s
66
126
  snapshotState,
67
127
  snapshotTipHeight,
68
128
  snapshotTipPreviousHashHex,
129
+ currentDisplayedBoard: {
130
+ settledBlockHeight: loopState.ui.settledBlockHeight,
131
+ settledBoardEntries: loopState.ui.settledBoardEntries,
132
+ },
69
133
  });
70
134
  loopState.ui.settledBlockHeight = settledBoard.settledBlockHeight;
71
135
  loopState.ui.settledBoardEntries = settledBoard.settledBoardEntries;
@@ -16,7 +16,7 @@ import { createDefaultWalletSecretProvider, createWalletSecretReference, inspect
16
16
  import { describeClientPasswordLockedMessage, describeClientPasswordMigrationMessage, describeClientPasswordSetupMessage, } from "../state/client-password.js";
17
17
  import { openManagedWalletReadServiceBundle } from "./managed-services.js";
18
18
  import { createWalletReadModel } from "./project.js";
19
- const DEFAULT_SERVICE_START_TIMEOUT_MS = 10_000;
19
+ const DEFAULT_SERVICE_START_TIMEOUT_MS = 60_000;
20
20
  function btcAmountToSats(value) {
21
21
  return BigInt(Math.round(value * 100_000_000));
22
22
  }
@@ -0,0 +1,16 @@
1
+ import type { WalletRuntimePaths } from "../runtime.js";
2
+ import type { StagedArtifact, WalletResetArtifactDependencies } from "./types.js";
3
+ export declare function pathExists(path: string, deps?: WalletResetArtifactDependencies): Promise<boolean>;
4
+ export declare function readJsonFileOrNull<T>(path: string, deps?: WalletResetArtifactDependencies): Promise<T | null>;
5
+ export declare function isPathWithin(root: string, target: string): boolean;
6
+ export declare function dedupeSortedPaths(candidates: readonly string[]): string[];
7
+ export declare function resolveDefaultRemovedRoots(paths: WalletRuntimePaths): string[];
8
+ export declare function resolveBitcoindPreservingRemovedRoots(paths: WalletRuntimePaths): string[];
9
+ export declare function resolveRemovedRoots(paths: WalletRuntimePaths, options?: {
10
+ preserveBitcoinDataDir: boolean;
11
+ }): string[];
12
+ export declare function isDeletedByRemovalPlan(removedRoots: readonly string[], targetPath: string): boolean;
13
+ export declare function stageArtifact(sourcePath: string, stagingRoot: string, label: string, deps?: WalletResetArtifactDependencies): Promise<StagedArtifact | null>;
14
+ export declare function restoreStagedArtifacts(artifacts: readonly StagedArtifact[], deps?: WalletResetArtifactDependencies): Promise<void>;
15
+ export declare function deleteRemovedRoots(roots: readonly string[], deps?: WalletResetArtifactDependencies): Promise<void>;
16
+ export declare function deleteBootstrapSnapshotArtifacts(dataDir: string, deps?: WalletResetArtifactDependencies): Promise<void>;
@@ -0,0 +1,141 @@
1
+ import { access, constants, copyFile, mkdir, readFile, rename, rm } from "node:fs/promises";
2
+ import { dirname, join, relative } from "node:path";
3
+ import { DEFAULT_SNAPSHOT_METADATA } from "../../bitcoind/bootstrap/constants.js";
4
+ import { resolveBootstrapPathsForTesting } from "../../bitcoind/bootstrap/paths.js";
5
+ import { resolveLegacyHooksRootPath } from "../../app-paths.js";
6
+ function resolveArtifactDependencies(overrides = {}) {
7
+ return {
8
+ access: overrides.access ?? access,
9
+ copyFile: overrides.copyFile ?? copyFile,
10
+ mkdir: overrides.mkdir ?? mkdir,
11
+ readFile: overrides.readFile ?? readFile,
12
+ rename: overrides.rename ?? rename,
13
+ remove: overrides.remove ?? rm,
14
+ };
15
+ }
16
+ export async function pathExists(path, deps = {}) {
17
+ const resolved = resolveArtifactDependencies(deps);
18
+ try {
19
+ await resolved.access(path, constants.F_OK);
20
+ return true;
21
+ }
22
+ catch (error) {
23
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
24
+ return false;
25
+ }
26
+ throw error;
27
+ }
28
+ }
29
+ export async function readJsonFileOrNull(path, deps = {}) {
30
+ const resolved = resolveArtifactDependencies(deps);
31
+ try {
32
+ return JSON.parse(await resolved.readFile(path, "utf8"));
33
+ }
34
+ catch (error) {
35
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
36
+ return null;
37
+ }
38
+ return null;
39
+ }
40
+ }
41
+ export function isPathWithin(root, target) {
42
+ const rel = relative(root, target);
43
+ return rel === "" || (!rel.startsWith("..") && rel !== ".");
44
+ }
45
+ export function dedupeSortedPaths(candidates) {
46
+ return [...new Set(candidates)].sort((left, right) => right.length - left.length);
47
+ }
48
+ export function resolveDefaultRemovedRoots(paths) {
49
+ const configRoot = dirname(paths.clientConfigPath);
50
+ return dedupeSortedPaths([
51
+ paths.dataRoot,
52
+ paths.stateRoot,
53
+ paths.runtimeRoot,
54
+ configRoot,
55
+ ]);
56
+ }
57
+ export function resolveBitcoindPreservingRemovedRoots(paths) {
58
+ const configRoot = dirname(paths.clientConfigPath);
59
+ return dedupeSortedPaths([
60
+ paths.clientDataDir,
61
+ paths.indexerRoot,
62
+ paths.stateRoot,
63
+ paths.runtimeRoot,
64
+ configRoot,
65
+ resolveLegacyHooksRootPath({
66
+ dataRoot: paths.dataRoot,
67
+ clientConfigPath: paths.clientConfigPath,
68
+ }),
69
+ ]);
70
+ }
71
+ export function resolveRemovedRoots(paths, options = {
72
+ preserveBitcoinDataDir: false,
73
+ }) {
74
+ return options.preserveBitcoinDataDir
75
+ ? resolveBitcoindPreservingRemovedRoots(paths)
76
+ : resolveDefaultRemovedRoots(paths);
77
+ }
78
+ export function isDeletedByRemovalPlan(removedRoots, targetPath) {
79
+ return removedRoots.some((root) => isPathWithin(root, targetPath));
80
+ }
81
+ async function moveFile(sourcePath, destinationPath, deps = {}) {
82
+ const resolved = resolveArtifactDependencies(deps);
83
+ await resolved.mkdir(dirname(destinationPath), { recursive: true });
84
+ try {
85
+ await resolved.rename(sourcePath, destinationPath);
86
+ }
87
+ catch (error) {
88
+ if (!(error instanceof Error) || !("code" in error) || error.code !== "EXDEV") {
89
+ throw error;
90
+ }
91
+ await resolved.copyFile(sourcePath, destinationPath);
92
+ await resolved.remove(sourcePath, { force: true });
93
+ }
94
+ }
95
+ export async function stageArtifact(sourcePath, stagingRoot, label, deps = {}) {
96
+ if (!await pathExists(sourcePath, deps)) {
97
+ return null;
98
+ }
99
+ const stagedPath = join(stagingRoot, label);
100
+ await moveFile(sourcePath, stagedPath, deps);
101
+ return {
102
+ originalPath: sourcePath,
103
+ stagedPath,
104
+ restorePath: sourcePath,
105
+ };
106
+ }
107
+ export async function restoreStagedArtifacts(artifacts, deps = {}) {
108
+ for (const artifact of artifacts) {
109
+ if (!await pathExists(artifact.stagedPath, deps)) {
110
+ continue;
111
+ }
112
+ await moveFile(artifact.stagedPath, artifact.restorePath, deps);
113
+ }
114
+ }
115
+ export async function deleteRemovedRoots(roots, deps = {}) {
116
+ const resolved = resolveArtifactDependencies(deps);
117
+ try {
118
+ for (const root of roots) {
119
+ await resolved.remove(root, {
120
+ recursive: true,
121
+ force: true,
122
+ });
123
+ }
124
+ }
125
+ catch {
126
+ throw new Error("reset_data_root_delete_failed");
127
+ }
128
+ }
129
+ export async function deleteBootstrapSnapshotArtifacts(dataDir, deps = {}) {
130
+ const resolved = resolveArtifactDependencies(deps);
131
+ const snapshotPaths = resolveBootstrapPathsForTesting(dataDir, DEFAULT_SNAPSHOT_METADATA);
132
+ await Promise.all([
133
+ snapshotPaths.snapshotPath,
134
+ snapshotPaths.partialSnapshotPath,
135
+ snapshotPaths.statePath,
136
+ snapshotPaths.quoteStatePath,
137
+ ].map(async (path) => resolved.remove(path, {
138
+ recursive: false,
139
+ force: true,
140
+ })));
141
+ }
@@ -0,0 +1,38 @@
1
+ import { type WalletRuntimePaths } from "../runtime.js";
2
+ import { type WalletSecretProvider } from "../state/provider.js";
3
+ import { type WalletStateSaveAccess } from "../state/storage.js";
4
+ import type { WalletStateV1 } from "../types.js";
5
+ import { preflightReset } from "./preflight.js";
6
+ import type { ResetExecutionDecision, WalletAccessForReset, WalletResetAction, WalletResetBitcoinDataDirResultStatus, WalletResetExecutionOptions, WalletResetPreflight, WalletResetResult, WalletResetSnapshotResultStatus } from "./types.js";
7
+ export declare function loadWalletForEntropyReset(options: {
8
+ wallet: WalletResetPreflight["wallet"];
9
+ paths: WalletRuntimePaths;
10
+ provider: WalletSecretProvider;
11
+ }): Promise<WalletAccessForReset>;
12
+ export declare function createEntropyRetainedWalletState(previousState: WalletStateV1, nowUnixMs: number): WalletStateV1;
13
+ export declare function recreateManagedCoreWalletReplicaForReset(options: {
14
+ state: WalletStateV1;
15
+ access: WalletStateSaveAccess;
16
+ paths: NonNullable<WalletResetExecutionOptions["paths"]>;
17
+ dataDir: string;
18
+ nowUnixMs: number;
19
+ attachService?: WalletResetExecutionOptions["attachService"];
20
+ rpcFactory?: WalletResetExecutionOptions["rpcFactory"];
21
+ }): Promise<WalletStateV1>;
22
+ export declare function resolveResetExecutionDecision(options: {
23
+ preflight: Awaited<ReturnType<typeof preflightReset>>;
24
+ provider: NonNullable<WalletResetExecutionOptions["provider"]>;
25
+ prompter: WalletResetExecutionOptions["prompter"];
26
+ paths: NonNullable<WalletResetExecutionOptions["paths"]>;
27
+ }): Promise<ResetExecutionDecision>;
28
+ export declare function determineWalletAction(walletPresent: boolean, walletChoice: ResetExecutionDecision["walletChoice"]): WalletResetAction;
29
+ export declare function determineSnapshotResultStatus(options: {
30
+ snapshotStatus: Awaited<ReturnType<typeof preflightReset>>["snapshot"]["status"];
31
+ deleteSnapshot: boolean;
32
+ }): WalletResetSnapshotResultStatus;
33
+ export declare function determineBitcoinDataDirResultStatus(options: {
34
+ bitcoinDataDirStatus: Awaited<ReturnType<typeof preflightReset>>["bitcoinDataDir"]["status"];
35
+ deleteSnapshot: boolean;
36
+ deleteBitcoinDataDir: boolean;
37
+ }): WalletResetBitcoinDataDirResultStatus;
38
+ export declare function resetWallet(options: WalletResetExecutionOptions): Promise<WalletResetResult>;