@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
package/docs/storage.md CHANGED
@@ -22,25 +22,29 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
22
22
 
23
23
  | | | |
24
24
  | --- | --- | --- |
25
- | [AdminStatsResult](#interface-adminstatsresult) | [ProvenTxFromTxidResult](#interface-proventxfromtxidresult) | [TableOutputBasket](#interface-tableoutputbasket) |
26
- | [CommitNewTxResults](#interface-commitnewtxresults) | [ProvenTxReqHistory](#interface-proventxreqhistory) | [TableOutputTag](#interface-tableoutputtag) |
27
- | [EntitySyncMap](#interface-entitysyncmap) | [ProvenTxReqHistorySummaryApi](#interface-proventxreqhistorysummaryapi) | [TableOutputTagMap](#interface-tableoutputtagmap) |
28
- | [GenerateChangeSdkChangeInput](#interface-generatechangesdkchangeinput) | [ProvenTxReqNotify](#interface-proventxreqnotify) | [TableOutputX](#interface-tableoutputx) |
29
- | [GenerateChangeSdkChangeOutput](#interface-generatechangesdkchangeoutput) | [StorageAdminStats](#interface-storageadminstats) | [TableProvenTx](#interface-tableproventx) |
30
- | [GenerateChangeSdkInput](#interface-generatechangesdkinput) | [StorageIdbOptions](#interface-storageidboptions) | [TableProvenTxReq](#interface-tableproventxreq) |
31
- | [GenerateChangeSdkOutput](#interface-generatechangesdkoutput) | [StorageIdbSchema](#interface-storageidbschema) | [TableProvenTxReqDynamics](#interface-tableproventxreqdynamics) |
32
- | [GenerateChangeSdkParams](#interface-generatechangesdkparams) | [StorageKnexOptions](#interface-storageknexoptions) | [TableSettings](#interface-tablesettings) |
33
- | [GenerateChangeSdkResult](#interface-generatechangesdkresult) | [StorageProviderOptions](#interface-storageprovideroptions) | [TableSyncState](#interface-tablesyncstate) |
34
- | [GenerateChangeSdkStorageChange](#interface-generatechangesdkstoragechange) | [StorageReaderOptions](#interface-storagereaderoptions) | [TableTransaction](#interface-tabletransaction) |
35
- | [GetReqsAndBeefDetail](#interface-getreqsandbeefdetail) | [StorageReaderWriterOptions](#interface-storagereaderwriteroptions) | [TableTxLabel](#interface-tabletxlabel) |
36
- | [GetReqsAndBeefResult](#interface-getreqsandbeefresult) | [SyncError](#interface-syncerror) | [TableTxLabelMap](#interface-tabletxlabelmap) |
37
- | [ListActionsSpecOp](#interface-listactionsspecop) | [SyncMap](#interface-syncmap) | [TableUser](#interface-tableuser) |
38
- | [ListOutputsSpecOp](#interface-listoutputsspecop) | [TableCertificate](#interface-tablecertificate) | [ValidateGenerateChangeSdkParamsResult](#interface-validategeneratechangesdkparamsresult) |
39
- | [MonitorAdminContext](#interface-monitoradmincontext) | [TableCertificateField](#interface-tablecertificatefield) | [VerifyAndRepairBeefResult](#interface-verifyandrepairbeefresult) |
40
- | [MonitorAdminContextConfig](#interface-monitoradmincontextconfig) | [TableCertificateX](#interface-tablecertificatex) | [WalletStorageServerOptions](#interface-walletstorageserveroptions) |
41
- | [PostBeefResultForTxidApi](#interface-postbeefresultfortxidapi) | [TableCommission](#interface-tablecommission) | [XValidCreateActionOutput](#interface-xvalidcreateactionoutput) |
42
- | [PostReqsToNetworkDetails](#interface-postreqstonetworkdetails) | [TableMonitorEvent](#interface-tablemonitorevent) | |
43
- | [PostReqsToNetworkResult](#interface-postreqstonetworkresult) | [TableOutput](#interface-tableoutput) | |
25
+ | [AdminStatsResult](#interface-adminstatsresult) | [PostBeefResultForTxidApi](#interface-postbeefresultfortxidapi) | [TableMonitorLease](#interface-tablemonitorlease) |
26
+ | [AggregatePostBeefTxResult](#interface-aggregatepostbeeftxresult) | [PostReqsToNetworkDetails](#interface-postreqstonetworkdetails) | [TableOutput](#interface-tableoutput) |
27
+ | [AuditEvent](#interface-auditevent) | [PostReqsToNetworkResult](#interface-postreqstonetworkresult) | [TableOutputBasket](#interface-tableoutputbasket) |
28
+ | [CommitNewTxResults](#interface-commitnewtxresults) | [ProvenTxFromTxidResult](#interface-proventxfromtxidresult) | [TableOutputTag](#interface-tableoutputtag) |
29
+ | [EntitySyncMap](#interface-entitysyncmap) | [ProvenTxReqHistory](#interface-proventxreqhistory) | [TableOutputTagMap](#interface-tableoutputtagmap) |
30
+ | [FsmTransitionResult](#interface-fsmtransitionresult) | [ProvenTxReqHistorySummaryApi](#interface-proventxreqhistorysummaryapi) | [TableOutputX](#interface-tableoutputx) |
31
+ | [GenerateChangeSdkChangeInput](#interface-generatechangesdkchangeinput) | [ProvenTxReqNotify](#interface-proventxreqnotify) | [TableProvenTx](#interface-tableproventx) |
32
+ | [GenerateChangeSdkChangeOutput](#interface-generatechangesdkchangeoutput) | [StorageAdminStats](#interface-storageadminstats) | [TableProvenTxReq](#interface-tableproventxreq) |
33
+ | [GenerateChangeSdkInput](#interface-generatechangesdkinput) | [StorageIdbOptions](#interface-storageidboptions) | [TableProvenTxReqDynamics](#interface-tableproventxreqdynamics) |
34
+ | [GenerateChangeSdkOutput](#interface-generatechangesdkoutput) | [StorageIdbSchema](#interface-storageidbschema) | [TableSettings](#interface-tablesettings) |
35
+ | [GenerateChangeSdkParams](#interface-generatechangesdkparams) | [StorageKnexOptions](#interface-storageknexoptions) | [TableSyncState](#interface-tablesyncstate) |
36
+ | [GenerateChangeSdkResult](#interface-generatechangesdkresult) | [StorageProviderOptions](#interface-storageprovideroptions) | [TableTransaction](#interface-tabletransaction) |
37
+ | [GenerateChangeSdkStorageChange](#interface-generatechangesdkstoragechange) | [StorageReaderOptions](#interface-storagereaderoptions) | [TableTransactionNew](#interface-tabletransactionnew) |
38
+ | [GetReqsAndBeefDetail](#interface-getreqsandbeefdetail) | [StorageReaderWriterOptions](#interface-storagereaderwriteroptions) | [TableTxAudit](#interface-tabletxaudit) |
39
+ | [GetReqsAndBeefResult](#interface-getreqsandbeefresult) | [SyncError](#interface-syncerror) | [TableTxLabel](#interface-tabletxlabel) |
40
+ | [ListActionsSpecOp](#interface-listactionsspecop) | [SyncMap](#interface-syncmap) | [TableTxLabelMap](#interface-tabletxlabelmap) |
41
+ | [ListOutputsSpecOp](#interface-listoutputsspecop) | [TableAction](#interface-tableaction) | [TableUser](#interface-tableuser) |
42
+ | [MonitorAdminContext](#interface-monitoradmincontext) | [TableCertificate](#interface-tablecertificate) | [ValidateGenerateChangeSdkParamsResult](#interface-validategeneratechangesdkparamsresult) |
43
+ | [MonitorAdminContextConfig](#interface-monitoradmincontextconfig) | [TableCertificateField](#interface-tablecertificatefield) | [VerifyAndRepairBeefResult](#interface-verifyandrepairbeefresult) |
44
+ | [MonitorLeaseClaim](#interface-monitorleaseclaim) | [TableCertificateX](#interface-tablecertificatex) | [WalletStorageServerOptions](#interface-walletstorageserveroptions) |
45
+ | [MonitorLeaseRelease](#interface-monitorleaserelease) | [TableChainTip](#interface-tablechaintip) | [XValidCreateActionOutput](#interface-xvalidcreateactionoutput) |
46
+ | [MonitorLeaseRenew](#interface-monitorleaserenew) | [TableCommission](#interface-tablecommission) | |
47
+ | [MonitorLeaseResult](#interface-monitorleaseresult) | [TableMonitorEvent](#interface-tablemonitorevent) | |
44
48
 
45
49
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
46
50
 
@@ -55,7 +59,61 @@ export interface AdminStatsResult extends StorageAdminStats {
55
59
  }
56
60
  ```
57
61
 
58
- See also: [ServicesCallHistory](./client.md#type-servicescallhistory), [StorageAdminStats](./storage.md#interface-storageadminstats)
62
+ See also: [ServicesCallHistory](./client.md#interface-servicescallhistory), [StorageAdminStats](./storage.md#interface-storageadminstats)
63
+
64
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
65
+
66
+ ---
67
+ ##### Interface: AggregatePostBeefTxResult
68
+
69
+ ```ts
70
+ export interface AggregatePostBeefTxResult {
71
+ txid: string;
72
+ txidResults: sdk.PostTxResultForTxid[];
73
+ status: AggregateStatus;
74
+ vreq: PostReqsToNetworkDetails;
75
+ successCount: number;
76
+ doubleSpendCount: number;
77
+ statusErrorCount: number;
78
+ serviceErrorCount: number;
79
+ competingTxs: string[];
80
+ }
81
+ ```
82
+
83
+ See also: [PostReqsToNetworkDetails](./storage.md#interface-postreqstonetworkdetails), [PostTxResultForTxid](./client.md#interface-posttxresultfortxid)
84
+
85
+ ###### Property competingTxs
86
+
87
+ Any competing double spend txids reported for this txid
88
+
89
+ ```ts
90
+ competingTxs: string[]
91
+ ```
92
+
93
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
94
+
95
+ ---
96
+ ##### Interface: AuditEvent
97
+
98
+ append-only audit log writer.
99
+
100
+ Each call inserts one `tx_audit` row. Events should be small, stable
101
+ identifiers (e.g. `processing.changed`, `proof.acquired`, `lease.claimed`).
102
+ Payload is stored as a JSON-encoded string so downstream consumers may add
103
+ shape over time without a migration.
104
+
105
+ ```ts
106
+ export interface AuditEvent {
107
+ transactionId?: number;
108
+ actionId?: number;
109
+ event: string;
110
+ fromState?: sdk.ProcessingStatus;
111
+ toState?: sdk.ProcessingStatus;
112
+ details?: Record<string, unknown>;
113
+ }
114
+ ```
115
+
116
+ See also: [ProcessingStatus](./client.md#type-processingstatus)
59
117
 
60
118
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
61
119
 
@@ -116,6 +174,18 @@ maxUpdated_at?: Date
116
174
 
117
175
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
118
176
 
177
+ ---
178
+ ##### Interface: FsmTransitionResult
179
+
180
+ ```ts
181
+ export interface FsmTransitionResult {
182
+ ok: boolean;
183
+ reason?: string;
184
+ }
185
+ ```
186
+
187
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
188
+
119
189
  ---
120
190
  ##### Interface: GenerateChangeSdkChangeInput
121
191
 
@@ -321,7 +391,7 @@ export interface ListActionsSpecOp {
321
391
  name: string;
322
392
  labelsToIntercept?: string[];
323
393
  setStatusFilter?: () => TransactionStatus[];
324
- postProcess?: (s: StorageProvider, auth: AuthId, vargs: Validation.ValidListActionsArgs, specOpLabels: string[], txs: Partial<TableTransaction>[]) => Promise<void>;
394
+ postProcess?: (s: StorageProvider, auth: AuthId, vargs: Validation.ValidListActionsArgs, specOpLabels: string[], txs: Array<Partial<TableTransaction>>) => Promise<void>;
325
395
  }
326
396
  ```
327
397
 
@@ -419,6 +489,72 @@ See also: [Chain](./client.md#type-chain)
419
489
 
420
490
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
421
491
 
492
+ ---
493
+ ##### Interface: MonitorLeaseClaim
494
+
495
+ monitor lease primitive.
496
+
497
+ A `monitor_lease` row records the owner that may currently execute a named
498
+ task. Acquisition is opportunistic: a Monitor calls `tryClaimLease()` to
499
+ insert or take over a stale row; if it succeeds it owns the task until
500
+ `expiresAt`. While running it calls `renewLease()` to extend the deadline.
501
+ On clean shutdown it calls `releaseLease()`.
502
+
503
+ The Knex driver expresses claim + takeover as a single conditional UPDATE
504
+ so that two contending Monitors cannot both believe they own the task — at
505
+ most one row write will succeed per (task, expiry) pair.
506
+
507
+ ```ts
508
+ export interface MonitorLeaseClaim {
509
+ taskName: string;
510
+ ownerId: string;
511
+ ttlMs: number;
512
+ note?: string;
513
+ }
514
+ ```
515
+
516
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
517
+
518
+ ---
519
+ ##### Interface: MonitorLeaseRelease
520
+
521
+ ```ts
522
+ export interface MonitorLeaseRelease {
523
+ taskName: string;
524
+ ownerId: string;
525
+ }
526
+ ```
527
+
528
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
529
+
530
+ ---
531
+ ##### Interface: MonitorLeaseRenew
532
+
533
+ ```ts
534
+ export interface MonitorLeaseRenew {
535
+ taskName: string;
536
+ ownerId: string;
537
+ ttlMs: number;
538
+ note?: string;
539
+ }
540
+ ```
541
+
542
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
543
+
544
+ ---
545
+ ##### Interface: MonitorLeaseResult
546
+
547
+ ```ts
548
+ export interface MonitorLeaseResult {
549
+ acquired: boolean;
550
+ lease?: TableMonitorLease;
551
+ }
552
+ ```
553
+
554
+ See also: [TableMonitorLease](./storage.md#interface-tablemonitorlease)
555
+
556
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
557
+
422
558
  ---
423
559
  ##### Interface: PostBeefResultForTxidApi
424
560
 
@@ -518,7 +654,7 @@ export interface ProvenTxReqHistory {
518
654
  }
519
655
  ```
520
656
 
521
- See also: [ReqHistoryNote](./client.md#type-reqhistorynote)
657
+ See also: [ReqHistoryNote](./client.md#interface-reqhistorynote)
522
658
 
523
659
  ###### Property notes
524
660
 
@@ -528,7 +664,7 @@ Values are a description of what happened.
528
664
  ```ts
529
665
  notes?: ReqHistoryNote[]
530
666
  ```
531
- See also: [ReqHistoryNote](./client.md#type-reqhistorynote)
667
+ See also: [ReqHistoryNote](./client.md#interface-reqhistorynote)
532
668
 
533
669
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
534
670
 
@@ -801,10 +937,57 @@ export interface StorageIdbSchema {
801
937
  identityKey: string;
802
938
  };
803
939
  };
940
+ transactionsNew: {
941
+ key: number;
942
+ value: TableTransactionNew;
943
+ indexes: {
944
+ txid: HexString;
945
+ processing: ProcessingStatus;
946
+ batch: string;
947
+ idempotencyKey: string;
948
+ };
949
+ };
950
+ actions: {
951
+ key: number;
952
+ value: TableAction;
953
+ indexes: {
954
+ userId: number;
955
+ transactionId: number;
956
+ userId_transactionId: [
957
+ number,
958
+ number
959
+ ];
960
+ userId_reference: [
961
+ number,
962
+ string
963
+ ];
964
+ };
965
+ };
966
+ chainTip: {
967
+ key: number;
968
+ value: TableChainTip;
969
+ indexes: Record<string, never>;
970
+ };
971
+ txAudit: {
972
+ key: number;
973
+ value: TableTxAudit;
974
+ indexes: {
975
+ transactionId: number;
976
+ actionId: number;
977
+ event: string;
978
+ };
979
+ };
980
+ monitorLease: {
981
+ key: string;
982
+ value: TableMonitorLease;
983
+ indexes: {
984
+ expiresAt: Date;
985
+ };
986
+ };
804
987
  }
805
988
  ```
806
989
 
807
- See also: [ProvenTxReqStatus](./client.md#type-proventxreqstatus), [SyncStatus](./client.md#type-syncstatus), [TableCertificate](./storage.md#interface-tablecertificate), [TableCertificateField](./storage.md#interface-tablecertificatefield), [TableCommission](./storage.md#interface-tablecommission), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputTagMap](./storage.md#interface-tableoutputtagmap), [TableProvenTx](./storage.md#interface-tableproventx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableTransaction](./storage.md#interface-tabletransaction), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TransactionStatus](./client.md#type-transactionstatus)
990
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [ProvenTxReqStatus](./client.md#type-proventxreqstatus), [SyncStatus](./client.md#type-syncstatus), [TableAction](./storage.md#interface-tableaction), [TableCertificate](./storage.md#interface-tablecertificate), [TableCertificateField](./storage.md#interface-tablecertificatefield), [TableChainTip](./storage.md#interface-tablechaintip), [TableCommission](./storage.md#interface-tablecommission), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableMonitorLease](./storage.md#interface-tablemonitorlease), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputTagMap](./storage.md#interface-tableoutputtagmap), [TableProvenTx](./storage.md#interface-tableproventx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableTransaction](./storage.md#interface-tabletransaction), [TableTransactionNew](./storage.md#interface-tabletransactionnew), [TableTxAudit](./storage.md#interface-tabletxaudit), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TransactionStatus](./client.md#type-transactionstatus)
808
991
 
809
992
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
810
993
 
@@ -926,6 +1109,121 @@ See also: [EntitySyncMap](./storage.md#interface-entitysyncmap)
926
1109
 
927
1110
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
928
1111
 
1112
+ ---
1113
+ ##### Interface: TableAction
1114
+
1115
+ per-user view of a transaction.
1116
+
1117
+ Migrated from the legacy `transactions` table. Holds everything that is truly
1118
+ per-user (description, labels via tx_labels_map -> actionId, soft-delete flags,
1119
+ notification subscribers). All on-chain status lives in the new `transactions`
1120
+ table addressed by `transactionId`.
1121
+
1122
+ UNIQUE(userId, transactionId).
1123
+
1124
+ ```ts
1125
+ export interface TableAction extends sdk.EntityTimeStamp {
1126
+ created_at: Date;
1127
+ updated_at: Date;
1128
+ actionId: number;
1129
+ userId: number;
1130
+ transactionId: number;
1131
+ reference: string;
1132
+ description: string;
1133
+ isOutgoing: boolean;
1134
+ satoshisDelta: number;
1135
+ userNosend: boolean;
1136
+ hidden: boolean;
1137
+ userAborted: boolean;
1138
+ notifyJson?: string;
1139
+ rowVersion: number;
1140
+ }
1141
+ ```
1142
+
1143
+ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp)
1144
+
1145
+ ###### Property actionId
1146
+
1147
+ PK
1148
+
1149
+ ```ts
1150
+ actionId: number
1151
+ ```
1152
+
1153
+ ###### Property hidden
1154
+
1155
+ Soft-delete flag — hide from default queries
1156
+
1157
+ ```ts
1158
+ hidden: boolean
1159
+ ```
1160
+
1161
+ ###### Property isOutgoing
1162
+
1163
+ true if originated in this wallet (change returns to it)
1164
+
1165
+ ```ts
1166
+ isOutgoing: boolean
1167
+ ```
1168
+
1169
+ ###### Property notifyJson
1170
+
1171
+ JSON string of per-user notification subscribers (mirrors legacy notify)
1172
+
1173
+ ```ts
1174
+ notifyJson?: string
1175
+ ```
1176
+
1177
+ ###### Property reference
1178
+
1179
+ Application reference, hex/Base64, max 64 chars
1180
+
1181
+ ```ts
1182
+ reference: string
1183
+ ```
1184
+
1185
+ ###### Property rowVersion
1186
+
1187
+ Optimistic concurrency token
1188
+
1189
+ ```ts
1190
+ rowVersion: number
1191
+ ```
1192
+
1193
+ ###### Property satoshisDelta
1194
+
1195
+ Signed net change to this user's balance from this action
1196
+
1197
+ ```ts
1198
+ satoshisDelta: number
1199
+ ```
1200
+
1201
+ ###### Property transactionId
1202
+
1203
+ FK -> new transactions.transactionId (per-txid record)
1204
+
1205
+ ```ts
1206
+ transactionId: number
1207
+ ```
1208
+
1209
+ ###### Property userAborted
1210
+
1211
+ Per-user abort flag
1212
+
1213
+ ```ts
1214
+ userAborted: boolean
1215
+ ```
1216
+
1217
+ ###### Property userNosend
1218
+
1219
+ Per-user nosend override
1220
+
1221
+ ```ts
1222
+ userNosend: boolean
1223
+ ```
1224
+
1225
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1226
+
929
1227
  ---
930
1228
  ##### Interface: TableCertificate
931
1229
 
@@ -982,6 +1280,44 @@ See also: [TableCertificate](./storage.md#interface-tablecertificate), [TableCer
982
1280
 
983
1281
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
984
1282
 
1283
+ ---
1284
+ ##### Interface: TableChainTip
1285
+
1286
+ singleton row tracking the most recently observed chain tip.
1287
+ Used by spendability checks and coinbase maturity calculations.
1288
+
1289
+ ```ts
1290
+ export interface TableChainTip extends sdk.EntityTimeStamp {
1291
+ created_at: Date;
1292
+ updated_at: Date;
1293
+ id: number;
1294
+ height: number;
1295
+ blockHash: string;
1296
+ merkleRoot?: string;
1297
+ observedAt: Date;
1298
+ }
1299
+ ```
1300
+
1301
+ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp), [blockHash](./services.md#function-blockhash)
1302
+
1303
+ ###### Property id
1304
+
1305
+ Always 1 — singleton enforced by storage layer
1306
+
1307
+ ```ts
1308
+ id: number
1309
+ ```
1310
+
1311
+ ###### Property observedAt
1312
+
1313
+ Wall-clock of the observation
1314
+
1315
+ ```ts
1316
+ observedAt: Date
1317
+ ```
1318
+
1319
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1320
+
985
1321
  ---
986
1322
  ##### Interface: TableCommission
987
1323
 
@@ -1020,6 +1356,71 @@ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp)
1020
1356
 
1021
1357
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1022
1358
 
1359
+ ---
1360
+ ##### Interface: TableMonitorLease
1361
+
1362
+ monitor_lease record so at most one Monitor daemon owns a given task at a time.
1363
+
1364
+ The Monitor acquires a lease by upserting `(taskName, ownerId, expiresAt)`
1365
+ and renews periodically. Stale leases (`expiresAt < now`) may be claimed by
1366
+ another instance.
1367
+
1368
+ ```ts
1369
+ export interface TableMonitorLease extends sdk.EntityTimeStamp {
1370
+ created_at: Date;
1371
+ updated_at: Date;
1372
+ taskName: string;
1373
+ ownerId: string;
1374
+ expiresAt: Date;
1375
+ renewCount: number;
1376
+ note?: string;
1377
+ }
1378
+ ```
1379
+
1380
+ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp)
1381
+
1382
+ ###### Property expiresAt
1383
+
1384
+ Lease expiry — claimants treat any row with expiresAt <= now() as free
1385
+
1386
+ ```ts
1387
+ expiresAt: Date
1388
+ ```
1389
+
1390
+ ###### Property note
1391
+
1392
+ Optional free-text description of current activity
1393
+
1394
+ ```ts
1395
+ note?: string
1396
+ ```
1397
+
1398
+ ###### Property ownerId
1399
+
1400
+ Stable identifier for the owning Monitor instance
1401
+
1402
+ ```ts
1403
+ ownerId: string
1404
+ ```
1405
+
1406
+ ###### Property renewCount
1407
+
1408
+ Monotonic counter incremented on each successful renew
1409
+
1410
+ ```ts
1411
+ renewCount: number
1412
+ ```
1413
+
1414
+ ###### Property taskName
1415
+
1416
+ Logical task name, e.g. 'proof-acquisition'
1417
+
1418
+ ```ts
1419
+ taskName: string
1420
+ ```
1421
+
1422
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1423
+
1023
1424
  ---
1024
1425
  ##### Interface: TableOutput
1025
1426
 
@@ -1050,11 +1451,23 @@ export interface TableOutput extends sdk.EntityTimeStamp {
1050
1451
  scriptLength?: number;
1051
1452
  scriptOffset?: number;
1052
1453
  lockingScript?: number[];
1454
+ maturesAtHeight?: number;
1053
1455
  }
1054
1456
  ```
1055
1457
 
1056
1458
  See also: [EntityTimeStamp](./client.md#interface-entitytimestamp), [StorageProvidedBy](./client.md#type-storageprovidedby)
1057
1459
 
1460
+ ###### Property maturesAtHeight
1461
+
1462
+ new-schema: minimum block height at which a coinbase output becomes spendable.
1463
+ NULL for non-coinbase outputs and for pre-new schema rows that have not yet been
1464
+ backfilled. The §4 spendability rule treats a non-coinbase output as
1465
+ mature regardless of this column.
1466
+
1467
+ ```ts
1468
+ maturesAtHeight?: number
1469
+ ```
1470
+
1058
1471
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1059
1472
 
1060
1473
  ---
@@ -1166,6 +1579,8 @@ export interface TableProvenTxReq extends TableProvenTxReqDynamics {
1166
1579
  notify: string;
1167
1580
  rawTx: number[];
1168
1581
  inputBEEF?: number[];
1582
+ wasBroadcast?: boolean;
1583
+ rebroadcastAttempts?: number;
1169
1584
  }
1170
1585
  ```
1171
1586
 
@@ -1213,6 +1628,27 @@ Parses to `ProvenTxReqNotifyApi`.
1213
1628
  notify: string
1214
1629
  ```
1215
1630
 
1631
+ ###### Property rebroadcastAttempts
1632
+
1633
+ Count of how many times this req has been reset to 'unsent' for rebroadcast
1634
+ after proof check timeout. Used by the circuit-breaker (maxRebroadcastAttempts).
1635
+ Defaults to 0 (added by migration 2026-04-30-001).
1636
+
1637
+ ```ts
1638
+ rebroadcastAttempts?: number
1639
+ ```
1640
+
1641
+ ###### Property wasBroadcast
1642
+
1643
+ Set to true the first time this req transitions to 'unmined' or 'callback' status,
1644
+ indicating the transaction was successfully broadcast to the network.
1645
+ Used to distinguish rebroadcast candidates from transactions that were never sent.
1646
+ Defaults to false (added by migration 2026-04-30-001).
1647
+
1648
+ ```ts
1649
+ wasBroadcast?: boolean
1650
+ ```
1651
+
1216
1652
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1217
1653
 
1218
1654
  ---
@@ -1230,6 +1666,8 @@ export interface TableProvenTxReqDynamics extends sdk.EntityTimeStamp {
1230
1666
  batch?: string;
1231
1667
  history: string;
1232
1668
  notify: string;
1669
+ wasBroadcast?: boolean;
1670
+ rebroadcastAttempts?: number;
1233
1671
  }
1234
1672
  ```
1235
1673
 
@@ -1277,9 +1715,27 @@ Parses to `ProvenTxReqNotifyApi`.
1277
1715
  notify: string
1278
1716
  ```
1279
1717
 
1280
- Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1718
+ ###### Property rebroadcastAttempts
1281
1719
 
1282
- ---
1720
+ Count of rebroadcast cycles for this req. Used by the circuit-breaker.
1721
+ Defaults to 0 (added by migration 2026-04-30-001).
1722
+
1723
+ ```ts
1724
+ rebroadcastAttempts?: number
1725
+ ```
1726
+
1727
+ ###### Property wasBroadcast
1728
+
1729
+ Set to true the first time this req transitions to 'unmined' or 'callback' status.
1730
+ Defaults to false (added by migration 2026-04-30-001).
1731
+
1732
+ ```ts
1733
+ wasBroadcast?: boolean
1734
+ ```
1735
+
1736
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1737
+
1738
+ ---
1283
1739
  ##### Interface: TableSettings
1284
1740
 
1285
1741
  ```ts
@@ -1403,6 +1859,237 @@ version?: number
1403
1859
 
1404
1860
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1405
1861
 
1862
+ ---
1863
+ ##### Interface: TableTransactionNew
1864
+
1865
+ new canonical per-txid table.
1866
+
1867
+ Single source of truth for everything about a transaction on the network.
1868
+ Merges the legacy `proven_tx_reqs` (broadcast queue + processing state) and
1869
+ `proven_txs` (final Merkle proof) tables into one row per txid.
1870
+
1871
+ Per-user metadata (description, labels, hidden, etc.) lives in `actions`.
1872
+
1873
+ ```ts
1874
+ export interface TableTransactionNew extends sdk.EntityTimeStamp {
1875
+ created_at: Date;
1876
+ updated_at: Date;
1877
+ transactionId: number;
1878
+ txid: string;
1879
+ processing: sdk.ProcessingStatus;
1880
+ processingChangedAt: Date;
1881
+ nextActionAt?: Date;
1882
+ attempts: number;
1883
+ rebroadcastCycles: number;
1884
+ wasBroadcast: boolean;
1885
+ idempotencyKey?: string;
1886
+ batch?: string;
1887
+ rawTx?: number[];
1888
+ inputBeef?: number[];
1889
+ height?: number;
1890
+ merkleIndex?: number;
1891
+ merklePath?: number[];
1892
+ merkleRoot?: string;
1893
+ blockHash?: string;
1894
+ isCoinbase: boolean;
1895
+ lastProvider?: string;
1896
+ lastProviderStatus?: string;
1897
+ frozenReason?: string;
1898
+ rowVersion: number;
1899
+ }
1900
+ ```
1901
+
1902
+ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp), [ProcessingStatus](./client.md#type-processingstatus), [blockHash](./services.md#function-blockhash)
1903
+
1904
+ ###### Property attempts
1905
+
1906
+ Cumulative network-service attempt count
1907
+
1908
+ ```ts
1909
+ attempts: number
1910
+ ```
1911
+
1912
+ ###### Property batch
1913
+
1914
+ Optional batch tag for grouped broadcast
1915
+
1916
+ ```ts
1917
+ batch?: string
1918
+ ```
1919
+
1920
+ ###### Property frozenReason
1921
+
1922
+ Reason a row is in `frozen` state, free text
1923
+
1924
+ ```ts
1925
+ frozenReason?: string
1926
+ ```
1927
+
1928
+ ###### Property height
1929
+
1930
+ Merkle proof fields — populated on transition to `proven`
1931
+
1932
+ ```ts
1933
+ height?: number
1934
+ ```
1935
+
1936
+ ###### Property idempotencyKey
1937
+
1938
+ Application-supplied idempotency key (unique when present)
1939
+
1940
+ ```ts
1941
+ idempotencyKey?: string
1942
+ ```
1943
+
1944
+ ###### Property nextActionAt
1945
+
1946
+ Wall-clock at which the next monitor pass should consider this row
1947
+
1948
+ ```ts
1949
+ nextActionAt?: Date
1950
+ ```
1951
+
1952
+ ###### Property processing
1953
+
1954
+ Granular FSM state (see ProcessingStatus)
1955
+
1956
+ ```ts
1957
+ processing: sdk.ProcessingStatus
1958
+ ```
1959
+ See also: [ProcessingStatus](./client.md#type-processingstatus)
1960
+
1961
+ ###### Property processingChangedAt
1962
+
1963
+ Wall-clock of the most recent processing transition
1964
+
1965
+ ```ts
1966
+ processingChangedAt: Date
1967
+ ```
1968
+
1969
+ ###### Property rebroadcastCycles
1970
+
1971
+ Count of times this row has been reset for rebroadcast (circuit-breaker)
1972
+
1973
+ ```ts
1974
+ rebroadcastCycles: number
1975
+ ```
1976
+
1977
+ ###### Property rowVersion
1978
+
1979
+ Optimistic concurrency token
1980
+
1981
+ ```ts
1982
+ rowVersion: number
1983
+ ```
1984
+
1985
+ ###### Property transactionId
1986
+
1987
+ PK
1988
+
1989
+ ```ts
1990
+ transactionId: number
1991
+ ```
1992
+
1993
+ ###### Property txid
1994
+
1995
+ UNIQUE — Bitcoin txid, hex
1996
+
1997
+ ```ts
1998
+ txid: string
1999
+ ```
2000
+
2001
+ ###### Property wasBroadcast
2002
+
2003
+ true once the row has reached a state implying successful broadcast
2004
+
2005
+ ```ts
2006
+ wasBroadcast: boolean
2007
+ ```
2008
+
2009
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
2010
+
2011
+ ---
2012
+ ##### Interface: TableTxAudit
2013
+
2014
+ per-event audit log for transactions and actions.
2015
+
2016
+ Each row records a single observable event scoped to either a transaction
2017
+ (per-txid) or an action (per-user) or both. Append-only.
2018
+
2019
+ ```ts
2020
+ export interface TableTxAudit extends sdk.EntityTimeStamp {
2021
+ created_at: Date;
2022
+ updated_at: Date;
2023
+ auditId: number;
2024
+ transactionId?: number;
2025
+ actionId?: number;
2026
+ event: string;
2027
+ fromState?: string;
2028
+ toState?: string;
2029
+ detailsJson?: string;
2030
+ }
2031
+ ```
2032
+
2033
+ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp)
2034
+
2035
+ ###### Property actionId
2036
+
2037
+ FK -> actions.actionId, optional for tx-only events
2038
+
2039
+ ```ts
2040
+ actionId?: number
2041
+ ```
2042
+
2043
+ ###### Property auditId
2044
+
2045
+ PK
2046
+
2047
+ ```ts
2048
+ auditId: number
2049
+ ```
2050
+
2051
+ ###### Property detailsJson
2052
+
2053
+ JSON-encoded event payload
2054
+
2055
+ ```ts
2056
+ detailsJson?: string
2057
+ ```
2058
+
2059
+ ###### Property event
2060
+
2061
+ Stable event identifier, e.g. 'processing.changed', 'proof.acquired'
2062
+
2063
+ ```ts
2064
+ event: string
2065
+ ```
2066
+
2067
+ ###### Property fromState
2068
+
2069
+ Optional FSM source state for transitions
2070
+
2071
+ ```ts
2072
+ fromState?: string
2073
+ ```
2074
+
2075
+ ###### Property toState
2076
+
2077
+ Optional FSM target state for transitions
2078
+
2079
+ ```ts
2080
+ toState?: string
2081
+ ```
2082
+
2083
+ ###### Property transactionId
2084
+
2085
+ FK -> transactions.transactionId, optional for action-only events
2086
+
2087
+ ```ts
2088
+ transactionId?: number
2089
+ ```
2090
+
2091
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
2092
+
1406
2093
  ---
1407
2094
  ##### Interface: TableTxLabel
1408
2095
 
@@ -1542,15 +2229,16 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
1542
2229
 
1543
2230
  | | | |
1544
2231
  | --- | --- | --- |
1545
- | [AdminServer](#class-adminserver) | [EntityProvenTx](#class-entityproventx) | [StorageClient](#class-storageclient) |
1546
- | [EntityBase](#class-entitybase) | [EntityProvenTxReq](#class-entityproventxreq) | [StorageIdb](#class-storageidb) |
1547
- | [EntityCertificate](#class-entitycertificate) | [EntitySyncState](#class-entitysyncstate) | [StorageKnex](#class-storageknex) |
1548
- | [EntityCertificateField](#class-entitycertificatefield) | [EntityTransaction](#class-entitytransaction) | [StorageProvider](#class-storageprovider) |
1549
- | [EntityCommission](#class-entitycommission) | [EntityTxLabel](#class-entitytxlabel) | [StorageReader](#class-storagereader) |
1550
- | [EntityOutput](#class-entityoutput) | [EntityTxLabelMap](#class-entitytxlabelmap) | [StorageReaderWriter](#class-storagereaderwriter) |
1551
- | [EntityOutputBasket](#class-entityoutputbasket) | [EntityUser](#class-entityuser) | [StorageServer](#class-storageserver) |
1552
- | [EntityOutputTag](#class-entityoutputtag) | [KnexMigrations](#class-knexmigrations) | [StorageSyncReader](#class-storagesyncreader) |
1553
- | [EntityOutputTagMap](#class-entityoutputtagmap) | [MergeEntity](#class-mergeentity) | [WalletStorageManager](#class-walletstoragemanager) |
2232
+ | [AdminServer](#class-adminserver) | [EntityProvenTxReq](#class-entityproventxreq) | [StorageIdb](#class-storageidb) |
2233
+ | [EntityBase](#class-entitybase) | [EntitySyncState](#class-entitysyncstate) | [StorageKnex](#class-storageknex) |
2234
+ | [EntityCertificate](#class-entitycertificate) | [EntityTransaction](#class-entitytransaction) | [StorageProvider](#class-storageprovider) |
2235
+ | [EntityCertificateField](#class-entitycertificatefield) | [EntityTxLabel](#class-entitytxlabel) | [StorageReader](#class-storagereader) |
2236
+ | [EntityCommission](#class-entitycommission) | [EntityTxLabelMap](#class-entitytxlabelmap) | [StorageReaderWriter](#class-storagereaderwriter) |
2237
+ | [EntityOutput](#class-entityoutput) | [EntityUser](#class-entityuser) | [StorageServer](#class-storageserver) |
2238
+ | [EntityOutputBasket](#class-entityoutputbasket) | [KnexMigrations](#class-knexmigrations) | [StorageSyncReader](#class-storagesyncreader) |
2239
+ | [EntityOutputTag](#class-entityoutputtag) | [MergeEntity](#class-mergeentity) | [TransactionService](#class-transactionservice) |
2240
+ | [EntityOutputTagMap](#class-entityoutputtagmap) | [StorageClient](#class-storageclient) | [WalletStorageManager](#class-walletstoragemanager) |
2241
+ | [EntityProvenTx](#class-entityproventx) | [StorageClientBase](#class-storageclientbase) | |
1554
2242
 
1555
2243
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
1556
2244
 
@@ -2026,9 +2714,9 @@ export class EntityProvenTx extends EntityBase<TableProvenTx> {
2026
2714
  }>
2027
2715
  override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: TrxToken): Promise<void>
2028
2716
  override async mergeExisting(storage: EntityStorage, since: Date | undefined, ei: TableProvenTx, syncMap: SyncMap, trx?: TrxToken): Promise<boolean>
2029
- static getProofAttemptsLimit = 8;
2030
- static getProofMinutes = 60;
2031
- static async fromReq(req: EntityProvenTxReq, gmpResult: GetMerklePathResult, countsAsAttempt: boolean): Promise<EntityProvenTx | undefined>
2717
+ static readonly getProofAttemptsLimit = 8;
2718
+ static readonly getProofMinutes = 60;
2719
+ static async fromReq(req: EntityProvenTxReq, gmpResult: GetMerklePathResult, countsAsAttempt: boolean, maxRebroadcastAttempts = 0): Promise<EntityProvenTx | undefined>
2032
2720
  }
2033
2721
  ```
2034
2722
 
@@ -2039,7 +2727,7 @@ See also: [EntityBase](./storage.md#class-entitybase), [EntityProvenTxReq](./sto
2039
2727
  How high attempts can go before status is forced to invalid
2040
2728
 
2041
2729
  ```ts
2042
- static getProofAttemptsLimit = 8
2730
+ static readonly getProofAttemptsLimit = 8
2043
2731
  ```
2044
2732
 
2045
2733
  ###### Property getProofMinutes
@@ -2047,7 +2735,7 @@ static getProofAttemptsLimit = 8
2047
2735
  How many hours we have to try for a poof
2048
2736
 
2049
2737
  ```ts
2050
- static getProofMinutes = 60
2738
+ static readonly getProofMinutes = 60
2051
2739
  ```
2052
2740
 
2053
2741
  ###### Method fromReq
@@ -2057,7 +2745,7 @@ Try to create a new ProvenTx from a ProvenTxReq and GetMerkleProofResultApi
2057
2745
  Otherwise it returns undefined and updates req.status to either 'unknown', 'invalid', or 'unconfirmed'
2058
2746
 
2059
2747
  ```ts
2060
- static async fromReq(req: EntityProvenTxReq, gmpResult: GetMerklePathResult, countsAsAttempt: boolean): Promise<EntityProvenTx | undefined>
2748
+ static async fromReq(req: EntityProvenTxReq, gmpResult: GetMerklePathResult, countsAsAttempt: boolean, maxRebroadcastAttempts = 0): Promise<EntityProvenTx | undefined>
2061
2749
  ```
2062
2750
  See also: [EntityProvenTx](./storage.md#class-entityproventx), [EntityProvenTxReq](./storage.md#class-entityproventxreq), [GetMerklePathResult](./client.md#interface-getmerklepathresult)
2063
2751
 
@@ -2095,6 +2783,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
2095
2783
 
2096
2784
  ```ts
2097
2785
  export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
2786
+ static readonly wasBroadcastStatuses: ProvenTxReqStatus[] = ["unmined", "callback", "unconfirmed", "completed"];
2098
2787
  static async fromStorageTxid(storage: EntityStorage, txid: string, trx?: TrxToken): Promise<EntityProvenTxReq | undefined>
2099
2788
  static async fromStorageId(storage: EntityStorage, id: number, trx?: TrxToken): Promise<EntityProvenTxReq>
2100
2789
  static fromTxid(txid: string, rawTx: number[], inputBEEF?: number[]): EntityProvenTxReq
@@ -2144,6 +2833,14 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
2144
2833
  set notified(v: boolean)
2145
2834
  get batch()
2146
2835
  set batch(v: string | undefined)
2836
+ get wasBroadcast(): boolean
2837
+ set wasBroadcast(v: boolean)
2838
+ get rebroadcastAttempts(): number
2839
+ set rebroadcastAttempts(v: number)
2840
+ applyProofTimeout(maxRebroadcastAttempts = 0): {
2841
+ action: "invalid" | "rebroadcast";
2842
+ rebroadcastAttempts: number;
2843
+ }
2147
2844
  override get id()
2148
2845
  override set id(v: number)
2149
2846
  override get entityName(): string
@@ -2163,7 +2860,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
2163
2860
  }
2164
2861
  ```
2165
2862
 
2166
- See also: [EntityBase](./storage.md#class-entitybase), [EntityStorage](./storage.md#type-entitystorage), [ProvenTxReqHistory](./storage.md#interface-proventxreqhistory), [ProvenTxReqHistorySummaryApi](./storage.md#interface-proventxreqhistorysummaryapi), [ProvenTxReqNotify](./storage.md#interface-proventxreqnotify), [ProvenTxReqStatus](./client.md#type-proventxreqstatus), [ReqHistoryNote](./client.md#type-reqhistorynote), [StorageProvider](./storage.md#class-storageprovider), [SyncMap](./storage.md#interface-syncmap), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TrxToken](./client.md#interface-trxtoken), [WalletStorageManager](./storage.md#class-walletstoragemanager)
2863
+ See also: [EntityBase](./storage.md#class-entitybase), [EntityStorage](./storage.md#type-entitystorage), [ProvenTxReqHistory](./storage.md#interface-proventxreqhistory), [ProvenTxReqHistorySummaryApi](./storage.md#interface-proventxreqhistorysummaryapi), [ProvenTxReqNotify](./storage.md#interface-proventxreqnotify), [ProvenTxReqStatus](./client.md#type-proventxreqstatus), [ReqHistoryNote](./client.md#interface-reqhistorynote), [StorageProvider](./storage.md#class-storageprovider), [SyncMap](./storage.md#interface-syncmap), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TrxToken](./client.md#interface-trxtoken), [WalletStorageManager](./storage.md#class-walletstoragemanager)
2167
2864
 
2168
2865
  ###### Method addHistoryNote
2169
2866
 
@@ -2173,7 +2870,7 @@ Notes with identical property values to an existing note are ignored.
2173
2870
  ```ts
2174
2871
  addHistoryNote(note: ReqHistoryNote, noDupes?: boolean)
2175
2872
  ```
2176
- See also: [ReqHistoryNote](./client.md#type-reqhistorynote)
2873
+ See also: [ReqHistoryNote](./client.md#interface-reqhistorynote)
2177
2874
 
2178
2875
  Argument Details
2179
2876
 
@@ -2299,28 +2996,28 @@ export class EntitySyncState extends EntityBase<TableSyncState> {
2299
2996
  to storage: ${c.toStorageIdentityKey}
2300
2997
  for user: ${c.userIdentityKey}
2301
2998
  `;
2302
- if (c.user)
2999
+ if (c.user != null)
2303
3000
  log += ` USER activeStorage ${c.user.activeStorage}\n`;
2304
- if (!!c.provenTxs) {
2305
- log += ` PROVEN_TXS\n`;
3001
+ if (c.provenTxs != null) {
3002
+ log += " PROVEN_TXS\n";
2306
3003
  for (const r of c.provenTxs) {
2307
3004
  log += ` ${r.provenTxId} ${r.txid}\n`;
2308
3005
  }
2309
3006
  }
2310
- if (!!c.provenTxReqs) {
2311
- log += ` PROVEN_TX_REQS\n`;
3007
+ if (c.provenTxReqs != null) {
3008
+ log += " PROVEN_TX_REQS\n";
2312
3009
  for (const r of c.provenTxReqs) {
2313
3010
  log += ` ${r.provenTxReqId} ${r.txid} ${r.status} ${r.provenTxId || ""}\n`;
2314
3011
  }
2315
3012
  }
2316
- if (!!c.transactions) {
2317
- log += ` TRANSACTIONS\n`;
3013
+ if (c.transactions != null) {
3014
+ log += " TRANSACTIONS\n";
2318
3015
  for (const r of c.transactions) {
2319
3016
  log += ` ${r.transactionId} ${r.txid} ${r.status} ${r.provenTxId || ""} sats:${r.satoshis}\n`;
2320
3017
  }
2321
3018
  }
2322
- if (!!c.outputs) {
2323
- log += ` OUTPUTS\n`;
3019
+ if (c.outputs != null) {
3020
+ log += " OUTPUTS\n";
2324
3021
  for (const r of c.outputs) {
2325
3022
  log += ` ${r.outputId} ${r.txid}.${r.vout} ${r.transactionId} ${r.spendable ? "spendable" : ""} sats:${r.satoshis}\n`;
2326
3023
  }
@@ -2642,11 +3339,49 @@ the party making requests of the remote service.
2642
3339
  For details of the API implemented, follow the "See also" link for the `WalletStorageProvider` interface.
2643
3340
 
2644
3341
  ```ts
2645
- export class StorageClient implements WalletStorageProvider {
3342
+ export class StorageClient extends StorageClientBase {
3343
+ constructor(wallet: WalletInterface, endpointUrl: string)
3344
+ protected async rpcCall<T>(method: string, params: unknown[]): Promise<T>
3345
+ }
3346
+ ```
3347
+
3348
+ See also: [StorageClientBase](./storage.md#class-storageclientbase)
3349
+
3350
+ ###### Method rpcCall
3351
+
3352
+ Make a JSON-RPC call to the remote server.
3353
+
3354
+ ```ts
3355
+ protected async rpcCall<T>(method: string, params: unknown[]): Promise<T>
3356
+ ```
3357
+
3358
+ Argument Details
3359
+
3360
+ + **method**
3361
+ + The WalletStorage method name to call.
3362
+ + **params**
3363
+ + The array of parameters to pass to the method in order.
3364
+
3365
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
3366
+
3367
+ ---
3368
+ ##### Class: StorageClientBase
3369
+
3370
+ Abstract base class shared by `StorageClient` and `StorageMobile`.
3371
+
3372
+ Contains all `WalletStorageProvider` method implementations and entity-validation
3373
+ helpers. Subclasses only need to provide `rpcCall`, which differs between
3374
+ the full (logger-aware) and mobile (lightweight) variants.
3375
+
3376
+ ```ts
3377
+ export abstract class StorageClientBase implements WalletStorageProvider {
2646
3378
  readonly endpointUrl: string;
3379
+ protected readonly authClient: AuthFetch;
3380
+ protected nextId = 1;
2647
3381
  public settings?: TableSettings;
2648
3382
  constructor(wallet: WalletInterface, endpointUrl: string)
2649
3383
  isStorageProvider(): boolean
3384
+ protected abstract rpcCall<T>(method: string, params: unknown[]): Promise<T>;
2650
3385
  isAvailable(): boolean
2651
3386
  getSettings(): TableSettings
2652
3387
  async makeAvailable(): Promise<TableSettings>
@@ -2686,7 +3421,7 @@ export class StorageClient implements WalletStorageProvider {
2686
3421
  }
2687
3422
  ```
2688
3423
 
2689
- See also: [AuthId](./client.md#interface-authid), [EntityTimeStamp](./client.md#interface-entitytimestamp), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindProvenTxReqsArgs](./client.md#interface-findproventxreqsargs), [ProcessSyncChunkResult](./client.md#interface-processsyncchunkresult), [RequestSyncChunkArgs](./client.md#interface-requestsyncchunkargs), [StorageCreateActionResult](./client.md#interface-storagecreateactionresult), [StorageInternalizeActionResult](./client.md#interface-storageinternalizeactionresult), [StorageProcessActionArgs](./client.md#interface-storageprocessactionargs), [StorageProcessActionResults](./client.md#interface-storageprocessactionresults), [SyncChunk](./client.md#interface-syncchunk), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableUser](./storage.md#interface-tableuser), [UpdateProvenTxReqWithNewProvenTxArgs](./client.md#interface-updateproventxreqwithnewproventxargs), [UpdateProvenTxReqWithNewProvenTxResult](./client.md#interface-updateproventxreqwithnewproventxresult), [WalletServices](./client.md#interface-walletservices), [WalletStorageProvider](./client.md#interface-walletstorageprovider), [createAction](./storage.md#function-createaction), [getSyncChunk](./storage.md#function-getsyncchunk), [internalizeAction](./storage.md#function-internalizeaction), [listActions](./storage.md#function-listactions), [listCertificates](./storage.md#function-listcertificates), [listOutputs](./storage.md#function-listoutputs), [processAction](./storage.md#function-processaction)
3424
+ See also: [AuthId](./client.md#interface-authid), [EntityTimeStamp](./client.md#interface-entitytimestamp), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindProvenTxReqsArgs](./client.md#interface-findproventxreqsargs), [ProcessSyncChunkResult](./client.md#interface-processsyncchunkresult), [RequestSyncChunkArgs](./client.md#interface-requestsyncchunkargs), [StorageCreateActionResult](./client.md#interface-storagecreateactionresult), [StorageInternalizeActionResult](./client.md#interface-storageinternalizeactionresult), [StorageProcessActionArgs](./client.md#interface-storageprocessactionargs), [StorageProcessActionResults](./client.md#interface-storageprocessactionresults), [SyncChunk](./client.md#interface-syncchunk), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableUser](./storage.md#interface-tableuser), [UpdateProvenTxReqWithNewProvenTxArgs](./client.md#interface-updateproventxreqwithnewproventxargs), [UpdateProvenTxReqWithNewProvenTxResult](./client.md#interface-updateproventxreqwithnewproventxresult), [WalletServices](./client.md#interface-walletservices), [WalletStorageProvider](./client.md#interface-walletstorageprovider), [createAction](./storage.md#function-createaction), [getSyncChunk](./storage.md#function-getsyncchunk), [internalizeAction](./storage.md#function-internalizeaction), [listActions](./storage.md#function-listactions), [listCertificates](./storage.md#function-listcertificates), [listOutputs](./storage.md#function-listoutputs), [processAction](./storage.md#function-processaction), [validateDate](./storage.md#function-validatedate), [validateEntities](./storage.md#function-validateentities), [validateEntity](./storage.md#function-validateentity)
2690
3425
 
2691
3426
  ###### Method abortAction
2692
3427
 
@@ -3176,6 +3911,22 @@ This must match the `AuthFetch` identity securing the remote conneciton.
3176
3911
  + **args**
3177
3912
  + original wallet `relinquishOutput` args.
3178
3913
 
3914
+ ###### Method rpcCall
3915
+
3916
+ Make a JSON-RPC call to the remote server.
3917
+ Implemented differently by each subclass (with or without logger support).
3918
+
3919
+ ```ts
3920
+ protected abstract rpcCall<T>(method: string, params: unknown[]): Promise<T>
3921
+ ```
3922
+
3923
+ Argument Details
3924
+
3925
+ + **method**
3926
+ + The WalletStorage method name to call.
3927
+ + **params**
3928
+ + The array of parameters to pass to the method in order.
3929
+
3179
3930
  ###### Method setActive
3180
3931
 
3181
3932
  Ensures up-to-date wallet data replication to all configured backup storage providers,
@@ -3316,7 +4067,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
3316
4067
  async insertTxLabelMap(labelMap: TableTxLabelMap, trx?: TrxToken): Promise<void>
3317
4068
  async insertUser(user: TableUser, trx?: TrxToken): Promise<number>
3318
4069
  async updateIdb<T>(id: number | number[], update: Partial<T>, keyProp: string, storeName: string, trx?: TrxToken): Promise<number>
3319
- async updateIdbKey<T>(key: (number | string)[], update: Partial<T>, keyProps: string[], storeName: string, trx?: TrxToken): Promise<number>
4070
+ async updateIdbKey<T>(key: Array<number | string>, update: Partial<T>, keyProps: string[], storeName: string, trx?: TrxToken): Promise<number>
3320
4071
  async updateCertificate(id: number, update: Partial<TableCertificate>, trx?: TrxToken): Promise<number>
3321
4072
  async updateCertificateField(certificateId: number, fieldName: string, update: Partial<TableCertificateField>, trx?: TrxToken): Promise<number>
3322
4073
  async updateCommission(id: number, update: Partial<TableCommission>, trx?: TrxToken): Promise<number>
@@ -3398,7 +4149,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
3398
4149
  }
3399
4150
  ```
3400
4151
 
3401
- See also: [AuthId](./client.md#interface-authid), [DBType](./storage.md#type-dbtype), [EntityTimeStamp](./client.md#interface-entitytimestamp), [FindCertificateFieldsArgs](./client.md#interface-findcertificatefieldsargs), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindCommissionsArgs](./client.md#interface-findcommissionsargs), [FindForUserSincePagedArgs](./client.md#interface-findforusersincepagedargs), [FindMonitorEventsArgs](./client.md#interface-findmonitoreventsargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputTagMapsArgs](./client.md#interface-findoutputtagmapsargs), [FindOutputTagsArgs](./client.md#interface-findoutputtagsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindProvenTxReqsArgs](./client.md#interface-findproventxreqsargs), [FindProvenTxsArgs](./client.md#interface-findproventxsargs), [FindSyncStatesArgs](./client.md#interface-findsyncstatesargs), [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [FindTxLabelMapsArgs](./client.md#interface-findtxlabelmapsargs), [FindTxLabelsArgs](./client.md#interface-findtxlabelsargs), [FindUsersArgs](./client.md#interface-findusersargs), [ProvenOrRawTx](./client.md#interface-provenorrawtx), [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [StorageAdminStats](./storage.md#interface-storageadminstats), [StorageIdbOptions](./storage.md#interface-storageidboptions), [StorageIdbSchema](./storage.md#interface-storageidbschema), [StorageProvider](./storage.md#class-storageprovider), [TableCertificate](./storage.md#interface-tablecertificate), [TableCertificateField](./storage.md#interface-tablecertificatefield), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableCommission](./storage.md#interface-tablecommission), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputTagMap](./storage.md#interface-tableoutputtagmap), [TableProvenTx](./storage.md#interface-tableproventx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableTransaction](./storage.md#interface-tabletransaction), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TrxToken](./client.md#interface-trxtoken), [WalletStorageProvider](./client.md#interface-walletstorageprovider), [listActions](./storage.md#function-listactions), [listOutputs](./storage.md#function-listoutputs), [purgeData](./storage.md#function-purgedata), [reviewStatus](./storage.md#function-reviewstatus)
4152
+ See also: [AuthId](./client.md#interface-authid), [DBType](./storage.md#type-dbtype), [EntityTimeStamp](./client.md#interface-entitytimestamp), [FindCertificateFieldsArgs](./client.md#interface-findcertificatefieldsargs), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindCommissionsArgs](./client.md#interface-findcommissionsargs), [FindForUserSincePagedArgs](./client.md#interface-findforusersincepagedargs), [FindMonitorEventsArgs](./client.md#interface-findmonitoreventsargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputTagMapsArgs](./client.md#interface-findoutputtagmapsargs), [FindOutputTagsArgs](./client.md#interface-findoutputtagsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindProvenTxReqsArgs](./client.md#interface-findproventxreqsargs), [FindProvenTxsArgs](./client.md#interface-findproventxsargs), [FindSyncStatesArgs](./client.md#interface-findsyncstatesargs), [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [FindTxLabelMapsArgs](./client.md#interface-findtxlabelmapsargs), [FindTxLabelsArgs](./client.md#interface-findtxlabelsargs), [FindUsersArgs](./client.md#interface-findusersargs), [ProvenOrRawTx](./client.md#interface-provenorrawtx), [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [StorageAdminStats](./storage.md#interface-storageadminstats), [StorageIdbOptions](./storage.md#interface-storageidboptions), [StorageIdbSchema](./storage.md#interface-storageidbschema), [StorageProvider](./storage.md#class-storageprovider), [TableCertificate](./storage.md#interface-tablecertificate), [TableCertificateField](./storage.md#interface-tablecertificatefield), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableCommission](./storage.md#interface-tablecommission), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputTagMap](./storage.md#interface-tableoutputtagmap), [TableProvenTx](./storage.md#interface-tableproventx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableTransaction](./storage.md#interface-tabletransaction), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TrxToken](./client.md#interface-trxtoken), [WalletStorageProvider](./client.md#interface-walletstorageprovider), [listActions](./storage.md#function-listactions), [listOutputs](./storage.md#function-listoutputs), [purgeData](./storage.md#function-purgedata), [reviewStatus](./storage.md#function-reviewstatus), [validateEntities](./storage.md#function-validateentities), [validateEntity](./storage.md#function-validateentity)
3402
4153
 
3403
4154
  ###### Method allocateChangeInput
3404
4155
 
@@ -3521,6 +4272,12 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
3521
4272
  export class StorageKnex extends StorageProvider implements WalletStorageProvider {
3522
4273
  knex: Knex;
3523
4274
  constructor(options: StorageKnexOptions)
4275
+ override getTransactionService(): TransactionService | undefined
4276
+ override async makeAvailable(): Promise<TableSettings>
4277
+ async provenTxsTableName(): Promise<string>
4278
+ async provenTxReqsTableName(): Promise<string>
4279
+ override async insertLegacyTransaction(tx: TableTransaction, trx?: TrxToken): Promise<number>
4280
+ override async insertLegacyTxLabelMap(labelMap: TableTxLabelMap, trx?: TrxToken): Promise<void>
3524
4281
  async readSettings(): Promise<TableSettings>
3525
4282
  override async getProvenOrRawTx(txid: string, trx?: TrxToken): Promise<ProvenOrRawTx>
3526
4283
  dbTypeSubstring(source: string, fromOffset: number, forLength?: number)
@@ -3574,9 +4331,9 @@ export class StorageKnex extends StorageProvider implements WalletStorageProvide
3574
4331
  findOutputsQuery(args: FindOutputsArgs, count?: boolean): Knex.QueryBuilder
3575
4332
  findOutputTagMapsQuery(args: FindOutputTagMapsArgs): Knex.QueryBuilder
3576
4333
  findOutputTagsQuery(args: FindOutputTagsArgs): Knex.QueryBuilder
3577
- findProvenTxReqsQuery(args: FindProvenTxReqsArgs): Knex.QueryBuilder
3578
- findProvenTxsQuery(args: FindProvenTxsArgs): Knex.QueryBuilder
3579
- findStaleMerkleRootsQuery(args: FindStaleMerkleRootsArgs): Knex.QueryBuilder
4334
+ findProvenTxReqsQuery(args: FindProvenTxReqsArgs, tableName = "proven_tx_reqs"): Knex.QueryBuilder
4335
+ findProvenTxsQuery(args: FindProvenTxsArgs, tableName = "proven_txs"): Knex.QueryBuilder
4336
+ findStaleMerkleRootsQuery(args: FindStaleMerkleRootsArgs, tableName = "proven_txs"): Knex.QueryBuilder
3580
4337
  findSyncStatesQuery(args: FindSyncStatesArgs): Knex.QueryBuilder
3581
4338
  findTransactionsQuery(args: FindTransactionsArgs, count?: boolean): Knex.QueryBuilder
3582
4339
  findTxLabelMapsQuery(args: FindTxLabelMapsArgs): Knex.QueryBuilder
@@ -3598,6 +4355,11 @@ export class StorageKnex extends StorageProvider implements WalletStorageProvide
3598
4355
  override async findStaleMerkleRoots(args: FindStaleMerkleRootsArgs): Promise<string[]>
3599
4356
  override async findSyncStates(args: FindSyncStatesArgs): Promise<TableSyncState[]>
3600
4357
  override async findTransactions(args: FindTransactionsArgs): Promise<TableTransaction[]>
4358
+ override async findLegacyTransactions(args: FindTransactionsArgs): Promise<TableTransaction[]>
4359
+ override async updateLegacyTransaction(id: number | number[], update: Partial<TableTransaction>, trx?: TrxToken): Promise<number>
4360
+ override async markOutputAsSpentBy(outputId: number, update: Partial<TableOutput>, trx?: TrxToken): Promise<void>
4361
+ override async disableForeignKeys(): Promise<void>
4362
+ override async enableForeignKeys(): Promise<void>
3601
4363
  override async findTxLabelMaps(args: FindTxLabelMapsArgs): Promise<TableTxLabelMap[]>
3602
4364
  override async findTxLabels(args: FindTxLabelsArgs): Promise<TableTxLabel[]>
3603
4365
  override async findUsers(args: FindUsersArgs): Promise<TableUser[]>
@@ -3625,7 +4387,7 @@ export class StorageKnex extends StorageProvider implements WalletStorageProvide
3625
4387
  override async transaction<T>(scope: (trx: TrxToken) => Promise<T>, trx?: TrxToken): Promise<T>
3626
4388
  toDb(trx?: TrxToken)
3627
4389
  async validateRawTransaction(t: TableTransaction, trx?: TrxToken): Promise<void>
3628
- _verifiedReadyForDatabaseAccess: boolean = false;
4390
+ _verifiedReadyForDatabaseAccess = false;
3629
4391
  async verifyReadyForDatabaseAccess(trx?: TrxToken): Promise<DBType>
3630
4392
  validatePartialForUpdate<T extends EntityTimeStamp>(update: Partial<T>, dateFields?: string[], booleanFields?: string[]): Partial<T>
3631
4393
  async validateEntityForInsert<T extends EntityTimeStamp>(entity: T, trx?: TrxToken, dateFields?: string[], booleanFields?: string[]): Promise<any>
@@ -3658,7 +4420,7 @@ export class StorageKnex extends StorageProvider implements WalletStorageProvide
3658
4420
  orderDescending: true,
3659
4421
  paged: { limit: 1 }
3660
4422
  }));
3661
- const monitorStats: ServicesCallHistory | undefined = monitorEvent ? JSON.parse(monitorEvent.details!) : undefined;
4423
+ const monitorStats: ServicesCallHistory | undefined = (monitorEvent != null) ? JSON.parse(monitorEvent.details!) : undefined;
3662
4424
  const servicesStats = this.getServices().getServicesCallHistory(true);
3663
4425
  const one_day_ago = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
3664
4426
  const one_week_ago = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
@@ -3713,14 +4475,14 @@ select
3713
4475
  (select count(*) from transactions where status = 'unfail' and created_at > '${one_week_ago}') as txUnfailWeek,
3714
4476
  (select count(*) from transactions where status = 'unfail' and created_at > '${one_month_ago}') as txUnfailMonth,
3715
4477
  (select count(*) from transactions where status = 'unfail') as txUnfailTotal,
3716
- (select sum(satoshis) from outputs where spendable = 1 and \`change\` = 1 and created_at > '${one_day_ago}') as satoshisDefaultDay,
3717
- (select sum(satoshis) from outputs where spendable = 1 and \`change\` = 1 and created_at > '${one_week_ago}') as satoshisDefaultWeek,
3718
- (select sum(satoshis) from outputs where spendable = 1 and \`change\` = 1 and created_at > '${one_month_ago}') as satoshisDefaultMonth,
3719
- (select sum(satoshis) from outputs where spendable = 1 and \`change\` = 1) as satoshisDefaultTotal,
3720
- (select sum(satoshis) from outputs where spendable = 1 and \`change\` = 0 and not basketId is null and created_at > '${one_day_ago}') as satoshisOtherDay,
3721
- (select sum(satoshis) from outputs where spendable = 1 and \`change\` = 0 and not basketId is null and created_at > '${one_week_ago}') as satoshisOtherWeek,
3722
- (select sum(satoshis) from outputs where spendable = 1 and \`change\` = 0 and not basketId is null and created_at > '${one_month_ago}') as satoshisOtherMonth,
3723
- (select sum(satoshis) from outputs where spendable = 1 and \`change\` = 0 and not basketId is null) as satoshisOtherTotal,
4478
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${one_day_ago}') as satoshisDefaultDay,
4479
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${one_week_ago}') as satoshisDefaultWeek,
4480
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${one_month_ago}') as satoshisDefaultMonth,
4481
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1) as satoshisDefaultTotal,
4482
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${one_day_ago}') as satoshisOtherDay,
4483
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${one_week_ago}') as satoshisOtherWeek,
4484
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${one_month_ago}') as satoshisOtherMonth,
4485
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null) as satoshisOtherTotal,
3724
4486
  (select count(*) from output_baskets where created_at > '${one_day_ago}') as basketsDay,
3725
4487
  (select count(*) from output_baskets where created_at > '${one_week_ago}') as basketsWeek,
3726
4488
  (select count(*) from output_baskets where created_at > '${one_month_ago}') as basketsMonth,
@@ -3813,7 +4575,7 @@ select
3813
4575
  }
3814
4576
  ```
3815
4577
 
3816
- See also: [AdminStatsResult](./storage.md#interface-adminstatsresult), [AuthId](./client.md#interface-authid), [DBType](./storage.md#type-dbtype), [EntityTimeStamp](./client.md#interface-entitytimestamp), [FindCertificateFieldsArgs](./client.md#interface-findcertificatefieldsargs), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindCommissionsArgs](./client.md#interface-findcommissionsargs), [FindForUserSincePagedArgs](./client.md#interface-findforusersincepagedargs), [FindMonitorEventsArgs](./client.md#interface-findmonitoreventsargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputTagMapsArgs](./client.md#interface-findoutputtagmapsargs), [FindOutputTagsArgs](./client.md#interface-findoutputtagsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindPartialSincePagedArgs](./client.md#interface-findpartialsincepagedargs), [FindProvenTxReqsArgs](./client.md#interface-findproventxreqsargs), [FindProvenTxsArgs](./client.md#interface-findproventxsargs), [FindStaleMerkleRootsArgs](./client.md#interface-findstalemerklerootsargs), [FindSyncStatesArgs](./client.md#interface-findsyncstatesargs), [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [FindTxLabelMapsArgs](./client.md#interface-findtxlabelmapsargs), [FindTxLabelsArgs](./client.md#interface-findtxlabelsargs), [FindUsersArgs](./client.md#interface-findusersargs), [ProvenOrRawTx](./client.md#interface-provenorrawtx), [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [ServicesCallHistory](./client.md#type-servicescallhistory), [StorageKnexOptions](./storage.md#interface-storageknexoptions), [StorageProvider](./storage.md#class-storageprovider), [TableCertificate](./storage.md#interface-tablecertificate), [TableCertificateField](./storage.md#interface-tablecertificatefield), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableCommission](./storage.md#interface-tablecommission), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputTagMap](./storage.md#interface-tableoutputtagmap), [TableProvenTx](./storage.md#interface-tableproventx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableTransaction](./storage.md#interface-tabletransaction), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TrxToken](./client.md#interface-trxtoken), [WERR_NOT_IMPLEMENTED](./client.md#class-werr_not_implemented), [WalletStorageProvider](./client.md#interface-walletstorageprovider), [listActions](./storage.md#function-listactions), [listOutputs](./storage.md#function-listoutputs), [purgeData](./storage.md#function-purgedata), [reviewStatus](./storage.md#function-reviewstatus), [verifyOneOrNone](./client.md#function-verifyoneornone)
4578
+ See also: [AdminStatsResult](./storage.md#interface-adminstatsresult), [AuthId](./client.md#interface-authid), [DBType](./storage.md#type-dbtype), [EntityTimeStamp](./client.md#interface-entitytimestamp), [FindCertificateFieldsArgs](./client.md#interface-findcertificatefieldsargs), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindCommissionsArgs](./client.md#interface-findcommissionsargs), [FindForUserSincePagedArgs](./client.md#interface-findforusersincepagedargs), [FindMonitorEventsArgs](./client.md#interface-findmonitoreventsargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputTagMapsArgs](./client.md#interface-findoutputtagmapsargs), [FindOutputTagsArgs](./client.md#interface-findoutputtagsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindPartialSincePagedArgs](./client.md#interface-findpartialsincepagedargs), [FindProvenTxReqsArgs](./client.md#interface-findproventxreqsargs), [FindProvenTxsArgs](./client.md#interface-findproventxsargs), [FindStaleMerkleRootsArgs](./client.md#interface-findstalemerklerootsargs), [FindSyncStatesArgs](./client.md#interface-findsyncstatesargs), [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [FindTxLabelMapsArgs](./client.md#interface-findtxlabelmapsargs), [FindTxLabelsArgs](./client.md#interface-findtxlabelsargs), [FindUsersArgs](./client.md#interface-findusersargs), [ProvenOrRawTx](./client.md#interface-provenorrawtx), [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [ServicesCallHistory](./client.md#interface-servicescallhistory), [StorageKnexOptions](./storage.md#interface-storageknexoptions), [StorageProvider](./storage.md#class-storageprovider), [TableCertificate](./storage.md#interface-tablecertificate), [TableCertificateField](./storage.md#interface-tablecertificatefield), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableCommission](./storage.md#interface-tablecommission), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputTagMap](./storage.md#interface-tableoutputtagmap), [TableProvenTx](./storage.md#interface-tableproventx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableTransaction](./storage.md#interface-tabletransaction), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TransactionService](./storage.md#class-transactionservice), [TrxToken](./client.md#interface-trxtoken), [WERR_NOT_IMPLEMENTED](./client.md#class-werr_not_implemented), [WalletStorageProvider](./client.md#interface-walletstorageprovider), [listActions](./storage.md#function-listactions), [listOutputs](./storage.md#function-listoutputs), [purgeData](./storage.md#function-purgedata), [reviewStatus](./storage.md#function-reviewstatus), [validateEntities](./storage.md#function-validateentities), [validateEntity](./storage.md#function-validateentity), [verifyOneOrNone](./client.md#function-verifyoneornone)
3817
4579
 
3818
4580
  ###### Method allocateChangeInput
3819
4581
 
@@ -3838,6 +4600,141 @@ AND whose transaction status is one of:
3838
4600
  async countChangeInputs(userId: number, basketId: number, excludeSending: boolean): Promise<number>
3839
4601
  ```
3840
4602
 
4603
+ ###### Method disableForeignKeys
4604
+
4605
+ Post-cutover SQLite: disable FK on the bare connection BEFORE opening a
4606
+ transaction. PRAGMA foreign_keys changes inside SQLite transactions are no-ops,
4607
+ so this MUST be called before `this.knex.transaction()`.
4608
+
4609
+ Only acts when post-cutover AND SQLite. Pre-cutover or MySQL: no-op.
4610
+
4611
+ ```ts
4612
+ override async disableForeignKeys(): Promise<void>
4613
+ ```
4614
+
4615
+ ###### Method enableForeignKeys
4616
+
4617
+ Re-enable FK after the transaction opened via `disableForeignKeys()` completes.
4618
+ Only acts when post-cutover AND SQLite.
4619
+
4620
+ ```ts
4621
+ override async enableForeignKeys(): Promise<void>
4622
+ ```
4623
+
4624
+ ###### Method findLegacyTransactions
4625
+
4626
+ Post-cutover: queries `transactions_legacy` for unsigned/pending rows
4627
+ created by `createAction` (which have no real txid yet and therefore have no
4628
+ new-schema counterpart). Falls back to the standard `findTransactions` pre-cutover.
4629
+
4630
+ Used by `processAction.validateCommitNewTxToStorageArgs` to locate the
4631
+ unsigned transaction row by `{userId, reference}`.
4632
+
4633
+ Mapping §2: legacy `unsigned` / `unprocessed` → these rows only exist in
4634
+ `transactions_legacy` post-cutover; new `transactions` has `processing` not
4635
+ `status` and no unsigned-state rows.
4636
+
4637
+ ```ts
4638
+ override async findLegacyTransactions(args: FindTransactionsArgs): Promise<TableTransaction[]>
4639
+ ```
4640
+ See also: [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [TableTransaction](./storage.md#interface-tabletransaction)
4641
+
4642
+ ###### Method insertLegacyTransaction
4643
+
4644
+ Insert a legacy-shaped transaction row into the correct table:
4645
+ - Post-cutover: `transactions_legacy` (the renamed legacy schema table)
4646
+ - Pre-cutover: `transactions` (the standard table, same behaviour as `insertTransaction`)
4647
+
4648
+ This allows `createAction` to store unsigned rows (txid unknown) without
4649
+ conflicting with the new `transactions` table's NOT NULL txid constraint.
4650
+ A new `transactions` row + `actions` row are created later by `processAction`
4651
+ once the real txid is known.
4652
+
4653
+ On SQLite, foreign key enforcement is temporarily disabled while inserting
4654
+ into `transactions_legacy` because the referenced `proven_txs` table was
4655
+ renamed to `proven_txs_legacy` during the the schema cutover. Since `provenTxId`
4656
+ is always NULL for new unsigned transactions this is semantically safe.
4657
+
4658
+ ```ts
4659
+ override async insertLegacyTransaction(tx: TableTransaction, trx?: TrxToken): Promise<number>
4660
+ ```
4661
+ See also: [TableTransaction](./storage.md#interface-tabletransaction), [TrxToken](./client.md#interface-trxtoken)
4662
+
4663
+ ###### Method insertLegacyTxLabelMap
4664
+
4665
+ Insert a `tx_labels_map` row for a legacy transaction that does not yet
4666
+ have a `actions.actionId`. On post-cutover SQLite, temporarily disables
4667
+ FK checks so that the legacy transactionId (which is not yet an actionId)
4668
+ can be written. processAction will repoint it via repointLabelsToActionId.
4669
+
4670
+ Note: bypasses `validateEntityForInsert` (and therefore `verifyReadyForDatabaseAccess`
4671
+ which would re-enable FK checks) to ensure the PRAGMA=OFF persists across
4672
+ the insert statement.
4673
+
4674
+ ```ts
4675
+ override async insertLegacyTxLabelMap(labelMap: TableTxLabelMap, trx?: TrxToken): Promise<void>
4676
+ ```
4677
+ See also: [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TrxToken](./client.md#interface-trxtoken)
4678
+
4679
+ ###### Method makeAvailable
4680
+
4681
+ Eagerly warm the `_postCutoverCache` so sync query builders such as
4682
+ `findOutputsQuery` can branch on cutover state without an extra await.
4683
+ Callers that have invoked `makeAvailable` are guaranteed the cache has
4684
+ been populated.
4685
+
4686
+ ```ts
4687
+ override async makeAvailable(): Promise<TableSettings>
4688
+ ```
4689
+ See also: [TableSettings](./storage.md#interface-tablesettings)
4690
+
4691
+ ###### Method markOutputAsSpentBy
4692
+
4693
+ Post-cutover SQLite: temporarily disable FK enforcement around the
4694
+ `outputs.spentBy = legacyTransactionId` UPDATE. The `outputs.spentBy` FK
4695
+ references `transactions.transactionId` after cutover, but unsigned
4696
+ transactions from `createAction` live in `transactions_legacy` (their new-schema
4697
+ counterpart is created later by `processAction`).
4698
+
4699
+ IMPORTANT: We bypass `updateOutput` (and therefore `verifyReadyForDatabaseAccess`)
4700
+ because `verifyReadyForDatabaseAccess` always re-enables FK with
4701
+ `PRAGMA foreign_keys = ON`, which would undo our bypass. Instead we
4702
+ directly run the UPDATE via the raw knex handle.
4703
+
4704
+ Pre-cutover or MySQL: delegates to `updateOutput` unchanged.
4705
+
4706
+ Mapping §2: bridge-period spentBy references transactions_legacy during
4707
+ createAction; FK bypass covers this until processAction wires the new-schema.
4708
+
4709
+ ```ts
4710
+ override async markOutputAsSpentBy(outputId: number, update: Partial<TableOutput>, trx?: TrxToken): Promise<void>
4711
+ ```
4712
+ See also: [TableOutput](./storage.md#interface-tableoutput), [TrxToken](./client.md#interface-trxtoken)
4713
+
4714
+ ###### Method provenTxReqsTableName
4715
+
4716
+ Returns the canonical name of the `proven_tx_reqs` table —
4717
+ `proven_tx_reqs_legacy` post-cutover, `proven_tx_reqs` otherwise.
4718
+
4719
+ Public so that helper modules (reviewStatus, purgeData) can resolve the
4720
+ correct table name without duplicating the post-cutover detection logic.
4721
+
4722
+ ```ts
4723
+ async provenTxReqsTableName(): Promise<string>
4724
+ ```
4725
+
4726
+ ###### Method provenTxsTableName
4727
+
4728
+ Returns the canonical name of the `proven_txs` table — `proven_txs_legacy`
4729
+ post-cutover, `proven_txs` otherwise.
4730
+
4731
+ Public so that helper modules (reviewStatus, purgeData) can resolve the
4732
+ correct table name without duplicating the post-cutover detection logic.
4733
+
4734
+ ```ts
4735
+ async provenTxsTableName(): Promise<string>
4736
+ ```
4737
+
3841
4738
  ###### Method toDb
3842
4739
 
3843
4740
  Convert the standard optional `TrxToken` parameter into either a direct knex database instance,
@@ -3848,6 +4745,22 @@ toDb(trx?: TrxToken)
3848
4745
  ```
3849
4746
  See also: [TrxToken](./client.md#interface-trxtoken)
3850
4747
 
4748
+ ###### Method updateLegacyTransaction
4749
+
4750
+ Post-cutover: updates `transactions_legacy` (where unsigned rows live).
4751
+ Pre-cutover: delegates to `updateTransaction`.
4752
+
4753
+ Used by `processAction.commitNewTxToStorage` to write back the real txid
4754
+ and status to the legacy row that was created by `createAction`.
4755
+
4756
+ Mapping §2: legacy `unsigned` → `unprocessed` transition and txid write-back
4757
+ must go to `transactions_legacy` post-cutover, not new `transactions`.
4758
+
4759
+ ```ts
4760
+ override async updateLegacyTransaction(id: number | number[], update: Partial<TableTransaction>, trx?: TrxToken): Promise<number>
4761
+ ```
4762
+ See also: [TableTransaction](./storage.md#interface-tabletransaction), [TrxToken](./client.md#interface-trxtoken)
4763
+
3851
4764
  ###### Method validateEntities
3852
4765
 
3853
4766
  Helper to force uniform behavior across database engines.
@@ -3953,6 +4866,15 @@ export abstract class StorageProvider extends StorageReaderWriter implements Wal
3953
4866
  override isStorageProvider(): boolean
3954
4867
  setServices(v: WalletServices)
3955
4868
  getServices(): WalletServices
4869
+ getTransactionService(): TransactionService | undefined
4870
+ async insertLegacyTransaction(tx: TableTransaction, trx?: TrxToken): Promise<number>
4871
+ async insertLegacyTxLabelMap(labelMap: TableTxLabelMap, trx?: TrxToken): Promise<void>
4872
+ async findOrInsertLegacyTxLabelMap(transactionId: number, txLabelId: number, trx?: TrxToken): Promise<TableTxLabelMap>
4873
+ async findLegacyTransactions(args: FindTransactionsArgs): Promise<TableTransaction[]>
4874
+ async updateLegacyTransaction(id: number | number[], update: Partial<TableTransaction>, trx?: TrxToken): Promise<number>
4875
+ async markOutputAsSpentBy(outputId: number, update: Partial<TableOutput>, trx?: TrxToken): Promise<void>
4876
+ async disableForeignKeys(): Promise<void>
4877
+ async enableForeignKeys(): Promise<void>
3956
4878
  async abortAction(auth: AuthId, args: AbortActionArgs): Promise<AbortActionResult>
3957
4879
  async internalizeAction(auth: AuthId, args: InternalizeActionArgs): Promise<StorageInternalizeActionResult>
3958
4880
  async getReqsAndBeefToShareWithWorld(txids: string[], knownTxids: string[], trx?: TrxToken): Promise<GetReqsAndBeefResult>
@@ -3982,7 +4904,7 @@ export abstract class StorageProvider extends StorageReaderWriter implements Wal
3982
4904
  }
3983
4905
  ```
3984
4906
 
3985
- See also: [AdminStatsResult](./storage.md#interface-adminstatsresult), [AuthId](./client.md#interface-authid), [Chain](./client.md#type-chain), [EntityProvenTxReq](./storage.md#class-entityproventxreq), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindStaleMerkleRootsArgs](./client.md#interface-findstalemerklerootsargs), [GetReqsAndBeefResult](./storage.md#interface-getreqsandbeefresult), [PostReqsToNetworkResult](./storage.md#interface-postreqstonetworkresult), [ProcessSyncChunkResult](./client.md#interface-processsyncchunkresult), [ProvenOrRawTx](./client.md#interface-provenorrawtx), [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [RequestSyncChunkArgs](./client.md#interface-requestsyncchunkargs), [StorageCreateActionResult](./client.md#interface-storagecreateactionresult), [StorageFeeModel](./client.md#interface-storagefeemodel), [StorageGetBeefOptions](./client.md#interface-storagegetbeefoptions), [StorageInternalizeActionResult](./client.md#interface-storageinternalizeactionresult), [StorageProcessActionArgs](./client.md#interface-storageprocessactionargs), [StorageProcessActionResults](./client.md#interface-storageprocessactionresults), [StorageProvenOrReq](./client.md#interface-storageprovenorreq), [StorageProviderOptions](./storage.md#interface-storageprovideroptions), [StorageReaderWriter](./storage.md#class-storagereaderwriter), [SyncChunk](./client.md#interface-syncchunk), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputX](./storage.md#interface-tableoutputx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableProvenTxReqDynamics](./storage.md#interface-tableproventxreqdynamics), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableUser](./storage.md#interface-tableuser), [TransactionStatus](./client.md#type-transactionstatus), [TrxToken](./client.md#interface-trxtoken), [UpdateProvenTxReqWithNewProvenTxArgs](./client.md#interface-updateproventxreqwithnewproventxargs), [UpdateProvenTxReqWithNewProvenTxResult](./client.md#interface-updateproventxreqwithnewproventxresult), [WalletServices](./client.md#interface-walletservices), [WalletStorageProvider](./client.md#interface-walletstorageprovider), [attemptToPostReqsToNetwork](./storage.md#function-attempttopostreqstonetwork), [createAction](./storage.md#function-createaction), [getBeefForTransaction](./storage.md#function-getbeeffortransaction), [internalizeAction](./storage.md#function-internalizeaction), [listActions](./storage.md#function-listactions), [listCertificates](./storage.md#function-listcertificates), [listOutputs](./storage.md#function-listoutputs), [logger](./client.md#variable-logger), [processAction](./storage.md#function-processaction), [purgeData](./storage.md#function-purgedata), [reviewStatus](./storage.md#function-reviewstatus)
4907
+ See also: [AdminStatsResult](./storage.md#interface-adminstatsresult), [AuthId](./client.md#interface-authid), [Chain](./client.md#type-chain), [EntityProvenTxReq](./storage.md#class-entityproventxreq), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindStaleMerkleRootsArgs](./client.md#interface-findstalemerklerootsargs), [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [GetReqsAndBeefResult](./storage.md#interface-getreqsandbeefresult), [PostReqsToNetworkResult](./storage.md#interface-postreqstonetworkresult), [ProcessSyncChunkResult](./client.md#interface-processsyncchunkresult), [ProvenOrRawTx](./client.md#interface-provenorrawtx), [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [RequestSyncChunkArgs](./client.md#interface-requestsyncchunkargs), [StorageCreateActionResult](./client.md#interface-storagecreateactionresult), [StorageFeeModel](./client.md#interface-storagefeemodel), [StorageGetBeefOptions](./client.md#interface-storagegetbeefoptions), [StorageInternalizeActionResult](./client.md#interface-storageinternalizeactionresult), [StorageProcessActionArgs](./client.md#interface-storageprocessactionargs), [StorageProcessActionResults](./client.md#interface-storageprocessactionresults), [StorageProvenOrReq](./client.md#interface-storageprovenorreq), [StorageProviderOptions](./storage.md#interface-storageprovideroptions), [StorageReaderWriter](./storage.md#class-storagereaderwriter), [SyncChunk](./client.md#interface-syncchunk), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputX](./storage.md#interface-tableoutputx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableProvenTxReqDynamics](./storage.md#interface-tableproventxreqdynamics), [TableTransaction](./storage.md#interface-tabletransaction), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TransactionService](./storage.md#class-transactionservice), [TransactionStatus](./client.md#type-transactionstatus), [TrxToken](./client.md#interface-trxtoken), [UpdateProvenTxReqWithNewProvenTxArgs](./client.md#interface-updateproventxreqwithnewproventxargs), [UpdateProvenTxReqWithNewProvenTxResult](./client.md#interface-updateproventxreqwithnewproventxresult), [WalletServices](./client.md#interface-walletservices), [WalletStorageProvider](./client.md#interface-walletstorageprovider), [attemptToPostReqsToNetwork](./storage.md#function-attempttopostreqstonetwork), [createAction](./storage.md#function-createaction), [getBeefForTransaction](./storage.md#function-getbeeffortransaction), [internalizeAction](./storage.md#function-internalizeaction), [listActions](./storage.md#function-listactions), [listCertificates](./storage.md#function-listcertificates), [listOutputs](./storage.md#function-listoutputs), [logger](./client.md#variable-logger), [processAction](./storage.md#function-processaction), [purgeData](./storage.md#function-purgedata), [reviewStatus](./storage.md#function-reviewstatus)
3986
4908
 
3987
4909
  ###### Method confirmSpendableOutputs
3988
4910
 
@@ -4001,44 +4923,182 @@ Returns
4001
4923
 
4002
4924
  object with invalidSpendableOutputs array. A good result is an empty array.
4003
4925
 
4004
- ###### Method getProvenOrReq
4926
+ ###### Method disableForeignKeys
4005
4927
 
4006
- Checks if txid is a known valid ProvenTx and returns it if found.
4007
- Next checks if txid is a current ProvenTxReq and returns that if found.
4008
- If `newReq` is provided and an existing ProvenTxReq isn't found,
4009
- use `newReq` to create a new ProvenTxReq.
4928
+ Disable FK enforcement on the underlying database connection.
4010
4929
 
4011
- This is safe "findOrInsert" operation using retry if unique index constraint
4012
- is violated by a race condition insert.
4930
+ No-op on non-SQLite or pre-cutover databases. On post-cutover SQLite,
4931
+ `StorageKnex` overrides this to run `PRAGMA foreign_keys = OFF` on the
4932
+ bare knex connection BEFORE a transaction is opened (since PRAGMA changes
4933
+ inside SQLite transactions are silently ignored).
4934
+
4935
+ Must be paired with a `enableForeignKeys()` call in a finally block.
4013
4936
 
4014
4937
  ```ts
4015
- async getProvenOrReq(txid: string, newReq?: TableProvenTxReq, trx?: TrxToken): Promise<StorageProvenOrReq>
4938
+ async disableForeignKeys(): Promise<void>
4016
4939
  ```
4017
- See also: [StorageProvenOrReq](./client.md#interface-storageprovenorreq), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TrxToken](./client.md#interface-trxtoken)
4018
4940
 
4019
- ###### Method getReqsAndBeefToShareWithWorld
4941
+ ###### Method enableForeignKeys
4020
4942
 
4021
- Given an array of transaction txids with current ProvenTxReq ready-to-share status,
4022
- lookup their ProvenTxReqApi req records.
4023
- For the txids with reqs and status still ready to send construct a single merged beef.
4943
+ Re-enable FK enforcement on the underlying database connection.
4944
+ Counterpart to `disableForeignKeys()`.
4024
4945
 
4025
4946
  ```ts
4026
- async getReqsAndBeefToShareWithWorld(txids: string[], knownTxids: string[], trx?: TrxToken): Promise<GetReqsAndBeefResult>
4947
+ async enableForeignKeys(): Promise<void>
4027
4948
  ```
4028
- See also: [GetReqsAndBeefResult](./storage.md#interface-getreqsandbeefresult), [TrxToken](./client.md#interface-trxtoken)
4029
4949
 
4030
- ###### Method getValidBeefForKnownTxid
4950
+ ###### Method findLegacyTransactions
4031
4951
 
4032
- Pulls data from storage to build a valid beef for a txid.
4952
+ Find legacy-shaped transaction rows from the appropriate table.
4033
4953
 
4034
- Optionally merges the data into an existing beef.
4035
- Optionally requires a minimum number of proof levels.
4954
+ Post-cutover: queries `transactions_legacy` (the renamed legacy schema
4955
+ table that holds unsigned/unprocessed rows without a real txid).
4956
+ Pre-cutover (or on providers that do not support the the new schema): falls back
4957
+ to the standard `findTransactions` which targets the `transactions` table.
4036
4958
 
4037
- ```ts
4959
+ Used by `processAction.validateCommitNewTxToStorageArgs` to locate the
4960
+ unsigned transaction row created by `createAction` via `insertLegacyTransaction`.
4961
+
4962
+ StorageKnex overrides this to route to `transactions_legacy` when the
4963
+ table exists (post-cutover), otherwise falls through to `findTransactions`.
4964
+
4965
+ ```ts
4966
+ async findLegacyTransactions(args: FindTransactionsArgs): Promise<TableTransaction[]>
4967
+ ```
4968
+ See also: [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [TableTransaction](./storage.md#interface-tabletransaction)
4969
+
4970
+ ###### Method findOrInsertLegacyTxLabelMap
4971
+
4972
+ Find-or-insert a `tx_labels_map` row using `insertLegacyTxLabelMap` so
4973
+ that post-cutover FK constraints are bypassed for new unsigned transactions.
4974
+
4975
+ Mirrors the logic of `findOrInsertTxLabelMap` (StorageReaderWriter) but
4976
+ delegates the insert step to `insertLegacyTxLabelMap`.
4977
+
4978
+ ```ts
4979
+ async findOrInsertLegacyTxLabelMap(transactionId: number, txLabelId: number, trx?: TrxToken): Promise<TableTxLabelMap>
4980
+ ```
4981
+ See also: [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TrxToken](./client.md#interface-trxtoken)
4982
+
4983
+ ###### Method getReqsAndBeefToShareWithWorld
4984
+
4985
+ Given an array of transaction txids with current ProvenTxReq ready-to-share status,
4986
+ lookup their ProvenTxReqApi req records.
4987
+ For the txids with reqs and status still ready to send construct a single merged beef.
4988
+
4989
+ ```ts
4990
+ async getReqsAndBeefToShareWithWorld(txids: string[], knownTxids: string[], trx?: TrxToken): Promise<GetReqsAndBeefResult>
4991
+ ```
4992
+ See also: [GetReqsAndBeefResult](./storage.md#interface-getreqsandbeefresult), [TrxToken](./client.md#interface-trxtoken)
4993
+
4994
+ ###### Method getTransactionService
4995
+
4996
+ Returns a TransactionService instance if this storage provider supports
4997
+ the the new schema (i.e. has a Knex handle). Returns undefined for providers
4998
+ that do not support the new schema layer (e.g. StorageIdb).
4999
+
5000
+ StorageKnex overrides this to return `new TransactionService(this.knex)`.
5001
+
5002
+ ```ts
5003
+ getTransactionService(): TransactionService | undefined
5004
+ ```
5005
+ See also: [TransactionService](./storage.md#class-transactionservice)
5006
+
5007
+ ###### Method getValidBeefForKnownTxid
5008
+
5009
+ Pulls data from storage to build a valid beef for a txid.
5010
+
5011
+ Optionally merges the data into an existing beef.
5012
+ Optionally requires a minimum number of proof levels.
5013
+
5014
+ ```ts
4038
5015
  async getValidBeefForKnownTxid(txid: string, mergeToBeef?: Beef, trustSelf?: TrustSelf, knownTxids?: string[], trx?: TrxToken, requiredLevels?: number): Promise<Beef>
4039
5016
  ```
4040
5017
  See also: [TrxToken](./client.md#interface-trxtoken)
4041
5018
 
5019
+ ###### Method insertLegacyTransaction
5020
+
5021
+ Insert a legacy-shaped transaction row.
5022
+
5023
+ Post-cutover: writes into `transactions_legacy` (the renamed legacy table)
5024
+ so that `createAction` can still store unsigned rows before the real txid is
5025
+ known, without touching the new `transactions` table (which requires a non-null txid).
5026
+
5027
+ Pre-cutover (or on providers that do not support the the new schema): falls back
5028
+ to the standard `insertTransaction` which targets the `transactions` table.
5029
+
5030
+ StorageKnex overrides this to route to `transactions_legacy` when the table
5031
+ exists, otherwise falls through to the standard `transactions` insert.
5032
+
5033
+ ```ts
5034
+ async insertLegacyTransaction(tx: TableTransaction, trx?: TrxToken): Promise<number>
5035
+ ```
5036
+ See also: [TableTransaction](./storage.md#interface-tabletransaction), [TrxToken](./client.md#interface-trxtoken)
5037
+
5038
+ ###### Method insertLegacyTxLabelMap
5039
+
5040
+ Insert a `tx_labels_map` row for a legacy transaction that does not yet
5041
+ have a `actions.actionId`.
5042
+
5043
+ Post-cutover the `tx_labels_map.transactionId` column has a FK to
5044
+ `actions.actionId`. When `createAction` writes labels against a legacy
5045
+ transactionId (before processAction creates the actions row), the FK
5046
+ cannot be satisfied. This shim bypasses that constraint temporarily.
5047
+ `processAction` later rewrites the rows to the real actionId via
5048
+ `TransactionService.repointLabelsToActionId`.
5049
+
5050
+ Pre-cutover: delegates to `insertTxLabelMap` with no FK bypass needed.
5051
+
5052
+ StorageKnex overrides this to temporarily disable FK checks on SQLite
5053
+ when `transactions_legacy` is present (indicating post-cutover).
5054
+
5055
+ ```ts
5056
+ async insertLegacyTxLabelMap(labelMap: TableTxLabelMap, trx?: TrxToken): Promise<void>
5057
+ ```
5058
+ See also: [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TrxToken](./client.md#interface-trxtoken)
5059
+
5060
+ ###### Method markOutputAsSpentBy
5061
+
5062
+ Mark an output as spent by a (potentially legacy) transaction.
5063
+
5064
+ Post-cutover on SQLite: setting `outputs.spentBy = legacyTransactionId`
5065
+ violates the FK `outputs.spentBy → transactions.transactionId` because
5066
+ unsigned transactions created by `createAction` live in `transactions_legacy`.
5067
+ This method disables the FK constraint for the duration of the update.
5068
+ The constraint will be satisfied once `processAction` creates the new schema row and
5069
+ the bridge-period is complete.
5070
+
5071
+ Pre-cutover: delegates to `updateOutput` with no FK bypass.
5072
+
5073
+ StorageKnex overrides this to toggle `PRAGMA foreign_keys` around the UPDATE
5074
+ when `isPostCutover()` and the dbtype is `SQLite`.
5075
+
5076
+ Mapping §2: bridge-period `outputs.spentBy` temporarily references
5077
+ `transactions_legacy.transactionId` during `createAction`; new-schema FK is bypassed.
5078
+
5079
+ ```ts
5080
+ async markOutputAsSpentBy(outputId: number, update: Partial<TableOutput>, trx?: TrxToken): Promise<void>
5081
+ ```
5082
+ See also: [TableOutput](./storage.md#interface-tableoutput), [TrxToken](./client.md#interface-trxtoken)
5083
+
5084
+ ###### Method updateLegacyTransaction
5085
+
5086
+ Update a legacy-shaped transaction row in the appropriate table.
5087
+
5088
+ Post-cutover: updates `transactions_legacy` (where unsigned rows live).
5089
+ Pre-cutover: delegates to the standard `updateTransaction`.
5090
+
5091
+ Used by `processAction.commitNewTxToStorage` to write back the final txid
5092
+ and status to the legacy row that was created by `createAction`.
5093
+
5094
+ StorageKnex overrides this to route to `transactions_legacy` when the
5095
+ table exists (post-cutover), otherwise falls through to `updateTransaction`.
5096
+
5097
+ ```ts
5098
+ async updateLegacyTransaction(id: number | number[], update: Partial<TableTransaction>, trx?: TrxToken): Promise<number>
5099
+ ```
5100
+ See also: [TableTransaction](./storage.md#interface-tabletransaction), [TrxToken](./client.md#interface-trxtoken)
5101
+
4042
5102
  ###### Method updateProvenTxReqWithNewProvenTx
4043
5103
 
4044
5104
  Handles storage changes when a valid MerklePath and mined block header are found for a ProvenTxReq txid.
@@ -4135,7 +5195,7 @@ export abstract class StorageReader implements sdk.WalletStorageSyncReader {
4135
5195
  }
4136
5196
  ```
4137
5197
 
4138
- See also: [Chain](./client.md#type-chain), [DBType](./storage.md#type-dbtype), [FindCertificateFieldsArgs](./client.md#interface-findcertificatefieldsargs), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindCommissionsArgs](./client.md#interface-findcommissionsargs), [FindForUserSincePagedArgs](./client.md#interface-findforusersincepagedargs), [FindMonitorEventsArgs](./client.md#interface-findmonitoreventsargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputTagsArgs](./client.md#interface-findoutputtagsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindSyncStatesArgs](./client.md#interface-findsyncstatesargs), [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [FindTxLabelsArgs](./client.md#interface-findtxlabelsargs), [FindUsersArgs](./client.md#interface-findusersargs), [RequestSyncChunkArgs](./client.md#interface-requestsyncchunkargs), [StorageReaderOptions](./storage.md#interface-storagereaderoptions), [SyncChunk](./client.md#interface-syncchunk), [TableCertificateField](./storage.md#interface-tablecertificatefield), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableCommission](./storage.md#interface-tablecommission), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputTagMap](./storage.md#interface-tableoutputtagmap), [TableProvenTx](./storage.md#interface-tableproventx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableTransaction](./storage.md#interface-tabletransaction), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TrxToken](./client.md#interface-trxtoken), [WalletStorageSyncReader](./client.md#interface-walletstoragesyncreader), [getSyncChunk](./storage.md#function-getsyncchunk)
5198
+ See also: [Chain](./client.md#type-chain), [DBType](./storage.md#type-dbtype), [FindCertificateFieldsArgs](./client.md#interface-findcertificatefieldsargs), [FindCertificatesArgs](./client.md#interface-findcertificatesargs), [FindCommissionsArgs](./client.md#interface-findcommissionsargs), [FindForUserSincePagedArgs](./client.md#interface-findforusersincepagedargs), [FindMonitorEventsArgs](./client.md#interface-findmonitoreventsargs), [FindOutputBasketsArgs](./client.md#interface-findoutputbasketsargs), [FindOutputTagsArgs](./client.md#interface-findoutputtagsargs), [FindOutputsArgs](./client.md#interface-findoutputsargs), [FindSyncStatesArgs](./client.md#interface-findsyncstatesargs), [FindTransactionsArgs](./client.md#interface-findtransactionsargs), [FindTxLabelsArgs](./client.md#interface-findtxlabelsargs), [FindUsersArgs](./client.md#interface-findusersargs), [RequestSyncChunkArgs](./client.md#interface-requestsyncchunkargs), [StorageReaderOptions](./storage.md#interface-storagereaderoptions), [SyncChunk](./client.md#interface-syncchunk), [TableCertificateField](./storage.md#interface-tablecertificatefield), [TableCertificateX](./storage.md#interface-tablecertificatex), [TableCommission](./storage.md#interface-tablecommission), [TableMonitorEvent](./storage.md#interface-tablemonitorevent), [TableOutput](./storage.md#interface-tableoutput), [TableOutputBasket](./storage.md#interface-tableoutputbasket), [TableOutputTag](./storage.md#interface-tableoutputtag), [TableOutputTagMap](./storage.md#interface-tableoutputtagmap), [TableProvenTx](./storage.md#interface-tableproventx), [TableProvenTxReq](./storage.md#interface-tableproventxreq), [TableSettings](./storage.md#interface-tablesettings), [TableSyncState](./storage.md#interface-tablesyncstate), [TableTransaction](./storage.md#interface-tabletransaction), [TableTxLabel](./storage.md#interface-tabletxlabel), [TableTxLabelMap](./storage.md#interface-tabletxlabelmap), [TableUser](./storage.md#interface-tableuser), [TrxToken](./client.md#interface-trxtoken), [WalletStorageSyncReader](./client.md#interface-walletstoragesyncreader), [getSyncChunk](./storage.md#function-getsyncchunk), [validateDate](./storage.md#function-validatedate)
4139
5199
 
4140
5200
  ###### Method validateEntityDate
4141
5201
 
@@ -4266,7 +5326,7 @@ export class StorageServer {
4266
5326
  }
4267
5327
  ```
4268
5328
 
4269
- See also: [EntityTimeStamp](./client.md#interface-entitytimestamp), [StorageProvider](./storage.md#class-storageprovider), [WalletStorageServerOptions](./storage.md#interface-walletstorageserveroptions)
5329
+ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp), [StorageProvider](./storage.md#class-storageprovider), [WalletStorageServerOptions](./storage.md#interface-walletstorageserveroptions), [validateDate](./storage.md#function-validatedate), [validateEntities](./storage.md#function-validateentities), [validateEntity](./storage.md#function-validateentity)
4270
5330
 
4271
5331
  ###### Method validateEntities
4272
5332
 
@@ -4306,7 +5366,7 @@ and the `StorageBaseReader` to be protected.
4306
5366
  export class StorageSyncReader implements sdk.WalletStorageSyncReader {
4307
5367
  constructor(public auth: sdk.AuthId, public storage: StorageReader)
4308
5368
  async makeAvailable(): Promise<TableSettings>
4309
- destroy(): Promise<void>
5369
+ async destroy(): Promise<void>
4310
5370
  async getSyncChunk(args: sdk.RequestSyncChunkArgs): Promise<sdk.SyncChunk>
4311
5371
  }
4312
5372
  ```
@@ -4315,6 +5375,543 @@ See also: [AuthId](./client.md#interface-authid), [RequestSyncChunkArgs](./clien
4315
5375
 
4316
5376
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4317
5377
 
5378
+ ---
5379
+ ##### Class: TransactionService
5380
+
5381
+ ```ts
5382
+ export class TransactionService {
5383
+ constructor(private readonly knex: Knex)
5384
+ async findByTxid(txid: string): Promise<TableTransactionNew | undefined>
5385
+ async findById(transactionId: number): Promise<TableTransactionNew | undefined>
5386
+ async create(args: {
5387
+ txid: string;
5388
+ processing?: sdk.ProcessingStatus;
5389
+ rawTx?: number[];
5390
+ inputBeef?: number[];
5391
+ batch?: string;
5392
+ idempotencyKey?: string;
5393
+ isCoinbase?: boolean;
5394
+ now?: Date;
5395
+ }): Promise<TableTransactionNew>
5396
+ async transition(args: {
5397
+ transactionId: number;
5398
+ expectedFrom: sdk.ProcessingStatus;
5399
+ to: sdk.ProcessingStatus;
5400
+ provider?: string;
5401
+ providerStatus?: string;
5402
+ details?: Record<string, unknown>;
5403
+ now?: Date;
5404
+ }): Promise<TableTransactionNew | undefined>
5405
+ async recordProof(args: {
5406
+ transactionId: number;
5407
+ height: number;
5408
+ merklePath: number[];
5409
+ merkleRoot: string;
5410
+ blockHash: string;
5411
+ expectedFrom: sdk.ProcessingStatus;
5412
+ now?: Date;
5413
+ }): Promise<TableTransactionNew | undefined>
5414
+ async findActionForUser(userId: number, transactionId: number): Promise<TableAction | undefined>
5415
+ async createAction(args: {
5416
+ userId: number;
5417
+ transactionId: number;
5418
+ reference: string;
5419
+ description: string;
5420
+ isOutgoing: boolean;
5421
+ satoshisDelta: number;
5422
+ userNosend?: boolean;
5423
+ notifyJson?: string;
5424
+ now?: Date;
5425
+ }): Promise<number>
5426
+ async getChainTip(): Promise<{
5427
+ height: number;
5428
+ blockHash: string;
5429
+ } | undefined>
5430
+ async setChainTip(args: {
5431
+ height: number;
5432
+ blockHash: string;
5433
+ merkleRoot?: string;
5434
+ now?: Date;
5435
+ }): Promise<void>
5436
+ async tryClaimLease(claim: MonitorLeaseClaim, now?: Date): Promise<MonitorLeaseResult>
5437
+ async renewLease(renew: MonitorLeaseRenew, now?: Date): Promise<MonitorLeaseResult>
5438
+ async releaseLease(release: MonitorLeaseRelease): Promise<boolean>
5439
+ async findActionByReference(userId: number, reference: string): Promise<{
5440
+ action: TableAction;
5441
+ transaction: TableTransactionNew;
5442
+ } | undefined>
5443
+ async findActionByUserTxid(userId: number, txid: string): Promise<{
5444
+ action: TableAction;
5445
+ transaction: TableTransactionNew;
5446
+ } | undefined>
5447
+ async findOrCreateActionForTxid(args: {
5448
+ userId: number;
5449
+ txid: string;
5450
+ isOutgoing: boolean;
5451
+ description: string;
5452
+ satoshisDelta: number;
5453
+ reference: string;
5454
+ rawTx?: number[];
5455
+ inputBeef?: number[];
5456
+ processing?: sdk.ProcessingStatus;
5457
+ now?: Date;
5458
+ }): Promise<{
5459
+ action: TableAction;
5460
+ transaction: TableTransactionNew;
5461
+ isNew: boolean;
5462
+ }>
5463
+ async updateActionSatoshisDelta(actionId: number, delta: number, now?: Date): Promise<void>
5464
+ async createWithProof(args: {
5465
+ txid: string;
5466
+ rawTx?: number[];
5467
+ inputBeef?: number[];
5468
+ height: number;
5469
+ merklePath: number[];
5470
+ merkleRoot: string;
5471
+ blockHash: string;
5472
+ isCoinbase?: boolean;
5473
+ now?: Date;
5474
+ }): Promise<TableTransactionNew>
5475
+ async findOrCreateForBroadcast(args: {
5476
+ txid: string;
5477
+ rawTx: number[];
5478
+ inputBeef?: number[];
5479
+ batch?: string;
5480
+ processing?: sdk.ProcessingStatus;
5481
+ now?: Date;
5482
+ }): Promise<{
5483
+ transaction: TableTransactionNew;
5484
+ isNew: boolean;
5485
+ }>
5486
+ async transitionMany(args: {
5487
+ transactionIds: number[];
5488
+ expectedFrom?: sdk.ProcessingStatus;
5489
+ to: sdk.ProcessingStatus;
5490
+ provider?: string;
5491
+ providerStatus?: string;
5492
+ details?: Record<string, unknown>;
5493
+ now?: Date;
5494
+ }): Promise<{
5495
+ updated: number[];
5496
+ skipped: number[];
5497
+ }>
5498
+ async setBatch(transactionIds: number[], batch: string | undefined, now?: Date): Promise<void>
5499
+ async incrementAttempts(transactionId: number, now?: Date): Promise<TableTransactionNew | undefined>
5500
+ async recordBroadcastResult(args: {
5501
+ transactionId: number;
5502
+ txid: string;
5503
+ status: sdk.ProcessingStatus;
5504
+ provider: string;
5505
+ providerStatus?: string;
5506
+ wasBroadcast?: boolean;
5507
+ details?: Record<string, unknown>;
5508
+ now?: Date;
5509
+ }): Promise<TableTransactionNew | undefined>
5510
+ async recordHistoryNote(transactionId: number, note: {
5511
+ what: string;
5512
+ [k: string]: unknown;
5513
+ }, now?: Date): Promise<void>
5514
+ async mergeBeefForTxids(beef: Beef, txids: string[]): Promise<void>
5515
+ async collectReqsAndBeef(txids: string[], extraTxids?: string[]): Promise<{
5516
+ beef: Beef;
5517
+ details: Array<{
5518
+ txid: string;
5519
+ status: "readyToSend" | "alreadySent" | "error" | "unknown";
5520
+ reason?: string;
5521
+ }>;
5522
+ }>
5523
+ async listActionsForUser(args: {
5524
+ userId: number;
5525
+ statusFilter?: sdk.ProcessingStatus[];
5526
+ labelIds?: number[];
5527
+ labelQueryMode?: "all" | "any";
5528
+ createdAtFrom?: Date;
5529
+ createdAtTo?: Date;
5530
+ limit: number;
5531
+ offset: number;
5532
+ }): Promise<{
5533
+ rows: Array<TableAction & {
5534
+ txid: string;
5535
+ processing: sdk.ProcessingStatus;
5536
+ height?: number;
5537
+ }>;
5538
+ total?: number;
5539
+ }>
5540
+ async listOutputsForUser(args: {
5541
+ userId: number;
5542
+ basketId?: number;
5543
+ tagIds?: number[];
5544
+ tagQueryMode?: "all" | "any";
5545
+ processingFilter: sdk.ProcessingStatus[];
5546
+ includeSpent: boolean;
5547
+ limit: number;
5548
+ offset: number;
5549
+ includeLockingScripts?: boolean;
5550
+ }): Promise<{
5551
+ rows: Array<TableOutput & {
5552
+ processing: sdk.ProcessingStatus;
5553
+ }>;
5554
+ total?: number;
5555
+ }>
5556
+ async repointLabelsToActionId(legacyTransactionId: number, actionId: number, now?: Date): Promise<void>
5557
+ async repointOutputsToNewTransactionId(legacyTransactionId: number, newTransactionId: number, now?: Date): Promise<void>
5558
+ }
5559
+ ```
5560
+
5561
+ See also: [MonitorLeaseClaim](./monitor.md#interface-monitorleaseclaim), [MonitorLeaseRelease](./monitor.md#interface-monitorleaserelease), [MonitorLeaseRenew](./monitor.md#interface-monitorleaserenew), [MonitorLeaseResult](./monitor.md#interface-monitorleaseresult), [ProcessingStatus](./client.md#type-processingstatus), [TableAction](./storage.md#interface-tableaction), [TableOutput](./storage.md#interface-tableoutput), [TableTransactionNew](./storage.md#interface-tabletransactionnew), [blockHash](./services.md#function-blockhash), [createAction](./storage.md#function-createaction), [getChainTip](./storage.md#function-getchaintip), [releaseLease](./monitor.md#function-releaselease), [renewLease](./monitor.md#function-renewlease), [setChainTip](./storage.md#function-setchaintip), [tryClaimLease](./monitor.md#function-tryclaimlease)
5562
+
5563
+ ###### Method collectReqsAndBeef
5564
+
5565
+ #13 — Collect broadcast-readiness info and a populated Beef for a list of
5566
+ txids. Each entry is classified as:
5567
+ - `readyToSend` — queued/sending → still needs broadcast
5568
+ - `alreadySent` — sent/seen/seen_multi/unconfirmed/confirmed → already on network
5569
+ - `error` — invalid/doubleSpend → terminal failure
5570
+ - `unknown` — not found in new-schema
5571
+
5572
+ ```ts
5573
+ async collectReqsAndBeef(txids: string[], extraTxids?: string[]): Promise<{
5574
+ beef: Beef;
5575
+ details: Array<{
5576
+ txid: string;
5577
+ status: "readyToSend" | "alreadySent" | "error" | "unknown";
5578
+ reason?: string;
5579
+ }>;
5580
+ }>
5581
+ ```
5582
+
5583
+ ###### Method create
5584
+
5585
+ Insert a new new transaction row. The row is created in `queued` state
5586
+ unless the caller overrides `processing`.
5587
+
5588
+ ```ts
5589
+ async create(args: {
5590
+ txid: string;
5591
+ processing?: sdk.ProcessingStatus;
5592
+ rawTx?: number[];
5593
+ inputBeef?: number[];
5594
+ batch?: string;
5595
+ idempotencyKey?: string;
5596
+ isCoinbase?: boolean;
5597
+ now?: Date;
5598
+ }): Promise<TableTransactionNew>
5599
+ ```
5600
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableTransactionNew](./storage.md#interface-tabletransactionnew)
5601
+
5602
+ ###### Method createWithProof
5603
+
5604
+ #5 — Create a new transaction row already in `confirmed` state with all proof
5605
+ columns populated. Useful for internalised transactions that arrive with a
5606
+ Merkle proof (bump) already attached.
5607
+
5608
+ ```ts
5609
+ async createWithProof(args: {
5610
+ txid: string;
5611
+ rawTx?: number[];
5612
+ inputBeef?: number[];
5613
+ height: number;
5614
+ merklePath: number[];
5615
+ merkleRoot: string;
5616
+ blockHash: string;
5617
+ isCoinbase?: boolean;
5618
+ now?: Date;
5619
+ }): Promise<TableTransactionNew>
5620
+ ```
5621
+ See also: [TableTransactionNew](./storage.md#interface-tabletransactionnew), [blockHash](./services.md#function-blockhash)
5622
+
5623
+ ###### Method findActionByReference
5624
+
5625
+ #1 — Look up an action + its backing transaction by (userId, reference).
5626
+
5627
+ ```ts
5628
+ async findActionByReference(userId: number, reference: string): Promise<{
5629
+ action: TableAction;
5630
+ transaction: TableTransactionNew;
5631
+ } | undefined>
5632
+ ```
5633
+ See also: [TableAction](./storage.md#interface-tableaction), [TableTransactionNew](./storage.md#interface-tabletransactionnew)
5634
+
5635
+ ###### Method findActionByUserTxid
5636
+
5637
+ #2 — Look up an action + its backing transaction by (userId, txid).
5638
+
5639
+ ```ts
5640
+ async findActionByUserTxid(userId: number, txid: string): Promise<{
5641
+ action: TableAction;
5642
+ transaction: TableTransactionNew;
5643
+ } | undefined>
5644
+ ```
5645
+ See also: [TableAction](./storage.md#interface-tableaction), [TableTransactionNew](./storage.md#interface-tabletransactionnew)
5646
+
5647
+ ###### Method findOrCreateActionForTxid
5648
+
5649
+ #3 — Upsert: find existing action for (userId, txid) or create both the new
5650
+ transaction row and the action row.
5651
+
5652
+ ```ts
5653
+ async findOrCreateActionForTxid(args: {
5654
+ userId: number;
5655
+ txid: string;
5656
+ isOutgoing: boolean;
5657
+ description: string;
5658
+ satoshisDelta: number;
5659
+ reference: string;
5660
+ rawTx?: number[];
5661
+ inputBeef?: number[];
5662
+ processing?: sdk.ProcessingStatus;
5663
+ now?: Date;
5664
+ }): Promise<{
5665
+ action: TableAction;
5666
+ transaction: TableTransactionNew;
5667
+ isNew: boolean;
5668
+ }>
5669
+ ```
5670
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableAction](./storage.md#interface-tableaction), [TableTransactionNew](./storage.md#interface-tabletransactionnew)
5671
+
5672
+ ###### Method findOrCreateForBroadcast
5673
+
5674
+ #6 — Find an existing new transaction row for the given txid (suitable for
5675
+ the broadcast queue) or create a new one in `queued` state.
5676
+
5677
+ ```ts
5678
+ async findOrCreateForBroadcast(args: {
5679
+ txid: string;
5680
+ rawTx: number[];
5681
+ inputBeef?: number[];
5682
+ batch?: string;
5683
+ processing?: sdk.ProcessingStatus;
5684
+ now?: Date;
5685
+ }): Promise<{
5686
+ transaction: TableTransactionNew;
5687
+ isNew: boolean;
5688
+ }>
5689
+ ```
5690
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableTransactionNew](./storage.md#interface-tabletransactionnew)
5691
+
5692
+ ###### Method incrementAttempts
5693
+
5694
+ #9 — Atomically increment the `attempts` counter for one transaction and
5695
+ write an `attempts.incremented` audit entry.
5696
+
5697
+ ```ts
5698
+ async incrementAttempts(transactionId: number, now?: Date): Promise<TableTransactionNew | undefined>
5699
+ ```
5700
+ See also: [TableTransactionNew](./storage.md#interface-tabletransactionnew)
5701
+
5702
+ ###### Method listActionsForUser
5703
+
5704
+ #14 — Paginated list of actions (per-user transaction views) with optional
5705
+ status and label filters.
5706
+
5707
+ After the the schema cutover `tx_labels_map.transactionId` references `actions.actionId`
5708
+ (not `transactions.transactionId`).
5709
+
5710
+ ```ts
5711
+ async listActionsForUser(args: {
5712
+ userId: number;
5713
+ statusFilter?: sdk.ProcessingStatus[];
5714
+ labelIds?: number[];
5715
+ labelQueryMode?: "all" | "any";
5716
+ createdAtFrom?: Date;
5717
+ createdAtTo?: Date;
5718
+ limit: number;
5719
+ offset: number;
5720
+ }): Promise<{
5721
+ rows: Array<TableAction & {
5722
+ txid: string;
5723
+ processing: sdk.ProcessingStatus;
5724
+ height?: number;
5725
+ }>;
5726
+ total?: number;
5727
+ }>
5728
+ ```
5729
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableAction](./storage.md#interface-tableaction)
5730
+
5731
+ ###### Method listOutputsForUser
5732
+
5733
+ #15 — Paginated list of outputs with their backing transaction processing
5734
+ state. Optional filters: basket, tag set, processing state, spent flag.
5735
+
5736
+ ```ts
5737
+ async listOutputsForUser(args: {
5738
+ userId: number;
5739
+ basketId?: number;
5740
+ tagIds?: number[];
5741
+ tagQueryMode?: "all" | "any";
5742
+ processingFilter: sdk.ProcessingStatus[];
5743
+ includeSpent: boolean;
5744
+ limit: number;
5745
+ offset: number;
5746
+ includeLockingScripts?: boolean;
5747
+ }): Promise<{
5748
+ rows: Array<TableOutput & {
5749
+ processing: sdk.ProcessingStatus;
5750
+ }>;
5751
+ total?: number;
5752
+ }>
5753
+ ```
5754
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableOutput](./storage.md#interface-tableoutput)
5755
+
5756
+ ###### Method mergeBeefForTxids
5757
+
5758
+ #12 — For each txid that exists in the new transactions table, merge the
5759
+ raw transaction bytes and (where available) the Merkle path into `beef`.
5760
+ Txids not present in new-schema are silently skipped.
5761
+
5762
+ ```ts
5763
+ async mergeBeefForTxids(beef: Beef, txids: string[]): Promise<void>
5764
+ ```
5765
+
5766
+ ###### Method recordBroadcastResult
5767
+
5768
+ #10 — Record the outcome of a broadcast attempt. Transitions processing
5769
+ state, updates `wasBroadcast` and `lastProvider*` columns, and writes an
5770
+ audit row.
5771
+
5772
+ ```ts
5773
+ async recordBroadcastResult(args: {
5774
+ transactionId: number;
5775
+ txid: string;
5776
+ status: sdk.ProcessingStatus;
5777
+ provider: string;
5778
+ providerStatus?: string;
5779
+ wasBroadcast?: boolean;
5780
+ details?: Record<string, unknown>;
5781
+ now?: Date;
5782
+ }): Promise<TableTransactionNew | undefined>
5783
+ ```
5784
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableTransactionNew](./storage.md#interface-tabletransactionnew)
5785
+
5786
+ ###### Method recordHistoryNote
5787
+
5788
+ #11 — Append a free-form history note to the audit log for a transaction.
5789
+
5790
+ ```ts
5791
+ async recordHistoryNote(transactionId: number, note: {
5792
+ what: string;
5793
+ [k: string]: unknown;
5794
+ }, now?: Date): Promise<void>
5795
+ ```
5796
+
5797
+ ###### Method recordProof
5798
+
5799
+ Record acquisition of a Merkle proof for a transaction. Atomically:
5800
+ - Updates proof columns (height, index, merkle_path, merkle_root, block_hash)
5801
+ - Transitions processing to `confirmed` from any spendable-class state.
5802
+ - Writes a `proof.acquired` audit row.
5803
+
5804
+ The merkle leaf index is derived from `merklePath` (BUMP) using the row's
5805
+ `txid`; callers do not pass it.
5806
+
5807
+ ```ts
5808
+ async recordProof(args: {
5809
+ transactionId: number;
5810
+ height: number;
5811
+ merklePath: number[];
5812
+ merkleRoot: string;
5813
+ blockHash: string;
5814
+ expectedFrom: sdk.ProcessingStatus;
5815
+ now?: Date;
5816
+ }): Promise<TableTransactionNew | undefined>
5817
+ ```
5818
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableTransactionNew](./storage.md#interface-tabletransactionnew), [blockHash](./services.md#function-blockhash)
5819
+
5820
+ ###### Method repointLabelsToActionId
5821
+
5822
+ Post-cutover helper: rewrite `tx_labels_map.transactionId` rows that were
5823
+ written with the legacy transactionId (before the real txid + actionId were
5824
+ known) so that they now point at the new-schema `actions.actionId`.
5825
+
5826
+ Call this once per new outgoing transaction immediately after
5827
+ `findOrCreateActionForTxid` resolves the actionId.
5828
+
5829
+ This is a no-op when:
5830
+ - `legacyTransactionId` has no rows in `tx_labels_map` (no labels on the tx)
5831
+ - `legacyTransactionId === actionId` (should not happen in practice but
5832
+ is safe to call anyway)
5833
+
5834
+ ```ts
5835
+ async repointLabelsToActionId(legacyTransactionId: number, actionId: number, now?: Date): Promise<void>
5836
+ ```
5837
+
5838
+ ###### Method repointOutputsToNewTransactionId
5839
+
5840
+ After `processAction` creates the new `transactions` row, remap
5841
+ `outputs.transactionId` and `outputs.spentBy` from the bridge-period
5842
+ `transactions_legacy.transactionId` to the real `transactions.transactionId`.
5843
+
5844
+ During `createAction`, new outputs are inserted with `transactionId =
5845
+ legacyTransactionId` (bypassing FK constraints). `listActionsKnex` queries
5846
+ outputs by new transactionId, so without this remap the outputs would be
5847
+ invisible to `listActions`.
5848
+
5849
+ This is a no-op when `legacyTransactionId === newTransactionId`.
5850
+
5851
+ ```ts
5852
+ async repointOutputsToNewTransactionId(legacyTransactionId: number, newTransactionId: number, now?: Date): Promise<void>
5853
+ ```
5854
+
5855
+ ###### Method setBatch
5856
+
5857
+ #8 — Bulk-set the `batch` column for a list of transaction ids.
5858
+ Pass `undefined` to clear the batch tag.
5859
+
5860
+ ```ts
5861
+ async setBatch(transactionIds: number[], batch: string | undefined, now?: Date): Promise<void>
5862
+ ```
5863
+
5864
+ ###### Method transition
5865
+
5866
+ Transition processing state with optimistic concurrency. Returns
5867
+ `undefined` when the FSM rejects the move OR the row's current state no
5868
+ longer matches `expectedFrom`.
5869
+
5870
+ ```ts
5871
+ async transition(args: {
5872
+ transactionId: number;
5873
+ expectedFrom: sdk.ProcessingStatus;
5874
+ to: sdk.ProcessingStatus;
5875
+ provider?: string;
5876
+ providerStatus?: string;
5877
+ details?: Record<string, unknown>;
5878
+ now?: Date;
5879
+ }): Promise<TableTransactionNew | undefined>
5880
+ ```
5881
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableTransactionNew](./storage.md#interface-tabletransactionnew)
5882
+
5883
+ ###### Method transitionMany
5884
+
5885
+ #7 — Bulk transition: attempt `transition` for each id; collect results.
5886
+ When `expectedFrom` is omitted the current state of each row is used as
5887
+ the expected source (lenient mode — only the FSM is checked).
5888
+
5889
+ ```ts
5890
+ async transitionMany(args: {
5891
+ transactionIds: number[];
5892
+ expectedFrom?: sdk.ProcessingStatus;
5893
+ to: sdk.ProcessingStatus;
5894
+ provider?: string;
5895
+ providerStatus?: string;
5896
+ details?: Record<string, unknown>;
5897
+ now?: Date;
5898
+ }): Promise<{
5899
+ updated: number[];
5900
+ skipped: number[];
5901
+ }>
5902
+ ```
5903
+ See also: [ProcessingStatus](./client.md#type-processingstatus)
5904
+
5905
+ ###### Method updateActionSatoshisDelta
5906
+
5907
+ #4 — Atomically update the satoshisDelta column on an action row.
5908
+
5909
+ ```ts
5910
+ async updateActionSatoshisDelta(actionId: number, delta: number, now?: Date): Promise<void>
5911
+ ```
5912
+
5913
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5914
+
4318
5915
  ---
4319
5916
  ##### Class: WalletStorageManager
4320
5917
 
@@ -4335,7 +5932,7 @@ for these services.
4335
5932
  ```ts
4336
5933
  export class WalletStorageManager implements sdk.WalletStorage {
4337
5934
  _stores: ManagedStorage[] = [];
4338
- _isAvailable: boolean = false;
5935
+ _isAvailable = false;
4339
5936
  _active?: ManagedStorage;
4340
5937
  _backups?: ManagedStorage[];
4341
5938
  _conflictingActives?: ManagedStorage[];
@@ -4389,12 +5986,12 @@ export class WalletStorageManager implements sdk.WalletStorage {
4389
5986
  async reproveHeader(deactivatedHash: string): Promise<sdk.ReproveHeaderResult>
4390
5987
  async reproveHeightMerkleRoot(height: number, staleMerkleRoot: string): Promise<sdk.ReproveHeaderResult>
4391
5988
  async reproveProven(ptx: TableProvenTx, noUpdate?: boolean): Promise<sdk.ReproveProvenResult>
4392
- async syncFromReader(identityKey: string, reader: sdk.WalletStorageSyncReader, activeSync?: sdk.WalletStorageSync, log: string = ""): Promise<{
5989
+ async syncFromReader(identityKey: string, reader: sdk.WalletStorageSyncReader, activeSync?: sdk.WalletStorageSync, log = ""): Promise<{
4393
5990
  inserts: number;
4394
5991
  updates: number;
4395
5992
  log: string;
4396
5993
  }>
4397
- async syncToWriter(auth: sdk.AuthId, writer: sdk.WalletStorageProvider, activeSync?: sdk.WalletStorageSync, log: string = "", progLog?: (s: string) => string): Promise<{
5994
+ async syncToWriter(auth: sdk.AuthId, writer: sdk.WalletStorageProvider, activeSync?: sdk.WalletStorageSync, log = "", progLog?: (s: string) => string): Promise<{
4398
5995
  inserts: number;
4399
5996
  updates: number;
4400
5997
  log: string;
@@ -4464,7 +6061,7 @@ _conflictingActives?: ManagedStorage[]
4464
6061
  True if makeAvailable has been run and access to managed stores (active) is allowed
4465
6062
 
4466
6063
  ```ts
4467
- _isAvailable: boolean = false
6064
+ _isAvailable = false
4468
6065
  ```
4469
6066
 
4470
6067
  ###### Property _services
@@ -4504,36 +6101,16 @@ Returns
4504
6101
 
4505
6102
  true if the active `WalletStorageProvider` also implements `StorageProvider`
4506
6103
 
4507
- ###### Method makeAvailable
4508
-
4509
- This async function must be called after construction and before
4510
- any other async function can proceed.
6104
+ ###### Method reproveHeader
4511
6105
 
4512
- Runs through `_stores` validating all properties and partitioning across `_active`, `_backups`, `_conflictingActives`.
6106
+ For each proven_txs record currently sourcing its transaction merkle proof from the given deactivated header,
6107
+ attempt to reprove the transaction against the current chain,
6108
+ updating the proven_txs record if a new valid proof is found.
4513
6109
 
4514
6110
  ```ts
4515
- async makeAvailable(): Promise<TableSettings>
6111
+ async reproveHeader(deactivatedHash: string): Promise<sdk.ReproveHeaderResult>
4516
6112
  ```
4517
- See also: [TableSettings](./storage.md#interface-tablesettings)
4518
-
4519
- Returns
4520
-
4521
- from the active storage.
4522
-
4523
- Throws
4524
-
4525
- WERR_INVALID_PARAMETER if canMakeAvailable returns false.
4526
-
4527
- ###### Method reproveHeader
4528
-
4529
- For each proven_txs record currently sourcing its transaction merkle proof from the given deactivated header,
4530
- attempt to reprove the transaction against the current chain,
4531
- updating the proven_txs record if a new valid proof is found.
4532
-
4533
- ```ts
4534
- async reproveHeader(deactivatedHash: string): Promise<sdk.ReproveHeaderResult>
4535
- ```
4536
- See also: [ReproveHeaderResult](./client.md#interface-reproveheaderresult)
6113
+ See also: [ReproveHeaderResult](./client.md#interface-reproveheaderresult)
4537
6114
 
4538
6115
  Argument Details
4539
6116
 
@@ -4552,23 +6129,6 @@ async reproveHeightMerkleRoot(height: number, staleMerkleRoot: string): Promise<
4552
6129
  ```
4553
6130
  See also: [ReproveHeaderResult](./client.md#interface-reproveheaderresult)
4554
6131
 
4555
- ###### Method reproveProven
4556
-
4557
- Attempt to reprove the transaction against the current chain,
4558
- If a new valid proof is found and noUpdate is not true,
4559
- update the proven_txs record with new block and merkle proof data.
4560
- If noUpdate is true, the update to be applied is available in the returned result.
4561
-
4562
- ```ts
4563
- async reproveProven(ptx: TableProvenTx, noUpdate?: boolean): Promise<sdk.ReproveProvenResult>
4564
- ```
4565
- See also: [ReproveProvenResult](./client.md#interface-reproveprovenresult), [TableProvenTx](./storage.md#interface-tableproventx)
4566
-
4567
- Argument Details
4568
-
4569
- + **ptx**
4570
- + proven_txs record to reprove
4571
-
4572
6132
  ###### Method runAsSync
4573
6133
 
4574
6134
  ```ts
@@ -4605,23 +6165,57 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
4605
6165
 
4606
6166
  | | | |
4607
6167
  | --- | --- | --- |
4608
- | [attemptToPostReqsToNetwork](#function-attempttopostreqstonetwork) | [listActions](#function-listactions) | [renderAdminPage](#function-renderadminpage) |
4609
- | [createAction](#function-createaction) | [listActionsIdb](#function-listactionsidb) | [reviewStatus](#function-reviewstatus) |
4610
- | [createStorageServiceChargeScript](#function-createstorageservicechargescript) | [listCertificates](#function-listcertificates) | [reviewStatusIdb](#function-reviewstatusidb) |
4611
- | [createSyncMap](#function-createsyncmap) | [listOutputs](#function-listoutputs) | [setDisableDoubleSpendCheckForTest](#function-setdisabledoublespendcheckfortest) |
4612
- | [determineDBType](#function-determinedbtype) | [listOutputsIdb](#function-listoutputsidb) | [shareReqsWithWorld](#function-sharereqswithworld) |
4613
- | [generateChangeSdk](#function-generatechangesdk) | [lockScriptWithKeyOffsetFromPubKey](#function-lockscriptwithkeyoffsetfrompubkey) | [transactionInputSize](#function-transactioninputsize) |
4614
- | [generateChangeSdkMakeStorage](#function-generatechangesdkmakestorage) | [offsetPrivKey](#function-offsetprivkey) | [transactionOutputSize](#function-transactionoutputsize) |
4615
- | [getBeefForTransaction](#function-getbeeffortransaction) | [offsetPubKey](#function-offsetpubkey) | [transactionSize](#function-transactionsize) |
4616
- | [getListOutputsSpecOp](#function-getlistoutputsspecop) | [processAction](#function-processaction) | [validateGenerateChangeSdkParams](#function-validategeneratechangesdkparams) |
4617
- | [getSyncChunk](#function-getsyncchunk) | [purgeData](#function-purgedata) | [validateGenerateChangeSdkResult](#function-validategeneratechangesdkresult) |
4618
- | [internalizeAction](#function-internalizeaction) | [purgeDataIdb](#function-purgedataidb) | [validateStorageFeeModel](#function-validatestoragefeemodel) |
4619
- | [keyOffsetToHashedSecret](#function-keyoffsettohashedsecret) | [redeemServiceCharges](#function-redeemservicecharges) | [varUintSize](#function-varuintsize) |
6168
+ | [appendTxAudit](#function-appendtxaudit) | [markStaleInputsAsSpent](#function-markstaleinputsasspent) | [transactionOutputSize](#function-transactionoutputsize) |
6169
+ | [attemptToPostReqsToNetwork](#function-attempttopostreqstonetwork) | [matchesCertificateFieldPartial](#function-matchescertificatefieldpartial) | [transactionSize](#function-transactionsize) |
6170
+ | [auditProcessingTransition](#function-auditprocessingtransition) | [matchesCertificatePartial](#function-matchescertificatepartial) | [transitionProcessing](#function-transitionprocessing) |
6171
+ | [classifyReqStatus](#function-classifyreqstatus) | [matchesCommissionPartial](#function-matchescommissionpartial) | [tryClaimLease](#function-tryclaimlease) |
6172
+ | [createAction](#function-createaction) | [matchesMonitorEventPartial](#function-matchesmonitoreventpartial) | [updateReqsFromAggregateResults](#function-updatereqsfromaggregateresults) |
6173
+ | [createStorageServiceChargeScript](#function-createstorageservicechargescript) | [matchesOutputBasketPartial](#function-matchesoutputbasketpartial) | [upgradeActions](#function-upgradeactions) |
6174
+ | [createSyncMap](#function-createsyncmap) | [matchesOutputPartial](#function-matchesoutputpartial) | [upgradeAllStoresV1](#function-upgradeallstoresv1) |
6175
+ | [dateMatches](#function-datematches) | [matchesOutputTagMapPartial](#function-matchesoutputtagmappartial) | [upgradeCertificateFields](#function-upgradecertificatefields) |
6176
+ | [determineDBType](#function-determinedbtype) | [matchesOutputTagPartial](#function-matchesoutputtagpartial) | [upgradeCertificates](#function-upgradecertificates) |
6177
+ | [findAction](#function-findaction) | [matchesProvenTxPartial](#function-matchesproventxpartial) | [upgradeChainTip](#function-upgradechaintip) |
6178
+ | [findTransactionNew](#function-findtransactionnew) | [matchesProvenTxReqPartial](#function-matchesproventxreqpartial) | [upgradeCommissions](#function-upgradecommissions) |
6179
+ | [findTransactionNewByTxid](#function-findtransactionnewbytxid) | [matchesSyncStatePartial](#function-matchessyncstatepartial) | [upgradeMonitorEvents](#function-upgrademonitorevents) |
6180
+ | [generateChangeSdk](#function-generatechangesdk) | [matchesTransactionPartial](#function-matchestransactionpartial) | [upgradeMonitorLease](#function-upgrademonitorlease) |
6181
+ | [generateChangeSdkMakeStorage](#function-generatechangesdkmakestorage) | [matchesTxLabelMapPartial](#function-matchestxlabelmappartial) | [upgradeOutputBaskets](#function-upgradeoutputbaskets) |
6182
+ | [getBeefForTransaction](#function-getbeeffortransaction) | [matchesTxLabelPartial](#function-matchestxlabelpartial) | [upgradeOutputTags](#function-upgradeoutputtags) |
6183
+ | [getChainTip](#function-getchaintip) | [mergeInputBeefs](#function-mergeinputbeefs) | [upgradeOutputTagsMap](#function-upgradeoutputtagsmap) |
6184
+ | [getListOutputsSpecOp](#function-getlistoutputsspecop) | [mergeInputsIntoBeef](#function-mergeinputsintobeef) | [upgradeOutputs](#function-upgradeoutputs) |
6185
+ | [getSyncChunk](#function-getsyncchunk) | [notifyTransactionsOfProof](#function-notifytransactionsofproof) | [upgradeProvenTxReqs](#function-upgradeproventxreqs) |
6186
+ | [indexFromMerklePath](#function-indexfrommerklepath) | [offsetPrivKey](#function-offsetprivkey) | [upgradeProvenTxs](#function-upgradeproventxs) |
6187
+ | [insertAction](#function-insertaction) | [offsetPubKey](#function-offsetpubkey) | [upgradeSyncStates](#function-upgradesyncstates) |
6188
+ | [insertTransactionNew](#function-inserttransactionnew) | [partitionActionLabels](#function-partitionactionlabels) | [upgradeTransactions](#function-upgradetransactions) |
6189
+ | [internalizeAction](#function-internalizeaction) | [processAction](#function-processaction) | [upgradeTransactionsNew](#function-upgradetransactionsnew) |
6190
+ | [isProcessingSpendable](#function-isprocessingspendable) | [processingTransitionMap](#function-processingtransitionmap) | [upgradeTxAudit](#function-upgradetxaudit) |
6191
+ | [isProcessingTerminal](#function-isprocessingterminal) | [purgeData](#function-purgedata) | [upgradeTxLabels](#function-upgradetxlabels) |
6192
+ | [isValidProcessingTransition](#function-isvalidprocessingtransition) | [purgeDataIdb](#function-purgedataidb) | [upgradeTxLabelsMap](#function-upgradetxlabelsmap) |
6193
+ | [keyOffsetToHashedSecret](#function-keyoffsettohashedsecret) | [redeemServiceCharges](#function-redeemservicecharges) | [upgradeUsers](#function-upgradeusers) |
6194
+ | [listActions](#function-listactions) | [releaseLease](#function-releaselease) | [validateDate](#function-validatedate) |
6195
+ | [listActionsIdb](#function-listactionsidb) | [renderAdminPage](#function-renderadminpage) | [validateEntities](#function-validateentities) |
6196
+ | [listAuditForTransaction](#function-listauditfortransaction) | [renewLease](#function-renewlease) | [validateEntity](#function-validateentity) |
6197
+ | [listCertificates](#function-listcertificates) | [reviewStatus](#function-reviewstatus) | [validateGenerateChangeSdkParams](#function-validategeneratechangesdkparams) |
6198
+ | [listOutputs](#function-listoutputs) | [reviewStatusIdb](#function-reviewstatusidb) | [validateGenerateChangeSdkResult](#function-validategeneratechangesdkresult) |
6199
+ | [listOutputsIdb](#function-listoutputsidb) | [setChainTip](#function-setchaintip) | [validateProcessingTransition](#function-validateprocessingtransition) |
6200
+ | [lockScriptWithKeyOffsetFromPubKey](#function-lockscriptwithkeyoffsetfrompubkey) | [setDisableDoubleSpendCheckForTest](#function-setdisabledoublespendcheckfortest) | [validateStorageFeeModel](#function-validatestoragefeemodel) |
6201
+ | [mapActionRow](#function-mapactionrow) | [shareReqsWithWorld](#function-sharereqswithworld) | [validateSyncChunkEntities](#function-validatesyncchunkentities) |
6202
+ | [mapTransactionRow](#function-maptransactionrow) | [transactionInputSize](#function-transactioninputsize) | [varUintSize](#function-varuintsize) |
4620
6203
 
4621
6204
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4622
6205
 
4623
6206
  ---
4624
6207
 
6208
+ ##### Function: appendTxAudit
6209
+
6210
+ ```ts
6211
+ export async function appendTxAudit(knex: Knex, ev: AuditEvent, now: Date = new Date()): Promise<number>
6212
+ ```
6213
+
6214
+ See also: [AuditEvent](./storage.md#interface-auditevent)
6215
+
6216
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6217
+
6218
+ ---
4625
6219
  ##### Function: attemptToPostReqsToNetwork
4626
6220
 
4627
6221
  Attempt to post one or more `ProvenTxReq` with status 'unsent'
@@ -4635,6 +6229,39 @@ See also: [EntityProvenTxReq](./storage.md#class-entityproventxreq), [PostReqsTo
4635
6229
 
4636
6230
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4637
6231
 
6232
+ ---
6233
+ ##### Function: auditProcessingTransition
6234
+
6235
+ Convenience helper for processing transitions. Validates the move first;
6236
+ on rejection it still records the attempt with `event = 'processing.rejected'`
6237
+ so the audit trail captures impossible transitions for later diagnosis.
6238
+
6239
+ Returns `true` when the transition is legal (audit row written with
6240
+ `processing.changed`) and `false` when rejected (audit row written with
6241
+ `processing.rejected`).
6242
+
6243
+ ```ts
6244
+ export async function auditProcessingTransition(knex: Knex, transactionId: number, from: sdk.ProcessingStatus, to: sdk.ProcessingStatus, details?: Record<string, unknown>, now: Date = new Date()): Promise<boolean>
6245
+ ```
6246
+
6247
+ See also: [ProcessingStatus](./client.md#type-processingstatus)
6248
+
6249
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6250
+
6251
+ ---
6252
+ ##### Function: classifyReqStatus
6253
+
6254
+ Classify a ProvenTxReq status into beef-sharing lifecycle status.
6255
+ Mutates `d` in place.
6256
+
6257
+ ```ts
6258
+ export function classifyReqStatus(d: GetReqsAndBeefDetail, req: TableProvenTxReq): void
6259
+ ```
6260
+
6261
+ See also: [GetReqsAndBeefDetail](./storage.md#interface-getreqsandbeefdetail), [TableProvenTxReq](./storage.md#interface-tableproventxreq)
6262
+
6263
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6264
+
4638
6265
  ---
4639
6266
  ##### Function: createAction
4640
6267
 
@@ -4669,6 +6296,15 @@ See also: [SyncMap](./storage.md#interface-syncmap)
4669
6296
 
4670
6297
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4671
6298
 
6299
+ ---
6300
+ ##### Function: dateMatches
6301
+
6302
+ ```ts
6303
+ export function dateMatches(a: Date | undefined, b: Date | undefined): boolean
6304
+ ```
6305
+
6306
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6307
+
4672
6308
  ---
4673
6309
  ##### Function: determineDBType
4674
6310
 
@@ -4684,6 +6320,45 @@ connected database engine variant
4684
6320
 
4685
6321
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4686
6322
 
6323
+ ---
6324
+ ##### Function: findAction
6325
+
6326
+ Find an action row by `(userId, transactionId)`.
6327
+
6328
+ ```ts
6329
+ export async function findAction(knex: Knex, userId: number, transactionId: number): Promise<TableAction | undefined>
6330
+ ```
6331
+
6332
+ See also: [TableAction](./storage.md#interface-tableaction)
6333
+
6334
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6335
+
6336
+ ---
6337
+ ##### Function: findTransactionNew
6338
+
6339
+ Read a single `transactions` (new canonical) row by PK.
6340
+
6341
+ ```ts
6342
+ export async function findTransactionNew(knex: Knex, transactionId: number): Promise<TableTransactionNew | undefined>
6343
+ ```
6344
+
6345
+ See also: [TableTransactionNew](./storage.md#interface-tabletransactionnew)
6346
+
6347
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6348
+
6349
+ ---
6350
+ ##### Function: findTransactionNewByTxid
6351
+
6352
+ Read a single `transactions` (new canonical) row by txid, returning `undefined` if absent.
6353
+
6354
+ ```ts
6355
+ export async function findTransactionNewByTxid(knex: Knex, txid: string): Promise<TableTransactionNew | undefined>
6356
+ ```
6357
+
6358
+ See also: [TableTransactionNew](./storage.md#interface-tabletransactionnew)
6359
+
6360
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6361
+
4687
6362
  ---
4688
6363
  ##### Function: generateChangeSdk
4689
6364
 
@@ -4747,6 +6422,19 @@ Argument Details
4747
6422
 
4748
6423
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4749
6424
 
6425
+ ---
6426
+ ##### Function: getChainTip
6427
+
6428
+ Get the singleton chain tip row (`id = 1`).
6429
+
6430
+ ```ts
6431
+ export async function getChainTip(knex: Knex): Promise<TableChainTip | undefined>
6432
+ ```
6433
+
6434
+ See also: [TableChainTip](./storage.md#interface-tablechaintip)
6435
+
6436
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6437
+
4750
6438
  ---
4751
6439
  ##### Function: getListOutputsSpecOp
4752
6440
 
@@ -4777,6 +6465,57 @@ See also: [RequestSyncChunkArgs](./client.md#interface-requestsyncchunkargs), [S
4777
6465
 
4778
6466
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4779
6467
 
6468
+ ---
6469
+ ##### Function: indexFromMerklePath
6470
+
6471
+ High-level service over the new-schema storage primitives.
6472
+
6473
+ Storage methods and the Monitor call into this surface rather than the
6474
+ lower-level CRUD/FSM/audit/lease modules so that:
6475
+ - Every processing transition is audited.
6476
+ - Optimistic concurrency is uniformly enforced.
6477
+ - Chain tip + monitor lease access have one canonical entry point.
6478
+
6479
+ Construction takes a Knex handle; instances are stateless and cheap to
6480
+ create — typically one per request or per Monitor task tick.
6481
+
6482
+ Extract the merkle leaf index for `txid` from a BUMP-encoded merkle path.
6483
+
6484
+ The BUMP format encodes level 0 leaves with `txid: true` and an `offset`
6485
+ equal to the position of the transaction in its block. For a single-tx
6486
+ proof exactly one leaf is flagged; for trimmed compound proofs the leaf
6487
+ matching `txid` is selected.
6488
+
6489
+ ```ts
6490
+ export function indexFromMerklePath(merklePath: number[], txid: string): number
6491
+ ```
6492
+
6493
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6494
+
6495
+ ---
6496
+ ##### Function: insertAction
6497
+
6498
+ ```ts
6499
+ export async function insertAction(knex: Knex, row: Omit<TableAction, "actionId" | "created_at" | "updated_at">, now: Date = new Date()): Promise<number>
6500
+ ```
6501
+
6502
+ See also: [TableAction](./storage.md#interface-tableaction)
6503
+
6504
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6505
+
6506
+ ---
6507
+ ##### Function: insertTransactionNew
6508
+
6509
+ Insert a new `transactions` (new canonical) row. Caller supplies the full body.
6510
+
6511
+ ```ts
6512
+ export async function insertTransactionNew(knex: Knex, row: Omit<TableTransactionNew, "transactionId" | "created_at" | "updated_at">, now: Date = new Date()): Promise<number>
6513
+ ```
6514
+
6515
+ See also: [TableTransactionNew](./storage.md#interface-tabletransactionnew)
6516
+
6517
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6518
+
4780
6519
  ---
4781
6520
  ##### Function: internalizeAction
4782
6521
 
@@ -4813,6 +6552,49 @@ See also: [AuthId](./client.md#interface-authid), [StorageInternalizeActionResul
4813
6552
 
4814
6553
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4815
6554
 
6555
+ ---
6556
+ ##### Function: isProcessingSpendable
6557
+
6558
+ True when the given state implies the transaction has been seen / accepted
6559
+ by at least one network provider — the precondition for output spendability
6560
+ in §4.
6561
+
6562
+ ```ts
6563
+ export function isProcessingSpendable(s: sdk.ProcessingStatus): boolean
6564
+ ```
6565
+
6566
+ See also: [ProcessingStatus](./client.md#type-processingstatus)
6567
+
6568
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6569
+
6570
+ ---
6571
+ ##### Function: isProcessingTerminal
6572
+
6573
+ True when the state is terminal (no further automatic transitions).
6574
+
6575
+ ```ts
6576
+ export function isProcessingTerminal(s: sdk.ProcessingStatus): boolean
6577
+ ```
6578
+
6579
+ See also: [ProcessingStatus](./client.md#type-processingstatus)
6580
+
6581
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6582
+
6583
+ ---
6584
+ ##### Function: isValidProcessingTransition
6585
+
6586
+ Returns true when `from -> to` is a permitted processing transition.
6587
+ Identity transitions (`from === to`) are always allowed — they represent a
6588
+ status refresh without state change.
6589
+
6590
+ ```ts
6591
+ export function isValidProcessingTransition(from: sdk.ProcessingStatus, to: sdk.ProcessingStatus): boolean
6592
+ ```
6593
+
6594
+ See also: [ProcessingStatus](./client.md#type-processingstatus)
6595
+
6596
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6597
+
4816
6598
  ---
4817
6599
  ##### Function: keyOffsetToHashedSecret
4818
6600
 
@@ -4847,6 +6629,19 @@ See also: [AuthId](./client.md#interface-authid), [StorageIdb](./storage.md#clas
4847
6629
 
4848
6630
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4849
6631
 
6632
+ ---
6633
+ ##### Function: listAuditForTransaction
6634
+
6635
+ Read all audit rows for a transaction, oldest first. Useful for tests.
6636
+
6637
+ ```ts
6638
+ export async function listAuditForTransaction(knex: Knex, transactionId: number): Promise<TableTxAudit[]>
6639
+ ```
6640
+
6641
+ See also: [TableTxAudit](./storage.md#interface-tabletxaudit)
6642
+
6643
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6644
+
4850
6645
  ---
4851
6646
  ##### Function: listCertificates
4852
6647
 
@@ -4893,67 +6688,108 @@ export function lockScriptWithKeyOffsetFromPubKey(pubKey: string, keyOffset?: st
4893
6688
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4894
6689
 
4895
6690
  ---
4896
- ##### Function: offsetPrivKey
6691
+ ##### Function: mapActionRow
4897
6692
 
4898
6693
  ```ts
4899
- export function offsetPrivKey(privKey: string, keyOffset?: string): {
4900
- offsetPrivKey: string;
4901
- keyOffset: string;
4902
- }
6694
+ export function mapActionRow(row: any): TableAction
4903
6695
  ```
4904
6696
 
6697
+ See also: [TableAction](./storage.md#interface-tableaction)
6698
+
4905
6699
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4906
6700
 
4907
6701
  ---
4908
- ##### Function: offsetPubKey
6702
+ ##### Function: mapTransactionRow
4909
6703
 
4910
6704
  ```ts
4911
- export function offsetPubKey(pubKey: string, keyOffset?: string): {
4912
- offsetPubKey: string;
4913
- keyOffset: string;
4914
- }
6705
+ export function mapTransactionRow(row: any): TableTransactionNew
4915
6706
  ```
4916
6707
 
6708
+ See also: [TableTransactionNew](./storage.md#interface-tabletransactionnew)
6709
+
4917
6710
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4918
6711
 
4919
6712
  ---
4920
- ##### Function: processAction
6713
+ ##### Function: markStaleInputsAsSpent
6714
+
6715
+ After any failed broadcast (doubleSpend, invalidTx, etc.), query each
6716
+ consumed-input outpoint of the failed transaction against on-chain
6717
+ UTXO state. For inputs the chain authoritatively confirms are spent
6718
+ (i.e. NOT a UTXO), update the corresponding wallet basket entry to
6719
+ spendable=false.
6720
+
6721
+ Background: `updateTransactionStatus(failed)` optimistically restores
6722
+ all consumed-input outputs to spendable=true so the user can retry
6723
+ with the same inputs. For some failures (genuine doubleSpend, or any
6724
+ 'missing-inputs' outcome where the input has been spent on chain by
6725
+ a different transaction), restoration is incorrect — the input is
6726
+ gone and restoring it produces an infinite missing-inputs loop on
6727
+ the next createAction → broadcast cycle. Apps cannot evict from the
6728
+ default basket on app-isolated wallets (admin-only policy), so this
6729
+ self-heal must run inside the wallet.
6730
+
6731
+ Different broadcasters classify the same on-chain reality differently
6732
+ (ARC → doubleSpend, WhatsOnChain/Bitails → invalidTx via
6733
+ 'missing-inputs'); this helper is broadcaster-agnostic because its
6734
+ decision is based on services.isUtxo, not the aggregate failure
6735
+ classification.
6736
+
6737
+ Pre-broadcast races where concurrent createActions reach the same
6738
+ UTXO across separate app processes are out of scope; see PR
6739
+ description.
6740
+
6741
+ Conservatively scoped:
6742
+ - Only inputs found in the failing user's basket are touched.
6743
+ - Inputs whose on-chain UTXO status cannot be determined (service
6744
+ error / inconclusive) are left spendable=true. Eviction is opt-in
6745
+ based on positive evidence of stale state.
6746
+ - Inputs the chain confirms are still UTXOs (e.g. a competing tx
6747
+ itself failed, or a malformed/fee failure where inputs are intact)
6748
+ are left spendable=true — preserving the existing transient-retry
6749
+ semantics callers depend on.
6750
+
6751
+ Returns counts for instrumentation and the set of stale outpoints
6752
+ that were actually evicted (added to history note for diagnostics).
4921
6753
 
4922
6754
  ```ts
4923
- export async function processAction(storage: StorageProvider, auth: AuthId, args: StorageProcessActionArgs): Promise<StorageProcessActionResults>
6755
+ export async function markStaleInputsAsSpent(ar: AggregatePostBeefTxResult, storage: StorageProvider, services: sdk.WalletServices, trx?: sdk.TrxToken, logger?: WalletLoggerInterface): Promise<{
6756
+ checked: number;
6757
+ staleConfirmed: number;
6758
+ staleOutpoints: string[];
6759
+ }>
4924
6760
  ```
4925
6761
 
4926
- See also: [AuthId](./client.md#interface-authid), [StorageProcessActionArgs](./client.md#interface-storageprocessactionargs), [StorageProcessActionResults](./client.md#interface-storageprocessactionresults), [StorageProvider](./storage.md#class-storageprovider)
6762
+ See also: [AggregatePostBeefTxResult](./storage.md#interface-aggregatepostbeeftxresult), [StorageProvider](./storage.md#class-storageprovider), [TrxToken](./client.md#interface-trxtoken), [WalletServices](./client.md#interface-walletservices), [logger](./client.md#variable-logger)
4927
6763
 
4928
6764
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4929
6765
 
4930
6766
  ---
4931
- ##### Function: purgeData
6767
+ ##### Function: matchesCertificateFieldPartial
4932
6768
 
4933
6769
  ```ts
4934
- export async function purgeData(storage: StorageKnex, params: PurgeParams, trx?: TrxToken): Promise<PurgeResults>
6770
+ export function matchesCertificateFieldPartial(r: TableCertificateField, partial: Partial<TableCertificateField>): boolean
4935
6771
  ```
4936
6772
 
4937
- See also: [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [StorageKnex](./storage.md#class-storageknex), [TrxToken](./client.md#interface-trxtoken)
6773
+ See also: [TableCertificateField](./storage.md#interface-tablecertificatefield)
4938
6774
 
4939
6775
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4940
6776
 
4941
6777
  ---
4942
- ##### Function: purgeDataIdb
6778
+ ##### Function: matchesCertificatePartial
4943
6779
 
4944
6780
  ```ts
4945
- export async function purgeDataIdb(storage: StorageIdb, params: PurgeParams, trx?: TrxToken): Promise<PurgeResults>
6781
+ export function matchesCertificatePartial(r: TableCertificate, partial: Partial<TableCertificate>): boolean
4946
6782
  ```
4947
6783
 
4948
- See also: [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [StorageIdb](./storage.md#class-storageidb), [TrxToken](./client.md#interface-trxtoken)
6784
+ See also: [TableCertificate](./storage.md#interface-tablecertificate)
4949
6785
 
4950
6786
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4951
6787
 
4952
6788
  ---
4953
- ##### Function: redeemServiceCharges
6789
+ ##### Function: matchesCommissionPartial
4954
6790
 
4955
6791
  ```ts
4956
- export function redeemServiceCharges(privateKeyWif: string, charges: TableCommission[]): {}[]
6792
+ export function matchesCommissionPartial(r: TableCommission, partial: Partial<TableCommission>): boolean
4957
6793
  ```
4958
6794
 
4959
6795
  See also: [TableCommission](./storage.md#interface-tablecommission)
@@ -4961,147 +6797,809 @@ See also: [TableCommission](./storage.md#interface-tablecommission)
4961
6797
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4962
6798
 
4963
6799
  ---
4964
- ##### Function: renderAdminPage
6800
+ ##### Function: matchesMonitorEventPartial
4965
6801
 
4966
6802
  ```ts
4967
- export function renderAdminPage(): string
6803
+ export function matchesMonitorEventPartial(r: TableMonitorEvent, partial: Partial<TableMonitorEvent>): boolean
4968
6804
  ```
4969
6805
 
6806
+ See also: [TableMonitorEvent](./storage.md#interface-tablemonitorevent)
6807
+
4970
6808
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4971
6809
 
4972
6810
  ---
4973
- ##### Function: reviewStatus
4974
-
4975
- Looks for unpropagated state:
4976
-
4977
- 1. set transactions to 'failed' if not already failed and provenTxReq with matching txid has status of 'invalid'.
4978
- 2. sets outputs to spendable true, spentBy undefined if spentBy is a transaction with status 'failed'.
4979
- 3. sets transactions to 'completed' if provenTx with matching txid exists and current provenTxId is null.
6811
+ ##### Function: matchesOutputBasketPartial
4980
6812
 
4981
6813
  ```ts
4982
- export async function reviewStatus(storage: StorageKnex, args: {
4983
- agedLimit: Date;
4984
- trx?: TrxToken;
4985
- }): Promise<{
4986
- log: string;
4987
- }>
6814
+ export function matchesOutputBasketPartial(r: TableOutputBasket, partial: Partial<TableOutputBasket>): boolean
4988
6815
  ```
4989
6816
 
4990
- See also: [StorageKnex](./storage.md#class-storageknex), [TrxToken](./client.md#interface-trxtoken)
6817
+ See also: [TableOutputBasket](./storage.md#interface-tableoutputbasket)
4991
6818
 
4992
6819
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
4993
6820
 
4994
6821
  ---
4995
- ##### Function: reviewStatusIdb
4996
-
4997
- Looks for unpropagated state:
4998
-
4999
- 1. set transactions to 'failed' if not already failed and provenTxReq with matching txid has status of 'invalid'.
5000
- 2. sets transactions to 'completed' if provenTx with matching txid exists and current provenTxId is null.
5001
- 3. sets outputs to spendable true, spentBy undefined if spentBy is a transaction with status 'failed'.
6822
+ ##### Function: matchesOutputPartial
5002
6823
 
5003
6824
  ```ts
5004
- export async function reviewStatusIdb(storage: StorageIdb, args: {
5005
- agedLimit: Date;
5006
- trx?: sdk.TrxToken;
5007
- }): Promise<{
5008
- log: string;
5009
- }>
6825
+ export function matchesOutputPartial(r: TableOutput, partial: Partial<TableOutput>): boolean
5010
6826
  ```
5011
6827
 
5012
- See also: [StorageIdb](./storage.md#class-storageidb), [TrxToken](./client.md#interface-trxtoken)
6828
+ See also: [TableOutput](./storage.md#interface-tableoutput)
5013
6829
 
5014
6830
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5015
6831
 
5016
6832
  ---
5017
- ##### Function: setDisableDoubleSpendCheckForTest
6833
+ ##### Function: matchesOutputTagMapPartial
5018
6834
 
5019
6835
  ```ts
5020
- export function setDisableDoubleSpendCheckForTest(v: boolean)
6836
+ export function matchesOutputTagMapPartial(r: TableOutputTagMap, partial: Partial<TableOutputTagMap>): boolean
5021
6837
  ```
5022
6838
 
6839
+ See also: [TableOutputTagMap](./storage.md#interface-tableoutputtagmap)
6840
+
5023
6841
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5024
6842
 
5025
6843
  ---
5026
- ##### Function: shareReqsWithWorld
5027
-
5028
- Verifies that all the txids are known reqs with ready-to-share status.
5029
- Assigns a batch identifier and updates all the provenTxReqs.
5030
- If not isDelayed, triggers an initial attempt to broadcast the batch and returns the results.
6844
+ ##### Function: matchesOutputTagPartial
5031
6845
 
5032
6846
  ```ts
5033
- export async function shareReqsWithWorld(storage: StorageProvider, userId: number, txids: string[], isDelayed: boolean, r?: GetReqsAndBeefResult, logger?: WalletLoggerInterface): Promise<{
5034
- swr: SendWithResult[];
5035
- ndr: ReviewActionResult[] | undefined;
5036
- }>
6847
+ export function matchesOutputTagPartial(r: TableOutputTag, partial: Partial<TableOutputTag>): boolean
5037
6848
  ```
5038
6849
 
5039
- See also: [GetReqsAndBeefResult](./storage.md#interface-getreqsandbeefresult), [ReviewActionResult](./client.md#interface-reviewactionresult), [StorageProvider](./storage.md#class-storageprovider), [logger](./client.md#variable-logger)
5040
-
5041
- Argument Details
5042
-
5043
- + **r**
5044
- + Optional. Ignores txids and allows ProvenTxReqs and merged beef to be passed in.
6850
+ See also: [TableOutputTag](./storage.md#interface-tableoutputtag)
5045
6851
 
5046
6852
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5047
6853
 
5048
6854
  ---
5049
- ##### Function: transactionInputSize
6855
+ ##### Function: matchesProvenTxPartial
5050
6856
 
5051
6857
  ```ts
5052
- export function transactionInputSize(scriptSize: number): number
6858
+ export function matchesProvenTxPartial(r: TableProvenTx, partial: Partial<TableProvenTx>): boolean
5053
6859
  ```
5054
6860
 
5055
- Returns
5056
-
5057
- serialized byte length a transaction input
5058
-
5059
- Argument Details
5060
-
5061
- + **scriptSize**
5062
- + byte length of input script
6861
+ See also: [TableProvenTx](./storage.md#interface-tableproventx)
5063
6862
 
5064
6863
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5065
6864
 
5066
6865
  ---
5067
- ##### Function: transactionOutputSize
6866
+ ##### Function: matchesProvenTxReqPartial
5068
6867
 
5069
6868
  ```ts
5070
- export function transactionOutputSize(scriptSize: number): number
6869
+ export function matchesProvenTxReqPartial(r: TableProvenTxReq, partial: Partial<TableProvenTxReq>): boolean
5071
6870
  ```
5072
6871
 
5073
- Returns
6872
+ See also: [TableProvenTxReq](./storage.md#interface-tableproventxreq)
5074
6873
 
5075
- serialized byte length a transaction output
6874
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5076
6875
 
5077
- Argument Details
6876
+ ---
6877
+ ##### Function: matchesSyncStatePartial
5078
6878
 
5079
- + **scriptSize**
5080
- + byte length of output script
6879
+ ```ts
6880
+ export function matchesSyncStatePartial(r: TableSyncState, partial: Partial<TableSyncState>): boolean
6881
+ ```
6882
+
6883
+ See also: [TableSyncState](./storage.md#interface-tablesyncstate)
5081
6884
 
5082
6885
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5083
6886
 
5084
6887
  ---
5085
- ##### Function: transactionSize
6888
+ ##### Function: matchesTransactionPartial
6889
+
6890
+ ```ts
6891
+ export function matchesTransactionPartial(r: TableTransaction, partial: Partial<TableTransaction>): boolean
6892
+ ```
6893
+
6894
+ See also: [TableTransaction](./storage.md#interface-tabletransaction)
6895
+
6896
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6897
+
6898
+ ---
6899
+ ##### Function: matchesTxLabelMapPartial
6900
+
6901
+ ```ts
6902
+ export function matchesTxLabelMapPartial(r: TableTxLabelMap, partial: Partial<TableTxLabelMap>): boolean
6903
+ ```
6904
+
6905
+ See also: [TableTxLabelMap](./storage.md#interface-tabletxlabelmap)
6906
+
6907
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6908
+
6909
+ ---
6910
+ ##### Function: matchesTxLabelPartial
6911
+
6912
+ ```ts
6913
+ export function matchesTxLabelPartial(r: TableTxLabel, partial: Partial<TableTxLabel>): boolean
6914
+ ```
6915
+
6916
+ See also: [TableTxLabel](./storage.md#interface-tabletxlabel)
6917
+
6918
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6919
+
6920
+ ---
6921
+ ##### Function: mergeInputBeefs
6922
+
6923
+ For each input of `rawTx`, ensure the source txid is represented in `beef`.
6924
+
6925
+ When `requiredLevels` is undefined/0 and `knownTxids` contains the source txid,
6926
+ a txid-only stub is merged rather than recursing into storage.
6927
+
6928
+ ```ts
6929
+ export async function mergeInputBeefs(rawTx: number[], beef: Beef, trustSelf: "known" | undefined, knownTxids: string[] | undefined, trx: TrxToken | undefined, requiredLevels: number | undefined, getValidBeef: (txid: string, beef: Beef, trustSelf: "known" | undefined, knownTxids: string[] | undefined, trx: TrxToken | undefined, requiredLevels: number | undefined) => Promise<unknown>): Promise<void>
6930
+ ```
6931
+
6932
+ See also: [TrxToken](./client.md#interface-trxtoken)
6933
+
6934
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6935
+
6936
+ ---
6937
+ ##### Function: mergeInputsIntoBeef
6938
+
6939
+ Convenience wrapper for the external-sharing path where `trustSelf` and
6940
+ `requiredLevels` are always absent.
6941
+
6942
+ ```ts
6943
+ export async function mergeInputsIntoBeef(rawTx: number[], beef: Beef, knownTxids: string[], trx: TrxToken | undefined, getValidBeef: (txid: string, beef: Beef, trustSelf: undefined, knownTxids: string[], trx: TrxToken | undefined) => Promise<unknown>): Promise<void>
6944
+ ```
6945
+
6946
+ See also: [TrxToken](./client.md#interface-trxtoken)
6947
+
6948
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6949
+
6950
+ ---
6951
+ ##### Function: notifyTransactionsOfProof
6952
+
6953
+ Notify each transaction that a proof has been found.
6954
+ Mutates `req` history notes in place.
6955
+
6956
+ The `addNote` and `flushNotes` callbacks avoid coupling this helper to a
6957
+ specific entity type.
6958
+
6959
+ ```ts
6960
+ export async function notifyTransactionsOfProof(ids: number[], provenTxId: number, addNote: (note: ReqHistoryNote) => void, flushNotes: () => Promise<void>, updateTransaction: (id: number, update: {
6961
+ provenTxId: number;
6962
+ status: "completed";
6963
+ }) => Promise<unknown>): Promise<void>
6964
+ ```
6965
+
6966
+ See also: [ReqHistoryNote](./client.md#interface-reqhistorynote)
6967
+
6968
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6969
+
6970
+ ---
6971
+ ##### Function: offsetPrivKey
6972
+
6973
+ ```ts
6974
+ export function offsetPrivKey(privKey: string, keyOffset?: string): {
6975
+ offsetPrivKey: string;
6976
+ keyOffset: string;
6977
+ }
6978
+ ```
6979
+
6980
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6981
+
6982
+ ---
6983
+ ##### Function: offsetPubKey
6984
+
6985
+ ```ts
6986
+ export function offsetPubKey(pubKey: string, keyOffset?: string): {
6987
+ offsetPubKey: string;
6988
+ keyOffset: string;
6989
+ }
6990
+ ```
6991
+
6992
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
6993
+
6994
+ ---
6995
+ ##### Function: partitionActionLabels
6996
+
6997
+ ```ts
6998
+ export function partitionActionLabels(ordinaryLabels: string[]): {
6999
+ specOp: ListActionsSpecOp | undefined;
7000
+ specOpLabels: string[];
7001
+ labels: string[];
7002
+ }
7003
+ ```
7004
+
7005
+ See also: [ListActionsSpecOp](./storage.md#interface-listactionsspecop)
7006
+
7007
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7008
+
7009
+ ---
7010
+ ##### Function: processAction
7011
+
7012
+ ```ts
7013
+ export async function processAction(storage: StorageProvider, auth: AuthId, args: StorageProcessActionArgs): Promise<StorageProcessActionResults>
7014
+ ```
7015
+
7016
+ See also: [AuthId](./client.md#interface-authid), [StorageProcessActionArgs](./client.md#interface-storageprocessactionargs), [StorageProcessActionResults](./client.md#interface-storageprocessactionresults), [StorageProvider](./storage.md#class-storageprovider)
7017
+
7018
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7019
+
7020
+ ---
7021
+ ##### Function: processingTransitionMap
7022
+
7023
+ Snapshot of the transition table for documentation + tests.
7024
+
7025
+ ```ts
7026
+ export function processingTransitionMap(): Readonly<Record<sdk.ProcessingStatus, readonly sdk.ProcessingStatus[]>>
7027
+ ```
7028
+
7029
+ See also: [ProcessingStatus](./client.md#type-processingstatus)
7030
+
7031
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7032
+
7033
+ ---
7034
+ ##### Function: purgeData
7035
+
7036
+ ```ts
7037
+ export async function purgeData(storage: StorageKnex, params: PurgeParams, trx?: TrxToken): Promise<PurgeResults>
7038
+ ```
7039
+
7040
+ See also: [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [StorageKnex](./storage.md#class-storageknex), [TrxToken](./client.md#interface-trxtoken)
7041
+
7042
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7043
+
7044
+ ---
7045
+ ##### Function: purgeDataIdb
7046
+
7047
+ ```ts
7048
+ export async function purgeDataIdb(storage: StorageIdb, params: PurgeParams, trx?: TrxToken): Promise<PurgeResults>
7049
+ ```
7050
+
7051
+ See also: [PurgeParams](./client.md#interface-purgeparams), [PurgeResults](./client.md#interface-purgeresults), [StorageIdb](./storage.md#class-storageidb), [TrxToken](./client.md#interface-trxtoken)
7052
+
7053
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7054
+
7055
+ ---
7056
+ ##### Function: redeemServiceCharges
7057
+
7058
+ ```ts
7059
+ export function redeemServiceCharges(privateKeyWif: string, charges: TableCommission[]): Array<{}>
7060
+ ```
7061
+
7062
+ See also: [TableCommission](./storage.md#interface-tablecommission)
7063
+
7064
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7065
+
7066
+ ---
7067
+ ##### Function: releaseLease
7068
+
7069
+ Release the lease (no-op when not owned by the caller).
7070
+ The row is deleted so subsequent claimants do not see an inherited
7071
+ `renew_count`.
7072
+
7073
+ ```ts
7074
+ export async function releaseLease(knex: Knex, release: MonitorLeaseRelease): Promise<boolean>
7075
+ ```
7076
+
7077
+ See also: [MonitorLeaseRelease](./monitor.md#interface-monitorleaserelease)
7078
+
7079
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7080
+
7081
+ ---
7082
+ ##### Function: renderAdminPage
7083
+
7084
+ ```ts
7085
+ export function renderAdminPage(): string
7086
+ ```
7087
+
7088
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7089
+
7090
+ ---
7091
+ ##### Function: renewLease
7092
+
7093
+ Extend the current owner's lease. Fails (returns `acquired: false`) when the
7094
+ row does not exist, is owned by someone else, or has already expired.
7095
+
7096
+ ```ts
7097
+ export async function renewLease(knex: Knex, renew: MonitorLeaseRenew, now: Date = new Date()): Promise<MonitorLeaseResult>
7098
+ ```
7099
+
7100
+ See also: [MonitorLeaseRenew](./monitor.md#interface-monitorleaserenew), [MonitorLeaseResult](./monitor.md#interface-monitorleaseresult)
7101
+
7102
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7103
+
7104
+ ---
7105
+ ##### Function: reviewStatus
7106
+
7107
+ Looks for unpropagated state:
7108
+
7109
+ 1. set transactions to 'failed' if not already failed and provenTxReq with matching txid has status of 'invalid'.
7110
+ 2. sets outputs to spendable true, spentBy undefined if spentBy is a transaction with status 'failed'.
7111
+ 3. sets transactions to 'completed' if provenTx with matching txid exists and current provenTxId is null.
7112
+
7113
+ ```ts
7114
+ export async function reviewStatus(storage: StorageKnex, args: {
7115
+ agedLimit: Date;
7116
+ trx?: TrxToken;
7117
+ }): Promise<{
7118
+ log: string;
7119
+ }>
7120
+ ```
7121
+
7122
+ See also: [StorageKnex](./storage.md#class-storageknex), [TrxToken](./client.md#interface-trxtoken)
7123
+
7124
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7125
+
7126
+ ---
7127
+ ##### Function: reviewStatusIdb
7128
+
7129
+ Looks for unpropagated state:
7130
+
7131
+ 1. set transactions to 'failed' if not already failed and provenTxReq with matching txid has status of 'invalid'.
7132
+ 2. sets transactions to 'completed' if provenTx with matching txid exists and current provenTxId is null.
7133
+ 3. sets outputs to spendable true, spentBy undefined if spentBy is a transaction with status 'failed'.
7134
+
7135
+ ```ts
7136
+ export async function reviewStatusIdb(storage: StorageIdb, args: {
7137
+ agedLimit: Date;
7138
+ trx?: sdk.TrxToken;
7139
+ }): Promise<{
7140
+ log: string;
7141
+ }>
7142
+ ```
7143
+
7144
+ See also: [StorageIdb](./storage.md#class-storageidb), [TrxToken](./client.md#interface-trxtoken)
7145
+
7146
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7147
+
7148
+ ---
7149
+ ##### Function: setChainTip
7150
+
7151
+ Upsert the singleton chain tip. Always uses `id = 1`.
7152
+
7153
+ ```ts
7154
+ export async function setChainTip(knex: Knex, args: {
7155
+ height: number;
7156
+ blockHash: string;
7157
+ merkleRoot?: string;
7158
+ }, now: Date = new Date()): Promise<void>
7159
+ ```
7160
+
7161
+ See also: [blockHash](./services.md#function-blockhash)
7162
+
7163
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7164
+
7165
+ ---
7166
+ ##### Function: setDisableDoubleSpendCheckForTest
7167
+
7168
+ ```ts
7169
+ export function setDisableDoubleSpendCheckForTest(v: boolean)
7170
+ ```
7171
+
7172
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7173
+
7174
+ ---
7175
+ ##### Function: shareReqsWithWorld
7176
+
7177
+ ```ts
7178
+ export async function shareReqsWithWorld(storage: StorageProvider, userId: number, txids: string[], isDelayed: boolean, r?: GetReqsAndBeefResult, logger?: WalletLoggerInterface): Promise<{
7179
+ swr: SendWithResult[];
7180
+ ndr: ReviewActionResult[] | undefined;
7181
+ }>
7182
+ ```
7183
+
7184
+ See also: [GetReqsAndBeefResult](./storage.md#interface-getreqsandbeefresult), [ReviewActionResult](./client.md#interface-reviewactionresult), [StorageProvider](./storage.md#class-storageprovider), [logger](./client.md#variable-logger)
7185
+
7186
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7187
+
7188
+ ---
7189
+ ##### Function: transactionInputSize
7190
+
7191
+ ```ts
7192
+ export function transactionInputSize(scriptSize: number): number
7193
+ ```
7194
+
7195
+ Returns
7196
+
7197
+ serialized byte length a transaction input
7198
+
7199
+ Argument Details
7200
+
7201
+ + **scriptSize**
7202
+ + byte length of input script
7203
+
7204
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7205
+
7206
+ ---
7207
+ ##### Function: transactionOutputSize
7208
+
7209
+ ```ts
7210
+ export function transactionOutputSize(scriptSize: number): number
7211
+ ```
7212
+
7213
+ Returns
7214
+
7215
+ serialized byte length a transaction output
7216
+
7217
+ Argument Details
7218
+
7219
+ + **scriptSize**
7220
+ + byte length of output script
7221
+
7222
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7223
+
7224
+ ---
7225
+ ##### Function: transactionSize
5086
7226
 
5087
7227
  Compute the serialized binary transaction size in bytes
5088
7228
  given the number of inputs and outputs,
5089
7229
  and the size of each script.
5090
7230
 
5091
7231
  ```ts
5092
- export function transactionSize(inputs: number[], outputs: number[]): number
7232
+ export function transactionSize(inputs: number[], outputs: number[]): number
7233
+ ```
7234
+
7235
+ Returns
7236
+
7237
+ total transaction size in bytes
7238
+
7239
+ Argument Details
7240
+
7241
+ + **inputs**
7242
+ + array of input script lengths, in bytes
7243
+ + **outputs**
7244
+ + array of output script lengths, in bytes
7245
+
7246
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7247
+
7248
+ ---
7249
+ ##### Function: transitionProcessing
7250
+
7251
+ Transition the processing column atomically and append a `tx_audit` row.
7252
+ Returns the new `TableTransactionNew` on success and `undefined` when the
7253
+ source state did not match the row (CAS failed) or the transition was
7254
+ rejected by the FSM.
7255
+
7256
+ Optimistic concurrency: the caller passes the `expectedFromState` they
7257
+ read in the same logical operation; the update only fires when the row's
7258
+ current `processing` still equals that value.
7259
+
7260
+ ```ts
7261
+ export async function transitionProcessing(knex: Knex, args: {
7262
+ transactionId: number;
7263
+ expectedFromState: sdk.ProcessingStatus;
7264
+ toState: sdk.ProcessingStatus;
7265
+ details?: Record<string, unknown>;
7266
+ provider?: string;
7267
+ providerStatus?: string;
7268
+ }, now: Date = new Date()): Promise<TableTransactionNew | undefined>
7269
+ ```
7270
+
7271
+ See also: [ProcessingStatus](./client.md#type-processingstatus), [TableTransactionNew](./storage.md#interface-tabletransactionnew)
7272
+
7273
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7274
+
7275
+ ---
7276
+ ##### Function: tryClaimLease
7277
+
7278
+ Try to claim a lease on `taskName`. Succeeds iff:
7279
+ - no row exists for the task, OR
7280
+ - the existing row has `expiresAt <= now`, OR
7281
+ - the existing row's `ownerId` already equals the requested owner.
7282
+
7283
+ On success the row is upserted with `expiresAt = now + ttlMs` and
7284
+ `renewCount = renewCount + 1` (0 for fresh rows).
7285
+
7286
+ ```ts
7287
+ export async function tryClaimLease(knex: Knex, claim: MonitorLeaseClaim, now: Date = new Date()): Promise<MonitorLeaseResult>
7288
+ ```
7289
+
7290
+ See also: [MonitorLeaseClaim](./monitor.md#interface-monitorleaseclaim), [MonitorLeaseResult](./monitor.md#interface-monitorleaseresult)
7291
+
7292
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7293
+
7294
+ ---
7295
+ ##### Function: updateReqsFromAggregateResults
7296
+
7297
+ For each txid in submitted `txids`:
7298
+
7299
+ Based on its aggregate status, and whether broadcast happening in background (isDelayed) or immediately (!isDelayed),
7300
+ and iff current req.status is not 'unproven' or 'completed':
7301
+
7302
+ 'success':
7303
+ req.status => 'unmined', tx.status => 'unproven'
7304
+ 'doubleSpend':
7305
+ req.status => 'doubleSpend', tx.status => 'failed'
7306
+ 'invalidTx':
7307
+ req.status => 'invalid', tx.status => 'failed'
7308
+ 'serviceError':
7309
+ increment req.attempts
7310
+
7311
+ ```ts
7312
+ export async function updateReqsFromAggregateResults(txids: string[], r: PostReqsToNetworkResult, apbrs: Record<string, AggregatePostBeefTxResult>, storage: StorageProvider, services?: sdk.WalletServices, trx?: sdk.TrxToken, logger?: WalletLoggerInterface): Promise<void>
7313
+ ```
7314
+
7315
+ See also: [AggregatePostBeefTxResult](./storage.md#interface-aggregatepostbeeftxresult), [PostReqsToNetworkResult](./storage.md#interface-postreqstonetworkresult), [StorageProvider](./storage.md#class-storageprovider), [TrxToken](./client.md#interface-trxtoken), [WalletServices](./client.md#interface-walletservices), [logger](./client.md#variable-logger)
7316
+
7317
+ Argument Details
7318
+
7319
+ + **services**
7320
+ + if valid, doubleSpend results will be verified (but only if not within a trx. e.g. trx must be undefined)
7321
+
7322
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7323
+
7324
+ ---
7325
+ ##### Function: upgradeActions
7326
+
7327
+ ```ts
7328
+ export function upgradeActions(db: IDBPDatabase<StorageIdbSchema>): void
7329
+ ```
7330
+
7331
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7332
+
7333
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7334
+
7335
+ ---
7336
+ ##### Function: upgradeAllStoresV1
7337
+
7338
+ Upgrade handler for every store that existed at schema version 1.
7339
+
7340
+ ```ts
7341
+ export function upgradeAllStoresV1(db: IDBPDatabase<StorageIdbSchema>): void
7342
+ ```
7343
+
7344
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7345
+
7346
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7347
+
7348
+ ---
7349
+ ##### Function: upgradeCertificateFields
7350
+
7351
+ ```ts
7352
+ export function upgradeCertificateFields(db: IDBPDatabase<StorageIdbSchema>): void
7353
+ ```
7354
+
7355
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7356
+
7357
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7358
+
7359
+ ---
7360
+ ##### Function: upgradeCertificates
7361
+
7362
+ ```ts
7363
+ export function upgradeCertificates(db: IDBPDatabase<StorageIdbSchema>): void
7364
+ ```
7365
+
7366
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7367
+
7368
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7369
+
7370
+ ---
7371
+ ##### Function: upgradeChainTip
7372
+
7373
+ ```ts
7374
+ export function upgradeChainTip(db: IDBPDatabase<StorageIdbSchema>): void
7375
+ ```
7376
+
7377
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7378
+
7379
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7380
+
7381
+ ---
7382
+ ##### Function: upgradeCommissions
7383
+
7384
+ ```ts
7385
+ export function upgradeCommissions(db: IDBPDatabase<StorageIdbSchema>): void
7386
+ ```
7387
+
7388
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7389
+
7390
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7391
+
7392
+ ---
7393
+ ##### Function: upgradeMonitorEvents
7394
+
7395
+ ```ts
7396
+ export function upgradeMonitorEvents(db: IDBPDatabase<StorageIdbSchema>): void
7397
+ ```
7398
+
7399
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7400
+
7401
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7402
+
7403
+ ---
7404
+ ##### Function: upgradeMonitorLease
7405
+
7406
+ ```ts
7407
+ export function upgradeMonitorLease(db: IDBPDatabase<StorageIdbSchema>): void
7408
+ ```
7409
+
7410
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7411
+
7412
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7413
+
7414
+ ---
7415
+ ##### Function: upgradeOutputBaskets
7416
+
7417
+ ```ts
7418
+ export function upgradeOutputBaskets(db: IDBPDatabase<StorageIdbSchema>): void
7419
+ ```
7420
+
7421
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7422
+
7423
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7424
+
7425
+ ---
7426
+ ##### Function: upgradeOutputTags
7427
+
7428
+ ```ts
7429
+ export function upgradeOutputTags(db: IDBPDatabase<StorageIdbSchema>): void
7430
+ ```
7431
+
7432
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7433
+
7434
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7435
+
7436
+ ---
7437
+ ##### Function: upgradeOutputTagsMap
7438
+
7439
+ ```ts
7440
+ export function upgradeOutputTagsMap(db: IDBPDatabase<StorageIdbSchema>): void
7441
+ ```
7442
+
7443
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7444
+
7445
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7446
+
7447
+ ---
7448
+ ##### Function: upgradeOutputs
7449
+
7450
+ ```ts
7451
+ export function upgradeOutputs(db: IDBPDatabase<StorageIdbSchema>): void
7452
+ ```
7453
+
7454
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7455
+
7456
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7457
+
7458
+ ---
7459
+ ##### Function: upgradeProvenTxReqs
7460
+
7461
+ ```ts
7462
+ export function upgradeProvenTxReqs(db: IDBPDatabase<StorageIdbSchema>): void
7463
+ ```
7464
+
7465
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7466
+
7467
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7468
+
7469
+ ---
7470
+ ##### Function: upgradeProvenTxs
7471
+
7472
+ ```ts
7473
+ export function upgradeProvenTxs(db: IDBPDatabase<StorageIdbSchema>): void
7474
+ ```
7475
+
7476
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7477
+
7478
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7479
+
7480
+ ---
7481
+ ##### Function: upgradeSyncStates
7482
+
7483
+ ```ts
7484
+ export function upgradeSyncStates(db: IDBPDatabase<StorageIdbSchema>): void
7485
+ ```
7486
+
7487
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7488
+
7489
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7490
+
7491
+ ---
7492
+ ##### Function: upgradeTransactions
7493
+
7494
+ ```ts
7495
+ export function upgradeTransactions(db: IDBPDatabase<StorageIdbSchema>): void
7496
+ ```
7497
+
7498
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7499
+
7500
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7501
+
7502
+ ---
7503
+ ##### Function: upgradeTransactionsNew
7504
+
7505
+ ```ts
7506
+ export function upgradeTransactionsNew(db: IDBPDatabase<StorageIdbSchema>): void
7507
+ ```
7508
+
7509
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7510
+
7511
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7512
+
7513
+ ---
7514
+ ##### Function: upgradeTxAudit
7515
+
7516
+ ```ts
7517
+ export function upgradeTxAudit(db: IDBPDatabase<StorageIdbSchema>): void
7518
+ ```
7519
+
7520
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7521
+
7522
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7523
+
7524
+ ---
7525
+ ##### Function: upgradeTxLabels
7526
+
7527
+ ```ts
7528
+ export function upgradeTxLabels(db: IDBPDatabase<StorageIdbSchema>): void
7529
+ ```
7530
+
7531
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7532
+
7533
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7534
+
7535
+ ---
7536
+ ##### Function: upgradeTxLabelsMap
7537
+
7538
+ ```ts
7539
+ export function upgradeTxLabelsMap(db: IDBPDatabase<StorageIdbSchema>): void
7540
+ ```
7541
+
7542
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7543
+
7544
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7545
+
7546
+ ---
7547
+ ##### Function: upgradeUsers
7548
+
7549
+ ```ts
7550
+ export function upgradeUsers(db: IDBPDatabase<StorageIdbSchema>): void
7551
+ ```
7552
+
7553
+ See also: [StorageIdbSchema](./storage.md#interface-storageidbschema)
7554
+
7555
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7556
+
7557
+ ---
7558
+ ##### Function: validateDate
7559
+
7560
+ Shared entity-validation helpers used by both client-side storage remoting
7561
+ (StorageClientBase / StorageMobile) and the server-side StorageServer.
7562
+
7563
+ These helpers normalise records returned from remote calls or database queries:
7564
+ - Coerce date strings / timestamps to `Date` objects.
7565
+ - Replace `null` values with `undefined`.
7566
+ - Replace `Uint8Array` / `Buffer` values with plain `number[]` arrays.
7567
+
7568
+ ```ts
7569
+ export function validateDate(date: Date | string | number): Date
7570
+ ```
7571
+
7572
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7573
+
7574
+ ---
7575
+ ##### Function: validateEntities
7576
+
7577
+ Force uniform behaviour across database engines.
7578
+ Use to process all arrays of records with timestamps retrieved from database.
7579
+
7580
+ ```ts
7581
+ export function validateEntities<T extends EntityTimeStamp>(entities: T[], dateFields?: string[]): T[]
5093
7582
  ```
5094
7583
 
7584
+ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp)
7585
+
5095
7586
  Returns
5096
7587
 
5097
- total transaction size in bytes
7588
+ input `entities` array with contained values validated.
5098
7589
 
5099
- Argument Details
7590
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5100
7591
 
5101
- + **inputs**
5102
- + array of input script lengths, in bytes
5103
- + **outputs**
5104
- + array of output script lengths, in bytes
7592
+ ---
7593
+ ##### Function: validateEntity
7594
+
7595
+ Force uniform behaviour across database engines.
7596
+ Use to process all individual records with timestamps retrieved from database.
7597
+
7598
+ ```ts
7599
+ export function validateEntity<T extends EntityTimeStamp>(entity: T, dateFields?: string[]): T
7600
+ ```
7601
+
7602
+ See also: [EntityTimeStamp](./client.md#interface-entitytimestamp)
5105
7603
 
5106
7604
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5107
7605
 
@@ -5130,6 +7628,20 @@ See also: [GenerateChangeSdkParams](./storage.md#interface-generatechangesdkpara
5130
7628
 
5131
7629
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5132
7630
 
7631
+ ---
7632
+ ##### Function: validateProcessingTransition
7633
+
7634
+ As `isValidProcessingTransition` but returns a structured result with a
7635
+ human-readable reason for any rejection. Useful for `tx_audit` payloads.
7636
+
7637
+ ```ts
7638
+ export function validateProcessingTransition(from: sdk.ProcessingStatus, to: sdk.ProcessingStatus): FsmTransitionResult
7639
+ ```
7640
+
7641
+ See also: [FsmTransitionResult](./storage.md#interface-fsmtransitionresult), [ProcessingStatus](./client.md#type-processingstatus)
7642
+
7643
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7644
+
5133
7645
  ---
5134
7646
  ##### Function: validateStorageFeeModel
5135
7647
 
@@ -5141,6 +7653,20 @@ See also: [StorageFeeModel](./client.md#interface-storagefeemodel)
5141
7653
 
5142
7654
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
5143
7655
 
7656
+ ---
7657
+ ##### Function: validateSyncChunkEntities
7658
+
7659
+ Validate all entity arrays within a `SyncChunk` received from a remote storage call.
7660
+ Normalises timestamps, nulls, and binary fields in-place.
7661
+
7662
+ ```ts
7663
+ export function validateSyncChunkEntities(r: SyncChunk): SyncChunk
7664
+ ```
7665
+
7666
+ See also: [SyncChunk](./client.md#interface-syncchunk)
7667
+
7668
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
7669
+
5144
7670
  ---
5145
7671
  ##### Function: varUintSize
5146
7672
 
@@ -5150,7 +7676,13 @@ Returns the byte size required to encode number as Bitcoin VarUint
5150
7676
  export function varUintSize(val: number): 1 | 3 | 5 | 9 {
5151
7677
  if (val < 0)
5152
7678
  throw new WERR_INVALID_PARAMETER("varUint", "non-negative");
5153
- return val <= 252 ? 1 : val <= 65535 ? 3 : val <= 4294967295 ? 5 : 9;
7679
+ if (val <= 252)
7680
+ return 1;
7681
+ if (val <= 65535)
7682
+ return 3;
7683
+ if (val <= 4294967295)
7684
+ return 5;
7685
+ return 9;
5154
7686
  }
5155
7687
  ```
5156
7688
 
@@ -5234,8 +7766,8 @@ getLabelToSpecOp: () => Record<string, ListActionsSpecOp> = () => {
5234
7766
  name: "noSendActions",
5235
7767
  labelsToIntercept: ["abort"],
5236
7768
  setStatusFilter: () => ["nosend"],
5237
- postProcess: async (s: StorageProvider, auth: AuthId, vargs: Validation.ValidListActionsArgs, specOpLabels: string[], txs: Partial<TableTransaction>[]): Promise<void> => {
5238
- if (specOpLabels.indexOf("abort") >= 0) {
7769
+ postProcess: async (s: StorageProvider, auth: AuthId, vargs: Validation.ValidListActionsArgs, specOpLabels: string[], txs: Array<Partial<TableTransaction>>): Promise<void> => {
7770
+ if (specOpLabels.includes("abort")) {
5239
7771
  for (const tx of txs) {
5240
7772
  if (tx.status === "nosend") {
5241
7773
  await s.abortAction(auth, { reference: tx.reference! });
@@ -5249,8 +7781,8 @@ getLabelToSpecOp: () => Record<string, ListActionsSpecOp> = () => {
5249
7781
  name: "failedActions",
5250
7782
  labelsToIntercept: ["unfail"],
5251
7783
  setStatusFilter: () => ["failed"],
5252
- postProcess: async (s: StorageProvider, auth: AuthId, vargs: Validation.ValidListActionsArgs, specOpLabels: string[], txs: Partial<TableTransaction>[]): Promise<void> => {
5253
- if (specOpLabels.indexOf("unfail") >= 0) {
7784
+ postProcess: async (s: StorageProvider, auth: AuthId, vargs: Validation.ValidListActionsArgs, specOpLabels: string[], txs: Array<Partial<TableTransaction>>): Promise<void> => {
7785
+ if (specOpLabels.includes("unfail")) {
5254
7786
  for (const tx of txs) {
5255
7787
  if (tx.status === "failed") {
5256
7788
  await s.updateTransaction(tx.transactionId!, { status: "unfail" });