@bsv/wallet-toolbox 1.1.60 → 1.1.62

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 (471) hide show
  1. package/.prettierrc +1 -1
  2. package/docs/client.md +39 -5
  3. package/docs/services.md +1 -0
  4. package/docs/setup.md +9 -26
  5. package/docs/storage.md +35 -0
  6. package/docs/wallet.md +39 -5
  7. package/out/src/Setup.d.ts.map +1 -1
  8. package/out/src/Setup.js +6 -16
  9. package/out/src/Setup.js.map +1 -1
  10. package/out/src/Wallet.d.ts.map +1 -1
  11. package/out/src/Wallet.js +4 -11
  12. package/out/src/Wallet.js.map +1 -1
  13. package/out/src/monitor/Monitor.d.ts.map +1 -1
  14. package/out/src/monitor/Monitor.js.map +1 -1
  15. package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
  16. package/out/src/monitor/MonitorDaemon.js +1 -3
  17. package/out/src/monitor/MonitorDaemon.js.map +1 -1
  18. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
  19. package/out/src/monitor/tasks/TaskCheckForProofs.js +2 -10
  20. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
  21. package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
  22. package/out/src/monitor/tasks/TaskClock.js +1 -1
  23. package/out/src/monitor/tasks/TaskClock.js.map +1 -1
  24. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
  25. package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
  26. package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
  27. package/out/src/monitor/tasks/TaskNewHeader.js +1 -2
  28. package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
  29. package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
  30. package/out/src/monitor/tasks/TaskPurge.js +1 -2
  31. package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
  32. package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
  33. package/out/src/monitor/tasks/TaskReviewStatus.js +1 -2
  34. package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
  35. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
  36. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
  37. package/out/src/sdk/CertOps.d.ts.map +1 -1
  38. package/out/src/sdk/CertOps.js +4 -12
  39. package/out/src/sdk/CertOps.js.map +1 -1
  40. package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
  41. package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
  42. package/out/src/sdk/WERR_errors.d.ts.map +1 -1
  43. package/out/src/sdk/WERR_errors.js.map +1 -1
  44. package/out/src/sdk/WalletError.d.ts.map +1 -1
  45. package/out/src/sdk/WalletError.js +1 -4
  46. package/out/src/sdk/WalletError.js.map +1 -1
  47. package/out/src/sdk/WalletServices.interfaces.d.ts +2 -0
  48. package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
  49. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  50. package/out/src/sdk/__test/CertificateLifeCycle.test.js +1 -3
  51. package/out/src/sdk/__test/CertificateLifeCycle.test.js.map +1 -1
  52. package/out/src/sdk/__test/PrivilegedKeyManager.test.js +13 -26
  53. package/out/src/sdk/__test/PrivilegedKeyManager.test.js.map +1 -1
  54. package/out/src/sdk/types.d.ts.map +1 -1
  55. package/out/src/sdk/types.js +2 -10
  56. package/out/src/sdk/types.js.map +1 -1
  57. package/out/src/sdk/validationHelpers.d.ts.map +1 -1
  58. package/out/src/sdk/validationHelpers.js +5 -12
  59. package/out/src/sdk/validationHelpers.js.map +1 -1
  60. package/out/src/services/Services.d.ts +1 -0
  61. package/out/src/services/Services.d.ts.map +1 -1
  62. package/out/src/services/Services.js +29 -38
  63. package/out/src/services/Services.js.map +1 -1
  64. package/out/src/services/__tests/ARC.test.js +9 -0
  65. package/out/src/services/__tests/ARC.test.js.map +1 -1
  66. package/out/src/services/__tests/bitrails.test.js.map +1 -1
  67. package/out/src/services/__tests/getMerklePath.test.js.map +1 -1
  68. package/out/src/services/__tests/getRawTx.test.js.map +1 -1
  69. package/out/src/services/__tests/verifyBeef.test.js +2 -1
  70. package/out/src/services/__tests/verifyBeef.test.js.map +1 -1
  71. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
  72. package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
  73. package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -1
  74. package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -1
  75. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
  76. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +1 -3
  77. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
  78. package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
  79. package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
  80. package/out/src/services/providers/ARC.d.ts.map +1 -1
  81. package/out/src/services/providers/ARC.js +2 -3
  82. package/out/src/services/providers/ARC.js.map +1 -1
  83. package/out/src/services/providers/Bitails.d.ts.map +1 -1
  84. package/out/src/services/providers/Bitails.js +62 -134
  85. package/out/src/services/providers/Bitails.js.map +1 -1
  86. package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
  87. package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
  88. package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
  89. package/out/src/services/providers/WhatsOnChain.js +6 -21
  90. package/out/src/services/providers/WhatsOnChain.js.map +1 -1
  91. package/out/src/services/providers/__tests/WhatsOnChain.test.js +1 -2
  92. package/out/src/services/providers/__tests/WhatsOnChain.test.js.map +1 -1
  93. package/out/src/services/providers/echangeRates.d.ts.map +1 -1
  94. package/out/src/services/providers/echangeRates.js.map +1 -1
  95. package/out/src/signer/WalletSigner.d.ts.map +1 -1
  96. package/out/src/signer/WalletSigner.js.map +1 -1
  97. package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
  98. package/out/src/signer/methods/acquireDirectCertificate.js +1 -3
  99. package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
  100. package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
  101. package/out/src/signer/methods/buildSignableTransaction.js +3 -11
  102. package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
  103. package/out/src/signer/methods/createAction.d.ts.map +1 -1
  104. package/out/src/signer/methods/createAction.js +3 -10
  105. package/out/src/signer/methods/createAction.js.map +1 -1
  106. package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
  107. package/out/src/signer/methods/internalizeAction.js.map +1 -1
  108. package/out/src/signer/methods/proveCertificate.d.ts.map +1 -1
  109. package/out/src/signer/methods/proveCertificate.js.map +1 -1
  110. package/out/src/signer/methods/signAction.d.ts.map +1 -1
  111. package/out/src/signer/methods/signAction.js +2 -7
  112. package/out/src/signer/methods/signAction.js.map +1 -1
  113. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  114. package/out/src/storage/StorageKnex.js +15 -44
  115. package/out/src/storage/StorageKnex.js.map +1 -1
  116. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  117. package/out/src/storage/StorageProvider.js +9 -34
  118. package/out/src/storage/StorageProvider.js.map +1 -1
  119. package/out/src/storage/StorageReader.d.ts.map +1 -1
  120. package/out/src/storage/StorageReader.js.map +1 -1
  121. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
  122. package/out/src/storage/StorageReaderWriter.js.map +1 -1
  123. package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
  124. package/out/src/storage/StorageSyncReader.js.map +1 -1
  125. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  126. package/out/src/storage/WalletStorageManager.js +5 -10
  127. package/out/src/storage/WalletStorageManager.js.map +1 -1
  128. package/out/src/storage/__test/WalletStorageManager.test.js +2 -8
  129. package/out/src/storage/__test/WalletStorageManager.test.js.map +1 -1
  130. package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js +10 -30
  131. package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js.map +1 -1
  132. package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts.map +1 -1
  133. package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js +17 -28
  134. package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js.map +1 -1
  135. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
  136. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +6 -20
  137. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
  138. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  139. package/out/src/storage/methods/createAction.js +4 -9
  140. package/out/src/storage/methods/createAction.js.map +1 -1
  141. package/out/src/storage/methods/generateChange.d.ts.map +1 -1
  142. package/out/src/storage/methods/generateChange.js +7 -18
  143. package/out/src/storage/methods/generateChange.js.map +1 -1
  144. package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -1
  145. package/out/src/storage/methods/getBeefForTransaction.js +1 -3
  146. package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
  147. package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
  148. package/out/src/storage/methods/getSyncChunk.js.map +1 -1
  149. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  150. package/out/src/storage/methods/internalizeAction.js +2 -9
  151. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  152. package/out/src/storage/methods/listActions.d.ts.map +1 -1
  153. package/out/src/storage/methods/listActions.js +3 -15
  154. package/out/src/storage/methods/listActions.js.map +1 -1
  155. package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
  156. package/out/src/storage/methods/listCertificates.js.map +1 -1
  157. package/out/src/storage/methods/listOutputs.d.ts.map +1 -1
  158. package/out/src/storage/methods/listOutputs.js +5 -12
  159. package/out/src/storage/methods/listOutputs.js.map +1 -1
  160. package/out/src/storage/methods/processAction.d.ts.map +1 -1
  161. package/out/src/storage/methods/processAction.js +4 -10
  162. package/out/src/storage/methods/processAction.js.map +1 -1
  163. package/out/src/storage/methods/purgeData.d.ts.map +1 -1
  164. package/out/src/storage/methods/purgeData.js +8 -32
  165. package/out/src/storage/methods/purgeData.js.map +1 -1
  166. package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
  167. package/out/src/storage/methods/reviewStatus.js +1 -3
  168. package/out/src/storage/methods/reviewStatus.js.map +1 -1
  169. package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
  170. package/out/src/storage/remoting/StorageClient.js +15 -41
  171. package/out/src/storage/remoting/StorageClient.js.map +1 -1
  172. package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
  173. package/out/src/storage/remoting/StorageServer.js +2 -5
  174. package/out/src/storage/remoting/StorageServer.js.map +1 -1
  175. package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
  176. package/out/src/storage/schema/KnexMigrations.js +24 -130
  177. package/out/src/storage/schema/KnexMigrations.js.map +1 -1
  178. package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
  179. package/out/src/storage/schema/entities/Certificate.js +1 -1
  180. package/out/src/storage/schema/entities/Certificate.js.map +1 -1
  181. package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
  182. package/out/src/storage/schema/entities/CertificateField.js +2 -5
  183. package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
  184. package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
  185. package/out/src/storage/schema/entities/Commission.js +2 -5
  186. package/out/src/storage/schema/entities/Commission.js.map +1 -1
  187. package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -1
  188. package/out/src/storage/schema/entities/EntityBase.js.map +1 -1
  189. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
  190. package/out/src/storage/schema/entities/MergeEntity.js +14 -9
  191. package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
  192. package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
  193. package/out/src/storage/schema/entities/Output.js +8 -25
  194. package/out/src/storage/schema/entities/Output.js.map +1 -1
  195. package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
  196. package/out/src/storage/schema/entities/OutputBasket.js +1 -1
  197. package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
  198. package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
  199. package/out/src/storage/schema/entities/OutputTag.js +1 -1
  200. package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
  201. package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
  202. package/out/src/storage/schema/entities/OutputTagMap.js +3 -7
  203. package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
  204. package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
  205. package/out/src/storage/schema/entities/ProvenTx.js +10 -20
  206. package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
  207. package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
  208. package/out/src/storage/schema/entities/ProvenTxReq.js +8 -18
  209. package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
  210. package/out/src/storage/schema/entities/SyncState.d.ts +1 -0
  211. package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
  212. package/out/src/storage/schema/entities/SyncState.js +41 -6
  213. package/out/src/storage/schema/entities/SyncState.js.map +1 -1
  214. package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
  215. package/out/src/storage/schema/entities/Transaction.js +4 -13
  216. package/out/src/storage/schema/entities/Transaction.js.map +1 -1
  217. package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
  218. package/out/src/storage/schema/entities/TxLabel.js +1 -1
  219. package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
  220. package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
  221. package/out/src/storage/schema/entities/TxLabelMap.js +3 -9
  222. package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
  223. package/out/src/storage/schema/entities/User.d.ts.map +1 -1
  224. package/out/src/storage/schema/entities/User.js +3 -5
  225. package/out/src/storage/schema/entities/User.js.map +1 -1
  226. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
  227. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
  228. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
  229. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
  230. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
  231. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
  232. package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
  233. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
  234. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +1 -2
  235. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
  236. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
  237. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +2 -2
  238. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
  239. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
  240. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
  241. package/out/src/storage/schema/entities/__tests/stampLogTests.test.js.map +1 -1
  242. package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
  243. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
  244. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
  245. package/out/src/storage/sync/StorageMySQLDojoReader.js +1 -3
  246. package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
  247. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
  248. package/out/src/utility/ScriptTemplateBRC29.js +1 -2
  249. package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
  250. package/out/src/utility/stampLog.d.ts.map +1 -1
  251. package/out/src/utility/stampLog.js.map +1 -1
  252. package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
  253. package/out/src/utility/tscProofToMerklePath.js.map +1 -1
  254. package/out/src/utility/utilityHelpers.buffer.d.ts.map +1 -1
  255. package/out/src/utility/utilityHelpers.buffer.js.map +1 -1
  256. package/out/src/utility/utilityHelpers.d.ts.map +1 -1
  257. package/out/src/utility/utilityHelpers.js +1 -3
  258. package/out/src/utility/utilityHelpers.js.map +1 -1
  259. package/out/test/Wallet/StorageClient/storageClient.man.test.js.map +1 -1
  260. package/out/test/Wallet/action/internalizeAction.a.test.js.map +1 -1
  261. package/out/test/Wallet/certificate/acquireCertificate.test.js.map +1 -1
  262. package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
  263. package/out/test/Wallet/get/getHeaderForHeight.test.js +2 -6
  264. package/out/test/Wallet/get/getHeaderForHeight.test.js.map +1 -1
  265. package/out/test/Wallet/get/getHeight.test.js.map +1 -1
  266. package/out/test/Wallet/get/getKnownTxids.test.js.map +1 -1
  267. package/out/test/Wallet/get/getNetwork.test.js.map +1 -1
  268. package/out/test/Wallet/get/getVersion.test.js.map +1 -1
  269. package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
  270. package/out/test/Wallet/live/walletLive.man.test.js +3 -9
  271. package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
  272. package/out/test/Wallet/local/localWallet.man.test.d.ts.map +1 -1
  273. package/out/test/Wallet/local/localWallet.man.test.js +39 -31
  274. package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
  275. package/out/test/Wallet/specOps/specOps.man.test.js +1 -4
  276. package/out/test/Wallet/specOps/specOps.man.test.js.map +1 -1
  277. package/out/test/Wallet/support/janitor.man.test.js.map +1 -1
  278. package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js.map +1 -1
  279. package/out/test/Wallet/sync/setActive.test.js +73 -50
  280. package/out/test/Wallet/sync/setActive.test.js.map +1 -1
  281. package/out/test/checkDB.d.ts.map +1 -1
  282. package/out/test/checkDB.js.map +1 -1
  283. package/out/test/examples/backup.man.test.d.ts.map +1 -1
  284. package/out/test/examples/backup.man.test.js.map +1 -1
  285. package/out/test/examples/pushdrop.test.d.ts.map +1 -1
  286. package/out/test/examples/pushdrop.test.js +5 -4
  287. package/out/test/examples/pushdrop.test.js.map +1 -1
  288. package/out/test/monitor/Monitor.test.js.map +1 -1
  289. package/out/test/services/Services.test.js.map +1 -1
  290. package/out/test/storage/KnexMigrations.test.js.map +1 -1
  291. package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -3
  292. package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
  293. package/out/test/storage/count.test.js.map +1 -1
  294. package/out/test/storage/find.test.js +5 -10
  295. package/out/test/storage/find.test.js.map +1 -1
  296. package/out/test/storage/findLegacy.test.js.map +1 -1
  297. package/out/test/storage/insert.test.js.map +1 -1
  298. package/out/test/storage/update.test.js +7 -19
  299. package/out/test/storage/update.test.js.map +1 -1
  300. package/out/test/storage/update2.test.js +22 -24
  301. package/out/test/storage/update2.test.js.map +1 -1
  302. package/out/test/utils/TestUtilsWalletStorage.d.ts +3 -1
  303. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  304. package/out/test/utils/TestUtilsWalletStorage.js +52 -76
  305. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  306. package/out/test/wallet/action/abortAction.test.js.map +1 -1
  307. package/out/test/wallet/action/createAction.test.js +1 -2
  308. package/out/test/wallet/action/createAction.test.js.map +1 -1
  309. package/out/test/wallet/action/createAction2.test.d.ts.map +1 -1
  310. package/out/test/wallet/action/createAction2.test.js +6 -16
  311. package/out/test/wallet/action/createAction2.test.js.map +1 -1
  312. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
  313. package/out/test/wallet/action/internalizeAction.test.js.map +1 -1
  314. package/out/test/wallet/action/relinquishOutput.test.js.map +1 -1
  315. package/out/test/wallet/list/listActions.test.js.map +1 -1
  316. package/out/test/wallet/list/listActions2.test.js.map +1 -1
  317. package/out/test/wallet/list/listCertificates.test.js +2 -6
  318. package/out/test/wallet/list/listCertificates.test.js.map +1 -1
  319. package/out/test/wallet/list/listOutputs.test.js +2 -10
  320. package/out/test/wallet/list/listOutputs.test.js.map +1 -1
  321. package/out/test/wallet/sync/Wallet.sync.test.js +4 -6
  322. package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -1
  323. package/out/tsconfig.all.tsbuildinfo +1 -1
  324. package/package.json +3 -3
  325. package/src/Setup.ts +15 -52
  326. package/src/Wallet.ts +58 -161
  327. package/src/monitor/Monitor.ts +7 -22
  328. package/src/monitor/MonitorDaemon.ts +6 -23
  329. package/src/monitor/tasks/TaskCheckForProofs.ts +4 -23
  330. package/src/monitor/tasks/TaskClock.ts +1 -3
  331. package/src/monitor/tasks/TaskFailAbandoned.ts +1 -3
  332. package/src/monitor/tasks/TaskNewHeader.ts +1 -4
  333. package/src/monitor/tasks/TaskPurge.ts +1 -2
  334. package/src/monitor/tasks/TaskReviewStatus.ts +1 -3
  335. package/src/monitor/tasks/TaskSendWaiting.ts +3 -10
  336. package/src/sdk/CertOps.ts +31 -103
  337. package/src/sdk/PrivilegedKeyManager.ts +18 -48
  338. package/src/sdk/WERR_errors.ts +6 -25
  339. package/src/sdk/WalletError.ts +5 -21
  340. package/src/sdk/WalletServices.interfaces.ts +11 -33
  341. package/src/sdk/WalletStorage.interfaces.ts +25 -91
  342. package/src/sdk/__test/CertificateLifeCycle.test.ts +9 -27
  343. package/src/sdk/__test/PrivilegedKeyManager.test.ts +29 -66
  344. package/src/sdk/types.ts +6 -26
  345. package/src/sdk/validationHelpers.ts +111 -402
  346. package/src/services/Services.ts +51 -114
  347. package/src/services/__tests/ARC.test.ts +14 -1
  348. package/src/services/__tests/bitrails.test.ts +4 -15
  349. package/src/services/__tests/getMerklePath.test.ts +1 -2
  350. package/src/services/__tests/getRawTx.test.ts +1 -3
  351. package/src/services/__tests/verifyBeef.test.ts +2 -1
  352. package/src/services/chaintracker/ChaintracksChainTracker.ts +3 -13
  353. package/src/services/chaintracker/chaintracks/BlockHeaderApi.ts +4 -12
  354. package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +9 -27
  355. package/src/services/createDefaultWalletServicesOptions.ts +2 -5
  356. package/src/services/processingErrors/arcSuccessError.json +76 -0
  357. package/src/services/providers/ARC.ts +6 -25
  358. package/src/services/providers/Bitails.ts +61 -159
  359. package/src/services/providers/SdkWhatsOnChain.ts +4 -17
  360. package/src/services/providers/WhatsOnChain.ts +31 -100
  361. package/src/services/providers/__tests/WhatsOnChain.test.ts +5 -15
  362. package/src/services/providers/echangeRates.ts +7 -22
  363. package/src/signer/WalletSigner.ts +1 -5
  364. package/src/signer/methods/acquireDirectCertificate.ts +1 -4
  365. package/src/signer/methods/buildSignableTransaction.ts +5 -20
  366. package/src/signer/methods/createAction.ts +15 -54
  367. package/src/signer/methods/internalizeAction.ts +10 -39
  368. package/src/signer/methods/proveCertificate.ts +2 -5
  369. package/src/signer/methods/signAction.ts +9 -39
  370. package/src/storage/StorageKnex.ts +166 -499
  371. package/src/storage/StorageProvider.ts +75 -291
  372. package/src/storage/StorageReader.ts +20 -65
  373. package/src/storage/StorageReaderWriter.ts +67 -264
  374. package/src/storage/StorageSyncReader.ts +2 -5
  375. package/src/storage/WalletStorageManager.ts +33 -108
  376. package/src/storage/__test/WalletStorageManager.test.ts +6 -23
  377. package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +53 -171
  378. package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +17 -28
  379. package/src/storage/methods/attemptToPostReqsToNetwork.ts +9 -37
  380. package/src/storage/methods/createAction.ts +45 -181
  381. package/src/storage/methods/generateChange.ts +33 -114
  382. package/src/storage/methods/getBeefForTransaction.ts +7 -37
  383. package/src/storage/methods/getSyncChunk.ts +18 -69
  384. package/src/storage/methods/internalizeAction.ts +18 -70
  385. package/src/storage/methods/listActions.ts +6 -23
  386. package/src/storage/methods/listCertificates.ts +5 -14
  387. package/src/storage/methods/listOutputs.ts +15 -69
  388. package/src/storage/methods/processAction.ts +29 -104
  389. package/src/storage/methods/purgeData.ts +11 -45
  390. package/src/storage/methods/reviewStatus.ts +3 -9
  391. package/src/storage/remoting/StorageClient.ts +43 -146
  392. package/src/storage/remoting/StorageServer.ts +21 -59
  393. package/src/storage/schema/KnexMigrations.ts +34 -165
  394. package/src/storage/schema/entities/Certificate.ts +3 -14
  395. package/src/storage/schema/entities/CertificateField.ts +6 -28
  396. package/src/storage/schema/entities/Commission.ts +6 -23
  397. package/src/storage/schema/entities/EntityBase.ts +1 -6
  398. package/src/storage/schema/entities/MergeEntity.ts +14 -21
  399. package/src/storage/schema/entities/Output.ts +10 -39
  400. package/src/storage/schema/entities/OutputBasket.ts +4 -16
  401. package/src/storage/schema/entities/OutputTag.ts +4 -17
  402. package/src/storage/schema/entities/OutputTagMap.ts +7 -30
  403. package/src/storage/schema/entities/ProvenTx.ts +16 -57
  404. package/src/storage/schema/entities/ProvenTxReq.ts +29 -93
  405. package/src/storage/schema/entities/SyncState.ts +64 -116
  406. package/src/storage/schema/entities/Transaction.ts +10 -35
  407. package/src/storage/schema/entities/TxLabel.ts +4 -17
  408. package/src/storage/schema/entities/TxLabelMap.ts +6 -28
  409. package/src/storage/schema/entities/User.ts +8 -31
  410. package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +23 -54
  411. package/src/storage/schema/entities/__tests/CertificateTests.test.ts +26 -59
  412. package/src/storage/schema/entities/__tests/CommissionTests.test.ts +2 -11
  413. package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +2 -10
  414. package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +2 -10
  415. package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +1 -4
  416. package/src/storage/schema/entities/__tests/OutputTests.test.ts +3 -14
  417. package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +4 -16
  418. package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +5 -18
  419. package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +5 -26
  420. package/src/storage/schema/entities/__tests/TransactionTests.test.ts +12 -48
  421. package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +4 -22
  422. package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +2 -10
  423. package/src/storage/schema/entities/__tests/stampLogTests.test.ts +3 -10
  424. package/src/storage/schema/entities/__tests/usersTests.test.ts +4 -7
  425. package/src/storage/schema/tables/TableSettings.ts +1 -3
  426. package/src/storage/sync/StorageMySQLDojoReader.ts +47 -148
  427. package/src/utility/ScriptTemplateBRC29.ts +2 -11
  428. package/src/utility/stampLog.ts +2 -6
  429. package/src/utility/tscProofToMerklePath.ts +1 -4
  430. package/src/utility/utilityHelpers.buffer.ts +3 -12
  431. package/src/utility/utilityHelpers.ts +14 -49
  432. package/test/Wallet/StorageClient/storageClient.man.test.ts +2 -8
  433. package/test/Wallet/action/internalizeAction.a.test.ts +8 -23
  434. package/test/Wallet/certificate/acquireCertificate.test.ts +10 -24
  435. package/test/Wallet/certificate/listCertificates.test.ts +8 -18
  436. package/test/Wallet/get/getHeaderForHeight.test.ts +4 -15
  437. package/test/Wallet/get/getHeight.test.ts +2 -6
  438. package/test/Wallet/get/getKnownTxids.test.ts +1 -5
  439. package/test/Wallet/get/getNetwork.test.ts +1 -2
  440. package/test/Wallet/get/getVersion.test.ts +1 -2
  441. package/test/Wallet/live/walletLive.man.test.ts +14 -41
  442. package/test/Wallet/local/localWallet.man.test.ts +45 -102
  443. package/test/Wallet/specOps/specOps.man.test.ts +4 -13
  444. package/test/Wallet/support/janitor.man.test.ts +2 -7
  445. package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +11 -34
  446. package/test/Wallet/sync/setActive.test.ts +75 -61
  447. package/test/checkDB.ts +2 -8
  448. package/test/examples/backup.man.test.ts +2 -9
  449. package/test/examples/pushdrop.test.ts +7 -20
  450. package/test/monitor/Monitor.test.ts +33 -87
  451. package/test/services/Services.test.ts +8 -19
  452. package/test/storage/KnexMigrations.test.ts +3 -18
  453. package/test/storage/StorageMySQLDojoReader.man.test.ts +4 -15
  454. package/test/storage/count.test.ts +7 -24
  455. package/test/storage/find.test.ts +7 -29
  456. package/test/storage/findLegacy.test.ts +2 -5
  457. package/test/storage/insert.test.ts +3 -19
  458. package/test/storage/update.test.ts +47 -179
  459. package/test/storage/update2.test.ts +54 -176
  460. package/test/utils/TestUtilsWalletStorage.ts +139 -372
  461. package/test/wallet/action/abortAction.test.ts +4 -12
  462. package/test/wallet/action/createAction.test.ts +4 -14
  463. package/test/wallet/action/createAction2.test.ts +74 -208
  464. package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +8 -11
  465. package/test/wallet/action/internalizeAction.test.ts +20 -72
  466. package/test/wallet/action/relinquishOutput.test.ts +3 -9
  467. package/test/wallet/list/listActions.test.ts +2 -9
  468. package/test/wallet/list/listActions2.test.ts +8 -34
  469. package/test/wallet/list/listCertificates.test.ts +5 -16
  470. package/test/wallet/list/listOutputs.test.ts +15 -54
  471. package/test/wallet/sync/Wallet.sync.test.ts +18 -49
