@bsv/wallet-toolbox-client 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 (146) hide show
  1. package/out/src/Wallet.d.ts.map +1 -1
  2. package/out/src/Wallet.js.map +1 -1
  3. package/out/src/WalletLogger.d.ts.map +1 -1
  4. package/out/src/WalletLogger.js.map +1 -1
  5. package/out/src/monitor/LeasedMonitorTask.d.ts +43 -0
  6. package/out/src/monitor/LeasedMonitorTask.d.ts.map +1 -0
  7. package/out/src/monitor/LeasedMonitorTask.js +89 -0
  8. package/out/src/monitor/LeasedMonitorTask.js.map +1 -0
  9. package/out/src/monitor/Monitor.d.ts +7 -0
  10. package/out/src/monitor/Monitor.d.ts.map +1 -1
  11. package/out/src/monitor/Monitor.js +7 -0
  12. package/out/src/monitor/Monitor.js.map +1 -1
  13. package/out/src/monitor/V7LeasedTask.d.ts +43 -0
  14. package/out/src/monitor/V7LeasedTask.d.ts.map +1 -0
  15. package/out/src/monitor/V7LeasedTask.js +89 -0
  16. package/out/src/monitor/V7LeasedTask.js.map +1 -0
  17. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +2 -0
  18. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
  19. package/out/src/monitor/tasks/TaskCheckForProofs.js +55 -0
  20. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
  21. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
  22. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
  23. package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
  24. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  25. package/out/src/sdk/types.d.ts +32 -0
  26. package/out/src/sdk/types.d.ts.map +1 -1
  27. package/out/src/sdk/types.js +50 -1
  28. package/out/src/sdk/types.js.map +1 -1
  29. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
  30. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
  31. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
  32. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
  33. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
  34. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
  35. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
  36. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
  37. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
  38. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
  39. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
  40. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -1
  41. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
  42. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
  43. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
  44. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
  45. package/out/src/storage/StorageIdb.d.ts.map +1 -1
  46. package/out/src/storage/StorageIdb.js +10 -5
  47. package/out/src/storage/StorageIdb.js.map +1 -1
  48. package/out/src/storage/StorageProvider.d.ts +114 -1
  49. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  50. package/out/src/storage/StorageProvider.js +164 -4
  51. package/out/src/storage/StorageProvider.js.map +1 -1
  52. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  53. package/out/src/storage/WalletStorageManager.js.map +1 -1
  54. package/out/src/storage/idbHelpers.d.ts +5 -0
  55. package/out/src/storage/idbHelpers.d.ts.map +1 -1
  56. package/out/src/storage/idbHelpers.js +42 -0
  57. package/out/src/storage/idbHelpers.js.map +1 -1
  58. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
  59. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +116 -4
  60. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
  61. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  62. package/out/src/storage/methods/createAction.js +22 -5
  63. package/out/src/storage/methods/createAction.js.map +1 -1
  64. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  65. package/out/src/storage/methods/internalizeAction.js +172 -5
  66. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  67. package/out/src/storage/methods/processAction.d.ts.map +1 -1
  68. package/out/src/storage/methods/processAction.js +82 -14
  69. package/out/src/storage/methods/processAction.js.map +1 -1
  70. package/out/src/storage/schema/StorageIdbSchema.d.ts +43 -2
  71. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
  72. package/out/src/storage/schema/monitorLease.d.ts +57 -0
  73. package/out/src/storage/schema/monitorLease.d.ts.map +1 -0
  74. package/out/src/storage/schema/monitorLease.js +101 -0
  75. package/out/src/storage/schema/monitorLease.js.map +1 -0
  76. package/out/src/storage/schema/processingFsm.d.ts +27 -0
  77. package/out/src/storage/schema/processingFsm.d.ts.map +1 -0
  78. package/out/src/storage/schema/processingFsm.js +132 -0
  79. package/out/src/storage/schema/processingFsm.js.map +1 -0
  80. package/out/src/storage/schema/tables/TableAction.d.ts +38 -0
  81. package/out/src/storage/schema/tables/TableAction.d.ts.map +1 -0
  82. package/out/src/storage/schema/tables/TableAction.js +3 -0
  83. package/out/src/storage/schema/tables/TableAction.js.map +1 -0
  84. package/out/src/storage/schema/tables/TableChainTip.d.ts +17 -0
  85. package/out/src/storage/schema/tables/TableChainTip.d.ts.map +1 -0
  86. package/out/src/storage/schema/tables/TableChainTip.js +3 -0
  87. package/out/src/storage/schema/tables/TableChainTip.js.map +1 -0
  88. package/out/src/storage/schema/tables/TableMonitorLease.d.ts +23 -0
  89. package/out/src/storage/schema/tables/TableMonitorLease.d.ts.map +1 -0
  90. package/out/src/storage/schema/tables/TableMonitorLease.js +3 -0
  91. package/out/src/storage/schema/tables/TableMonitorLease.js.map +1 -0
  92. package/out/src/storage/schema/tables/TableOutput.d.ts +7 -0
  93. package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -1
  94. package/out/src/storage/schema/tables/TableOutput.js.map +1 -1
  95. package/out/src/storage/schema/tables/TableTransactionNew.d.ts +50 -0
  96. package/out/src/storage/schema/tables/TableTransactionNew.d.ts.map +1 -0
  97. package/out/src/storage/schema/tables/TableTransactionNew.js +3 -0
  98. package/out/src/storage/schema/tables/TableTransactionNew.js.map +1 -0
  99. package/out/src/storage/schema/tables/TableTransactionV7.d.ts +50 -0
  100. package/out/src/storage/schema/tables/TableTransactionV7.d.ts.map +1 -0
  101. package/out/src/storage/schema/tables/TableTransactionV7.js +3 -0
  102. package/out/src/storage/schema/tables/TableTransactionV7.js.map +1 -0
  103. package/out/src/storage/schema/tables/TableTxAudit.d.ts +26 -0
  104. package/out/src/storage/schema/tables/TableTxAudit.d.ts.map +1 -0
  105. package/out/src/storage/schema/tables/TableTxAudit.js +3 -0
  106. package/out/src/storage/schema/tables/TableTxAudit.js.map +1 -0
  107. package/out/src/storage/schema/tables/index.d.ts +5 -0
  108. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  109. package/out/src/storage/schema/tables/index.js +5 -0
  110. package/out/src/storage/schema/tables/index.js.map +1 -1
  111. package/out/src/storage/schema/transactionCrud.d.ts +41 -0
  112. package/out/src/storage/schema/transactionCrud.d.ts.map +1 -0
  113. package/out/src/storage/schema/transactionCrud.js +205 -0
  114. package/out/src/storage/schema/transactionCrud.js.map +1 -0
  115. package/out/src/storage/schema/transactionService.d.ts +315 -0
  116. package/out/src/storage/schema/transactionService.d.ts.map +1 -0
  117. package/out/src/storage/schema/transactionService.js +783 -0
  118. package/out/src/storage/schema/transactionService.js.map +1 -0
  119. package/out/src/storage/schema/txAudit.d.ts +33 -0
  120. package/out/src/storage/schema/txAudit.d.ts.map +1 -0
  121. package/out/src/storage/schema/txAudit.js +64 -0
  122. package/out/src/storage/schema/txAudit.js.map +1 -0
  123. package/out/src/storage/schema/v7Crud.d.ts +41 -0
  124. package/out/src/storage/schema/v7Crud.d.ts.map +1 -0
  125. package/out/src/storage/schema/v7Crud.js +205 -0
  126. package/out/src/storage/schema/v7Crud.js.map +1 -0
  127. package/out/src/storage/schema/v7Fsm.d.ts +27 -0
  128. package/out/src/storage/schema/v7Fsm.d.ts.map +1 -0
  129. package/out/src/storage/schema/v7Fsm.js +124 -0
  130. package/out/src/storage/schema/v7Fsm.js.map +1 -0
  131. package/out/src/storage/schema/v7MonitorLease.d.ts +57 -0
  132. package/out/src/storage/schema/v7MonitorLease.d.ts.map +1 -0
  133. package/out/src/storage/schema/v7MonitorLease.js +101 -0
  134. package/out/src/storage/schema/v7MonitorLease.js.map +1 -0
  135. package/out/src/storage/schema/v7Service.d.ts +305 -0
  136. package/out/src/storage/schema/v7Service.d.ts.map +1 -0
  137. package/out/src/storage/schema/v7Service.js +757 -0
  138. package/out/src/storage/schema/v7Service.js.map +1 -0
  139. package/out/src/storage/schema/v7TxAudit.d.ts +33 -0
  140. package/out/src/storage/schema/v7TxAudit.d.ts.map +1 -0
  141. package/out/src/storage/schema/v7TxAudit.js +64 -0
  142. package/out/src/storage/schema/v7TxAudit.js.map +1 -0
  143. package/out/src/storage/storageProviderHelpers.js +1 -1
  144. package/out/src/storage/storageProviderHelpers.js.map +1 -1
  145. package/out/tsconfig.client.tsbuildinfo +1 -1
  146. package/package.json +1 -1
