@bsv/wallet-toolbox 2.1.25 → 3.0.0-alpha.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 (257) hide show
  1. package/docs/CREATEACTION_BLOCKERS.md +391 -0
  2. package/docs/CUTOVER_RUNBOOK.md +95 -0
  3. package/docs/REQUIREMENTS_COMPLIANCE.md +157 -0
  4. package/docs/ROLLOUT_PLAN.md +273 -0
  5. package/docs/SESSION_HANDOFF.md +298 -0
  6. package/docs/STORAGE_METHOD_WIRING.md +176 -0
  7. package/docs/client.md +3765 -1325
  8. package/docs/monitor.md +255 -33
  9. package/docs/services.md +304 -280
  10. package/docs/setup.md +24 -24
  11. package/docs/storage.md +2783 -251
  12. package/docs/v3-upgrade/index.html +911 -0
  13. package/docs/wallet.md +4956 -9455
  14. package/out/src/Wallet.d.ts.map +1 -1
  15. package/out/src/Wallet.js.map +1 -1
  16. package/out/src/WalletLogger.d.ts.map +1 -1
  17. package/out/src/WalletLogger.js.map +1 -1
  18. package/out/src/__tests/CWIStyleWalletManager.test.js.map +1 -1
  19. package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts.map +1 -1
  20. package/out/src/__tests/WalletPermissionsManager.fixtures.js.map +1 -1
  21. package/out/src/entropy/EntropyCollector.d.ts.map +1 -1
  22. package/out/src/entropy/EntropyCollector.js.map +1 -1
  23. package/out/src/monitor/LeasedMonitorTask.d.ts +43 -0
  24. package/out/src/monitor/LeasedMonitorTask.d.ts.map +1 -0
  25. package/out/src/monitor/LeasedMonitorTask.js +89 -0
  26. package/out/src/monitor/LeasedMonitorTask.js.map +1 -0
  27. package/out/src/monitor/Monitor.d.ts +7 -0
  28. package/out/src/monitor/Monitor.d.ts.map +1 -1
  29. package/out/src/monitor/Monitor.js +7 -0
  30. package/out/src/monitor/Monitor.js.map +1 -1
  31. package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
  32. package/out/src/monitor/MonitorDaemon.js.map +1 -1
  33. package/out/src/monitor/V7LeasedTask.d.ts +43 -0
  34. package/out/src/monitor/V7LeasedTask.d.ts.map +1 -0
  35. package/out/src/monitor/V7LeasedTask.js +89 -0
  36. package/out/src/monitor/V7LeasedTask.js.map +1 -0
  37. package/out/src/monitor/index.all.d.ts +1 -0
  38. package/out/src/monitor/index.all.d.ts.map +1 -1
  39. package/out/src/monitor/index.all.js +1 -0
  40. package/out/src/monitor/index.all.js.map +1 -1
  41. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +2 -0
  42. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
  43. package/out/src/monitor/tasks/TaskCheckForProofs.js +55 -0
  44. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
  45. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
  46. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
  47. package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
  48. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  49. package/out/src/sdk/types.d.ts +32 -0
  50. package/out/src/sdk/types.d.ts.map +1 -1
  51. package/out/src/sdk/types.js +50 -1
  52. package/out/src/sdk/types.js.map +1 -1
  53. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
  54. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
  55. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
  56. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
  57. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts.map +1 -1
  58. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js.map +1 -1
  59. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
  60. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
  61. package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.d.ts.map +1 -1
  62. package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.js.map +1 -1
  63. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
  64. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
  65. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
  66. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
  67. package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.d.ts.map +1 -1
  68. package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.js.map +1 -1
  69. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
  70. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -1
  71. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
  72. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
  73. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.d.ts.map +1 -1
  74. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.js.map +1 -1
  75. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
  76. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
  77. package/out/src/services/chaintracker/chaintracks/util/__tests/SingleWriterMultiReaderLock.test.js.map +1 -1
  78. package/out/src/storage/StorageIdb.d.ts.map +1 -1
  79. package/out/src/storage/StorageIdb.js +10 -5
  80. package/out/src/storage/StorageIdb.js.map +1 -1
  81. package/out/src/storage/StorageKnex.d.ts +133 -3
  82. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  83. package/out/src/storage/StorageKnex.js +691 -94
  84. package/out/src/storage/StorageKnex.js.map +1 -1
  85. package/out/src/storage/StorageProvider.d.ts +114 -1
  86. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  87. package/out/src/storage/StorageProvider.js +164 -4
  88. package/out/src/storage/StorageProvider.js.map +1 -1
  89. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  90. package/out/src/storage/WalletStorageManager.js.map +1 -1
  91. package/out/src/storage/idbHelpers.d.ts +5 -0
  92. package/out/src/storage/idbHelpers.d.ts.map +1 -1
  93. package/out/src/storage/idbHelpers.js +42 -0
  94. package/out/src/storage/idbHelpers.js.map +1 -1
  95. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
  96. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +116 -4
  97. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
  98. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  99. package/out/src/storage/methods/createAction.js +22 -5
  100. package/out/src/storage/methods/createAction.js.map +1 -1
  101. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  102. package/out/src/storage/methods/internalizeAction.js +172 -5
  103. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  104. package/out/src/storage/methods/listActionsKnex.d.ts +49 -0
  105. package/out/src/storage/methods/listActionsKnex.d.ts.map +1 -1
  106. package/out/src/storage/methods/listActionsKnex.js +179 -69
  107. package/out/src/storage/methods/listActionsKnex.js.map +1 -1
  108. package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -1
  109. package/out/src/storage/methods/listOutputsKnex.js +51 -4
  110. package/out/src/storage/methods/listOutputsKnex.js.map +1 -1
  111. package/out/src/storage/methods/processAction.d.ts.map +1 -1
  112. package/out/src/storage/methods/processAction.js +82 -14
  113. package/out/src/storage/methods/processAction.js.map +1 -1
  114. package/out/src/storage/methods/purgeData.d.ts.map +1 -1
  115. package/out/src/storage/methods/purgeData.js +22 -14
  116. package/out/src/storage/methods/purgeData.js.map +1 -1
  117. package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
  118. package/out/src/storage/methods/reviewStatus.js +18 -9
  119. package/out/src/storage/methods/reviewStatus.js.map +1 -1
  120. package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
  121. package/out/src/storage/schema/KnexMigrations.js +134 -0
  122. package/out/src/storage/schema/KnexMigrations.js.map +1 -1
  123. package/out/src/storage/schema/StorageIdbSchema.d.ts +43 -2
  124. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
  125. package/out/src/storage/schema/__tests/backfill.runner.test.d.ts +2 -0
  126. package/out/src/storage/schema/__tests/backfill.runner.test.d.ts.map +1 -0
  127. package/out/src/storage/schema/__tests/backfill.runner.test.js +148 -0
  128. package/out/src/storage/schema/__tests/backfill.runner.test.js.map +1 -0
  129. package/out/src/storage/schema/__tests/backfill.test.d.ts +2 -0
  130. package/out/src/storage/schema/__tests/backfill.test.d.ts.map +1 -0
  131. package/out/src/storage/schema/__tests/backfill.test.js +96 -0
  132. package/out/src/storage/schema/__tests/backfill.test.js.map +1 -0
  133. package/out/src/storage/schema/__tests/processingFsm.test.d.ts +2 -0
  134. package/out/src/storage/schema/__tests/processingFsm.test.d.ts.map +1 -0
  135. package/out/src/storage/schema/__tests/processingFsm.test.js +42 -0
  136. package/out/src/storage/schema/__tests/processingFsm.test.js.map +1 -0
  137. package/out/src/storage/schema/__tests/processingFsmLegacyMapping.test.d.ts +2 -0
  138. package/out/src/storage/schema/__tests/processingFsmLegacyMapping.test.d.ts.map +1 -0
  139. package/out/src/storage/schema/__tests/processingFsmLegacyMapping.test.js +82 -0
  140. package/out/src/storage/schema/__tests/processingFsmLegacyMapping.test.js.map +1 -0
  141. package/out/src/storage/schema/__tests/spendabilityRule.test.d.ts +2 -0
  142. package/out/src/storage/schema/__tests/spendabilityRule.test.d.ts.map +1 -0
  143. package/out/src/storage/schema/__tests/spendabilityRule.test.js +29 -0
  144. package/out/src/storage/schema/__tests/spendabilityRule.test.js.map +1 -0
  145. package/out/src/storage/schema/__tests/v7FsmLegacyMapping.test.d.ts +2 -0
  146. package/out/src/storage/schema/__tests/v7FsmLegacyMapping.test.d.ts.map +1 -0
  147. package/out/src/storage/schema/__tests/v7FsmLegacyMapping.test.js +77 -0
  148. package/out/src/storage/schema/__tests/v7FsmLegacyMapping.test.js.map +1 -0
  149. package/out/src/storage/schema/backfill.d.ts +35 -0
  150. package/out/src/storage/schema/backfill.d.ts.map +1 -0
  151. package/out/src/storage/schema/backfill.idb.d.ts +32 -0
  152. package/out/src/storage/schema/backfill.idb.d.ts.map +1 -0
  153. package/out/src/storage/schema/backfill.idb.js +95 -0
  154. package/out/src/storage/schema/backfill.idb.js.map +1 -0
  155. package/out/src/storage/schema/backfill.js +150 -0
  156. package/out/src/storage/schema/backfill.js.map +1 -0
  157. package/out/src/storage/schema/backfill.knex.d.ts +32 -0
  158. package/out/src/storage/schema/backfill.knex.d.ts.map +1 -0
  159. package/out/src/storage/schema/backfill.knex.js +240 -0
  160. package/out/src/storage/schema/backfill.knex.js.map +1 -0
  161. package/out/src/storage/schema/backfill.runner.d.ts +63 -0
  162. package/out/src/storage/schema/backfill.runner.d.ts.map +1 -0
  163. package/out/src/storage/schema/backfill.runner.js +64 -0
  164. package/out/src/storage/schema/backfill.runner.js.map +1 -0
  165. package/out/src/storage/schema/coinbaseMaturityBackfill.d.ts +25 -0
  166. package/out/src/storage/schema/coinbaseMaturityBackfill.d.ts.map +1 -0
  167. package/out/src/storage/schema/coinbaseMaturityBackfill.js +75 -0
  168. package/out/src/storage/schema/coinbaseMaturityBackfill.js.map +1 -0
  169. package/out/src/storage/schema/monitorLease.d.ts +57 -0
  170. package/out/src/storage/schema/monitorLease.d.ts.map +1 -0
  171. package/out/src/storage/schema/monitorLease.js +101 -0
  172. package/out/src/storage/schema/monitorLease.js.map +1 -0
  173. package/out/src/storage/schema/processingFsm.d.ts +27 -0
  174. package/out/src/storage/schema/processingFsm.d.ts.map +1 -0
  175. package/out/src/storage/schema/processingFsm.js +132 -0
  176. package/out/src/storage/schema/processingFsm.js.map +1 -0
  177. package/out/src/storage/schema/schemaCutover.d.ts +34 -0
  178. package/out/src/storage/schema/schemaCutover.d.ts.map +1 -0
  179. package/out/src/storage/schema/schemaCutover.js +230 -0
  180. package/out/src/storage/schema/schemaCutover.js.map +1 -0
  181. package/out/src/storage/schema/schemaCutoverIdb.d.ts +26 -0
  182. package/out/src/storage/schema/schemaCutoverIdb.d.ts.map +1 -0
  183. package/out/src/storage/schema/schemaCutoverIdb.js +90 -0
  184. package/out/src/storage/schema/schemaCutoverIdb.js.map +1 -0
  185. package/out/src/storage/schema/spendabilityRefresh.d.ts +49 -0
  186. package/out/src/storage/schema/spendabilityRefresh.d.ts.map +1 -0
  187. package/out/src/storage/schema/spendabilityRefresh.js +120 -0
  188. package/out/src/storage/schema/spendabilityRefresh.js.map +1 -0
  189. package/out/src/storage/schema/spendabilityRule.d.ts +45 -0
  190. package/out/src/storage/schema/spendabilityRule.d.ts.map +1 -0
  191. package/out/src/storage/schema/spendabilityRule.js +52 -0
  192. package/out/src/storage/schema/spendabilityRule.js.map +1 -0
  193. package/out/src/storage/schema/tables/TableAction.d.ts +3 -3
  194. package/out/src/storage/schema/tables/TableAction.d.ts.map +1 -1
  195. package/out/src/storage/schema/tables/TableChainTip.d.ts +1 -1
  196. package/out/src/storage/schema/tables/TableMonitorLease.d.ts +1 -1
  197. package/out/src/storage/schema/tables/TableOutput.d.ts +7 -0
  198. package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -1
  199. package/out/src/storage/schema/tables/TableOutput.js.map +1 -1
  200. package/out/src/storage/schema/tables/TableTransactionNew.d.ts +50 -0
  201. package/out/src/storage/schema/tables/TableTransactionNew.d.ts.map +1 -0
  202. package/out/src/storage/schema/tables/TableTransactionNew.js +3 -0
  203. package/out/src/storage/schema/tables/TableTransactionNew.js.map +1 -0
  204. package/out/src/storage/schema/tables/TableTxAudit.d.ts +1 -1
  205. package/out/src/storage/schema/tables/index.d.ts +5 -0
  206. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  207. package/out/src/storage/schema/tables/index.js +5 -0
  208. package/out/src/storage/schema/tables/index.js.map +1 -1
  209. package/out/src/storage/schema/transactionCrud.d.ts +41 -0
  210. package/out/src/storage/schema/transactionCrud.d.ts.map +1 -0
  211. package/out/src/storage/schema/transactionCrud.js +205 -0
  212. package/out/src/storage/schema/transactionCrud.js.map +1 -0
  213. package/out/src/storage/schema/transactionService.d.ts +315 -0
  214. package/out/src/storage/schema/transactionService.d.ts.map +1 -0
  215. package/out/src/storage/schema/transactionService.js +783 -0
  216. package/out/src/storage/schema/transactionService.js.map +1 -0
  217. package/out/src/storage/schema/txAudit.d.ts +33 -0
  218. package/out/src/storage/schema/txAudit.d.ts.map +1 -0
  219. package/out/src/storage/schema/txAudit.js +64 -0
  220. package/out/src/storage/schema/txAudit.js.map +1 -0
  221. package/out/src/storage/schema/v7Backfill.d.ts.map +1 -1
  222. package/out/src/storage/schema/v7Backfill.js +4 -1
  223. package/out/src/storage/schema/v7Backfill.js.map +1 -1
  224. package/out/src/storage/schema/v7Backfill.runner.d.ts.map +1 -1
  225. package/out/src/storage/schema/v7Backfill.runner.js +3 -1
  226. package/out/src/storage/schema/v7Backfill.runner.js.map +1 -1
  227. package/out/src/storage/schema/v7CoinbaseMaturityBackfill.d.ts +25 -0
  228. package/out/src/storage/schema/v7CoinbaseMaturityBackfill.d.ts.map +1 -0
  229. package/out/src/storage/schema/v7CoinbaseMaturityBackfill.js +75 -0
  230. package/out/src/storage/schema/v7CoinbaseMaturityBackfill.js.map +1 -0
  231. package/out/src/storage/schema/v7Crud.d.ts +5 -3
  232. package/out/src/storage/schema/v7Crud.d.ts.map +1 -1
  233. package/out/src/storage/schema/v7Crud.js +11 -9
  234. package/out/src/storage/schema/v7Crud.js.map +1 -1
  235. package/out/src/storage/schema/v7Cutover.d.ts +34 -0
  236. package/out/src/storage/schema/v7Cutover.d.ts.map +1 -0
  237. package/out/src/storage/schema/v7Cutover.js +223 -0
  238. package/out/src/storage/schema/v7Cutover.js.map +1 -0
  239. package/out/src/storage/schema/v7CutoverIdb.d.ts +26 -0
  240. package/out/src/storage/schema/v7CutoverIdb.d.ts.map +1 -0
  241. package/out/src/storage/schema/v7CutoverIdb.js +90 -0
  242. package/out/src/storage/schema/v7CutoverIdb.js.map +1 -0
  243. package/out/src/storage/schema/v7Fsm.d.ts.map +1 -1
  244. package/out/src/storage/schema/v7Fsm.js +22 -6
  245. package/out/src/storage/schema/v7Fsm.js.map +1 -1
  246. package/out/src/storage/schema/v7Service.d.ts +305 -0
  247. package/out/src/storage/schema/v7Service.d.ts.map +1 -0
  248. package/out/src/storage/schema/v7Service.js +757 -0
  249. package/out/src/storage/schema/v7Service.js.map +1 -0
  250. package/out/src/storage/schema/v7SpendabilityRefresh.d.ts +49 -0
  251. package/out/src/storage/schema/v7SpendabilityRefresh.d.ts.map +1 -0
  252. package/out/src/storage/schema/v7SpendabilityRefresh.js +111 -0
  253. package/out/src/storage/schema/v7SpendabilityRefresh.js.map +1 -0
  254. package/out/src/storage/storageProviderHelpers.js +1 -1
  255. package/out/src/storage/storageProviderHelpers.js.map +1 -1
  256. package/out/src/utility/Format.js.map +1 -1
  257. package/package.json +7 -4
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runV7Cutover = runV7Cutover;
4
+ exports.rollbackV7Cutover = rollbackV7Cutover;
5
+ const v7Backfill_knex_1 = require("./v7Backfill.knex");
6
+ const v7Backfill_runner_1 = require("./v7Backfill.runner");
7
+ /**
8
+ * §3 Step 6 of PROD_REQ_V7_TS.md — destructive cutover.
9
+ *
10
+ * Renames the legacy `transactions`, `proven_tx_reqs`, and `proven_txs` tables
11
+ * to `*_legacy`, swaps the V7 `transactions_v7` table in as the new
12
+ * canonical `transactions`, and remaps every FK value in `outputs`,
13
+ * `commissions`, and `tx_labels_map` so that downstream storage methods
14
+ * continue to read consistent rows.
15
+ *
16
+ * Not registered as a Knex migration because applying it changes the meaning
17
+ * of table names that legacy storage methods still address. Run it only when
18
+ * the calling application is ready to use the V7 storage path.
19
+ *
20
+ * Safe to call:
21
+ * - on a populated DB that has not yet been cutover (performs full migration)
22
+ * - on a fresh DB (renames empty tables to match the post-cutover layout)
23
+ * - twice in a row (second call is a no-op via the `transactions_legacy`
24
+ * presence guard)
25
+ *
26
+ * The function is intentionally not wrapped in a Knex transaction: on SQLite
27
+ * we need to toggle the per-connection `legacy_alter_table` pragma between
28
+ * statements, which is incompatible with the deferred-commit semantics
29
+ * Knex uses inside `knex.transaction`.
30
+ */
31
+ async function runV7Cutover(knex) {
32
+ var _a, _b;
33
+ const dbtype = await determineDBType(knex);
34
+ const isSqlite = dbtype === 'SQLite';
35
+ // Idempotency guard.
36
+ if (await hasTable(knex, 'transactions_legacy'))
37
+ return;
38
+ // Ensure backfill has populated transactions_v7 / actions before remapping.
39
+ const txCount = await knex('transactions').count({ c: '*' }).first();
40
+ const v7Count = await knex('transactions_v7').count({ c: '*' }).first();
41
+ const hasLegacyData = ((_a = txCount === null || txCount === void 0 ? void 0 : txCount.c) !== null && _a !== void 0 ? _a : 0) > 0;
42
+ const v7Populated = ((_b = v7Count === null || v7Count === void 0 ? void 0 : v7Count.c) !== null && _b !== void 0 ? _b : 0) > 0;
43
+ if (hasLegacyData && !v7Populated) {
44
+ const driver = new v7Backfill_knex_1.V7KnexBackfillDriver(knex);
45
+ await (0, v7Backfill_runner_1.runV7Backfill)(driver);
46
+ }
47
+ // Build mappings legacy.transactionId -> { v7Id, actionId }.
48
+ const txMapRows = hasLegacyData
49
+ ? await knex('transactions as t')
50
+ .join('transactions_v7 as v', 'v.txid', 't.txid')
51
+ .select(knex.ref('t.transactionId').as('legacyId'), knex.ref('v.transactionId').as('v7Id'))
52
+ : [];
53
+ const actionMapRows = hasLegacyData
54
+ ? await knex('transactions as t')
55
+ .join('transactions_v7 as v', 'v.txid', 't.txid')
56
+ .join('actions as a', function joinAction() {
57
+ this.on('a.userId', '=', 't.userId').andOn('a.transactionId', '=', 'v.transactionId');
58
+ })
59
+ .select(knex.ref('t.transactionId').as('legacyId'), knex.ref('a.actionId').as('actionId'))
60
+ : [];
61
+ const legacyToV7 = new Map(txMapRows.map(r => [r.legacyId, r.v7Id]));
62
+ const legacyToAction = new Map(actionMapRows.map(r => [r.legacyId, r.actionId]));
63
+ await disableFks(knex, isSqlite);
64
+ try {
65
+ // Remap downstream FK values with a temporary offset to dodge collisions
66
+ // with the existing legacy keyspace during partial updates.
67
+ const OFFSET = 1000000000;
68
+ for (const [legacy, v7] of legacyToV7) {
69
+ const shifted = v7 + OFFSET;
70
+ await knex('outputs').where({ transactionId: legacy }).update({ transactionId: shifted });
71
+ await knex('outputs').where({ spentBy: legacy }).update({ spentBy: shifted });
72
+ await knex('commissions').where({ transactionId: legacy }).update({ transactionId: shifted });
73
+ }
74
+ await knex('outputs').where('transactionId', '>=', OFFSET).update({
75
+ transactionId: knex.raw('?? - ?', ['transactionId', OFFSET])
76
+ });
77
+ await knex('outputs').where('spentBy', '>=', OFFSET).update({
78
+ spentBy: knex.raw('?? - ?', ['spentBy', OFFSET])
79
+ });
80
+ await knex('commissions').where('transactionId', '>=', OFFSET).update({
81
+ transactionId: knex.raw('?? - ?', ['transactionId', OFFSET])
82
+ });
83
+ for (const [legacy, actionId] of legacyToAction) {
84
+ const shifted = actionId + OFFSET;
85
+ await knex('tx_labels_map').where({ transactionId: legacy }).update({ transactionId: shifted });
86
+ }
87
+ await knex('tx_labels_map').where('transactionId', '>=', OFFSET).update({
88
+ transactionId: knex.raw('?? - ?', ['transactionId', OFFSET])
89
+ });
90
+ // legacy_alter_table = ON suppresses SQLite's automatic FK rewrite on
91
+ // RENAME. We want it ON for the legacy-table renames (so that outputs /
92
+ // commissions / tx_labels_map FKs keep pointing at the bare string
93
+ // "transactions" and resolve to the new table after the swap) and OFF
94
+ // for the V7 rename (so that tx_audit / actions FKs that originally
95
+ // targeted `transactions_v7` follow the rename to `transactions`).
96
+ if (isSqlite)
97
+ await knex.raw('PRAGMA legacy_alter_table = ON');
98
+ await knex.schema.renameTable('transactions', 'transactions_legacy');
99
+ await knex.schema.renameTable('proven_tx_reqs', 'proven_tx_reqs_legacy');
100
+ await knex.schema.renameTable('proven_txs', 'proven_txs_legacy');
101
+ if (isSqlite)
102
+ await knex.raw('PRAGMA legacy_alter_table = OFF');
103
+ await knex.schema.renameTable('transactions_v7', 'transactions');
104
+ await rebuildTxLabelsMap(knex, dbtype);
105
+ }
106
+ finally {
107
+ await enableFks(knex, isSqlite);
108
+ }
109
+ }
110
+ /**
111
+ * Inverse of `runV7Cutover` for test rollback. Renames `*_legacy` tables back
112
+ * to their canonical names and swaps `transactions` back to `transactions_v7`.
113
+ * Does not reverse the FK value remap — call this only when the cutover was
114
+ * applied to seed data that the test no longer needs.
115
+ */
116
+ async function rollbackV7Cutover(knex) {
117
+ const dbtype = await determineDBType(knex);
118
+ const isSqlite = dbtype === 'SQLite';
119
+ await disableFks(knex, isSqlite);
120
+ try {
121
+ if (isSqlite)
122
+ await knex.raw('PRAGMA legacy_alter_table = ON');
123
+ if (await hasTable(knex, 'transactions')) {
124
+ await knex.schema.renameTable('transactions', 'transactions_v7');
125
+ }
126
+ if (await hasTable(knex, 'transactions_legacy')) {
127
+ await knex.schema.renameTable('transactions_legacy', 'transactions');
128
+ }
129
+ if (await hasTable(knex, 'proven_tx_reqs_legacy')) {
130
+ await knex.schema.renameTable('proven_tx_reqs_legacy', 'proven_tx_reqs');
131
+ }
132
+ if (await hasTable(knex, 'proven_txs_legacy')) {
133
+ await knex.schema.renameTable('proven_txs_legacy', 'proven_txs');
134
+ }
135
+ if (isSqlite)
136
+ await knex.raw('PRAGMA legacy_alter_table = OFF');
137
+ }
138
+ finally {
139
+ await enableFks(knex, isSqlite);
140
+ }
141
+ }
142
+ async function determineDBType(knex) {
143
+ var _a, _b, _c;
144
+ // Avoid pulling KnexMigrations' determineDBType to keep this module
145
+ // free of cyclic imports.
146
+ try {
147
+ const r = await knex.raw("SELECT 'MySQL' AS database_type FROM dual");
148
+ const dbtype = (_c = (Array.isArray(r) ? r[0] : (_b = (_a = r.rows) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : r[0])) === null || _c === void 0 ? void 0 : _c.database_type;
149
+ if (dbtype === 'MySQL')
150
+ return 'MySQL';
151
+ }
152
+ catch (e) {
153
+ // fallthrough — SQLite has no `dual` table
154
+ }
155
+ try {
156
+ await knex.raw('SELECT 1');
157
+ return 'SQLite';
158
+ }
159
+ catch (e) {
160
+ throw new Error('Unsupported database engine for V7 cutover');
161
+ }
162
+ }
163
+ async function hasTable(knex, name) {
164
+ return await knex.schema.hasTable(name);
165
+ }
166
+ async function disableFks(knex, isSqlite) {
167
+ if (isSqlite) {
168
+ await knex.raw('PRAGMA foreign_keys = OFF');
169
+ }
170
+ else {
171
+ await knex.raw('SET FOREIGN_KEY_CHECKS=0');
172
+ }
173
+ }
174
+ async function enableFks(knex, isSqlite) {
175
+ if (isSqlite) {
176
+ await knex.raw('PRAGMA foreign_keys = ON');
177
+ }
178
+ else {
179
+ await knex.raw('SET FOREIGN_KEY_CHECKS=1');
180
+ }
181
+ }
182
+ async function rebuildTxLabelsMap(knex, dbtype) {
183
+ var _a, _b;
184
+ if (dbtype === 'SQLite') {
185
+ await knex.schema.createTable('tx_labels_map_new', table => {
186
+ table.timestamp('created_at', { precision: 3 }).defaultTo(knex.fn.now()).notNullable();
187
+ table.timestamp('updated_at', { precision: 3 }).defaultTo(knex.fn.now()).notNullable();
188
+ table.integer('txLabelId').unsigned().references('txLabelId').inTable('tx_labels').notNullable();
189
+ table.integer('transactionId').unsigned().references('actionId').inTable('actions').notNullable();
190
+ table.boolean('isDeleted').notNullable().defaultTo(false);
191
+ table.unique(['txLabelId', 'transactionId']);
192
+ });
193
+ await knex.raw('INSERT INTO tx_labels_map_new (created_at, updated_at, txLabelId, transactionId, isDeleted) ' +
194
+ 'SELECT created_at, updated_at, txLabelId, transactionId, isDeleted FROM tx_labels_map');
195
+ await knex.schema.dropTable('tx_labels_map');
196
+ await knex.schema.renameTable('tx_labels_map_new', 'tx_labels_map');
197
+ await knex.schema.alterTable('tx_labels_map', table => {
198
+ table.index('transactionId');
199
+ table.index(['transactionId', 'isDeleted'], 'idx_tx_labels_map_tx_deleted');
200
+ });
201
+ }
202
+ else {
203
+ const dbRow = (await knex.raw('SELECT DATABASE() AS d'))[0];
204
+ const dbName = Array.isArray(dbRow) ? (_a = dbRow[0]) === null || _a === void 0 ? void 0 : _a.d : dbRow === null || dbRow === void 0 ? void 0 : dbRow.d;
205
+ const fkRows = await knex('information_schema.KEY_COLUMN_USAGE')
206
+ .select('CONSTRAINT_NAME')
207
+ .where({
208
+ TABLE_SCHEMA: dbName,
209
+ TABLE_NAME: 'tx_labels_map',
210
+ COLUMN_NAME: 'transactionId'
211
+ })
212
+ .whereNotNull('REFERENCED_TABLE_NAME');
213
+ for (const row of fkRows !== null && fkRows !== void 0 ? fkRows : []) {
214
+ const constraintName = (_b = row.CONSTRAINT_NAME) !== null && _b !== void 0 ? _b : row.constraint_name;
215
+ if (constraintName != null) {
216
+ await knex.raw('ALTER TABLE tx_labels_map DROP FOREIGN KEY `' + constraintName + '`');
217
+ }
218
+ }
219
+ await knex.raw('ALTER TABLE tx_labels_map ADD CONSTRAINT fk_tx_labels_map_action ' +
220
+ 'FOREIGN KEY (transactionId) REFERENCES actions(actionId)');
221
+ }
222
+ }
223
+ //# sourceMappingURL=v7Cutover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v7Cutover.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7Cutover.ts"],"names":[],"mappings":";;AA6BA,oCAmFC;AAQD,8CAsBC;AA5ID,uDAAwD;AACxD,2DAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,KAAK,UAAU,YAAY,CAAE,IAAU;;IAC5C,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,MAAM,KAAK,Q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wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAChE,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,CAAC,CAAC,CAAC,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,CAAC,CAAA;QAC5D,MAAM,MAAM,GAAQ,MAAM,IAAI,CAAC,qCAAqC,CAAC;aAClE,MAAM,CAAC,iBAAiB,CAAC;aACzB,KAAK,CAAC;YACL,YAAY,EAAE,MAAM;YACpB,UAAU,EAAE,eAAe;YAC3B,WAAW,EAAE,eAAe;SAC7B,CAAC;aACD,YAAY,CAAC,uBAAuB,CAAC,CAAA;QACxC,KAAK,MAAM,GAAG,IAAI,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,EAAE,CAAC;YAC/B,MAAM,cAAc,GAAG,MAAA,GAAG,CAAC,eAAe,mCAAI,GAAG,CAAC,eAAe,CAAA;YACjE,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;gBAC3B,MAAM,IAAI,CAAC,GAAG,CAAC,8CAA8C,GAAG,cAAc,GAAG,GAAG,CAAC,CAAA;YACvF,CAAC;QACH,CAAC;QACD,MAAM,IAAI,CAAC,GAAG,CACZ,mEAAmE;YACnE,0DAA0D,CAC3D,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { IDBPDatabase } from 'idb';
2
+ import { StorageIdbSchema } from './StorageIdbSchema';
3
+ /**
4
+ * V7 IDB-side cutover.
5
+ *
6
+ * IndexedDB has no `RENAME STORE` primitive, and store creation/deletion is
7
+ * only permitted during a version-upgrade transaction. The cutover therefore:
8
+ *
9
+ * 1. Re-opens the database at a higher version, supplying an `upgrade`
10
+ * callback that does the rename via copy-and-delete on the upgrade trx.
11
+ * 2. For each table that needs renaming:
12
+ * a. Read every row from the source store.
13
+ * b. Create the destination store with the same indexes.
14
+ * c. Write rows into the destination store.
15
+ * d. Delete the source store.
16
+ * 3. Returns the upgraded database handle (caller is responsible for
17
+ * closing it).
18
+ *
19
+ * Safe to call twice — the second call sees the post-cutover layout, skips
20
+ * the rename block, and returns without error.
21
+ *
22
+ * `targetVersion` defaults to 2; bump it if the caller already operates on a
23
+ * higher schema version.
24
+ */
25
+ export declare function runV7IdbCutover(dbName: string, targetVersion?: number): Promise<IDBPDatabase<StorageIdbSchema>>;
26
+ //# sourceMappingURL=v7CutoverIdb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v7CutoverIdb.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7CutoverIdb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA2B,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,aAAa,SAAI,GAChB,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAyDzC"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runV7IdbCutover = runV7IdbCutover;
4
+ const idb_1 = require("idb");
5
+ /**
6
+ * V7 IDB-side cutover.
7
+ *
8
+ * IndexedDB has no `RENAME STORE` primitive, and store creation/deletion is
9
+ * only permitted during a version-upgrade transaction. The cutover therefore:
10
+ *
11
+ * 1. Re-opens the database at a higher version, supplying an `upgrade`
12
+ * callback that does the rename via copy-and-delete on the upgrade trx.
13
+ * 2. For each table that needs renaming:
14
+ * a. Read every row from the source store.
15
+ * b. Create the destination store with the same indexes.
16
+ * c. Write rows into the destination store.
17
+ * d. Delete the source store.
18
+ * 3. Returns the upgraded database handle (caller is responsible for
19
+ * closing it).
20
+ *
21
+ * Safe to call twice — the second call sees the post-cutover layout, skips
22
+ * the rename block, and returns without error.
23
+ *
24
+ * `targetVersion` defaults to 2; bump it if the caller already operates on a
25
+ * higher schema version.
26
+ */
27
+ async function runV7IdbCutover(dbName, targetVersion = 2) {
28
+ return await (0, idb_1.openDB)(dbName, targetVersion, {
29
+ async upgrade(db, oldVersion, _newVersion, trx) {
30
+ if (oldVersion >= 2)
31
+ return;
32
+ if (!db.objectStoreNames.contains('transactions_v7'))
33
+ return;
34
+ await renameStore(db, trx, 'transactions', 'transactions_legacy', store => {
35
+ store.createIndex('userId', 'userId');
36
+ store.createIndex('status', 'status');
37
+ store.createIndex('status_userId', ['status', 'userId']);
38
+ store.createIndex('provenTxId', 'provenTxId');
39
+ store.createIndex('reference', 'reference', { unique: true });
40
+ });
41
+ await renameStore(db, trx, 'proven_tx_reqs', 'proven_tx_reqs_legacy', store => {
42
+ store.createIndex('provenTxId', 'provenTxId');
43
+ store.createIndex('txid', 'txid', { unique: true });
44
+ store.createIndex('status', 'status');
45
+ store.createIndex('batch', 'batch');
46
+ });
47
+ await renameStore(db, trx, 'proven_txs', 'proven_txs_legacy', store => {
48
+ store.createIndex('txid', 'txid', { unique: true });
49
+ });
50
+ await renameStore(db, trx, 'transactions_v7', 'transactions', store => {
51
+ store.createIndex('txid', 'txid', { unique: true });
52
+ store.createIndex('processing', 'processing');
53
+ store.createIndex('batch', 'batch');
54
+ store.createIndex('idempotencyKey', 'idempotencyKey', { unique: true });
55
+ });
56
+ }
57
+ });
58
+ }
59
+ async function renameStore(db, trx, fromName, toName, applyIndexes) {
60
+ if (!db.objectStoreNames.contains(fromName))
61
+ return;
62
+ if (db.objectStoreNames.contains(toName)) {
63
+ // Target already exists — assume a prior partial cutover. Drop the source
64
+ // and continue rather than fail; the application is expected to verify
65
+ // post-cutover state via its own smoke tests before resuming traffic.
66
+ db.deleteObjectStore(fromName);
67
+ return;
68
+ }
69
+ const sourceStore = trx.objectStore(fromName);
70
+ const sourceKeyPath = sourceStore.keyPath;
71
+ const sourceAutoIncrement = sourceStore.autoIncrement;
72
+ const rows = await sourceStore.getAll();
73
+ const keys = await sourceStore.getAllKeys();
74
+ db.deleteObjectStore(fromName);
75
+ const dest = db.createObjectStore(toName, {
76
+ keyPath: sourceKeyPath !== null && sourceKeyPath !== void 0 ? sourceKeyPath : undefined,
77
+ autoIncrement: sourceAutoIncrement
78
+ });
79
+ applyIndexes(dest);
80
+ const destStore = trx.objectStore(toName);
81
+ for (let i = 0; i < rows.length; i++) {
82
+ if (sourceAutoIncrement || sourceKeyPath != null) {
83
+ await destStore.put(rows[i]);
84
+ }
85
+ else {
86
+ await destStore.put(rows[i], keys[i]);
87
+ }
88
+ }
89
+ }
90
+ //# sourceMappingURL=v7CutoverIdb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v7CutoverIdb.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7CutoverIdb.ts"],"names":[],"mappings":";;AAyBA,0CA4DC;AArFD,6BAA2D;AAG3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,aAAa,GAAG,CAAC;IAEjB,OAAO,MAAM,IAAA,YAAM,EAAmB,MAAM,EAAE,aAAa,EAAE;QAC3D,KAAK,CAAC,OAAO,CAAE,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG;YAC7C,IAAI,UAAU,IAAI,CAAC;gBAAE,OAAM;YAC3B,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,iBAAiB,CAAC;gBAAE,OAAM;YAE5D,MAAM,WAAW,CACf,EAAE,EACF,GAA8D,EAC9D,cAAc,EACd,qBAAqB,EACrB,KAAK,CAAC,EAAE;gBACN,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;gBACrC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;gBACrC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;gBACxD,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CAAC,CAAA;QAC9B,CAAC;aAAM,CAAC;YACN,MAAM,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"v7Fsm.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7Fsm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAA;AA+BhC,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,GAAG,CAAC,gBAAgB,EAC1B,EAAE,EAAE,GAAG,CAAC,gBAAgB,GACvB,OAAO,CAGT;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,GAAG,CAAC,gBAAgB,EAC1B,EAAE,EAAE,GAAG,CAAC,gBAAgB,GACvB,mBAAmB,CAMrB;AAED,kEAAkE;AAClE,wBAAgB,uBAAuB,IAAK,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,SAAS,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAElH;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAE,CAAC,EAAE,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAEvE;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAE,CAAC,EAAE,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAEtE"}
1
+ {"version":3,"file":"v7Fsm.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7Fsm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAA;AA+ChC,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,GAAG,CAAC,gBAAgB,EAC1B,EAAE,EAAE,GAAG,CAAC,gBAAgB,GACvB,OAAO,CAGT;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,GAAG,CAAC,gBAAgB,EAC1B,EAAE,EAAE,GAAG,CAAC,gBAAgB,GACvB,mBAAmB,CAMrB;AAED,kEAAkE;AAClE,wBAAgB,uBAAuB,IAAK,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,SAAS,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAElH;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAE,CAAC,EAAE,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAEvE;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAE,CAAC,EAAE,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAEtE"}
@@ -52,20 +52,36 @@ const sdk = __importStar(require("../../sdk"));
52
52
  * provider acknowledged) are enforced at the call site.