@@ -23,8 +23,7 @@ import {
23
23
  verifyOneOrNone
24
24
  } from '../../index.client'
25
25
 
26
- export interface StorageInternalizeActionResult
27
- extends InternalizeActionResult {
26
+ export interface StorageInternalizeActionResult extends InternalizeActionResult {
28
27
  /** true if internalizing outputs on an existing storage transaction */
29
28
  isMerge: boolean
30
29
  /** txid of transaction being internalized */
@@ -165,11 +164,7 @@ class InternalizeActionContext {
165
164
  }
166
165
 
167
166
  async asyncSetup() {
168
- ;({
169
- ab: this.ab,
170
- tx: this.tx,
171
- txid: this.txid
172
- } = await this.validateAtomicBeef(this.args.tx))
167
+ ;({ ab: this.ab, tx: this.tx, txid: this.txid } = await this.validateAtomicBeef(this.args.tx))
173
168
 
174
169
  for (const o of this.args.outputs) {
175
170
  if (o.outputIndex < 0 || o.outputIndex >= this.tx.outputs.length)
@@ -225,14 +220,7 @@ class InternalizeActionContext {
225
220
  partial: { userId: this.userId, txid: this.txid }
226
221
  })
227
222
  )
228
- if (
229
- this.etx &&
230
- !(
231
- this.etx.status == 'completed' ||
232
- this.etx.status === 'unproven' ||
233
- this.etx.status === 'nosend'
234
- )
235
- )
223
+ if (this.etx && !(this.etx.status == 'completed' || this.etx.status === 'unproven' || this.etx.status === 'nosend'))
236
224
  throw new sdk.WERR_INVALID_PARAMETER(
237
225
  'tx',
238
226
  `target transaction of internalizeAction has invalid status ${this.etx.status}.`
@@ -246,11 +234,7 @@ class InternalizeActionContext {
246
234
  for (const eo of this.eos) {
247
235
  const bi = this.basketInsertions.find(b => b.vout === eo.vout)
248
236
  const wp = this.walletPayments.find(b => b.vout === eo.vout)
249
- if (bi && wp)
250
- throw new sdk.WERR_INVALID_PARAMETER(
251
- 'outputs',
252
- `unique outputIndex values`
253
- )
237
+ if (bi && wp) throw new sdk.WERR_INVALID_PARAMETER('outputs', `unique outputIndex values`)
254
238
  if (bi) bi.eo = eo
255
239
  if (wp) wp.eo = eo
256
240
  }
@@ -290,19 +274,11 @@ class InternalizeActionContext {
290
274
 
291
275
  async validateAtomicBeef(atomicBeef: number[]) {
292
276
  const ab = Beef.fromBinary(atomicBeef)
293
- const txValid = await ab.verify(
294
- await this.storage.getServices().getChainTracker(),
295
- false
296
- )
297
- if (!txValid || !ab.atomicTxid)
298
- throw new sdk.WERR_INVALID_PARAMETER('tx', 'valid AtomicBEEF')
277
+ const txValid = await ab.verify(await this.storage.getServices().getChainTracker(), false)
278
+ if (!txValid || !ab.atomicTxid) throw new sdk.WERR_INVALID_PARAMETER('tx', 'valid AtomicBEEF')
299
279
  const txid = ab.atomicTxid
300
280
  const btx = ab.findTxid(txid)
301
- if (!btx)
302
- throw new sdk.WERR_INVALID_PARAMETER(
303
- 'tx',
304
- `valid AtomicBEEF with newest txid of ${txid}`
305
- )
281
+ if (!btx) throw new sdk.WERR_INVALID_PARAMETER('tx', `valid AtomicBEEF with newest txid of ${txid}`)
306
282
  const tx = btx.tx!
307
283
 
308
284
  /*
@@ -321,10 +297,7 @@ class InternalizeActionContext {
321
297
  return { ab, tx, txid }
322
298
  }
323
299
 
324
- async findOrInsertTargetTransaction(
325
- satoshis: number,
326
- status: sdk.TransactionStatus
327
- ): Promise<TableTransaction> {
300
+ async findOrInsertTargetTransaction(satoshis: number, status: sdk.TransactionStatus): Promise<TableTransaction> {
328
301
  const now = new Date()
329
302
  const newTx: TableTransaction = {
330
303
  created_at: now,
@@ -365,34 +338,24 @@ class InternalizeActionContext {
365
338
  await this.addLabels(transactionId)
366
339
 
367
340
  for (const payment of this.walletPayments) {
368
- if (payment.eo && !payment.ignore)
369
- await this.mergeWalletPaymentForOutput(transactionId, payment)
370
- else if (!payment.ignore)
371
- await this.storeNewWalletPaymentForOutput(transactionId, payment)
341
+ if (payment.eo && !payment.ignore) await this.mergeWalletPaymentForOutput(transactionId, payment)
342
+ else if (!payment.ignore) await this.storeNewWalletPaymentForOutput(transactionId, payment)
372
343
  }
373
344
 
374
345
  for (const basket of this.basketInsertions) {
375
- if (basket.eo)
376
- await this.mergeBasketInsertionForOutput(transactionId, basket)
346
+ if (basket.eo) await this.mergeBasketInsertionForOutput(transactionId, basket)
377
347
  else await this.storeNewBasketInsertionForOutput(transactionId, basket)
378
348
  }
379
349
  }
380
350
 
381
351
  async newInternalize() {
382
- this.etx = await this.findOrInsertTargetTransaction(
383
- this.satoshis,
384
- 'unproven'
385
- )
352
+ this.etx = await this.findOrInsertTargetTransaction(this.satoshis, 'unproven')
386
353
 
387
354
  const transactionId = this.etx!.transactionId!
388
355
 
389
356
  // transaction record for user is new, but the txid may not be new to storage
390
357
  // make sure storage pursues getting a proof for it.
391
- const newReq = EntityProvenTxReq.fromTxid(
392
- this.txid,
393
- this.tx.toBinary(),
394
- this.args.tx
395
- )
358
+ const newReq = EntityProvenTxReq.fromTxid(this.txid, this.tx.toBinary(), this.args.tx)
396
359
  newReq.status = 'unmined'
397
360
  newReq.addHistoryNote({ what: 'internalizeAction', userId: this.userId })
398
361
  newReq.addNotifyTransactionId(transactionId)
@@ -412,10 +375,7 @@ class InternalizeActionContext {
412
375
  async addLabels(transactionId: number) {
413
376
  for (const label of this.vargs.labels) {
414
377
  const txLabel = await this.storage.findOrInsertTxLabel(this.userId, label)
415
- await this.storage.findOrInsertTxLabelMap(
416
- verifyId(transactionId),
417
- verifyId(txLabel.txLabelId)
418
- )
378
+ await this.storage.findOrInsertTxLabelMap(verifyId(transactionId), verifyId(txLabel.txLabelId))
419
379
  }
420
380
  }
421
381
 
@@ -425,10 +385,7 @@ class InternalizeActionContext {
425
385
  }
426
386
  }
427
387
 
428
- async storeNewWalletPaymentForOutput(
429
- transactionId: number,
430
- payment: WalletPaymentX
431
- ): Promise<void> {
388
+ async storeNewWalletPaymentForOutput(transactionId: number, payment: WalletPaymentX): Promise<void> {
432
389
  const now = new Date()
433
390
  const txOut: TableOutput = {
434
391
  created_at: now,
@@ -459,10 +416,7 @@ class InternalizeActionContext {
459
416
  payment.eo = txOut
460
417
  }
461
418
 
462
- async mergeWalletPaymentForOutput(
463
- transactionId: number,
464
- payment: WalletPaymentX
465
- ) {
419
+ async mergeWalletPaymentForOutput(transactionId: number, payment: WalletPaymentX) {
466
420
  const outputId = payment.eo!.outputId!
467
421
  const update: Partial<TableOutput> = {
468
422
  basketId: this.changeBasket.basketId,
@@ -479,10 +433,7 @@ class InternalizeActionContext {
479
433
  payment.eo = { ...payment.eo!, ...update }
480
434
  }
481
435
 
482
- async mergeBasketInsertionForOutput(
483
- transactionId: number,
484
- basket: BasketInsertionX
485
- ) {
436
+ async mergeBasketInsertionForOutput(transactionId: number, basket: BasketInsertionX) {
486
437
  const outputId = basket.eo!.outputId!
487
438
  const update: Partial<TableOutput> = {
488
439
  basketId: (await this.getBasket(basket.basket)).basketId,
@@ -499,10 +450,7 @@ class InternalizeActionContext {
499
450
  basket.eo = { ...basket.eo!, ...update }
500
451
  }
501
452
 
502
- async storeNewBasketInsertionForOutput(
503
- transactionId: number,
504
- basket: BasketInsertionX
505
- ): Promise<void> {
453
+ async storeNewBasketInsertionForOutput(transactionId: number, basket: BasketInsertionX): Promise<void> {
506
454
  const now = new Date()
507
455
  const txOut: TableOutput = {
508
456
  created_at: now,
@@ -58,15 +58,7 @@ export async function listActions(
58
58
  'version',
59
59
  'lockTime'
60
60
  ]
61
- const stati: string[] = [
62
- 'completed',
63
- 'unprocessed',
64
- 'sending',
65
- 'unproven',
66
- 'unsigned',
67
- 'nosend',
68
- 'nonfinal'
69
- ]
61
+ const stati: string[] = ['completed', 'unprocessed', 'sending', 'unproven', 'unsigned', 'nosend', 'nonfinal']
70
62
 
71
63
  const noLabels = labelIds.length === 0
72
64
 
@@ -94,16 +86,12 @@ export async function listActions(
94
86
  }
95
87
 
96
88
  const makeWithoutLabelsQueries = () => {
97
- const q = k('transactions')
98
- .where('userId', auth.userId)
99
- .whereIn('status', stati)
89
+ const q = k('transactions').where('userId', auth.userId).whereIn('status', stati)
100
90
  const qcount = q.clone().count('transactionId as total')
101
91
  return { q, qcount }
102
92
  }
103
93
 
104
- const { q, qcount } = noLabels
105
- ? makeWithoutLabelsQueries()
106
- : makeWithLabelsQueries()
94
+ const { q, qcount } = noLabels ? makeWithoutLabelsQueries() : makeWithLabelsQueries()
107
95
 
108
96
  q.limit(limit).offset(offset).orderBy('transactionId', 'asc')
109
97
 
@@ -136,9 +124,7 @@ export async function listActions(
136
124
  // i++
137
125
  const action = r.actions[i]
138
126
  if (vargs.includeLabels) {
139
- action.labels = (
140
- await storage.getLabelsForTransactionId(tx.transactionId)
141
- ).map(l => l.label)
127
+ action.labels = (await storage.getLabelsForTransactionId(tx.transactionId)).map(l => l.label)
142
128
  }
143
129
  if (vargs.includeOutputs) {
144
130
  const outputs: TableOutputX[] = await storage.findOutputs({
@@ -156,8 +142,7 @@ export async function listActions(
156
142
  outputDescription: o.outputDescription || '',
157
143
  basket: o.basket?.name || ''
158
144
  }
159
- if (vargs.includeOutputLockingScripts)
160
- wo.lockingScript = asString(o.lockingScript || [])
145
+ if (vargs.includeOutputLockingScripts) wo.lockingScript = asString(o.lockingScript || [])
161
146
  action.outputs.push(wo)
162
147
  }
163
148
  }
@@ -175,9 +160,7 @@ export async function listActions(
175
160
  }
176
161
  for (const o of inputs) {
177
162
  await storage.extendOutput(o, true, true)
178
- const input = bsvTx?.inputs.find(
179
- v => v.sourceTXID === o.txid && v.sourceOutputIndex === o.vout
180
- )
163
+ const input = bsvTx?.inputs.find(v => v.sourceTXID === o.txid && v.sourceOutputIndex === o.vout)
181
164
  const wo: WalletActionInput = {
182
165
  sourceOutpoint: `${o.txid}.${o.vout}`,
183
166
  sourceSatoshis: o.satoshis || 0,
@@ -1,7 +1,4 @@
1
- import {
2
- ListCertificatesResult,
3
- OriginatorDomainNameStringUnder250Bytes
4
- } from '@bsv/sdk'
1
+ import { ListCertificatesResult, OriginatorDomainNameStringUnder250Bytes } from '@bsv/sdk'
5
2
  import { StorageProvider, TableCertificate } from '../index.client'
6
3
  import { sdk } from '../../index.client'
7
4
 
@@ -24,8 +21,7 @@ export async function listCertificates(
24
21
  if (vp.subject) partial['subject'] = vp.subject
25
22
  if (vp.serialNumber) partial['serialNumber'] = vp.serialNumber
26
23
  if (vp.certifier) partial['certifier'] = vp.certifier
27
- if (vp.revocationOutpoint)
28
- partial['revocationOutpoint'] = vp.revocationOutpoint
24
+ if (vp.revocationOutpoint) partial['revocationOutpoint'] = vp.revocationOutpoint
29
25
  if (vp.signature) partial['signature'] = vp.signature
30
26
  }
31
27
 
@@ -46,12 +42,8 @@ export async function listCertificates(
46
42
  })
47
43
  return {
48
44
  ...cert,
49
- fields: Object.fromEntries(
50
- fields.map(f => [f.fieldName, f.fieldValue])
51
- ),
52
- masterKeyring: Object.fromEntries(
53
- fields.map(f => [f.fieldName, f.masterKey])
54
- )
45
+ fields: Object.fromEntries(fields.map(f => [f.fieldName, f.fieldValue])),
46
+ masterKeyring: Object.fromEntries(fields.map(f => [f.fieldName, f.masterKey]))
55
47
  }
56
48
  })
57
49
  )
@@ -69,8 +61,7 @@ export async function listCertificates(
69
61
  keyring: cwf.masterKeyring
70
62
  }))
71
63
  }
72
- if (r.certificates.length < paged.limit)
73
- r.totalCertificates = r.certificates.length
64
+ if (r.certificates.length < paged.limit) r.totalCertificates = r.certificates.length
74
65
  else {
75
66
  r.totalCertificates = await storage.countCertificates(findCertsArgs)
76
67
  }
@@ -1,17 +1,6 @@
1
- import {
2
- Beef,
3
- ListOutputsResult,
4
- OriginatorDomainNameStringUnder250Bytes,
5
- WalletOutput
6
- } from '@bsv/sdk'
1
+ import { Beef, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes, WalletOutput } from '@bsv/sdk'
7
2
  import { TableOutput, TableOutputBasket, TableOutputTag } from '../index.client'
8
- import {
9
- asString,
10
- sdk,
11
- verifyId,
12
- verifyInteger,
13
- verifyOne
14
- } from '../../index.client'
3
+ import { asString, sdk, verifyId, verifyInteger, verifyOne } from '../../index.client'
15
4
  import { StorageKnex } from '../StorageKnex'
16
5
  import { ValidListOutputsArgs } from '../../sdk'
17
6
 
@@ -81,21 +70,12 @@ const basketToSpecOp: Record<string, SpecOp> = {
81
70
  outputs: TableOutput[]
82
71
  ): Promise<TableOutput[]> => {
83
72
  const filteredOutputs: TableOutput[] = []
84
- let ok = false
85
73
  for (const o of outputs) {
74
+ let ok = false
86
75
  if (o.lockingScript && o.lockingScript.length > 0) {
87
- const r = await s
88
- .getServices()
89
- .getUtxoStatus(asString(o.lockingScript), 'script')
76
+ const r = await s.getServices().getUtxoStatus(asString(o.lockingScript), 'script')
90
77
  if (r.status === 'success' && r.isUtxo && r.details?.length > 0) {
91
- if (
92
- r.details.some(
93
- d =>
94
- d.txid === o.txid &&
95
- d.satoshis === o.satoshis &&
96
- d.index === o.vout
97
- )
98
- ) {
78
+ if (r.details.some(d => d.txid === o.txid && d.satoshis === o.satoshis && d.index === o.vout)) {
99
79
  ok = true
100
80
  }
101
81
  }
@@ -122,14 +102,9 @@ const basketToSpecOp: Record<string, SpecOp> = {
122
102
  specOpTags: string[]
123
103
  ): Promise<ListOutputsResult> => {
124
104
  if (specOpTags.length !== 2)
125
- throw new sdk.WERR_INVALID_PARAMETER(
126
- 'numberOfDesiredUTXOs and minimumDesiredUTXOValue',
127
- 'valid'
128
- )
105
+ throw new sdk.WERR_INVALID_PARAMETER('numberOfDesiredUTXOs and minimumDesiredUTXOValue', 'valid')
129
106
  const numberOfDesiredUTXOs: number = verifyInteger(Number(specOpTags[0]))
130
- const minimumDesiredUTXOValue: number = verifyInteger(
131
- Number(specOpTags[1])
132
- )
107
+ const minimumDesiredUTXOValue: number = verifyInteger(Number(specOpTags[1]))
133
108
  const basket = verifyOne(
134
109
  await s.findOutputBaskets({
135
110
  partial: { userId: verifyId(auth.userId), name: 'default' }
@@ -200,19 +175,14 @@ export async function listOutputs(
200
175
  let tags = [...vargs.tags]
201
176
  const specOpTags: string[] = []
202
177
  if (specOp && specOp.tagsParamsCount) {
203
- specOpTags.push(
204
- ...tags.splice(0, Math.min(tags.length, specOp.tagsParamsCount))
205
- )
178
+ specOpTags.push(...tags.splice(0, Math.min(tags.length, specOp.tagsParamsCount)))
206
179
  }
207
180
  if (specOp && specOp.tagsToIntercept) {
208
181
  // Pull out tags used by current specOp
209
182
  const ts = tags
210
183
  tags = []
211
184
  for (const t of ts) {
212
- if (
213
- specOp.tagsToIntercept.length === 0 ||
214
- specOp.tagsToIntercept.indexOf(t) >= 0
215
- ) {
185
+ if (specOp.tagsToIntercept.length === 0 || specOp.tagsToIntercept.indexOf(t) >= 0) {
216
186
  specOpTags.push(t)
217
187
  } else {
218
188
  tags.push(t)
@@ -297,9 +267,7 @@ export async function listOutputs(
297
267
  return { q, qcount }
298
268
  }
299
269
 
300
- const { q, qcount } = noTags
301
- ? makeWithoutTagsQueries()
302
- : makeWithTagsQueries()
270
+ const { q, qcount } = noTags ? makeWithoutTagsQueries() : makeWithTagsQueries()
303
271
 
304
272
  // Sort order when limit and offset are possible must be ascending for determinism.
305
273
  if (!specOp || !specOp.ignoreLimit) q.limit(limit).offset(offset)
@@ -309,22 +277,9 @@ export async function listOutputs(
309
277
  let outputs: TableOutput[] = await q
310
278
 
311
279
  if (specOp) {
312
- if (specOp.filterOutputs)
313
- outputs = await specOp.filterOutputs(
314
- dsk,
315
- auth,
316
- vargs,
317
- specOpTags,
318
- outputs
319
- )
280
+ if (specOp.filterOutputs) outputs = await specOp.filterOutputs(dsk, auth, vargs, specOpTags, outputs)
320
281
  if (specOp.resultFromOutputs) {
321
- const r = await specOp.resultFromOutputs(
322
- dsk,
323
- auth,
324
- vargs,
325
- specOpTags,
326
- outputs
327
- )
282
+ const r = await specOp.resultFromOutputs(dsk, auth, vargs, specOpTags, outputs)
328
283
  return r
329
284
  }
330
285
  }
@@ -378,13 +333,10 @@ export async function listOutputs(
378
333
  // }
379
334
  // wo.basket = basketsById[o.basketId].name
380
335
  //}
381
- if (vargs.includeCustomInstructions && o.customInstructions)
382
- wo.customInstructions = o.customInstructions
336
+ if (vargs.includeCustomInstructions && o.customInstructions) wo.customInstructions = o.customInstructions
383
337
  if (vargs.includeLabels && o.txid) {
384
338
  if (labelsByTxid[o.txid] === undefined) {
385
- labelsByTxid[o.txid] = (
386
- await dsk.getLabelsForTransactionId(o.transactionId, trx)
387
- ).map(l => l.label)
339
+ labelsByTxid[o.txid] = (await dsk.getLabelsForTransactionId(o.transactionId, trx)).map(l => l.label)
388
340
  }
389
341
  wo.labels = labelsByTxid[o.txid]
390
342
  }
@@ -396,13 +348,7 @@ export async function listOutputs(
396
348
  if (o.lockingScript) wo.lockingScript = asString(o.lockingScript)
397
349
  }
398
350
  if (vargs.includeTransactions && !beef.findTxid(o.txid!)) {
399
- await dsk.getValidBeefForKnownTxid(
400
- o.txid!,
401
- beef,
402
- undefined,
403
- vargs.knownTxids,
404
- trx
405
- )
351
+ await dsk.getValidBeefForKnownTxid(o.txid!, beef, undefined, vargs.knownTxids, trx)
406
352
  }
407
353
  }
408
354