@@ -0,0 +1,57 @@
1
+ import { Knex } from 'knex';
2
+ import { TableMonitorLease } from './tables';
3
+ /**
4
+ * monitor lease primitive.
5
+ *
6
+ * A `monitor_lease` row records the owner that may currently execute a named
7
+ * task. Acquisition is opportunistic: a Monitor calls `tryClaimLease()` to
8
+ * insert or take over a stale row; if it succeeds it owns the task until
9
+ * `expiresAt`. While running it calls `renewLease()` to extend the deadline.
10
+ * On clean shutdown it calls `releaseLease()`.
11
+ *
12
+ * The Knex driver expresses claim + takeover as a single conditional UPDATE
13
+ * so that two contending Monitors cannot both believe they own the task — at
14
+ * most one row write will succeed per (task, expiry) pair.
15
+ */
16
+ export interface MonitorLeaseClaim {
17
+ taskName: string;
18
+ ownerId: string;
19
+ ttlMs: number;
20
+ note?: string;
21
+ }
22
+ export interface MonitorLeaseRenew {
23
+ taskName: string;
24
+ ownerId: string;
25
+ ttlMs: number;
26
+ note?: string;
27
+ }
28
+ export interface MonitorLeaseRelease {
29
+ taskName: string;
30
+ ownerId: string;
31
+ }
32
+ export interface MonitorLeaseResult {
33
+ acquired: boolean;
34
+ lease?: TableMonitorLease;
35
+ }
36
+ /**
37
+ * Try to claim a lease on `taskName`. Succeeds iff:
38
+ * - no row exists for the task, OR
39
+ * - the existing row has `expiresAt <= now`, OR
40
+ * - the existing row's `ownerId` already equals the requested owner.
41
+ *
42
+ * On success the row is upserted with `expiresAt = now + ttlMs` and
43
+ * `renewCount = renewCount + 1` (0 for fresh rows).
44
+ */
45
+ export declare function tryClaimLease(knex: Knex, claim: MonitorLeaseClaim, now?: Date): Promise<MonitorLeaseResult>;
46
+ /**
47
+ * Extend the current owner's lease. Fails (returns `acquired: false`) when the
48
+ * row does not exist, is owned by someone else, or has already expired.
49
+ */
50
+ export declare function renewLease(knex: Knex, renew: MonitorLeaseRenew, now?: Date): Promise<MonitorLeaseResult>;
51
+ /**
52
+ * Release the lease (no-op when not owned by the caller).
53
+ * The row is deleted so subsequent claimants do not see an inherited
54
+ * `renew_count`.
55
+ */
56
+ export declare function releaseLease(knex: Knex, release: MonitorLeaseRelease): Promise<boolean>;
57
+ //# sourceMappingURL=monitorLease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitorLease.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/monitorLease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,iBAAiB,EACxB,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,kBAAkB,CAAC,CAmC7B;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,iBAAiB,EACxB,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,kBAAkB,CAAC,CAkB7B;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAK9F"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tryClaimLease = tryClaimLease;
4
+ exports.renewLease = renewLease;
5
+ exports.releaseLease = releaseLease;
6
+ /**
7
+ * Try to claim a lease on `taskName`. Succeeds iff:
8
+ * - no row exists for the task, OR
9
+ * - the existing row has `expiresAt <= now`, OR
10
+ * - the existing row's `ownerId` already equals the requested owner.
11
+ *
12
+ * On success the row is upserted with `expiresAt = now + ttlMs` and
13
+ * `renewCount = renewCount + 1` (0 for fresh rows).
14
+ */
15
+ async function tryClaimLease(knex, claim, now = new Date()) {
16
+ const expiresAt = new Date(now.getTime() + claim.ttlMs);
17
+ return await knex.transaction(async (trx) => {
18
+ var _a, _b;
19
+ const existing = await trx('monitor_lease').where({ task_name: claim.taskName }).forUpdate().first();
20
+ const canClaim = existing == null ||
21
+ new Date(existing.expires_at).getTime() <= now.getTime() ||
22
+ existing.owner_id === claim.ownerId;
23
+ if (!canClaim)
24
+ return { acquired: false };
25
+ if (existing == null) {
26
+ await trx('monitor_lease').insert({
27
+ task_name: claim.taskName,
28
+ owner_id: claim.ownerId,
29
+ expires_at: expiresAt,
30
+ renew_count: 0,
31
+ note: (_a = claim.note) !== null && _a !== void 0 ? _a : null,
32
+ created_at: now,
33
+ updated_at: now
34
+ });
35
+ }
36
+ else {
37
+ await trx('monitor_lease')
38
+ .where({ task_name: claim.taskName })
39
+ .update({
40
+ owner_id: claim.ownerId,
41
+ expires_at: expiresAt,
42
+ renew_count: existing.owner_id === claim.ownerId ? existing.renew_count + 1 : 0,
43
+ note: (_b = claim.note) !== null && _b !== void 0 ? _b : existing.note,
44
+ updated_at: now
45
+ });
46
+ }
47
+ const row = await trx('monitor_lease').where({ task_name: claim.taskName }).first();
48
+ return { acquired: true, lease: mapRow(row) };
49
+ });
50
+ }
51
+ /**
52
+ * Extend the current owner's lease. Fails (returns `acquired: false`) when the
53
+ * row does not exist, is owned by someone else, or has already expired.
54
+ */
55
+ async function renewLease(knex, renew, now = new Date()) {
56
+ const expiresAt = new Date(now.getTime() + renew.ttlMs);
57
+ return await knex.transaction(async (trx) => {
58
+ var _a;
59
+ const existing = await trx('monitor_lease').where({ task_name: renew.taskName }).forUpdate().first();
60
+ if (existing == null)
61
+ return { acquired: false };
62
+ if (existing.owner_id !== renew.ownerId)
63
+ return { acquired: false };
64
+ if (new Date(existing.expires_at).getTime() <= now.getTime())
65
+ return { acquired: false };
66
+ await trx('monitor_lease')
67
+ .where({ task_name: renew.taskName })
68
+ .update({
69
+ expires_at: expiresAt,
70
+ renew_count: existing.renew_count + 1,
71
+ note: (_a = renew.note) !== null && _a !== void 0 ? _a : existing.note,
72
+ updated_at: now
73
+ });
74
+ const row = await trx('monitor_lease').where({ task_name: renew.taskName }).first();
75
+ return { acquired: true, lease: mapRow(row) };
76
+ });
77
+ }
78
+ /**
79
+ * Release the lease (no-op when not owned by the caller).
80
+ * The row is deleted so subsequent claimants do not see an inherited
81
+ * `renew_count`.
82
+ */
83
+ async function releaseLease(knex, release) {
84
+ const deleted = await knex('monitor_lease')
85
+ .where({ task_name: release.taskName, owner_id: release.ownerId })
86
+ .delete();
87
+ return deleted > 0;
88
+ }
89
+ function mapRow(row) {
90
+ var _a;
91
+ return {
92
+ created_at: new Date(row.created_at),
93
+ updated_at: new Date(row.updated_at),
94
+ taskName: row.task_name,
95
+ ownerId: row.owner_id,
96
+ expiresAt: new Date(row.expires_at),
97
+ renewCount: row.renew_count,
98
+ note: (_a = row.note) !== null && _a !== void 0 ? _a : undefined
99
+ };
100
+ }
101
+ //# sourceMappingURL=monitorLease.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitorLease.js","sourceRoot":"","sources":["../../../../../src/storage/schema/monitorLease.ts"],"names":[],"mappings":";;AAiDA,sCAuCC;AAMD,gCAsBC;AAOD,oCAKC;AAxFD;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CACjC,IAAU,EACV,KAAwB,EACxB,MAAY,IAAI,IAAI,EAAE;IAEtB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;IAC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'../../sdk';
2
+ export interface FsmTransitionResult {
3
+ ok: boolean;
4
+ reason?: string;
5
+ }
6
+ /**
7
+ * Returns true when `from -> to` is a permitted processing transition.
8
+ * Identity transitions (`from === to`) are always allowed — they represent a
9
+ * status refresh without state change.
10
+ */
11
+ export declare function isValidProcessingTransition(from: sdk.ProcessingStatus, to: sdk.ProcessingStatus): boolean;
12
+ /**
13
+ * As `isValidProcessingTransition` but returns a structured result with a
14
+ * human-readable reason for any rejection. Useful for `tx_audit` payloads.
15
+ */
16
+ export declare function validateProcessingTransition(from: sdk.ProcessingStatus, to: sdk.ProcessingStatus): FsmTransitionResult;
17
+ /** Snapshot of the transition table for documentation + tests. */
18
+ export declare function processingTransitionMap(): Readonly<Record<sdk.ProcessingStatus, readonly sdk.ProcessingStatus[]>>;
19
+ /**
20
+ * True when the given state implies the transaction has been seen / accepted
21
+ * by at least one network provider — the precondition for output spendability
22
+ * in §4.
23
+ */
24
+ export declare function isProcessingSpendable(s: sdk.ProcessingStatus): boolean;
25
+ /** True when the state is terminal (no further automatic transitions). */
26
+ export declare function isProcessingTerminal(s: sdk.ProcessingStatus): boolean;
27
+ //# sourceMappingURL=processingFsm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processingFsm.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/processingFsm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAA;AAuDhC,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"}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.isValidProcessingTransition = isValidProcessingTransition;
37
+ exports.validateProcessingTransition = validateProcessingTransition;
38
+ exports.processingTransitionMap = processingTransitionMap;
39
+ exports.isProcessingSpendable = isProcessingSpendable;
40
+ exports.isProcessingTerminal = isProcessingTerminal;
41
+ const sdk = __importStar(require("../../sdk"));
42
+ /**
43
+ * processing-state machine.
44
+ *
45
+ * Maps each `ProcessingStatus` to the set of states it may legally transition
46
+ * to. Terminal states (`confirmed`, `invalid`, `doubleSpend`) have no outgoing
47
+ * transitions except via the `unfail` operator override.
48
+ *
49
+ * The transition table is intentionally permissive — the goal is to *reject
50
+ * impossible* moves (e.g. `queued -> confirmed` without ever broadcasting) rather
51
+ * than to enumerate the happy path. Stateful preconditions (proof present,
52
+ * provider acknowledged) are enforced at the call site.
53
+ */
54
+ const TRANSITIONS = {
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 STORAGE_METHOD_WIRING §4
58
+ // legacy mapping `* -> doubleSpend (rejection)`.
59
+ queued: ['sending', 'sent', 'nosend', 'frozen', 'nonfinal', 'invalid', 'doubleSpend'],
60
+ sending: ['sent', 'seen', 'seen_multi', 'invalid', 'doubleSpend', 'frozen', 'queued'],
61
+ sent: ['seen', 'seen_multi', 'unconfirmed', 'confirmed', 'invalid', 'doubleSpend', 'frozen', 'sending'],
62
+ // `seen -> sending`: provider re-acknowledgment lost; legacy mapping
63
+ // `* -> sending (serviceError retry)` from STORAGE_METHOD_WIRING §4.
64
+ seen: ['seen_multi', 'unconfirmed', 'confirmed', 'invalid', 'doubleSpend', 'reorging', 'frozen', 'sending'],
65
+ // `seen_multi -> sending`: same retry semantics as `seen -> sending`.
66
+ seen_multi: ['unconfirmed', 'confirmed', '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: ['confirmed', 'invalid', 'reorging', 'frozen', 'seen', 'seen_multi', 'doubleSpend', 'sending'],
71
+ confirmed: ['reorging'],
72
+ // Reorg rule (bsv_wallet_transaction_requirements v1.0 §5):
73
+ // "A reorg SHALL never cause a transaction to be marked Invalid or
74
+ // DoubleSpend." The reorging state is therefore restricted to recovery
75
+ // edges only — back to a confirmation-class state or to frozen for
76
+ // operator review. Callers that later determine the tx is genuinely
77
+ // invalid or a doubleSpend must first transition through `unconfirmed`
78
+ // (where the standard FSM edges to `invalid`/`doubleSpend` apply) so the
79
+ // rejection is recorded against a non-reorg cause in `tx_audit`.
80
+ reorging: ['confirmed', 'seen', 'seen_multi', 'unconfirmed', 'frozen'],
81
+ invalid: ['unfail'],
82
+ doubleSpend: ['unfail'],
83
+ unfail: ['queued', 'sending', 'sent', 'seen', 'seen_multi', 'unconfirmed', 'confirmed', 'invalid', 'doubleSpend'],
84
+ frozen: ['queued', 'sending', 'sent', 'seen', 'seen_multi', 'unconfirmed', 'invalid', 'doubleSpend'],
85
+ // `nosend -> sending`: operator (or processAction promotion) moves a
86
+ // never-broadcast tx into the active broadcast pipeline. `nosend ->
87
+ // doubleSpend`: an externally-broadcast nosend tx may be reported as a
88
+ // double-spend. Both per §4 legacy mapping.
89
+ nosend: ['queued', 'sending', 'sent', 'seen', 'invalid', 'doubleSpend', 'frozen'],
90
+ // `nonfinal -> doubleSpend`: a live-nLockTime tx may be replaced by a
91
+ // confirmed competing tx and reported as a double-spend.
92
+ nonfinal: ['queued', 'sending', 'sent', 'invalid', 'doubleSpend', 'frozen']
93
+ };
94
+ /**
95
+ * Returns true when `from -> to` is a permitted processing transition.
96
+ * Identity transitions (`from === to`) are always allowed — they represent a
97
+ * status refresh without state change.
98
+ */
99
+ function isValidProcessingTransition(from, to) {
100
+ if (from === to)
101
+ return true;
102
+ return TRANSITIONS[from].includes(to);
103
+ }
104
+ /**
105
+ * As `isValidProcessingTransition` but returns a structured result with a
106
+ * human-readable reason for any rejection. Useful for `tx_audit` payloads.
107
+ */
108
+ function validateProcessingTransition(from, to) {
109
+ if (isValidProcessingTransition(from, to))
110
+ return { ok: true };
111
+ return {
112
+ ok: false,
113
+ reason: `illegal transition ${from} -> ${to}; legal next: ${TRANSITIONS[from].join(', ')}`
114
+ };
115
+ }
116
+ /** Snapshot of the transition table for documentation + tests. */
117
+ function processingTransitionMap() {
118
+ return TRANSITIONS;
119
+ }
120
+ /**
121
+ * True when the given state implies the transaction has been seen / accepted
122
+ * by at least one network provider — the precondition for output spendability
123
+ * in §4.
124
+ */
125
+ function isProcessingSpendable(s) {
126
+ return sdk.ProcessingSpendableStatus.includes(s);
127
+ }
128
+ /** True when the state is terminal (no further automatic transitions). */
129
+ function isProcessingTerminal(s) {
130
+ return sdk.ProcessingTerminalStatus.includes(s);
131
+ }
132
+ //# sourceMappingURL=processingFsm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processingFsm.js","sourceRoot":"","sources":["../../../../../src/storage/schema/processingFsm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,kEAMC;AAMD,oEASC;AAGD,0DAEC;AAOD,sDAEC;AAGD,oDAEC;AAzGD,+CAAgC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,GAAyD;IACxE,oEAAoE;IACpE,0EAA0E;IAC1E,0EAA0E;IAC1E,iDAAiD;IACjD,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC;IACrF,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,WAAW,EAAE,SAAS,E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EAAsE;IACtE,yDAAyD;IACzD,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,CAAC;CAC5E,CAAA;AAOD;;;;GAIG;AACH,SAAgB,2BAA2B,CACzC,IAA0B,EAC1B,EAAwB;IAExB,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,IAAI,CAAA;IAC5B,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AACvC,CAAC;AAED;;;GAGG;AACH,SAAgB,4BAA4B,CAC1C,IAA0B,EAC1B,EAAwB;IAExB,IAAI,2BAA2B,CAAC,IAAI,EAAE,EAAE,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;IAC9D,OAAO;QACL,EAAE,EAAE,KAAK;QACT,MAAM,EAAE,sBAAsB,IAAI,OAAO,EAAE,iBAAiB,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;KAC3F,CAAA;AACH,CAAC;AAED,kEAAkE;AAClE,SAAgB,uBAAuB;IACrC,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAE,CAAuB;IAC5D,OAAO,GAAG,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC;AAED,0EAA0E;AAC1E,SAAgB,oBAAoB,CAAE,CAAuB;IAC3D,OAAO,GAAG,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AACjD,CAAC"}
@@ -0,0 +1,38 @@
1
+ import * as sdk from '../../../sdk';
2
+ /**
3
+ * per-user view of a transaction.
4
+ *
5
+ * Migrated from the legacy `transactions` table. Holds everything that is truly
6
+ * per-user (description, labels via tx_labels_map -> actionId, soft-delete flags,
7
+ * notification subscribers). All on-chain status lives in the new `transactions`
8
+ * table addressed by `transactionId`.
9
+ *
10
+ * UNIQUE(userId, transactionId).
11
+ */
12
+ export interface TableAction extends sdk.EntityTimeStamp {
13
+ created_at: Date;
14
+ updated_at: Date;
15
+ /** PK */
16
+ actionId: number;
17
+ userId: number;
18
+ /** FK -> new transactions.transactionId (per-txid record) */
19
+ transactionId: number;
20
+ /** Application reference, hex/Base64, max 64 chars */
21
+ reference: string;
22
+ description: string;
23
+ /** true if originated in this wallet (change returns to it) */
24
+ isOutgoing: boolean;
25
+ /** Signed net change to this user's balance from this action */
26
+ satoshisDelta: number;
27
+ /** Per-user nosend override */
28
+ userNosend: boolean;
29
+ /** Soft-delete flag — hide from default queries */
30
+ hidden: boolean;
31
+ /** Per-user abort flag */
32
+ userAborted: boolean;
33
+ /** JSON string of per-user notification subscribers (mirrors legacy notify) */
34
+ notifyJson?: string;
35
+ /** Optimistic concurrency token */
36
+ rowVersion: number;
37
+ }
38
+ //# sourceMappingURL=TableAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableAction.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAY,SAAQ,GAAG,CAAC,eAAe;IACtD,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS;IACT,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAA;IACrB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,+DAA+D;IAC/D,UAAU,EAAE,OAAO,CAAA;IACnB,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAA;IACrB,+BAA+B;IAC/B,UAAU,EAAE,OAAO,CAAA;IACnB,mDAAmD;IACnD,MAAM,EAAE,OAAO,CAAA;IACf,0BAA0B;IAC1B,WAAW,EAAE,OAAO,CAAA;IACpB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TableAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableAction.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableAction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import * as sdk from '../../../sdk';
2
+ /**
3
+ * singleton row tracking the most recently observed chain tip.
4
+ * Used by spendability checks and coinbase maturity calculations.
5
+ */
6
+ export interface TableChainTip extends sdk.EntityTimeStamp {
7
+ created_at: Date;
8
+ updated_at: Date;
9
+ /** Always 1 — singleton enforced by storage layer */
10
+ id: number;
11
+ height: number;
12
+ blockHash: string;
13
+ merkleRoot?: string;
14
+ /** Wall-clock of the observation */
15
+ observedAt: Date;
16
+ }
17
+ //# sourceMappingURL=TableChainTip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableChainTip.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableChainTip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,GAAG,CAAC,eAAe;IACxD,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,UAAU,EAAE,IAAI,CAAA;CACjB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TableChainTip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableChainTip.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableChainTip.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import * as sdk from '../../../sdk';
2
+ /**
3
+ * monitor_lease record so at most one Monitor daemon owns a given task at a time.
4
+ *
5
+ * The Monitor acquires a lease by upserting `(taskName, ownerId, expiresAt)`
6
+ * and renews periodically. Stale leases (`expiresAt < now`) may be claimed by
7
+ * another instance.
8
+ */
9
+ export interface TableMonitorLease extends sdk.EntityTimeStamp {
10
+ created_at: Date;
11
+ updated_at: Date;
12
+ /** Logical task name, e.g. 'proof-acquisition' */
13
+ taskName: string;
14
+ /** Stable identifier for the owning Monitor instance */
15
+ ownerId: string;
16
+ /** Lease expiry — claimants treat any row with expiresAt <= now() as free */
17
+ expiresAt: Date;
18
+ /** Monotonic counter incremented on each successful renew */
19
+ renewCount: number;
20
+ /** Optional free-text description of current activity */
21
+ note?: string;
22
+ }
23
+ //# sourceMappingURL=TableMonitorLease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableMonitorLease.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableMonitorLease.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,GAAG,CAAC,eAAe;IAC5D,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAA;IACf,6EAA6E;IAC7E,SAAS,EAAE,IAAI,CAAA;IACf,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TableMonitorLease.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableMonitorLease.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableMonitorLease.ts"],"names":[],"mappings":""}
@@ -28,6 +28,13 @@ export interface TableOutput extends sdk.EntityTimeStamp {
28
28
  scriptLength?: number;
29
29
  scriptOffset?: number;
30
30
  lockingScript?: number[];
31
+ /**
32
+ * new-schema: minimum block height at which a coinbase output becomes spendable.
33
+ * NULL for non-coinbase outputs and for pre-new schema rows that have not yet been
34
+ * backfilled. The §4 spendability rule treats a non-coinbase output as
35
+ * mature regardless of this column.
36
+ */
37
+ maturesAtHeight?: number;
31
38
  }
32
39
  export interface TableOutputX extends TableOutput {
33
40
  basket?: TableOutputBasket;
@@ -1 +1 @@
1
- {"version":3,"file":"TableOutput.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,2BAA2B,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC,MAAM,WAAW,WAAY,SAAQ,GAAG,CAAC,eAAe;IACtD,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,OAAO,CAAA;IACf,iBAAiB,EAAE,2BAA2B,CAAA;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,M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,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,OAAO,CAAA;IACf,iBAAiB,EAAE,2BAA2B,CAAA;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,GAAG,CAAC,iBAAiB,CAAA;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAC7B,gBAAgB,CAAC,EAAE,YAAY,CAAA;IAC/B,gBAAgB,CAAC,EAAE,YAAY,CAAA;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,IAAI,CAAC,EAAE,cAAc,EAAE,CAAA;CACxB;AAED,eAAO,MAAM,iCAAiC,UA0B7C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"TableOutput.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableOutput.ts"],"names":[],"mappings":";;;AAsCa,QAAA,iCAAiC,GAAG;IAC/C,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,eAAe;IACf,UAAU;IACV,WAAW;IACX,QAAQ;IACR,MAAM;IACN,UAAU;IACV,YAAY;IACZ,SAAS;IACT,MAAM;IACN,mBAAmB;IACnB,MAAM;IACN,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,oBAAoB;IACpB,SAAS;IACT,gBAAgB;IAChB,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,mBAAmB;CACpB,CAAA"}
1
+ {"version":3,"file":"TableOutput.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableOutput.ts"],"names":[],"mappings":";;;AA6Ca,QAAA,iCAAiC,GAAG;IAC/C,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,eAAe;IACf,UAAU;IACV,WAAW;IACX,QAAQ;IACR,MAAM;IACN,UAAU;IACV,YAAY;IACZ,SAAS;IACT,MAAM;IACN,mBAAmB;IACnB,MAAM;IACN,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,oBAAoB;IACpB,SAAS;IACT,gBAAgB;IAChB,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,mBAAmB;CACpB,CAAA"}
@@ -0,0 +1,50 @@
1
+ import * as sdk from '../../../sdk';
2
+ /**
3
+ * new canonical per-txid table.
4
+ *
5
+ * Single source of truth for everything about a transaction on the network.
6
+ * Merges the legacy `proven_tx_reqs` (broadcast queue + processing state) and
7
+ * `proven_txs` (final Merkle proof) tables into one row per txid.
8
+ *
9
+ * Per-user metadata (description, labels, hidden, etc.) lives in `actions`.
10
+ */
11
+ export interface TableTransactionNew extends sdk.EntityTimeStamp {
12
+ created_at: Date;
13
+ updated_at: Date;
14
+ /** PK */
15
+ transactionId: number;
16
+ /** UNIQUE — Bitcoin txid, hex */
17
+ txid: string;
18
+ /** Granular FSM state (see ProcessingStatus) */
19
+ processing: sdk.ProcessingStatus;
20
+ /** Wall-clock of the most recent processing transition */
21
+ processingChangedAt: Date;
22
+ /** Wall-clock at which the next monitor pass should consider this row */
23
+ nextActionAt?: Date;
24
+ /** Cumulative network-service attempt count */
25
+ attempts: number;
26
+ /** Count of times this row has been reset for rebroadcast (circuit-breaker) */
27
+ rebroadcastCycles: number;
28
+ /** true once the row has reached a state implying successful broadcast */
29
+ wasBroadcast: boolean;
30
+ /** Application-supplied idempotency key (unique when present) */
31
+ idempotencyKey?: string;
32
+ /** Optional batch tag for grouped broadcast */
33
+ batch?: string;
34
+ rawTx?: number[];
35
+ inputBeef?: number[];
36
+ /** Merkle proof fields — populated on transition to `proven` */
37
+ height?: number;
38
+ merkleIndex?: number;
39
+ merklePath?: number[];
40
+ merkleRoot?: string;
41
+ blockHash?: string;
42
+ isCoinbase: boolean;
43
+ lastProvider?: string;
44
+ lastProviderStatus?: string;
45
+ /** Reason a row is in `frozen` state, free text */
46
+ frozenReason?: string;
47
+ /** Optimistic concurrency token */
48
+ rowVersion: number;
49
+ }
50
+ //# sourceMappingURL=TableTransactionNew.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableTransactionNew.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableTransactionNew.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAoB,SAAQ,GAAG,CAAC,eAAe;IAC9D,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS;IACT,aAAa,EAAE,MAAM,CAAA;IACrB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAA;IAChC,0DAA0D;IAC1D,mBAAmB,EAAE,IAAI,CAAA;IACzB,yEAAyE;IACzE,YAAY,CAAC,EAAE,IAAI,CAAA;IACnB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAA;IAChB,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,CAAA;IACzB,0EAA0E;IAC1E,YAAY,EAAE,OAAO,CAAA;IACrB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TableTransactionNew.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableTransactionNew.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableTransactionNew.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import * as sdk from '../../../sdk';
2
+ /**
3
+ * V7 canonical per-txid table.
4
+ *
5
+ * Single source of truth for everything about a transaction on the network.
6
+ * Merges the legacy `proven_tx_reqs` (broadcast queue + processing state) and
7
+ * `proven_txs` (final Merkle proof) tables into one row per txid.
8
+ *
9
+ * Per-user metadata (description, labels, hidden, etc.) lives in `actions`.
10
+ */
11
+ export interface TableTransactionV7 extends sdk.EntityTimeStamp {
12
+ created_at: Date;
13
+ updated_at: Date;
14
+ /** PK */
15
+ transactionId: number;
16
+ /** UNIQUE — Bitcoin txid, hex */
17
+ txid: string;
18
+ /** Granular FSM state (see ProcessingStatus) */
19
+ processing: sdk.ProcessingStatus;
20
+ /** Wall-clock of the most recent processing transition */
21
+ processingChangedAt: Date;
22
+ /** Wall-clock at which the next monitor pass should consider this row */
23
+ nextActionAt?: Date;
24
+ /** Cumulative network-service attempt count */
25
+ attempts: number;
26
+ /** Count of times this row has been reset for rebroadcast (circuit-breaker) */
27
+ rebroadcastCycles: number;
28
+ /** true once the row has reached a state implying successful broadcast */
29
+ wasBroadcast: boolean;
30
+ /** Application-supplied idempotency key (unique when present) */
31
+ idempotencyKey?: string;
32
+ /** Optional batch tag for grouped broadcast */
33
+ batch?: string;
34
+ rawTx?: number[];
35
+ inputBeef?: number[];
36
+ /** Merkle proof fields — populated on transition to `proven` */
37
+ height?: number;
38
+ merkleIndex?: number;
39
+ merklePath?: number[];
40
+ merkleRoot?: string;
41
+ blockHash?: string;
42
+ isCoinbase: boolean;
43
+ lastProvider?: string;
44
+ lastProviderStatus?: string;
45
+ /** Reason a row is in `frozen` state, free text */
46
+ frozenReason?: string;
47
+ /** Optimistic concurrency token */
48
+ rowVersion: number;
49
+ }
50
+ //# sourceMappingURL=TableTransactionV7.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableTransactionV7.d.ts","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableTransactionV7.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAmB,SAAQ,GAAG,CAAC,eAAe;IAC7D,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS;IACT,aAAa,EAAE,MAAM,CAAA;IACrB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAA;IAChC,0DAA0D;IAC1D,mBAAmB,EAAE,IAAI,CAAA;IACzB,yEAAyE;IACzE,YAAY,CAAC,EAAE,IAAI,CAAA;IACnB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAA;IAChB,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,CAAA;IACzB,0EAA0E;IAC1E,YAAY,EAAE,OAAO,CAAA;IACrB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TableTransactionV7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableTransactionV7.js","sourceRoot":"","sources":["../../../../../../src/storage/schema/tables/TableTransactionV7.ts"],"names":[],"mappings":""}