53
53
  */
54
54
  const TRANSITIONS = {
55
- queued: ['sending', 'sent', 'nosend', 'frozen', 'nonfinal', 'invalid'],
55
+ // `queued -> doubleSpend`: a tx queued locally may be reported as a
56
+ // double-spend by the network before our first send attempt (e.g. another
57
+ // wallet broadcast the same outpoint first). See V7_STORAGE_METHOD_WIRING §4
58
+ // legacy mapping `* -> doubleSpend (rejection)`.
59
+ queued: ['sending', 'sent', 'nosend', 'frozen', 'nonfinal', 'invalid', 'doubleSpend'],
56
60
  sending: ['sent', 'seen', 'seen_multi', 'invalid', 'doubleSpend', 'frozen', 'queued'],
57
61
  sent: ['seen', 'seen_multi', 'unconfirmed', 'proven', 'invalid', 'doubleSpend', 'frozen', 'sending'],
58
- seen: ['seen_multi', 'unconfirmed', 'proven', 'invalid', 'doubleSpend', 'reorging', 'frozen'],
59
- seen_multi: ['unconfirmed', 'proven', 'invalid', 'doubleSpend', 'reorging', 'frozen'],
60
- unconfirmed: ['proven', 'invalid', 'reorging', 'frozen', 'seen', 'seen_multi'],
62
+ // `seen -> sending`: provider re-acknowledgment lost; legacy mapping
63
+ // `* -> sending (serviceError retry)` from V7_STORAGE_METHOD_WIRING §4.
64
+ seen: ['seen_multi', 'unconfirmed', 'proven', 'invalid', 'doubleSpend', 'reorging', 'frozen', 'sending'],
65
+ // `seen_multi -> sending`: same retry semantics as `seen -> sending`.
66
+ seen_multi: ['unconfirmed', 'proven', 'invalid', 'doubleSpend', 'reorging', 'frozen', 'sending'],
67
+ // `unconfirmed -> doubleSpend`: a provider's proof candidate may be retracted
68
+ // when a competing tx is mined. `unconfirmed -> sending`: candidate failed
69
+ // chaintracks validation, restart broadcast attempts. Both per §4.
70
+ unconfirmed: ['proven', 'invalid', 'reorging', 'frozen', 'seen', 'seen_multi', 'doubleSpend', 'sending'],
61
71
  proven: ['reorging'],
62
72
  reorging: ['proven', 'seen', 'seen_multi', 'unconfirmed', 'invalid', 'doubleSpend', 'frozen'],
63
73
  invalid: ['unfail'],
64
74
  doubleSpend: ['unfail'],
65
75
  unfail: ['queued', 'sending', 'sent', 'seen', 'seen_multi', 'unconfirmed', 'proven', 'invalid', 'doubleSpend'],
66
76
  frozen: ['queued', 'sending', 'sent', 'seen', 'seen_multi', 'unconfirmed', 'invalid', 'doubleSpend'],
67
- nosend: ['queued', 'sent', 'seen', 'invalid', 'frozen'],
68
- nonfinal: ['queued', 'sending', 'sent', 'invalid', 'frozen']
77
+ // `nosend -> sending`: operator (or processAction promotion) moves a
78
+ // never-broadcast tx into the active broadcast pipeline. `nosend ->
79
+ // doubleSpend`: an externally-broadcast nosend tx may be reported as a
80
+ // double-spend. Both per §4 legacy mapping.
81
+ nosend: ['queued', 'sending', 'sent', 'seen', 'invalid', 'doubleSpend', 'frozen'],
82
+ // `nonfinal -> doubleSpend`: a live-nLockTime tx may be replaced by a
83
+ // confirmed competing tx and reported as a double-spend.
84
+ nonfinal: ['queued', 'sending', 'sent', 'invalid', 'doubleSpend', 'frozen']
69
85
  };
70
86
  /**
71
87
  * Returns true when `from -> to` is a permitted V7 processing transition.
@@ -1 +1 @@
1
- {"version":3,"file":"v7Fsm.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7Fsm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,kEAMC;AAMD,oEASC;AAGD,0DAEC;AAOD,sDAEC;AAGD,oDAEC;AAjFD,+CAAgC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,GAAyD;IACxE,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC;IACtE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC;IACrF,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,CAAC;IACpG,IAAI,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC;IAC7F,UAAU,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC;IACrF,WAAW,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC;IAC9E,MAAM,EAAE,CAAC,UAAU,CAAC;IACpB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,CAAC;IAC7F,OAAO,EAAE,CAAC,QAAQ,CAAC;IACnB,WAAW,EAAE,CAA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