@bsv/wallet-toolbox 1.1.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 (919) hide show
  1. package/.env.template +22 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +40 -0
  3. package/.github/ISSUE_TEMPLATE/discussion.md +24 -0
  4. package/.github/pull_request_template.md +24 -0
  5. package/.github/workflows/push.yaml +66 -0
  6. package/.prettierrc +10 -0
  7. package/CONTRIBUTING.md +89 -0
  8. package/LICENSE.txt +28 -0
  9. package/README.md +124 -0
  10. package/dev.sqlite3 +0 -0
  11. package/docs/README.md +15 -0
  12. package/docs/client.md +6812 -0
  13. package/docs/monitor.md +648 -0
  14. package/docs/services.md +496 -0
  15. package/docs/storage.md +1884 -0
  16. package/docs/wallet.md +6812 -0
  17. package/jest.config.ts +29 -0
  18. package/knexfile.js +9 -0
  19. package/license.md +1 -0
  20. package/out/src/Wallet.d.ts +83 -0
  21. package/out/src/Wallet.d.ts.map +1 -0
  22. package/out/src/Wallet.js +415 -0
  23. package/out/src/Wallet.js.map +1 -0
  24. package/out/src/index.all.d.ts +9 -0
  25. package/out/src/index.all.d.ts.map +1 -0
  26. package/out/src/index.all.js +48 -0
  27. package/out/src/index.all.js.map +1 -0
  28. package/out/src/index.client.d.ts +8 -0
  29. package/out/src/index.client.d.ts.map +1 -0
  30. package/out/src/index.client.js +47 -0
  31. package/out/src/index.client.js.map +1 -0
  32. package/out/src/index.d.ts +3 -0
  33. package/out/src/index.d.ts.map +1 -0
  34. package/out/src/index.js +42 -0
  35. package/out/src/index.js.map +1 -0
  36. package/out/src/monitor/Monitor.d.ts +89 -0
  37. package/out/src/monitor/Monitor.d.ts.map +1 -0
  38. package/out/src/monitor/Monitor.js +253 -0
  39. package/out/src/monitor/Monitor.js.map +1 -0
  40. package/out/src/monitor/MonitorDaemon.d.ts +30 -0
  41. package/out/src/monitor/MonitorDaemon.d.ts.map +1 -0
  42. package/out/src/monitor/MonitorDaemon.js +135 -0
  43. package/out/src/monitor/MonitorDaemon.js.map +1 -0
  44. package/out/src/monitor/__test/MonitorDaemon.man.test.d.ts +2 -0
  45. package/out/src/monitor/__test/MonitorDaemon.man.test.d.ts.map +1 -0
  46. package/out/src/monitor/__test/MonitorDaemon.man.test.js +50 -0
  47. package/out/src/monitor/__test/MonitorDaemon.man.test.js.map +1 -0
  48. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +53 -0
  49. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -0
  50. package/out/src/monitor/tasks/TaskCheckForProofs.js +197 -0
  51. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -0
  52. package/out/src/monitor/tasks/TaskClock.d.ts +14 -0
  53. package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -0
  54. package/out/src/monitor/tasks/TaskClock.js +27 -0
  55. package/out/src/monitor/tasks/TaskClock.js.map +1 -0
  56. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +20 -0
  57. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -0
  58. package/out/src/monitor/tasks/TaskFailAbandoned.js +52 -0
  59. package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -0
  60. package/out/src/monitor/tasks/TaskNewHeader.d.ts +15 -0
  61. package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -0
  62. package/out/src/monitor/tasks/TaskNewHeader.js +45 -0
  63. package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -0
  64. package/out/src/monitor/tasks/TaskPurge.d.ts +45 -0
  65. package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -0
  66. package/out/src/monitor/tasks/TaskPurge.js +35 -0
  67. package/out/src/monitor/tasks/TaskPurge.js.map +1 -0
  68. package/out/src/monitor/tasks/TaskReviewStatus.d.ts +26 -0
  69. package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -0
  70. package/out/src/monitor/tasks/TaskReviewStatus.js +44 -0
  71. package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -0
  72. package/out/src/monitor/tasks/TaskSendWaiting.d.ts +32 -0
  73. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -0
  74. package/out/src/monitor/tasks/TaskSendWaiting.js +99 -0
  75. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -0
  76. package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts +12 -0
  77. package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts.map +1 -0
  78. package/out/src/monitor/tasks/TaskSyncWhenIdle.js +22 -0
  79. package/out/src/monitor/tasks/TaskSyncWhenIdle.js.map +1 -0
  80. package/out/src/monitor/tasks/WalletMonitorTask.d.ts +40 -0
  81. package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -0
  82. package/out/src/monitor/tasks/WalletMonitorTask.js +37 -0
  83. package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -0
  84. package/out/src/sdk/CertOps.d.ts +66 -0
  85. package/out/src/sdk/CertOps.d.ts.map +1 -0
  86. package/out/src/sdk/CertOps.js +198 -0
  87. package/out/src/sdk/CertOps.js.map +1 -0
  88. package/out/src/sdk/PrivilegedKeyManager.d.ts +125 -0
  89. package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -0
  90. package/out/src/sdk/PrivilegedKeyManager.js +293 -0
  91. package/out/src/sdk/PrivilegedKeyManager.js.map +1 -0
  92. package/out/src/sdk/StorageSyncReader.d.ts +121 -0
  93. package/out/src/sdk/StorageSyncReader.d.ts.map +1 -0
  94. package/out/src/sdk/StorageSyncReader.js +3 -0
  95. package/out/src/sdk/StorageSyncReader.js.map +1 -0
  96. package/out/src/sdk/StorageSyncReaderWriter.d.ts +89 -0
  97. package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +1 -0
  98. package/out/src/sdk/StorageSyncReaderWriter.js +3 -0
  99. package/out/src/sdk/StorageSyncReaderWriter.js.map +1 -0
  100. package/out/src/sdk/WERR_errors.d.ts +90 -0
  101. package/out/src/sdk/WERR_errors.d.ts.map +1 -0
  102. package/out/src/sdk/WERR_errors.js +128 -0
  103. package/out/src/sdk/WERR_errors.js.map +1 -0
  104. package/out/src/sdk/WalletError.d.ts +45 -0
  105. package/out/src/sdk/WalletError.d.ts.map +1 -0
  106. package/out/src/sdk/WalletError.js +122 -0
  107. package/out/src/sdk/WalletError.js.map +1 -0
  108. package/out/src/sdk/WalletServices.interfaces.d.ts +325 -0
  109. package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -0
  110. package/out/src/sdk/WalletServices.interfaces.js +3 -0
  111. package/out/src/sdk/WalletServices.interfaces.js.map +1 -0
  112. package/out/src/sdk/WalletSigner.interfaces.d.ts +10 -0
  113. package/out/src/sdk/WalletSigner.interfaces.d.ts.map +1 -0
  114. package/out/src/sdk/WalletSigner.interfaces.js +3 -0
  115. package/out/src/sdk/WalletSigner.interfaces.js.map +1 -0
  116. package/out/src/sdk/WalletStorage.interfaces.d.ts +299 -0
  117. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -0
  118. package/out/src/sdk/WalletStorage.interfaces.js +3 -0
  119. package/out/src/sdk/WalletStorage.interfaces.js.map +1 -0
  120. package/out/src/sdk/__test/CertificateLifeCycle.test.d.ts +2 -0
  121. package/out/src/sdk/__test/CertificateLifeCycle.test.d.ts.map +1 -0
  122. package/out/src/sdk/__test/CertificateLifeCycle.test.js +125 -0
  123. package/out/src/sdk/__test/CertificateLifeCycle.test.js.map +1 -0
  124. package/out/src/sdk/__test/PrivilegedKeyManager.test.d.ts +2 -0
  125. package/out/src/sdk/__test/PrivilegedKeyManager.test.d.ts.map +1 -0
  126. package/out/src/sdk/__test/PrivilegedKeyManager.test.js +660 -0
  127. package/out/src/sdk/__test/PrivilegedKeyManager.test.js.map +1 -0
  128. package/out/src/sdk/index.d.ts +12 -0
  129. package/out/src/sdk/index.d.ts.map +1 -0
  130. package/out/src/sdk/index.js +28 -0
  131. package/out/src/sdk/index.js.map +1 -0
  132. package/out/src/sdk/types.d.ts +74 -0
  133. package/out/src/sdk/types.d.ts.map +1 -0
  134. package/out/src/sdk/types.js +20 -0
  135. package/out/src/sdk/types.js.map +1 -0
  136. package/out/src/sdk/validationHelpers.d.ts +288 -0
  137. package/out/src/sdk/validationHelpers.d.ts.map +1 -0
  138. package/out/src/sdk/validationHelpers.js +630 -0
  139. package/out/src/sdk/validationHelpers.js.map +1 -0
  140. package/out/src/services/ServiceCollection.d.ts +25 -0
  141. package/out/src/services/ServiceCollection.d.ts.map +1 -0
  142. package/out/src/services/ServiceCollection.js +43 -0
  143. package/out/src/services/ServiceCollection.js.map +1 -0
  144. package/out/src/services/Services.d.ts +60 -0
  145. package/out/src/services/Services.d.ts.map +1 -0
  146. package/out/src/services/Services.js +342 -0
  147. package/out/src/services/Services.js.map +1 -0
  148. package/out/src/services/__tests/getMerklePath.test.d.ts +2 -0
  149. package/out/src/services/__tests/getMerklePath.test.d.ts.map +1 -0
  150. package/out/src/services/__tests/getMerklePath.test.js +16 -0
  151. package/out/src/services/__tests/getMerklePath.test.js.map +1 -0
  152. package/out/src/services/__tests/getRawTx.test.d.ts +2 -0
  153. package/out/src/services/__tests/getRawTx.test.d.ts.map +1 -0
  154. package/out/src/services/__tests/getRawTx.test.js +13 -0
  155. package/out/src/services/__tests/getRawTx.test.js.map +1 -0
  156. package/out/src/services/__tests/postBeef.test.d.ts +2 -0
  157. package/out/src/services/__tests/postBeef.test.d.ts.map +1 -0
  158. package/out/src/services/__tests/postBeef.test.js +18 -0
  159. package/out/src/services/__tests/postBeef.test.js.map +1 -0
  160. package/out/src/services/__tests/postBeefToArcTaal.test.d.ts +2 -0
  161. package/out/src/services/__tests/postBeefToArcTaal.test.d.ts.map +1 -0
  162. package/out/src/services/__tests/postBeefToArcTaal.test.js +479 -0
  163. package/out/src/services/__tests/postBeefToArcTaal.test.js.map +1 -0
  164. package/out/src/services/__tests/postTxs.test.d.ts +2 -0
  165. package/out/src/services/__tests/postTxs.test.d.ts.map +1 -0
  166. package/out/src/services/__tests/postTxs.test.js +19 -0
  167. package/out/src/services/__tests/postTxs.test.js.map +1 -0
  168. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts +15 -0
  169. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -0
  170. package/out/src/services/chaintracker/ChaintracksChainTracker.js +51 -0
  171. package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -0
  172. package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.d.ts +2 -0
  173. package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.d.ts.map +1 -0
  174. package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.js +19 -0
  175. package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.js.map +1 -0
  176. package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.d.ts +2 -0
  177. package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.d.ts.map +1 -0
  178. package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.js +29 -0
  179. package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.js.map +1 -0
  180. package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts +98 -0
  181. package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -0
  182. package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js +38 -0
  183. package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -0
  184. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +36 -0
  185. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -0
  186. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +130 -0
  187. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -0
  188. package/out/src/services/chaintracker/chaintracks/index.d.ts +3 -0
  189. package/out/src/services/chaintracker/chaintracks/index.d.ts.map +1 -0
  190. package/out/src/services/chaintracker/chaintracks/index.js +19 -0
  191. package/out/src/services/chaintracker/chaintracks/index.js.map +1 -0
  192. package/out/src/services/chaintracker/index.d.ts +3 -0
  193. package/out/src/services/chaintracker/index.d.ts.map +1 -0
  194. package/out/src/services/chaintracker/index.js +19 -0
  195. package/out/src/services/chaintracker/index.js.map +1 -0
  196. package/out/src/services/createDefaultWalletServicesOptions.d.ts +3 -0
  197. package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -0
  198. package/out/src/services/createDefaultWalletServicesOptions.js +34 -0
  199. package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -0
  200. package/out/src/services/index.d.ts +2 -0
  201. package/out/src/services/index.d.ts.map +1 -0
  202. package/out/src/services/index.js +18 -0
  203. package/out/src/services/index.js.map +1 -0
  204. package/out/src/services/providers/arcServices.d.ts +62 -0
  205. package/out/src/services/providers/arcServices.d.ts.map +1 -0
  206. package/out/src/services/providers/arcServices.js +368 -0
  207. package/out/src/services/providers/arcServices.js.map +1 -0
  208. package/out/src/services/providers/echangeRates.d.ts +12 -0
  209. package/out/src/services/providers/echangeRates.d.ts.map +1 -0
  210. package/out/src/services/providers/echangeRates.js +237 -0
  211. package/out/src/services/providers/echangeRates.js.map +1 -0
  212. package/out/src/services/providers/whatsonchain.d.ts +17 -0
  213. package/out/src/services/providers/whatsonchain.d.ts.map +1 -0
  214. package/out/src/services/providers/whatsonchain.js +130 -0
  215. package/out/src/services/providers/whatsonchain.js.map +1 -0
  216. package/out/src/signer/WalletSigner.d.ts +11 -0
  217. package/out/src/signer/WalletSigner.d.ts.map +1 -0
  218. package/out/src/signer/WalletSigner.js +13 -0
  219. package/out/src/signer/WalletSigner.js.map +1 -0
  220. package/out/src/signer/methods/acquireDirectCertificate.d.ts +4 -0
  221. package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -0
  222. package/out/src/signer/methods/acquireDirectCertificate.js +47 -0
  223. package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -0
  224. package/out/src/signer/methods/createAction.d.ts +7 -0
  225. package/out/src/signer/methods/createAction.d.ts.map +1 -0
  226. package/out/src/signer/methods/createAction.js +250 -0
  227. package/out/src/signer/methods/createAction.js.map +1 -0
  228. package/out/src/signer/methods/internalizeAction.d.ts +31 -0
  229. package/out/src/signer/methods/internalizeAction.d.ts.map +1 -0
  230. package/out/src/signer/methods/internalizeAction.js +95 -0
  231. package/out/src/signer/methods/internalizeAction.js.map +1 -0
  232. package/out/src/signer/methods/proveCertificate.d.ts +4 -0
  233. package/out/src/signer/methods/proveCertificate.d.ts.map +1 -0
  234. package/out/src/signer/methods/proveCertificate.js +45 -0
  235. package/out/src/signer/methods/proveCertificate.js.map +1 -0
  236. package/out/src/signer/methods/signAction.d.ts +6 -0
  237. package/out/src/signer/methods/signAction.d.ts.map +1 -0
  238. package/out/src/signer/methods/signAction.js +79 -0
  239. package/out/src/signer/methods/signAction.js.map +1 -0
  240. package/out/src/storage/StorageKnex.d.ts +176 -0
  241. package/out/src/storage/StorageKnex.d.ts.map +1 -0
  242. package/out/src/storage/StorageKnex.js +1035 -0
  243. package/out/src/storage/StorageKnex.js.map +1 -0
  244. package/out/src/storage/StorageProvider.d.ts +140 -0
  245. package/out/src/storage/StorageProvider.d.ts.map +1 -0
  246. package/out/src/storage/StorageProvider.js +539 -0
  247. package/out/src/storage/StorageProvider.js.map +1 -0
  248. package/out/src/storage/StorageReader.d.ts +76 -0
  249. package/out/src/storage/StorageReader.d.ts.map +1 -0
  250. package/out/src/storage/StorageReader.js +124 -0
  251. package/out/src/storage/StorageReader.js.map +1 -0
  252. package/out/src/storage/StorageReaderWriter.d.ts +87 -0
  253. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -0
  254. package/out/src/storage/StorageReaderWriter.js +337 -0
  255. package/out/src/storage/StorageReaderWriter.js.map +1 -0
  256. package/out/src/storage/StorageSyncReader.d.ts +33 -0
  257. package/out/src/storage/StorageSyncReader.d.ts.map +1 -0
  258. package/out/src/storage/StorageSyncReader.js +142 -0
  259. package/out/src/storage/StorageSyncReader.js.map +1 -0
  260. package/out/src/storage/WalletStorageManager.d.ts +103 -0
  261. package/out/src/storage/WalletStorageManager.d.ts.map +1 -0
  262. package/out/src/storage/WalletStorageManager.js +408 -0
  263. package/out/src/storage/WalletStorageManager.js.map +1 -0
  264. package/out/src/storage/__test/WalletStorageManager.test.d.ts +2 -0
  265. package/out/src/storage/__test/WalletStorageManager.test.d.ts.map +1 -0
  266. package/out/src/storage/__test/WalletStorageManager.test.js +260 -0
  267. package/out/src/storage/__test/WalletStorageManager.test.js.map +1 -0
  268. package/out/src/storage/index.all.d.ts +11 -0
  269. package/out/src/storage/index.all.d.ts.map +1 -0
  270. package/out/src/storage/index.all.js +50 -0
  271. package/out/src/storage/index.all.js.map +1 -0
  272. package/out/src/storage/index.client.d.ts +7 -0
  273. package/out/src/storage/index.client.d.ts.map +1 -0
  274. package/out/src/storage/index.client.js +46 -0
  275. package/out/src/storage/index.client.js.map +1 -0
  276. package/out/src/storage/index.db.d.ts +1 -0
  277. package/out/src/storage/index.db.d.ts.map +1 -0
  278. package/out/src/storage/index.db.js +2 -0
  279. package/out/src/storage/index.db.js.map +1 -0
  280. package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.d.ts +2 -0
  281. package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.d.ts.map +1 -0
  282. package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js +948 -0
  283. package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js.map +1 -0
  284. package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts +2 -0
  285. package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts.map +1 -0
  286. package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js +35 -0
  287. package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js.map +1 -0
  288. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +27 -0
  289. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -0
  290. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +148 -0
  291. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -0
  292. package/out/src/storage/methods/createAction.d.ts +23 -0
  293. package/out/src/storage/methods/createAction.d.ts.map +1 -0
  294. package/out/src/storage/methods/createAction.js +663 -0
  295. package/out/src/storage/methods/createAction.js.map +1 -0
  296. package/out/src/storage/methods/generateChange.d.ts +108 -0
  297. package/out/src/storage/methods/generateChange.d.ts.map +1 -0
  298. package/out/src/storage/methods/generateChange.js +422 -0
  299. package/out/src/storage/methods/generateChange.js.map +1 -0
  300. package/out/src/storage/methods/getBeefForTransaction.d.ts +22 -0
  301. package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -0
  302. package/out/src/storage/methods/getBeefForTransaction.js +94 -0
  303. package/out/src/storage/methods/getBeefForTransaction.js.map +1 -0
  304. package/out/src/storage/methods/getSyncChunk.d.ts +10 -0
  305. package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -0
  306. package/out/src/storage/methods/getSyncChunk.js +271 -0
  307. package/out/src/storage/methods/getSyncChunk.js.map +1 -0
  308. package/out/src/storage/methods/internalizeAction.d.ts +38 -0
  309. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -0
  310. package/out/src/storage/methods/internalizeAction.js +378 -0
  311. package/out/src/storage/methods/internalizeAction.js.map +1 -0
  312. package/out/src/storage/methods/listActions.d.ts +5 -0
  313. package/out/src/storage/methods/listActions.d.ts.map +1 -0
  314. package/out/src/storage/methods/listActions.js +174 -0
  315. package/out/src/storage/methods/listActions.js.map +1 -0
  316. package/out/src/storage/methods/listCertificates.d.ts +5 -0
  317. package/out/src/storage/methods/listCertificates.d.ts.map +1 -0
  318. package/out/src/storage/methods/listCertificates.js +68 -0
  319. package/out/src/storage/methods/listCertificates.js.map +1 -0
  320. package/out/src/storage/methods/listOutputs.d.ts +5 -0
  321. package/out/src/storage/methods/listOutputs.d.ts.map +1 -0
  322. package/out/src/storage/methods/listOutputs.js +189 -0
  323. package/out/src/storage/methods/listOutputs.js.map +1 -0
  324. package/out/src/storage/methods/processAction.d.ts +35 -0
  325. package/out/src/storage/methods/processAction.d.ts.map +1 -0
  326. package/out/src/storage/methods/processAction.js +271 -0
  327. package/out/src/storage/methods/processAction.js.map +1 -0
  328. package/out/src/storage/methods/purgeData.d.ts +4 -0
  329. package/out/src/storage/methods/purgeData.d.ts.map +1 -0
  330. package/out/src/storage/methods/purgeData.js +229 -0
  331. package/out/src/storage/methods/purgeData.js.map +1 -0
  332. package/out/src/storage/methods/reviewStatus.d.ts +9 -0
  333. package/out/src/storage/methods/reviewStatus.d.ts.map +1 -0
  334. package/out/src/storage/methods/reviewStatus.js +75 -0
  335. package/out/src/storage/methods/reviewStatus.js.map +1 -0
  336. package/out/src/storage/remoting/StorageClient.d.ts +56 -0
  337. package/out/src/storage/remoting/StorageClient.d.ts.map +1 -0
  338. package/out/src/storage/remoting/StorageClient.js +181 -0
  339. package/out/src/storage/remoting/StorageClient.js.map +1 -0
  340. package/out/src/storage/remoting/StorageServer.d.ts +26 -0
  341. package/out/src/storage/remoting/StorageServer.d.ts.map +1 -0
  342. package/out/src/storage/remoting/StorageServer.js +144 -0
  343. package/out/src/storage/remoting/StorageServer.js.map +1 -0
  344. package/out/src/storage/schema/KnexMigrations.d.ts +39 -0
  345. package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -0
  346. package/out/src/storage/schema/KnexMigrations.js +442 -0
  347. package/out/src/storage/schema/KnexMigrations.js.map +1 -0
  348. package/out/src/storage/schema/entities/Certificate.d.ts +43 -0
  349. package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -0
  350. package/out/src/storage/schema/entities/Certificate.js +162 -0
  351. package/out/src/storage/schema/entities/Certificate.js.map +1 -0
  352. package/out/src/storage/schema/entities/CertificateField.d.ts +32 -0
  353. package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -0
  354. package/out/src/storage/schema/entities/CertificateField.js +114 -0
  355. package/out/src/storage/schema/entities/CertificateField.js.map +1 -0
  356. package/out/src/storage/schema/entities/Commission.d.ts +37 -0
  357. package/out/src/storage/schema/entities/Commission.d.ts.map +1 -0
  358. package/out/src/storage/schema/entities/Commission.js +130 -0
  359. package/out/src/storage/schema/entities/Commission.js.map +1 -0
  360. package/out/src/storage/schema/entities/EntityBase.d.ts +105 -0
  361. package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -0
  362. package/out/src/storage/schema/entities/EntityBase.js +100 -0
  363. package/out/src/storage/schema/entities/EntityBase.js.map +1 -0
  364. package/out/src/storage/schema/entities/MergeEntity.d.ts +34 -0
  365. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -0
  366. package/out/src/storage/schema/entities/MergeEntity.js +57 -0
  367. package/out/src/storage/schema/entities/MergeEntity.js.map +1 -0
  368. package/out/src/storage/schema/entities/Output.d.ts +67 -0
  369. package/out/src/storage/schema/entities/Output.d.ts.map +1 -0
  370. package/out/src/storage/schema/entities/Output.js +281 -0
  371. package/out/src/storage/schema/entities/Output.js.map +1 -0
  372. package/out/src/storage/schema/entities/OutputBasket.d.ts +35 -0
  373. package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -0
  374. package/out/src/storage/schema/entities/OutputBasket.js +133 -0
  375. package/out/src/storage/schema/entities/OutputBasket.js.map +1 -0
  376. package/out/src/storage/schema/entities/OutputTag.d.ts +31 -0
  377. package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -0
  378. package/out/src/storage/schema/entities/OutputTag.js +104 -0
  379. package/out/src/storage/schema/entities/OutputTag.js.map +1 -0
  380. package/out/src/storage/schema/entities/OutputTagMap.d.ts +28 -0
  381. package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -0
  382. package/out/src/storage/schema/entities/OutputTagMap.js +101 -0
  383. package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -0
  384. package/out/src/storage/schema/entities/ProvenTx.d.ts +84 -0
  385. package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -0
  386. package/out/src/storage/schema/entities/ProvenTx.js +283 -0
  387. package/out/src/storage/schema/entities/ProvenTx.js.map +1 -0
  388. package/out/src/storage/schema/entities/ProvenTxReq.d.ts +130 -0
  389. package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -0
  390. package/out/src/storage/schema/entities/ProvenTxReq.js +521 -0
  391. package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -0
  392. package/out/src/storage/schema/entities/SyncState.d.ts +66 -0
  393. package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -0
  394. package/out/src/storage/schema/entities/SyncState.js +284 -0
  395. package/out/src/storage/schema/entities/SyncState.js.map +1 -0
  396. package/out/src/storage/schema/entities/Transaction.d.ts +67 -0
  397. package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -0
  398. package/out/src/storage/schema/entities/Transaction.js +264 -0
  399. package/out/src/storage/schema/entities/Transaction.js.map +1 -0
  400. package/out/src/storage/schema/entities/TxLabel.d.ts +31 -0
  401. package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -0
  402. package/out/src/storage/schema/entities/TxLabel.js +104 -0
  403. package/out/src/storage/schema/entities/TxLabel.js.map +1 -0
  404. package/out/src/storage/schema/entities/TxLabelMap.d.ts +28 -0
  405. package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -0
  406. package/out/src/storage/schema/entities/TxLabelMap.js +103 -0
  407. package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -0
  408. package/out/src/storage/schema/entities/User.d.ts +29 -0
  409. package/out/src/storage/schema/entities/User.d.ts.map +1 -0
  410. package/out/src/storage/schema/entities/User.js +100 -0
  411. package/out/src/storage/schema/entities/User.js.map +1 -0
  412. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.d.ts +2 -0
  413. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.d.ts.map +1 -0
  414. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js +588 -0
  415. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -0
  416. package/out/src/storage/schema/entities/__tests/CertificateTests.test.d.ts +2 -0
  417. package/out/src/storage/schema/entities/__tests/CertificateTests.test.d.ts.map +1 -0
  418. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js +449 -0
  419. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -0
  420. package/out/src/storage/schema/entities/__tests/CommissionTests.test.d.ts +2 -0
  421. package/out/src/storage/schema/entities/__tests/CommissionTests.test.d.ts.map +1 -0
  422. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js +602 -0
  423. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -0
  424. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.d.ts +2 -0
  425. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.d.ts.map +1 -0
  426. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js +515 -0
  427. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -0
  428. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.d.ts +2 -0
  429. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.d.ts.map +1 -0
  430. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js +478 -0
  431. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -0
  432. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.d.ts +2 -0
  433. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.d.ts.map +1 -0
  434. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js +440 -0
  435. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -0
  436. package/out/src/storage/schema/entities/__tests/OutputTests.test.d.ts +2 -0
  437. package/out/src/storage/schema/entities/__tests/OutputTests.test.d.ts.map +1 -0
  438. package/out/src/storage/schema/entities/__tests/OutputTests.test.js +626 -0
  439. package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -0
  440. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.d.ts +2 -0
  441. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.d.ts.map +1 -0
  442. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js +585 -0
  443. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -0
  444. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.d.ts +2 -0
  445. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.d.ts.map +1 -0
  446. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +628 -0
  447. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -0
  448. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.d.ts +2 -0
  449. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.d.ts.map +1 -0
  450. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js +307 -0
  451. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -0
  452. package/out/src/storage/schema/entities/__tests/TransactionTests.test.d.ts +2 -0
  453. package/out/src/storage/schema/entities/__tests/TransactionTests.test.d.ts.map +1 -0
  454. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +823 -0
  455. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -0
  456. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.d.ts +2 -0
  457. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.d.ts.map +1 -0
  458. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js +442 -0
  459. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -0
  460. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.d.ts +2 -0
  461. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.d.ts.map +1 -0
  462. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js +313 -0
  463. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -0
  464. package/out/src/storage/schema/entities/__tests/stampLogTests.test.d.ts +2 -0
  465. package/out/src/storage/schema/entities/__tests/stampLogTests.test.d.ts.map +1 -0
  466. package/out/src/storage/schema/entities/__tests/stampLogTests.test.js +81 -0
  467. package/out/src/storage/schema/entities/__tests/stampLogTests.test.js.map +1 -0
  468. package/out/src/storage/schema/entities/__tests/usersTests.test.d.ts +2 -0
  469. package/out/src/storage/schema/entities/__tests/usersTests.test.d.ts.map +1 -0
  470. package/out/src/storage/schema/entities/__tests/usersTests.test.js +418 -0
  471. package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -0
  472. package/out/src/storage/schema/entities/index.d.ts +17 -0
  473. package/out/src/storage/schema/entities/index.d.ts.map +1 -0
  474. package/out/src/storage/schema/entities/index.js +33 -0
  475. package/out/src/storage/schema/entities/index.js.map +1 -0
  476. package/out/src/storage/schema/tables/Certificate.d.ts +20 -0
  477. package/out/src/storage/schema/tables/Certificate.d.ts.map +1 -0
  478. package/out/src/storage/schema/tables/Certificate.js +3 -0
  479. package/out/src/storage/schema/tables/Certificate.js.map +1 -0
  480. package/out/src/storage/schema/tables/CertificateField.d.ts +12 -0
  481. package/out/src/storage/schema/tables/CertificateField.d.ts.map +1 -0
  482. package/out/src/storage/schema/tables/CertificateField.js +3 -0
  483. package/out/src/storage/schema/tables/CertificateField.js.map +1 -0
  484. package/out/src/storage/schema/tables/Commission.d.ts +13 -0
  485. package/out/src/storage/schema/tables/Commission.d.ts.map +1 -0
  486. package/out/src/storage/schema/tables/Commission.js +3 -0
  487. package/out/src/storage/schema/tables/Commission.js.map +1 -0
  488. package/out/src/storage/schema/tables/MonitorEvent.d.ts +9 -0
  489. package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +1 -0
  490. package/out/src/storage/schema/tables/MonitorEvent.js +3 -0
  491. package/out/src/storage/schema/tables/MonitorEvent.js.map +1 -0
  492. package/out/src/storage/schema/tables/Output.d.ts +36 -0
  493. package/out/src/storage/schema/tables/Output.d.ts.map +1 -0
  494. package/out/src/storage/schema/tables/Output.js +31 -0
  495. package/out/src/storage/schema/tables/Output.js.map +1 -0
  496. package/out/src/storage/schema/tables/OutputBasket.d.ts +12 -0
  497. package/out/src/storage/schema/tables/OutputBasket.d.ts.map +1 -0
  498. package/out/src/storage/schema/tables/OutputBasket.js +3 -0
  499. package/out/src/storage/schema/tables/OutputBasket.js.map +1 -0
  500. package/out/src/storage/schema/tables/OutputTag.d.ts +10 -0
  501. package/out/src/storage/schema/tables/OutputTag.d.ts.map +1 -0
  502. package/out/src/storage/schema/tables/OutputTag.js +3 -0
  503. package/out/src/storage/schema/tables/OutputTag.js.map +1 -0
  504. package/out/src/storage/schema/tables/OutputTagMap.d.ts +9 -0
  505. package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +1 -0
  506. package/out/src/storage/schema/tables/OutputTagMap.js +3 -0
  507. package/out/src/storage/schema/tables/OutputTagMap.js.map +1 -0
  508. package/out/src/storage/schema/tables/ProvenTx.d.ts +14 -0
  509. package/out/src/storage/schema/tables/ProvenTx.d.ts.map +1 -0
  510. package/out/src/storage/schema/tables/ProvenTx.js +3 -0
  511. package/out/src/storage/schema/tables/ProvenTx.js.map +1 -0
  512. package/out/src/storage/schema/tables/ProvenTxReq.d.ts +64 -0
  513. package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +1 -0
  514. package/out/src/storage/schema/tables/ProvenTxReq.js +3 -0
  515. package/out/src/storage/schema/tables/ProvenTxReq.js.map +1 -0
  516. package/out/src/storage/schema/tables/Settings.d.ts +17 -0
  517. package/out/src/storage/schema/tables/Settings.d.ts.map +1 -0
  518. package/out/src/storage/schema/tables/Settings.js +3 -0
  519. package/out/src/storage/schema/tables/Settings.js.map +1 -0
  520. package/out/src/storage/schema/tables/SyncState.d.ts +18 -0
  521. package/out/src/storage/schema/tables/SyncState.d.ts.map +1 -0
  522. package/out/src/storage/schema/tables/SyncState.js +3 -0
  523. package/out/src/storage/schema/tables/SyncState.js.map +1 -0
  524. package/out/src/storage/schema/tables/Transaction.d.ts +37 -0
  525. package/out/src/storage/schema/tables/Transaction.d.ts.map +1 -0
  526. package/out/src/storage/schema/tables/Transaction.js +21 -0
  527. package/out/src/storage/schema/tables/Transaction.js.map +1 -0
  528. package/out/src/storage/schema/tables/TxLabel.d.ts +10 -0
  529. package/out/src/storage/schema/tables/TxLabel.d.ts.map +1 -0
  530. package/out/src/storage/schema/tables/TxLabel.js +3 -0
  531. package/out/src/storage/schema/tables/TxLabel.js.map +1 -0
  532. package/out/src/storage/schema/tables/TxLabelMap.d.ts +9 -0
  533. package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +1 -0
  534. package/out/src/storage/schema/tables/TxLabelMap.js +3 -0
  535. package/out/src/storage/schema/tables/TxLabelMap.js.map +1 -0
  536. package/out/src/storage/schema/tables/User.d.ts +16 -0
  537. package/out/src/storage/schema/tables/User.d.ts.map +1 -0
  538. package/out/src/storage/schema/tables/User.js +3 -0
  539. package/out/src/storage/schema/tables/User.js.map +1 -0
  540. package/out/src/storage/schema/tables/index.d.ts +17 -0
  541. package/out/src/storage/schema/tables/index.d.ts.map +1 -0
  542. package/out/src/storage/schema/tables/index.js +33 -0
  543. package/out/src/storage/schema/tables/index.js.map +1 -0
  544. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts +71 -0
  545. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -0
  546. package/out/src/storage/sync/StorageMySQLDojoReader.js +612 -0
  547. package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -0
  548. package/out/src/storage/sync/index.d.ts +2 -0
  549. package/out/src/storage/sync/index.d.ts.map +1 -0
  550. package/out/src/storage/sync/index.js +18 -0
  551. package/out/src/storage/sync/index.js.map +1 -0
  552. package/out/src/utility/ScriptTemplateSABPPP.d.ts +25 -0
  553. package/out/src/utility/ScriptTemplateSABPPP.d.ts.map +1 -0
  554. package/out/src/utility/ScriptTemplateSABPPP.js +46 -0
  555. package/out/src/utility/ScriptTemplateSABPPP.js.map +1 -0
  556. package/out/src/utility/index.all.d.ts +7 -0
  557. package/out/src/utility/index.all.d.ts.map +1 -0
  558. package/out/src/utility/index.all.js +23 -0
  559. package/out/src/utility/index.all.js.map +1 -0
  560. package/out/src/utility/index.client.d.ts +7 -0
  561. package/out/src/utility/index.client.d.ts.map +1 -0
  562. package/out/src/utility/index.client.js +23 -0
  563. package/out/src/utility/index.client.js.map +1 -0
  564. package/out/src/utility/parseTxScriptOffsets.d.ts +14 -0
  565. package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -0
  566. package/out/src/utility/parseTxScriptOffsets.js +26 -0
  567. package/out/src/utility/parseTxScriptOffsets.js.map +1 -0
  568. package/out/src/utility/stampLog.d.ts +18 -0
  569. package/out/src/utility/stampLog.d.ts.map +1 -0
  570. package/out/src/utility/stampLog.js +72 -0
  571. package/out/src/utility/stampLog.js.map +1 -0
  572. package/out/src/utility/tscProofToMerklePath.d.ts +8 -0
  573. package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -0
  574. package/out/src/utility/tscProofToMerklePath.js +41 -0
  575. package/out/src/utility/tscProofToMerklePath.js.map +1 -0
  576. package/out/src/utility/utilityHelpers.buffer.d.ts +18 -0
  577. package/out/src/utility/utilityHelpers.buffer.d.ts.map +1 -0
  578. package/out/src/utility/utilityHelpers.buffer.js +45 -0
  579. package/out/src/utility/utilityHelpers.buffer.js.map +1 -0
  580. package/out/src/utility/utilityHelpers.d.ts +129 -0
  581. package/out/src/utility/utilityHelpers.d.ts.map +1 -0
  582. package/out/src/utility/utilityHelpers.js +268 -0
  583. package/out/src/utility/utilityHelpers.js.map +1 -0
  584. package/out/src/utility/utilityHelpers.noBuffer.d.ts +9 -0
  585. package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -0
  586. package/out/src/utility/utilityHelpers.noBuffer.js +23 -0
  587. package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -0
  588. package/out/test/Wallet/StorageClient/storageClient.man.test.d.ts +2 -0
  589. package/out/test/Wallet/StorageClient/storageClient.man.test.d.ts.map +1 -0
  590. package/out/test/Wallet/StorageClient/storageClient.man.test.js +45 -0
  591. package/out/test/Wallet/StorageClient/storageClient.man.test.js.map +1 -0
  592. package/out/test/Wallet/action/internalizeAction.a.test.d.ts +2 -0
  593. package/out/test/Wallet/action/internalizeAction.a.test.d.ts.map +1 -0
  594. package/out/test/Wallet/action/internalizeAction.a.test.js +243 -0
  595. package/out/test/Wallet/action/internalizeAction.a.test.js.map +1 -0
  596. package/out/test/Wallet/certificate/acquireCertificate.test.d.ts +2 -0
  597. package/out/test/Wallet/certificate/acquireCertificate.test.d.ts.map +1 -0
  598. package/out/test/Wallet/certificate/acquireCertificate.test.js +213 -0
  599. package/out/test/Wallet/certificate/acquireCertificate.test.js.map +1 -0
  600. package/out/test/Wallet/certificate/listCertificates.test.d.ts +2 -0
  601. package/out/test/Wallet/certificate/listCertificates.test.d.ts.map +1 -0
  602. package/out/test/Wallet/certificate/listCertificates.test.js +305 -0
  603. package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -0
  604. package/out/test/Wallet/get/getHeaderForHeight.test.d.ts +2 -0
  605. package/out/test/Wallet/get/getHeaderForHeight.test.d.ts.map +1 -0
  606. package/out/test/Wallet/get/getHeaderForHeight.test.js +68 -0
  607. package/out/test/Wallet/get/getHeaderForHeight.test.js.map +1 -0
  608. package/out/test/Wallet/get/getHeight.test.d.ts +2 -0
  609. package/out/test/Wallet/get/getHeight.test.d.ts.map +1 -0
  610. package/out/test/Wallet/get/getHeight.test.js +45 -0
  611. package/out/test/Wallet/get/getHeight.test.js.map +1 -0
  612. package/out/test/Wallet/get/getKnownTxids.test.d.ts +2 -0
  613. package/out/test/Wallet/get/getKnownTxids.test.d.ts.map +1 -0
  614. package/out/test/Wallet/get/getKnownTxids.test.js +73 -0
  615. package/out/test/Wallet/get/getKnownTxids.test.js.map +1 -0
  616. package/out/test/Wallet/get/getNetwork.test.d.ts +2 -0
  617. package/out/test/Wallet/get/getNetwork.test.d.ts.map +1 -0
  618. package/out/test/Wallet/get/getNetwork.test.js +26 -0
  619. package/out/test/Wallet/get/getNetwork.test.js.map +1 -0
  620. package/out/test/Wallet/get/getVersion.test.d.ts +2 -0
  621. package/out/test/Wallet/get/getVersion.test.d.ts.map +1 -0
  622. package/out/test/Wallet/get/getVersion.test.js +25 -0
  623. package/out/test/Wallet/get/getVersion.test.js.map +1 -0
  624. package/out/test/Wallet/live/walletLive.man.test.d.ts +26 -0
  625. package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -0
  626. package/out/test/Wallet/live/walletLive.man.test.js +389 -0
  627. package/out/test/Wallet/live/walletLive.man.test.js.map +1 -0
  628. package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.d.ts +2 -0
  629. package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.d.ts.map +1 -0
  630. package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js +153 -0
  631. package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js.map +1 -0
  632. package/out/test/checkDB.d.ts +4 -0
  633. package/out/test/checkDB.d.ts.map +1 -0
  634. package/out/test/checkDB.js +55 -0
  635. package/out/test/checkDB.js.map +1 -0
  636. package/out/test/examples/README.man.test.d.ts +2 -0
  637. package/out/test/examples/README.man.test.d.ts.map +1 -0
  638. package/out/test/examples/README.man.test.js +46 -0
  639. package/out/test/examples/README.man.test.js.map +1 -0
  640. package/out/test/monitor/Monitor.test.d.ts +2 -0
  641. package/out/test/monitor/Monitor.test.d.ts.map +1 -0
  642. package/out/test/monitor/Monitor.test.js +446 -0
  643. package/out/test/monitor/Monitor.test.js.map +1 -0
  644. package/out/test/services/Services.test.d.ts +2 -0
  645. package/out/test/services/Services.test.d.ts.map +1 -0
  646. package/out/test/services/Services.test.js +128 -0
  647. package/out/test/services/Services.test.js.map +1 -0
  648. package/out/test/storage/KnexMigrations.test.d.ts +2 -0
  649. package/out/test/storage/KnexMigrations.test.d.ts.map +1 -0
  650. package/out/test/storage/KnexMigrations.test.js +81 -0
  651. package/out/test/storage/KnexMigrations.test.js.map +1 -0
  652. package/out/test/storage/StorageMySQLDojoReader.man.test.d.ts +2 -0
  653. package/out/test/storage/StorageMySQLDojoReader.man.test.d.ts.map +1 -0
  654. package/out/test/storage/StorageMySQLDojoReader.man.test.js +88 -0
  655. package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -0
  656. package/out/test/storage/count.test.d.ts +2 -0
  657. package/out/test/storage/count.test.d.ts.map +1 -0
  658. package/out/test/storage/count.test.js +141 -0
  659. package/out/test/storage/count.test.js.map +1 -0
  660. package/out/test/storage/find.test.d.ts +2 -0
  661. package/out/test/storage/find.test.d.ts.map +1 -0
  662. package/out/test/storage/find.test.js +148 -0
  663. package/out/test/storage/find.test.js.map +1 -0
  664. package/out/test/storage/findLegacy.test.d.ts +2 -0
  665. package/out/test/storage/findLegacy.test.d.ts.map +1 -0
  666. package/out/test/storage/findLegacy.test.js +52 -0
  667. package/out/test/storage/findLegacy.test.js.map +1 -0
  668. package/out/test/storage/insert.test.d.ts +2 -0
  669. package/out/test/storage/insert.test.d.ts.map +1 -0
  670. package/out/test/storage/insert.test.js +256 -0
  671. package/out/test/storage/insert.test.js.map +1 -0
  672. package/out/test/storage/update.test.d.ts +2 -0
  673. package/out/test/storage/update.test.d.ts.map +1 -0
  674. package/out/test/storage/update.test.js +926 -0
  675. package/out/test/storage/update.test.js.map +1 -0
  676. package/out/test/storage/update2.test.d.ts +2 -0
  677. package/out/test/storage/update2.test.d.ts.map +1 -0
  678. package/out/test/storage/update2.test.js +766 -0
  679. package/out/test/storage/update2.test.js.map +1 -0
  680. package/out/test/utils/TestUtilsWalletStorage.d.ts +399 -0
  681. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -0
  682. package/out/test/utils/TestUtilsWalletStorage.js +1337 -0
  683. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -0
  684. package/out/test/wallet/action/abortAction.test.d.ts +2 -0
  685. package/out/test/wallet/action/abortAction.test.d.ts.map +1 -0
  686. package/out/test/wallet/action/abortAction.test.js +44 -0
  687. package/out/test/wallet/action/abortAction.test.js.map +1 -0
  688. package/out/test/wallet/action/createAction.test.d.ts +2 -0
  689. package/out/test/wallet/action/createAction.test.d.ts.map +1 -0
  690. package/out/test/wallet/action/createAction.test.js +230 -0
  691. package/out/test/wallet/action/createAction.test.js.map +1 -0
  692. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts +2 -0
  693. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +1 -0
  694. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js +273 -0
  695. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -0
  696. package/out/test/wallet/action/internalizeAction.test.d.ts +2 -0
  697. package/out/test/wallet/action/internalizeAction.test.d.ts.map +1 -0
  698. package/out/test/wallet/action/internalizeAction.test.js +603 -0
  699. package/out/test/wallet/action/internalizeAction.test.js.map +1 -0
  700. package/out/test/wallet/action/relinquishOutput.test.d.ts +2 -0
  701. package/out/test/wallet/action/relinquishOutput.test.d.ts.map +1 -0
  702. package/out/test/wallet/action/relinquishOutput.test.js +31 -0
  703. package/out/test/wallet/action/relinquishOutput.test.js.map +1 -0
  704. package/out/test/wallet/construct/Wallet.constructor.test.d.ts +2 -0
  705. package/out/test/wallet/construct/Wallet.constructor.test.d.ts.map +1 -0
  706. package/out/test/wallet/construct/Wallet.constructor.test.js +49 -0
  707. package/out/test/wallet/construct/Wallet.constructor.test.js.map +1 -0
  708. package/out/test/wallet/list/listActions.test.d.ts +2 -0
  709. package/out/test/wallet/list/listActions.test.d.ts.map +1 -0
  710. package/out/test/wallet/list/listActions.test.js +265 -0
  711. package/out/test/wallet/list/listActions.test.js.map +1 -0
  712. package/out/test/wallet/list/listActions2.test.d.ts +2 -0
  713. package/out/test/wallet/list/listActions2.test.d.ts.map +1 -0
  714. package/out/test/wallet/list/listActions2.test.js +423 -0
  715. package/out/test/wallet/list/listActions2.test.js.map +1 -0
  716. package/out/test/wallet/list/listCertificates.test.d.ts +2 -0
  717. package/out/test/wallet/list/listCertificates.test.d.ts.map +1 -0
  718. package/out/test/wallet/list/listCertificates.test.js +115 -0
  719. package/out/test/wallet/list/listCertificates.test.js.map +1 -0
  720. package/out/test/wallet/list/listOutputs.test.d.ts +2 -0
  721. package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -0
  722. package/out/test/wallet/list/listOutputs.test.js +521 -0
  723. package/out/test/wallet/list/listOutputs.test.js.map +1 -0
  724. package/out/test/wallet/sync/Wallet.sync.test.d.ts +2 -0
  725. package/out/test/wallet/sync/Wallet.sync.test.d.ts.map +1 -0
  726. package/out/test/wallet/sync/Wallet.sync.test.js +142 -0
  727. package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -0
  728. package/out/tsconfig.all.tsbuildinfo +1 -0
  729. package/package.json +63 -0
  730. package/src/Wallet.ts +771 -0
  731. package/src/index.all.ts +8 -0
  732. package/src/index.client.ts +7 -0
  733. package/src/index.ts +2 -0
  734. package/src/monitor/Monitor.ts +317 -0
  735. package/src/monitor/MonitorDaemon.ts +197 -0
  736. package/src/monitor/README.md +3 -0
  737. package/src/monitor/__test/MonitorDaemon.man.test.ts +17 -0
  738. package/src/monitor/tasks/TaskCheckForProofs.ts +235 -0
  739. package/src/monitor/tasks/TaskClock.ts +35 -0
  740. package/src/monitor/tasks/TaskFailAbandoned.ts +56 -0
  741. package/src/monitor/tasks/TaskNewHeader.ts +48 -0
  742. package/src/monitor/tasks/TaskPurge.ts +69 -0
  743. package/src/monitor/tasks/TaskReviewStatus.ts +51 -0
  744. package/src/monitor/tasks/TaskSendWaiting.ts +107 -0
  745. package/src/monitor/tasks/TaskSyncWhenIdle.ts +26 -0
  746. package/src/monitor/tasks/WalletMonitorTask.ts +47 -0
  747. package/src/sdk/CertOps.ts +346 -0
  748. package/src/sdk/PrivilegedKeyManager.ts +402 -0
  749. package/src/sdk/README.md +13 -0
  750. package/src/sdk/StorageSyncReader.ts +155 -0
  751. package/src/sdk/StorageSyncReaderWriter.ts +263 -0
  752. package/src/sdk/WERR_errors.ts +152 -0
  753. package/src/sdk/WalletError.ts +136 -0
  754. package/src/sdk/WalletServices.interfaces.ts +399 -0
  755. package/src/sdk/WalletSigner.interfaces.ts +38 -0
  756. package/src/sdk/WalletStorage.interfaces.ts +416 -0
  757. package/src/sdk/__test/CertificateLifeCycle.test.ts +194 -0
  758. package/src/sdk/__test/PrivilegedKeyManager.test.ts +775 -0
  759. package/src/sdk/index.ts +11 -0
  760. package/src/sdk/types.ts +115 -0
  761. package/src/sdk/validationHelpers.ts +1248 -0
  762. package/src/services/README.md +11 -0
  763. package/src/services/ServiceCollection.ts +50 -0
  764. package/src/services/Services.ts +461 -0
  765. package/src/services/__tests/getMerklePath.test.ts +16 -0
  766. package/src/services/__tests/getRawTx.test.ts +15 -0
  767. package/src/services/__tests/postBeef.test.ts +19 -0
  768. package/src/services/__tests/postBeefToArcTaal.test.ts +487 -0
  769. package/src/services/__tests/postTxs.test.ts +20 -0
  770. package/src/services/chaintracker/ChaintracksChainTracker.ts +78 -0
  771. package/src/services/chaintracker/__tests/ChaintracksChainTracker.test.ts +25 -0
  772. package/src/services/chaintracker/__tests/ChaintracksServiceClient.test.ts +32 -0
  773. package/src/services/chaintracker/chaintracks/BlockHeaderApi.ts +123 -0
  774. package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +160 -0
  775. package/src/services/chaintracker/chaintracks/index.ts +2 -0
  776. package/src/services/chaintracker/index.ts +2 -0
  777. package/src/services/createDefaultWalletServicesOptions.ts +38 -0
  778. package/src/services/index.ts +1 -0
  779. package/src/services/providers/arcServices.ts +570 -0
  780. package/src/services/providers/echangeRates.ts +276 -0
  781. package/src/services/providers/whatsonchain.ts +170 -0
  782. package/src/signer/README.md +5 -0
  783. package/src/signer/WalletSigner.ts +21 -0
  784. package/src/signer/methods/acquireDirectCertificate.ts +53 -0
  785. package/src/signer/methods/createAction.ts +364 -0
  786. package/src/signer/methods/internalizeAction.ts +142 -0
  787. package/src/signer/methods/proveCertificate.ts +51 -0
  788. package/src/signer/methods/signAction.ts +121 -0
  789. package/src/storage/README.md +14 -0
  790. package/src/storage/StorageKnex.ts +1449 -0
  791. package/src/storage/StorageProvider.ts +853 -0
  792. package/src/storage/StorageReader.ts +222 -0
  793. package/src/storage/StorageReaderWriter.ts +623 -0
  794. package/src/storage/StorageSyncReader.ts +143 -0
  795. package/src/storage/WalletStorageManager.ts +532 -0
  796. package/src/storage/__test/WalletStorageManager.test.ts +292 -0
  797. package/src/storage/index.all.ts +10 -0
  798. package/src/storage/index.client.ts +6 -0
  799. package/src/storage/index.db.ts +0 -0
  800. package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +1143 -0
  801. package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +31 -0
  802. package/src/storage/methods/attemptToPostReqsToNetwork.ts +185 -0
  803. package/src/storage/methods/createAction.ts +997 -0
  804. package/src/storage/methods/generateChange.ts +629 -0
  805. package/src/storage/methods/getBeefForTransaction.ts +143 -0
  806. package/src/storage/methods/getSyncChunk.ts +330 -0
  807. package/src/storage/methods/internalizeAction.ts +538 -0
  808. package/src/storage/methods/listActions.ts +203 -0
  809. package/src/storage/methods/listCertificates.ts +81 -0
  810. package/src/storage/methods/listOutputs.ts +219 -0
  811. package/src/storage/methods/processAction.ts +477 -0
  812. package/src/storage/methods/purgeData.ts +276 -0
  813. package/src/storage/methods/reviewStatus.ts +95 -0
  814. package/src/storage/remoting/StorageClient.ts +306 -0
  815. package/src/storage/remoting/StorageServer.ts +179 -0
  816. package/src/storage/schema/KnexMigrations.ts +488 -0
  817. package/src/storage/schema/entities/Certificate.ts +199 -0
  818. package/src/storage/schema/entities/CertificateField.ts +157 -0
  819. package/src/storage/schema/entities/Commission.ts +169 -0
  820. package/src/storage/schema/entities/EntityBase.ts +214 -0
  821. package/src/storage/schema/entities/MergeEntity.ts +79 -0
  822. package/src/storage/schema/entities/Output.ts +323 -0
  823. package/src/storage/schema/entities/OutputBasket.ts +165 -0
  824. package/src/storage/schema/entities/OutputTag.ts +138 -0
  825. package/src/storage/schema/entities/OutputTagMap.ts +146 -0
  826. package/src/storage/schema/entities/ProvenTx.ts +349 -0
  827. package/src/storage/schema/entities/ProvenTxReq.ts +646 -0
  828. package/src/storage/schema/entities/SyncState.ts +429 -0
  829. package/src/storage/schema/entities/Transaction.ts +334 -0
  830. package/src/storage/schema/entities/TxLabel.ts +135 -0
  831. package/src/storage/schema/entities/TxLabelMap.ts +148 -0
  832. package/src/storage/schema/entities/User.ts +138 -0
  833. package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +663 -0
  834. package/src/storage/schema/entities/__tests/CertificateTests.test.ts +527 -0
  835. package/src/storage/schema/entities/__tests/CommissionTests.test.ts +658 -0
  836. package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +567 -0
  837. package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +530 -0
  838. package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +504 -0
  839. package/src/storage/schema/entities/__tests/OutputTests.test.ts +689 -0
  840. package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +669 -0
  841. package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +700 -0
  842. package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +376 -0
  843. package/src/storage/schema/entities/__tests/TransactionTests.test.ts +920 -0
  844. package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +512 -0
  845. package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +350 -0
  846. package/src/storage/schema/entities/__tests/stampLogTests.test.ts +97 -0
  847. package/src/storage/schema/entities/__tests/usersTests.test.ts +485 -0
  848. package/src/storage/schema/entities/index.ts +16 -0
  849. package/src/storage/schema/tables/Certificate.ts +21 -0
  850. package/src/storage/schema/tables/CertificateField.ts +12 -0
  851. package/src/storage/schema/tables/Commission.ts +13 -0
  852. package/src/storage/schema/tables/MonitorEvent.ts +9 -0
  853. package/src/storage/schema/tables/Output.ts +64 -0
  854. package/src/storage/schema/tables/OutputBasket.ts +12 -0
  855. package/src/storage/schema/tables/OutputTag.ts +10 -0
  856. package/src/storage/schema/tables/OutputTagMap.ts +9 -0
  857. package/src/storage/schema/tables/ProvenTx.ts +14 -0
  858. package/src/storage/schema/tables/ProvenTxReq.ts +65 -0
  859. package/src/storage/schema/tables/Settings.ts +17 -0
  860. package/src/storage/schema/tables/SyncState.ts +18 -0
  861. package/src/storage/schema/tables/Transaction.ts +54 -0
  862. package/src/storage/schema/tables/TxLabel.ts +10 -0
  863. package/src/storage/schema/tables/TxLabelMap.ts +9 -0
  864. package/src/storage/schema/tables/User.ts +16 -0
  865. package/src/storage/schema/tables/index.ts +16 -0
  866. package/src/storage/sync/StorageMySQLDojoReader.ts +771 -0
  867. package/src/storage/sync/index.ts +1 -0
  868. package/src/utility/README.md +3 -0
  869. package/src/utility/ScriptTemplateSABPPP.ts +79 -0
  870. package/src/utility/index.all.ts +7 -0
  871. package/src/utility/index.client.ts +7 -0
  872. package/src/utility/parseTxScriptOffsets.ts +29 -0
  873. package/src/utility/stampLog.ts +73 -0
  874. package/src/utility/tscProofToMerklePath.ts +51 -0
  875. package/src/utility/utilityHelpers.buffer.ts +43 -0
  876. package/src/utility/utilityHelpers.noBuffer.ts +18 -0
  877. package/src/utility/utilityHelpers.ts +283 -0
  878. package/test/Wallet/StorageClient/storageClient.man.test.ts +55 -0
  879. package/test/Wallet/action/internalizeAction.a.test.ts +301 -0
  880. package/test/Wallet/certificate/acquireCertificate.test.ts +253 -0
  881. package/test/Wallet/certificate/listCertificates.test.ts +352 -0
  882. package/test/Wallet/get/getHeaderForHeight.test.ts +79 -0
  883. package/test/Wallet/get/getHeight.test.ts +52 -0
  884. package/test/Wallet/get/getKnownTxids.test.ts +90 -0
  885. package/test/Wallet/get/getNetwork.test.ts +28 -0
  886. package/test/Wallet/get/getVersion.test.ts +28 -0
  887. package/test/Wallet/live/walletLive.man.test.ts +510 -0
  888. package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +155 -0
  889. package/test/checkDB.ts +63 -0
  890. package/test/checkdb +0 -0
  891. package/test/examples/README.man.test.ts +53 -0
  892. package/test/monitor/Monitor.test.ts +536 -0
  893. package/test/services/Services.test.ts +149 -0
  894. package/test/storage/KnexMigrations.test.ts +100 -0
  895. package/test/storage/StorageMySQLDojoReader.man.test.ts +71 -0
  896. package/test/storage/count.test.ts +193 -0
  897. package/test/storage/find.test.ts +216 -0
  898. package/test/storage/findLegacy.test.ts +70 -0
  899. package/test/storage/insert.test.ts +294 -0
  900. package/test/storage/update.test.ts +1146 -0
  901. package/test/storage/update2.test.ts +1017 -0
  902. package/test/utils/TestUtilsWalletStorage.ts +1923 -0
  903. package/test/utils/removeFailedFromDatabase.sql +17 -0
  904. package/test/wallet/action/abortAction.test.ts +55 -0
  905. package/test/wallet/action/createAction.test.ts +266 -0
  906. package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +297 -0
  907. package/test/wallet/action/internalizeAction.test.ts +729 -0
  908. package/test/wallet/action/relinquishOutput.test.ts +43 -0
  909. package/test/wallet/construct/Wallet.constructor.test.ts +57 -0
  910. package/test/wallet/list/listActions.test.ts +282 -0
  911. package/test/wallet/list/listActions2.test.ts +570 -0
  912. package/test/wallet/list/listCertificates.test.ts +129 -0
  913. package/test/wallet/list/listOutputs.test.ts +573 -0
  914. package/test/wallet/sync/Wallet.sync.test.ts +226 -0
  915. package/ts2md.json +32 -0
  916. package/tsconfig.all.json +29 -0
  917. package/tsconfig.client.json +22 -0
  918. package/tsconfig.json +14 -0
  919. package/unlock-migrations.sh +41 -0
@@ -0,0 +1,1143 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+
3
+ import { Transaction as BsvTransaction, Script } from '@bsv/sdk'
4
+ import { randomValsUsed1 } from './randomValsUsed1'
5
+ import { sdk } from '../../../../index.client'
6
+ import {
7
+ generateChangeSdk,
8
+ GenerateChangeSdkChangeInput,
9
+ generateChangeSdkMakeStorage,
10
+ GenerateChangeSdkParams,
11
+ GenerateChangeSdkResult
12
+ } from '../../generateChange'
13
+
14
+ describe('generateChange tests', () => {
15
+ jest.setTimeout(99999999)
16
+
17
+ test('0 two outputs', async () => {
18
+ const params: GenerateChangeSdkParams = {
19
+ ...defParams,
20
+ fixedOutputs: [
21
+ { satoshis: 1234, lockingScriptLength: 1739091 },
22
+ { satoshis: 2, lockingScriptLength: 25 }
23
+ ]
24
+ }
25
+ const availableChange: GenerateChangeSdkChangeInput[] = [
26
+ ...defAvailableChange()
27
+ ]
28
+
29
+ const { allocateChangeInput, releaseChangeInput } =
30
+ generateChangeSdkMakeStorage(availableChange)
31
+
32
+ const r = await generateChangeSdk(
33
+ params,
34
+ allocateChangeInput,
35
+ releaseChangeInput
36
+ )
37
+ expect(JSON.stringify(r)).toBe(
38
+ '{"allocatedChangeInputs":[{"satoshis":6323,"outputId":15005,"spendable":false}],"changeOutputs":[{"satoshis":1608,"lockingScriptLength":25}],"size":1739330,"fee":3479,"satsPerKb":2}'
39
+ )
40
+ expectTransactionSize(params, r)
41
+ })
42
+
43
+ test('0a two outputs exact input', async () => {
44
+ const params: GenerateChangeSdkParams = {
45
+ ...defParams,
46
+ fixedOutputs: [
47
+ { satoshis: 1234, lockingScriptLength: 1739091 },
48
+ { satoshis: 2, lockingScriptLength: 25 }
49
+ ]
50
+ }
51
+ const availableChange: GenerateChangeSdkChangeInput[] = [
52
+ ...defAvailableChange()
53
+ ]
54
+ availableChange[5].satoshis = 4715
55
+
56
+ const { allocateChangeInput, releaseChangeInput } =
57
+ generateChangeSdkMakeStorage(availableChange)
58
+
59
+ const r = await generateChangeSdk(
60
+ params,
61
+ allocateChangeInput,
62
+ releaseChangeInput
63
+ )
64
+ expect(JSON.stringify(r)).toBe(
65
+ '{"allocatedChangeInputs":[{"satoshis":4715,"outputId":15027,"spendable":false}],"changeOutputs":[],"size":1739296,"fee":3479,"satsPerKb":2}'
66
+ )
67
+ expectTransactionSize(params, r)
68
+ })
69
+
70
+ test('0b two outputs 666666 200 ', async () => {
71
+ const params: GenerateChangeSdkParams = {
72
+ ...defParams,
73
+ fixedOutputs: [
74
+ { satoshis: 666666, lockingScriptLength: 197 },
75
+ { satoshis: 200, lockingScriptLength: 25 }
76
+ ]
77
+ }
78
+ const availableChange: GenerateChangeSdkChangeInput[] = [
79
+ ...defAvailableChange()
80
+ ]
81
+ availableChange[5].satoshis = 4715
82
+
83
+ const { allocateChangeInput, releaseChangeInput } =
84
+ generateChangeSdkMakeStorage(availableChange)
85
+
86
+ const r = await generateChangeSdk(
87
+ params,
88
+ allocateChangeInput,
89
+ releaseChangeInput
90
+ )
91
+ expect(JSON.stringify(r)).toBe(
92
+ '{"allocatedChangeInputs":[{"satoshis":1575097,"outputId":15101,"spendable":false}],"changeOutputs":[{"satoshis":908230,"lockingScriptLength":25}],"size":432,"fee":1,"satsPerKb":2}'
93
+ )
94
+ expectTransactionSize(params, r)
95
+ })
96
+
97
+ test('0c two outputs 666666 200 two change inputs ', async () => {
98
+ const params: GenerateChangeSdkParams = {
99
+ ...defParams,
100
+ fixedOutputs: [
101
+ { satoshis: 666666, lockingScriptLength: 197 },
102
+ { satoshis: 200, lockingScriptLength: 25 }
103
+ ]
104
+ }
105
+ const availableChange: GenerateChangeSdkChangeInput[] = [
106
+ { satoshis: 191051, outputId: 14101 },
107
+ { satoshis: 129470, outputId: 14106 },
108
+ { satoshis: 273356, outputId: 14110 },
109
+ { satoshis: 65612, outputId: 14120 },
110
+ { satoshis: 44778, outputId: 14126 },
111
+ { satoshis: 58732, outputId: 14141 },
112
+ { satoshis: 160865, outputId: 14142 },
113
+ { satoshis: 535280, outputId: 14146 },
114
+ { satoshis: 1006, outputId: 14177 },
115
+ { satoshis: 1000, outputId: 14178 }
116
+ ]
117
+
118
+ const { allocateChangeInput, releaseChangeInput } =
119
+ generateChangeSdkMakeStorage(availableChange)
120
+
121
+ const r = await generateChangeSdk(
122
+ params,
123
+ allocateChangeInput,
124
+ releaseChangeInput
125
+ )
126
+ expect(JSON.stringify(r)).toBe(
127
+ '{"allocatedChangeInputs":[{"satoshis":535280,"outputId":14146,"spendable":false},{"satoshis":160865,"outputId":14142,"spendable":false}],"changeOutputs":[{"satoshis":29277,"lockingScriptLength":25}],"size":580,"fee":2,"satsPerKb":2}'
128
+ )
129
+ expectTransactionSize(params, r)
130
+ })
131
+
132
+ test('1 two outputs four change outputs', async () => {
133
+ const params: GenerateChangeSdkParams = {
134
+ ...defParams,
135
+ fixedOutputs: [
136
+ { satoshis: 1234, lockingScriptLength: 1739091 },
137
+ { satoshis: 2, lockingScriptLength: 25 }
138
+ ],
139
+ targetNetCount: 4
140
+ }
141
+ const availableChange: GenerateChangeSdkChangeInput[] = [
142
+ ...defAvailableChange()
143
+ ]
144
+
145
+ const { allocateChangeInput, releaseChangeInput } =
146
+ generateChangeSdkMakeStorage(availableChange)
147
+
148
+ const r = await generateChangeSdk(
149
+ params,
150
+ allocateChangeInput,
151
+ releaseChangeInput
152
+ )
153
+ expect(JSON.stringify(r)).toBe(
154
+ '{"allocatedChangeInputs":[{"satoshis":10735,"outputId":15106,"spendable":false}],"changeOutputs":[{"satoshis":1237,"lockingScriptLength":25},{"satoshis":1334,"lockingScriptLength":25},{"satoshis":1369,"lockingScriptLength":25},{"satoshis":1008,"lockingScriptLength":25},{"satoshis":1072,"lockingScriptLength":25}],"size":1739466,"fee":3479,"satsPerKb":2}'
155
+ )
156
+ expectTransactionSize(params, r)
157
+ })
158
+
159
+ test('2 WERR_INSUFFICIENT_FUNDS', async () => {
160
+ const params: GenerateChangeSdkParams = {
161
+ ...defParams,
162
+ fixedOutputs: [
163
+ { satoshis: 1234, lockingScriptLength: 1739091 },
164
+ { satoshis: 2, lockingScriptLength: 25 }
165
+ ],
166
+ targetNetCount: 4
167
+ }
168
+ const availableChange: GenerateChangeSdkChangeInput[] =
169
+ defAvailableChange().slice(1, 4)
170
+
171
+ const { allocateChangeInput, releaseChangeInput } =
172
+ generateChangeSdkMakeStorage(availableChange)
173
+
174
+ expectToThrowWERR(sdk.WERR_INSUFFICIENT_FUNDS, () =>
175
+ generateChangeSdk(params, allocateChangeInput, releaseChangeInput)
176
+ )
177
+ })
178
+
179
+ test('2a WERR_INSUFFICIENT_FUNDS no inputs', async () => {
180
+ const params: GenerateChangeSdkParams = {
181
+ ...defParams,
182
+ fixedOutputs: [
183
+ { satoshis: 1234, lockingScriptLength: 1739091 },
184
+ { satoshis: 2, lockingScriptLength: 25 }
185
+ ],
186
+ targetNetCount: 4
187
+ }
188
+ const availableChange: GenerateChangeSdkChangeInput[] = []
189
+
190
+ const { allocateChangeInput, releaseChangeInput } =
191
+ generateChangeSdkMakeStorage(availableChange)
192
+
193
+ expectToThrowWERR(sdk.WERR_INSUFFICIENT_FUNDS, () =>
194
+ generateChangeSdk(params, allocateChangeInput, releaseChangeInput)
195
+ )
196
+ })
197
+
198
+ test('3 allocate all', async () => {
199
+ const params: GenerateChangeSdkParams = {
200
+ ...defParams,
201
+ fixedOutputs: [
202
+ { satoshis: 1234, lockingScriptLength: 39091 },
203
+ { satoshis: 2, lockingScriptLength: 25 }
204
+ ],
205
+ targetNetCount: 4
206
+ }
207
+ const availableChange: GenerateChangeSdkChangeInput[] =
208
+ defAvailableChange().slice(1, 4)
209
+
210
+ const { allocateChangeInput, releaseChangeInput } =
211
+ generateChangeSdkMakeStorage(availableChange)
212
+
213
+ const r = await generateChangeSdk(
214
+ params,
215
+ allocateChangeInput,
216
+ releaseChangeInput
217
+ )
218
+ expect(JSON.stringify(r)).toBe(
219
+ '{"allocatedChangeInputs":[{"satoshis":1004,"outputId":15011,"spendable":false},{"satoshis":1000,"outputId":15017,"spendable":false},{"satoshis":1000,"outputId":15013,"spendable":false}],"changeOutputs":[{"satoshis":688,"lockingScriptLength":25},{"satoshis":1000,"lockingScriptLength":25}],"size":39658,"fee":80,"satsPerKb":2}'
220
+ )
221
+ expectTransactionSize(params, r)
222
+ })
223
+
224
+ test('4 feeModel 5 sat per kb', async () => {
225
+ const params: GenerateChangeSdkParams = {
226
+ ...defParams,
227
+ fixedOutputs: [
228
+ { satoshis: 1234, lockingScriptLength: 39091 },
229
+ { satoshis: 2, lockingScriptLength: 25 }
230
+ ],
231
+ feeModel: { value: 5, model: 'sat/kb' },
232
+ targetNetCount: 4
233
+ }
234
+ const availableChange: GenerateChangeSdkChangeInput[] =
235
+ defAvailableChange().slice(1, 4)
236
+
237
+ const { allocateChangeInput, releaseChangeInput } =
238
+ generateChangeSdkMakeStorage(availableChange)
239
+
240
+ const r = await generateChangeSdk(
241
+ params,
242
+ allocateChangeInput,
243
+ releaseChangeInput
244
+ )
245
+ expect(JSON.stringify(r)).toBe(
246
+ '{"allocatedChangeInputs":[{"satoshis":1004,"outputId":15011,"spendable":false},{"satoshis":1000,"outputId":15017,"spendable":false},{"satoshis":1000,"outputId":15013,"spendable":false}],"changeOutputs":[{"satoshis":569,"lockingScriptLength":25},{"satoshis":1000,"lockingScriptLength":25}],"size":39658,"fee":199,"satsPerKb":5}'
247
+ )
248
+ expectTransactionSize(params, r)
249
+ })
250
+
251
+ test('4a feeModel 1 sat per kb', async () => {
252
+ const params: GenerateChangeSdkParams = {
253
+ ...defParams,
254
+ fixedOutputs: [
255
+ { satoshis: 1234, lockingScriptLength: 39091 },
256
+ { satoshis: 2, lockingScriptLength: 25 }
257
+ ],
258
+ feeModel: { value: 1, model: 'sat/kb' },
259
+ targetNetCount: 4
260
+ }
261
+ const availableChange: GenerateChangeSdkChangeInput[] =
262
+ defAvailableChange().slice(1, 4)
263
+
264
+ const { allocateChangeInput, releaseChangeInput } =
265
+ generateChangeSdkMakeStorage(availableChange)
266
+
267
+ const r = await generateChangeSdk(
268
+ params,
269
+ allocateChangeInput,
270
+ releaseChangeInput
271
+ )
272
+ expect(JSON.stringify(r)).toBe(
273
+ '{"allocatedChangeInputs":[{"satoshis":1004,"outputId":15011,"spendable":false},{"satoshis":1000,"outputId":15017,"spendable":false},{"satoshis":1000,"outputId":15013,"spendable":false}],"changeOutputs":[{"satoshis":728,"lockingScriptLength":25},{"satoshis":1000,"lockingScriptLength":25}],"size":39658,"fee":40,"satsPerKb":1}'
274
+ )
275
+ expectTransactionSize(params, r)
276
+ })
277
+
278
+ test('5 one fixedInput', async () => {
279
+ const params: GenerateChangeSdkParams = {
280
+ ...defParams,
281
+ fixedInputs: [{ satoshis: 1234, unlockingScriptLength: 42 }],
282
+ fixedOutputs: [
283
+ { satoshis: 1234, lockingScriptLength: 1739091 },
284
+ { satoshis: 2, lockingScriptLength: 25 }
285
+ ],
286
+ targetNetCount: 4
287
+ }
288
+ const availableChange: GenerateChangeSdkChangeInput[] = [
289
+ ...defAvailableChange()
290
+ ]
291
+
292
+ const { allocateChangeInput, releaseChangeInput } =
293
+ generateChangeSdkMakeStorage(availableChange)
294
+
295
+ const r = await generateChangeSdk(
296
+ params,
297
+ allocateChangeInput,
298
+ releaseChangeInput
299
+ )
300
+ expect(JSON.stringify(r)).toBe(
301
+ '{"allocatedChangeInputs":[{"satoshis":10735,"outputId":15106,"spendable":false}],"changeOutputs":[{"satoshis":1526,"lockingScriptLength":25},{"satoshis":1738,"lockingScriptLength":25},{"satoshis":1816,"lockingScriptLength":25},{"satoshis":1016,"lockingScriptLength":25},{"satoshis":1157,"lockingScriptLength":25}],"size":1739549,"fee":3480,"satsPerKb":2}'
302
+ )
303
+ expectTransactionSize(params, r)
304
+ })
305
+
306
+ test('5a one larger fixedInput', async () => {
307
+ const params: GenerateChangeSdkParams = {
308
+ ...defParams,
309
+ fixedInputs: [{ satoshis: 1234, unlockingScriptLength: 242 }],
310
+ fixedOutputs: [
311
+ { satoshis: 1234, lockingScriptLength: 1739091 },
312
+ { satoshis: 2, lockingScriptLength: 25 }
313
+ ],
314
+ targetNetCount: 4
315
+ }
316
+ const availableChange: GenerateChangeSdkChangeInput[] = [
317
+ ...defAvailableChange()
318
+ ]
319
+
320
+ const { allocateChangeInput, releaseChangeInput } =
321
+ generateChangeSdkMakeStorage(availableChange)
322
+
323
+ const r = await generateChangeSdk(
324
+ params,
325
+ allocateChangeInput,
326
+ releaseChangeInput
327
+ )
328
+ expect(JSON.stringify(r)).toBe(
329
+ '{"allocatedChangeInputs":[{"satoshis":10735,"outputId":15106,"spendable":false}],"changeOutputs":[{"satoshis":1526,"lockingScriptLength":25},{"satoshis":1738,"lockingScriptLength":25},{"satoshis":1816,"lockingScriptLength":25},{"satoshis":1016,"lockingScriptLength":25},{"satoshis":1157,"lockingScriptLength":25}],"size":1739749,"fee":3480,"satsPerKb":2}'
330
+ )
331
+ expectTransactionSize(params, r)
332
+ })
333
+
334
+ test('5b one fixedInput 1001 73', async () => {
335
+ const params: GenerateChangeSdkParams = {
336
+ ...defParams,
337
+ fixedInputs: [{ satoshis: 1001, unlockingScriptLength: 73 }]
338
+ }
339
+ const availableChange: GenerateChangeSdkChangeInput[] = [
340
+ ...defAvailableChange()
341
+ ]
342
+
343
+ const { allocateChangeInput, releaseChangeInput } =
344
+ generateChangeSdkMakeStorage(availableChange)
345
+
346
+ const r = await generateChangeSdk(
347
+ params,
348
+ allocateChangeInput,
349
+ releaseChangeInput
350
+ )
351
+ expect(JSON.stringify(r)).toBe(
352
+ '{"allocatedChangeInputs":[],"changeOutputs":[{"satoshis":1000,"lockingScriptLength":25}],"size":158,"fee":1,"satsPerKb":2}'
353
+ )
354
+ expectTransactionSize(params, r)
355
+ })
356
+
357
+ test('6 no fixedOutputs one fixedInput', async () => {
358
+ const params: GenerateChangeSdkParams = {
359
+ ...defParams,
360
+ fixedInputs: [{ satoshis: 1234, unlockingScriptLength: 42 }],
361
+ fixedOutputs: [],
362
+ targetNetCount: 4
363
+ }
364
+ const availableChange: GenerateChangeSdkChangeInput[] = [
365
+ ...defAvailableChange()
366
+ ]
367
+
368
+ const { allocateChangeInput, releaseChangeInput, getLog } =
369
+ generateChangeSdkMakeStorage(availableChange)
370
+
371
+ const r = await generateChangeSdk(
372
+ params,
373
+ allocateChangeInput,
374
+ releaseChangeInput
375
+ )
376
+ //console.log(getLog())
377
+ expect(JSON.stringify(r)).toBe(
378
+ '{"allocatedChangeInputs":[{"satoshis":6323,"outputId":15005,"spendable":false}],"changeOutputs":[{"satoshis":1597,"lockingScriptLength":25},{"satoshis":1837,"lockingScriptLength":25},{"satoshis":1925,"lockingScriptLength":25},{"satoshis":1019,"lockingScriptLength":25},{"satoshis":1178,"lockingScriptLength":25}],"size":411,"fee":1,"satsPerKb":2}'
379
+ )
380
+ expectTransactionSize(params, r)
381
+ })
382
+
383
+ test('6a no fixedOutputs no fixedInput', async () => {
384
+ const params: GenerateChangeSdkParams = {
385
+ ...defParams,
386
+ fixedInputs: [],
387
+ fixedOutputs: [],
388
+ targetNetCount: 4
389
+ }
390
+ const availableChange: GenerateChangeSdkChangeInput[] = [
391
+ ...defAvailableChange()
392
+ ]
393
+
394
+ const { allocateChangeInput, releaseChangeInput } =
395
+ generateChangeSdkMakeStorage(availableChange)
396
+
397
+ const r = await generateChangeSdk(
398
+ params,
399
+ allocateChangeInput,
400
+ releaseChangeInput
401
+ )
402
+ expect(JSON.stringify(r)).toBe(
403
+ '{"allocatedChangeInputs":[{"satoshis":6323,"outputId":15005,"spendable":false}],"changeOutputs":[{"satoshis":1309,"lockingScriptLength":25},{"satoshis":1433,"lockingScriptLength":25},{"satoshis":1478,"lockingScriptLength":25},{"satoshis":1009,"lockingScriptLength":25},{"satoshis":1093,"lockingScriptLength":25}],"size":328,"fee":1,"satsPerKb":2}'
404
+ )
405
+ expectTransactionSize(params, r)
406
+ })
407
+
408
+ test('7 paramsText4 d4', async () => {
409
+ const params: GenerateChangeSdkParams = {
410
+ ...defParams,
411
+ fixedOutputs: [
412
+ { satoshis: 309000, lockingScriptLength: 198 },
413
+ { satoshis: 2, lockingScriptLength: 25 }
414
+ ]
415
+ }
416
+ const availableChange: GenerateChangeSdkChangeInput[] = [
417
+ { satoshis: 7130, outputId: 15142 },
418
+ { satoshis: 474866, outputId: 15332 },
419
+ { satoshis: 16411, outputId: 15355 },
420
+ { satoshis: 763632, outputId: 15368 },
421
+ { satoshis: 18894, outputId: 15371 },
422
+ { satoshis: 1574590, outputId: 15420 },
423
+ { satoshis: 43207, outputId: 15480 },
424
+ { satoshis: 12342, outputId: 15541 },
425
+ { satoshis: 123453, outputId: 15548 },
426
+ { satoshis: 7890, outputId: 16020 },
427
+ { satoshis: 1073, outputId: 16026 }
428
+ ]
429
+
430
+ const { allocateChangeInput, releaseChangeInput } =
431
+ generateChangeSdkMakeStorage(availableChange)
432
+
433
+ const r = await generateChangeSdk(
434
+ params,
435
+ allocateChangeInput,
436
+ releaseChangeInput
437
+ )
438
+ expect(JSON.stringify(r)).toBe(
439
+ '{"allocatedChangeInputs":[{"satoshis":474866,"outputId":15332,"spendable":false}],"changeOutputs":[{"satoshis":165863,"lockingScriptLength":25}],"size":433,"fee":1,"satsPerKb":2}'
440
+ )
441
+ expectTransactionSize(params, r)
442
+ })
443
+
444
+ interface TestCase {
445
+ p: GenerateChangeSdkParams
446
+ availableChange: GenerateChangeSdkChangeInput[]
447
+ }
448
+
449
+ const d5: TestCase = {
450
+ p: {
451
+ fixedInputs: [{ satoshis: 1000, unlockingScriptLength: 72 }],
452
+ fixedOutputs: [{ satoshis: 200, lockingScriptLength: 25 }],
453
+ feeModel: { model: 'sat/kb', value: 2 },
454
+ changeInitialSatoshis: 1000,
455
+ changeFirstSatoshis: 285,
456
+ changeLockingScriptLength: 25,
457
+ changeUnlockingScriptLength: 107
458
+ },
459
+ availableChange: [
460
+ { satoshis: 191051, outputId: 14101 },
461
+ { satoshis: 273356, outputId: 14110 },
462
+ { satoshis: 65612, outputId: 14120 },
463
+ { satoshis: 44778, outputId: 14126 },
464
+ { satoshis: 58732, outputId: 14141 },
465
+ { satoshis: 160865, outputId: 14142 },
466
+ { satoshis: 1006, outputId: 14177 },
467
+ { satoshis: 1000, outputId: 14178 },
468
+ { satoshis: 1000, outputId: 14180 },
469
+ { satoshis: 1000, outputId: 14181 },
470
+ { satoshis: 1000, outputId: 14183 },
471
+ { satoshis: 1000, outputId: 14185 },
472
+ { satoshis: 1000, outputId: 14186 },
473
+ { satoshis: 1001, outputId: 14188 },
474
+ { satoshis: 1000, outputId: 14189 },
475
+ { satoshis: 1000, outputId: 14190 },
476
+ { satoshis: 1001, outputId: 14192 },
477
+ { satoshis: 1000, outputId: 14195 },
478
+ { satoshis: 1000, outputId: 14196 },
479
+ { satoshis: 1000, outputId: 14197 },
480
+ { satoshis: 1000, outputId: 14198 },
481
+ { satoshis: 1000, outputId: 14199 },
482
+ { satoshis: 1000, outputId: 14200 },
483
+ { satoshis: 1000, outputId: 14201 },
484
+ { satoshis: 1000, outputId: 14202 },
485
+ { satoshis: 1000, outputId: 14203 },
486
+ { satoshis: 1000, outputId: 14204 },
487
+ { satoshis: 1000, outputId: 14205 },
488
+ { satoshis: 1000, outputId: 14206 },
489
+ { satoshis: 1003, outputId: 14207 },
490
+ { satoshis: 1001, outputId: 14208 },
491
+ { satoshis: 1000, outputId: 14209 },
492
+ { satoshis: 1000, outputId: 14210 },
493
+ { satoshis: 1006, outputId: 14211 },
494
+ { satoshis: 1020, outputId: 14212 },
495
+ { satoshis: 1000, outputId: 14213 },
496
+ { satoshis: 1000, outputId: 14214 },
497
+ { satoshis: 1000, outputId: 14215 },
498
+ { satoshis: 1000, outputId: 14216 },
499
+ { satoshis: 1002, outputId: 14217 },
500
+ { satoshis: 1046, outputId: 14218 },
501
+ { satoshis: 1103, outputId: 14219 },
502
+ { satoshis: 1001, outputId: 14221 },
503
+ { satoshis: 1000, outputId: 14222 },
504
+ { satoshis: 1000, outputId: 14223 },
505
+ { satoshis: 1000, outputId: 14224 },
506
+ { satoshis: 31311, outputId: 14321 },
507
+ { satoshis: 1042, outputId: 14656 },
508
+ { satoshis: 1099, outputId: 14661 },
509
+ { satoshis: 1100, outputId: 14675 },
510
+ { satoshis: 1019, outputId: 14676 },
511
+ { satoshis: 1040, outputId: 14677 },
512
+ { satoshis: 1000, outputId: 14679 },
513
+ { satoshis: 1000, outputId: 14680 },
514
+ { satoshis: 1001, outputId: 14681 },
515
+ { satoshis: 1000, outputId: 14682 },
516
+ { satoshis: 1001, outputId: 14683 },
517
+ { satoshis: 1002, outputId: 14684 },
518
+ { satoshis: 1005, outputId: 14685 },
519
+ { satoshis: 1000, outputId: 14686 },
520
+ { satoshis: 1007, outputId: 14687 },
521
+ { satoshis: 1000, outputId: 14802 },
522
+ { satoshis: 1069, outputId: 14803 },
523
+ { satoshis: 1231, outputId: 15465 },
524
+ { satoshis: 2386, outputId: 15468 },
525
+ { satoshis: 1267, outputId: 15471 },
526
+ { satoshis: 1283, outputId: 15472 },
527
+ { satoshis: 1054, outputId: 15473 },
528
+ { satoshis: 2031, outputId: 15475 },
529
+ { satoshis: 1065, outputId: 15478 },
530
+ { satoshis: 1268, outputId: 15479 },
531
+ { satoshis: 1066, outputId: 15480 },
532
+ { satoshis: 1065, outputId: 15481 },
533
+ { satoshis: 1006, outputId: 15482 },
534
+ { satoshis: 999799, outputId: 16338 },
535
+ { satoshis: 2021, outputId: 16339 },
536
+ { satoshis: 666465, outputId: 16340 },
537
+ { satoshis: 5354, outputId: 16341 },
538
+ { satoshis: 3132, outputId: 16342 }
539
+ ]
540
+ }
541
+ const d6: TestCase = {
542
+ p: {
543
+ fixedInputs: [],
544
+ fixedOutputs: [
545
+ { satoshis: 500, lockingScriptLength: 436 },
546
+ { satoshis: 200, lockingScriptLength: 25 }
547
+ ],
548
+ feeModel: { model: 'sat/kb', value: 2 },
549
+ changeInitialSatoshis: 1000,
550
+ changeFirstSatoshis: 285,
551
+ changeLockingScriptLength: 25,
552
+ changeUnlockingScriptLength: 107
553
+ },
554
+ availableChange: [
555
+ { satoshis: 1040, outputId: 16345 },
556
+ { satoshis: 1000, outputId: 16346 },
557
+ { satoshis: 1023, outputId: 16348 },
558
+ { satoshis: 1054, outputId: 16350 },
559
+ { satoshis: 1118, outputId: 16353 },
560
+ { satoshis: 1000, outputId: 16354 },
561
+ { satoshis: 1001, outputId: 16355 },
562
+ { satoshis: 1000, outputId: 16356 },
563
+ { satoshis: 1005, outputId: 16360 },
564
+ { satoshis: 1000, outputId: 16361 },
565
+ { satoshis: 375235, outputId: 16362 },
566
+ { satoshis: 1000, outputId: 16363 },
567
+ { satoshis: 1000, outputId: 16364 },
568
+ { satoshis: 45658, outputId: 16365 },
569
+ { satoshis: 286834, outputId: 16367 },
570
+ { satoshis: 1001, outputId: 16368 },
571
+ { satoshis: 1001, outputId: 16369 },
572
+ { satoshis: 57051, outputId: 16370 },
573
+ { satoshis: 1036, outputId: 16371 },
574
+ { satoshis: 16508, outputId: 16372 },
575
+ { satoshis: 1000, outputId: 16373 },
576
+ { satoshis: 64213, outputId: 16374 },
577
+ { satoshis: 1000, outputId: 16376 },
578
+ { satoshis: 1000, outputId: 16377 },
579
+ { satoshis: 1154, outputId: 16378 },
580
+ { satoshis: 1000, outputId: 16380 },
581
+ { satoshis: 1008, outputId: 16381 },
582
+ { satoshis: 1064, outputId: 16382 },
583
+ { satoshis: 1234, outputId: 16383 },
584
+ { satoshis: 119205, outputId: 16395 },
585
+ { satoshis: 582, outputId: 16397 },
586
+ { satoshis: 2384, outputId: 16399 },
587
+ { satoshis: 4391, outputId: 16401 },
588
+ { satoshis: 600, outputId: 16406 },
589
+ { satoshis: 2599799, outputId: 16407 }
590
+ ]
591
+ }
592
+ const d7: TestCase = {
593
+ p: {
594
+ fixedInputs: [],
595
+ fixedOutputs: [
596
+ { satoshis: 1570, lockingScriptLength: 25 },
597
+ { satoshis: 200, lockingScriptLength: 25 }
598
+ ],
599
+ feeModel: { model: 'sat/kb', value: 2 },
600
+ changeInitialSatoshis: 1000,
601
+ changeFirstSatoshis: 285,
602
+ changeLockingScriptLength: 25,
603
+ changeUnlockingScriptLength: 107
604
+ },
605
+ availableChange: [
606
+ { satoshis: 23082, outputId: 14734 },
607
+ { satoshis: 16496, outputId: 14742 },
608
+ { satoshis: 270789, outputId: 14744 },
609
+ { satoshis: 81520, outputId: 14763 },
610
+ { satoshis: 14759, outputId: 14770 },
611
+ { satoshis: 390625, outputId: 14774 },
612
+ { satoshis: 674234, outputId: 14790 },
613
+ { satoshis: 999799, outputId: 14794 },
614
+ { satoshis: 1000, outputId: 15583 },
615
+ { satoshis: 1000, outputId: 15584 },
616
+ { satoshis: 1000, outputId: 15585 },
617
+ { satoshis: 1000, outputId: 15586 },
618
+ { satoshis: 1000, outputId: 15587 },
619
+ { satoshis: 1000, outputId: 15588 },
620
+ { satoshis: 1025, outputId: 15589 },
621
+ { satoshis: 1000, outputId: 15590 },
622
+ { satoshis: 1000, outputId: 15591 },
623
+ { satoshis: 1000, outputId: 15593 },
624
+ { satoshis: 1000, outputId: 15594 },
625
+ { satoshis: 1000, outputId: 15595 },
626
+ { satoshis: 1000, outputId: 15596 },
627
+ { satoshis: 1000, outputId: 15597 },
628
+ { satoshis: 1316, outputId: 15598 },
629
+ { satoshis: 1000, outputId: 15599 },
630
+ { satoshis: 1000, outputId: 15600 },
631
+ { satoshis: 1000, outputId: 15601 },
632
+ { satoshis: 1426, outputId: 15602 },
633
+ { satoshis: 1000, outputId: 15603 },
634
+ { satoshis: 1000, outputId: 15604 },
635
+ { satoshis: 1000, outputId: 15605 },
636
+ { satoshis: 1000, outputId: 15606 },
637
+ { satoshis: 1000, outputId: 15607 },
638
+ { satoshis: 1000, outputId: 15608 },
639
+ { satoshis: 1000, outputId: 15609 },
640
+ { satoshis: 1004, outputId: 15610 },
641
+ { satoshis: 1000, outputId: 15611 },
642
+ { satoshis: 1013, outputId: 15612 },
643
+ { satoshis: 1001, outputId: 15614 },
644
+ { satoshis: 1000, outputId: 15615 },
645
+ { satoshis: 1000, outputId: 15616 },
646
+ { satoshis: 1000, outputId: 15617 },
647
+ { satoshis: 1000, outputId: 15618 },
648
+ { satoshis: 1000, outputId: 15619 },
649
+ { satoshis: 1006, outputId: 15620 },
650
+ { satoshis: 1000, outputId: 15621 },
651
+ { satoshis: 1000, outputId: 15622 },
652
+ { satoshis: 1000, outputId: 15623 },
653
+ { satoshis: 1000, outputId: 15624 },
654
+ { satoshis: 1032, outputId: 15625 },
655
+ { satoshis: 4571, outputId: 15626 },
656
+ { satoshis: 1000, outputId: 15628 },
657
+ { satoshis: 1000, outputId: 15629 },
658
+ { satoshis: 1087, outputId: 15630 },
659
+ { satoshis: 1000, outputId: 15631 },
660
+ { satoshis: 1000, outputId: 15632 },
661
+ { satoshis: 1001, outputId: 15633 },
662
+ { satoshis: 1001, outputId: 15634 },
663
+ { satoshis: 1000, outputId: 15635 },
664
+ { satoshis: 1000, outputId: 15637 },
665
+ { satoshis: 1001, outputId: 15638 },
666
+ { satoshis: 1000, outputId: 15639 },
667
+ { satoshis: 1000, outputId: 15640 },
668
+ { satoshis: 1000, outputId: 15641 },
669
+ { satoshis: 1000, outputId: 15642 },
670
+ { satoshis: 1000, outputId: 15643 },
671
+ { satoshis: 1036, outputId: 15644 },
672
+ { satoshis: 1000, outputId: 15645 },
673
+ { satoshis: 1000, outputId: 15646 },
674
+ { satoshis: 1000, outputId: 15647 },
675
+ { satoshis: 1000, outputId: 15648 },
676
+ { satoshis: 1001, outputId: 15649 },
677
+ { satoshis: 1000, outputId: 15650 },
678
+ { satoshis: 1050, outputId: 15651 },
679
+ { satoshis: 1273, outputId: 15653 },
680
+ { satoshis: 1029, outputId: 15654 },
681
+ { satoshis: 1524, outputId: 15655 },
682
+ { satoshis: 1817, outputId: 15658 },
683
+ { satoshis: 1041, outputId: 16409 }
684
+ ]
685
+ }
686
+ const d8: TestCase = {
687
+ p: {
688
+ fixedInputs: [],
689
+ fixedOutputs: [
690
+ { satoshis: 1564, lockingScriptLength: 25 },
691
+ { satoshis: 200, lockingScriptLength: 25 }
692
+ ],
693
+ feeModel: { model: 'sat/kb', value: 2 },
694
+ changeInitialSatoshis: 1000,
695
+ changeFirstSatoshis: 285,
696
+ changeLockingScriptLength: 25,
697
+ changeUnlockingScriptLength: 107
698
+ },
699
+ availableChange: [
700
+ { satoshis: 23082, outputId: 14734 },
701
+ { satoshis: 16496, outputId: 14742 },
702
+ { satoshis: 270789, outputId: 14744 },
703
+ { satoshis: 81520, outputId: 14763 },
704
+ { satoshis: 14759, outputId: 14770 },
705
+ { satoshis: 390625, outputId: 14774 },
706
+ { satoshis: 674234, outputId: 14790 },
707
+ { satoshis: 999799, outputId: 14794 },
708
+ { satoshis: 1000, outputId: 15583 },
709
+ { satoshis: 1000, outputId: 15584 },
710
+ { satoshis: 1000, outputId: 15585 },
711
+ { satoshis: 1000, outputId: 15586 },
712
+ { satoshis: 1000, outputId: 15587 },
713
+ { satoshis: 1000, outputId: 15588 },
714
+ { satoshis: 1025, outputId: 15589 },
715
+ { satoshis: 1000, outputId: 15590 },
716
+ { satoshis: 1000, outputId: 15591 },
717
+ { satoshis: 1000, outputId: 15593 },
718
+ { satoshis: 1000, outputId: 15594 },
719
+ { satoshis: 1000, outputId: 15595 },
720
+ { satoshis: 1000, outputId: 15596 },
721
+ { satoshis: 1000, outputId: 15597 },
722
+ { satoshis: 1316, outputId: 15598 },
723
+ { satoshis: 1000, outputId: 15599 },
724
+ { satoshis: 1000, outputId: 15600 },
725
+ { satoshis: 1000, outputId: 15601 },
726
+ { satoshis: 1426, outputId: 15602 },
727
+ { satoshis: 1000, outputId: 15603 },
728
+ { satoshis: 1000, outputId: 15604 },
729
+ { satoshis: 1000, outputId: 15605 },
730
+ { satoshis: 1000, outputId: 15606 },
731
+ { satoshis: 1000, outputId: 15607 },
732
+ { satoshis: 1000, outputId: 15608 },
733
+ { satoshis: 1000, outputId: 15609 },
734
+ { satoshis: 1004, outputId: 15610 },
735
+ { satoshis: 1000, outputId: 15611 },
736
+ { satoshis: 1013, outputId: 15612 },
737
+ { satoshis: 1001, outputId: 15614 },
738
+ { satoshis: 1000, outputId: 15615 },
739
+ { satoshis: 1000, outputId: 15616 },
740
+ { satoshis: 1000, outputId: 15617 },
741
+ { satoshis: 1000, outputId: 15618 },
742
+ { satoshis: 1000, outputId: 15619 },
743
+ { satoshis: 1006, outputId: 15620 },
744
+ { satoshis: 1000, outputId: 15621 },
745
+ { satoshis: 1000, outputId: 15622 },
746
+ { satoshis: 1000, outputId: 15623 },
747
+ { satoshis: 1000, outputId: 15624 },
748
+ { satoshis: 1032, outputId: 15625 },
749
+ { satoshis: 4571, outputId: 15626 },
750
+ { satoshis: 1000, outputId: 15628 },
751
+ { satoshis: 1000, outputId: 15629 },
752
+ { satoshis: 1087, outputId: 15630 },
753
+ { satoshis: 1000, outputId: 15631 },
754
+ { satoshis: 1000, outputId: 15632 },
755
+ { satoshis: 1001, outputId: 15633 },
756
+ { satoshis: 1001, outputId: 15634 },
757
+ { satoshis: 1000, outputId: 15635 },
758
+ { satoshis: 1000, outputId: 15637 },
759
+ { satoshis: 1001, outputId: 15638 },
760
+ { satoshis: 1000, outputId: 15639 },
761
+ { satoshis: 1000, outputId: 15640 },
762
+ { satoshis: 1000, outputId: 15641 },
763
+ { satoshis: 1000, outputId: 15642 },
764
+ { satoshis: 1000, outputId: 15643 },
765
+ { satoshis: 1036, outputId: 15644 },
766
+ { satoshis: 1000, outputId: 15645 },
767
+ { satoshis: 1000, outputId: 15646 },
768
+ { satoshis: 1000, outputId: 15647 },
769
+ { satoshis: 1000, outputId: 15648 },
770
+ { satoshis: 1001, outputId: 15649 },
771
+ { satoshis: 1000, outputId: 15650 },
772
+ { satoshis: 1050, outputId: 15651 },
773
+ { satoshis: 1273, outputId: 15653 },
774
+ { satoshis: 1029, outputId: 15654 },
775
+ { satoshis: 1524, outputId: 15655 },
776
+ { satoshis: 1817, outputId: 15658 },
777
+ { satoshis: 1041, outputId: 16409 }
778
+ ]
779
+ }
780
+ const d9: TestCase = {
781
+ p: {
782
+ fixedInputs: [],
783
+ fixedOutputs: [
784
+ { satoshis: 1000, lockingScriptLength: 1136 },
785
+ { satoshis: 200, lockingScriptLength: 25 }
786
+ ],
787
+ feeModel: { model: 'sat/kb', value: 2 },
788
+ changeInitialSatoshis: 1000,
789
+ changeFirstSatoshis: 285,
790
+ changeLockingScriptLength: 25,
791
+ changeUnlockingScriptLength: 107
792
+ },
793
+ availableChange: [
794
+ { satoshis: 23082, outputId: 14734 },
795
+ { satoshis: 270789, outputId: 14744 },
796
+ { satoshis: 81520, outputId: 14763 },
797
+ { satoshis: 14759, outputId: 14770 },
798
+ { satoshis: 390625, outputId: 14774 },
799
+ { satoshis: 674234, outputId: 14790 },
800
+ { satoshis: 999799, outputId: 14794 },
801
+ { satoshis: 1000, outputId: 15583 },
802
+ { satoshis: 1000, outputId: 15584 },
803
+ { satoshis: 1000, outputId: 15585 },
804
+ { satoshis: 1000, outputId: 15586 },
805
+ { satoshis: 1000, outputId: 15587 },
806
+ { satoshis: 1000, outputId: 15588 },
807
+ { satoshis: 1000, outputId: 15590 },
808
+ { satoshis: 1000, outputId: 15591 },
809
+ { satoshis: 1000, outputId: 15593 },
810
+ { satoshis: 1000, outputId: 15594 },
811
+ { satoshis: 1000, outputId: 15595 },
812
+ { satoshis: 1000, outputId: 15596 },
813
+ { satoshis: 1000, outputId: 15597 },
814
+ { satoshis: 1000, outputId: 15599 },
815
+ { satoshis: 1000, outputId: 15600 },
816
+ { satoshis: 1000, outputId: 15601 },
817
+ { satoshis: 1000, outputId: 15603 },
818
+ { satoshis: 1000, outputId: 15604 },
819
+ { satoshis: 1000, outputId: 15605 },
820
+ { satoshis: 1000, outputId: 15606 },
821
+ { satoshis: 1000, outputId: 15607 },
822
+ { satoshis: 1000, outputId: 15608 },
823
+ { satoshis: 1000, outputId: 15609 },
824
+ { satoshis: 1004, outputId: 15610 },
825
+ { satoshis: 1000, outputId: 15611 },
826
+ { satoshis: 1001, outputId: 15614 },
827
+ { satoshis: 1000, outputId: 15615 },
828
+ { satoshis: 1000, outputId: 15616 },
829
+ { satoshis: 1000, outputId: 15617 },
830
+ { satoshis: 1000, outputId: 15618 },
831
+ { satoshis: 1000, outputId: 15619 },
832
+ { satoshis: 1006, outputId: 15620 },
833
+ { satoshis: 1000, outputId: 15621 },
834
+ { satoshis: 1000, outputId: 15622 },
835
+ { satoshis: 1000, outputId: 15623 },
836
+ { satoshis: 1000, outputId: 15624 },
837
+ { satoshis: 4571, outputId: 15626 },
838
+ { satoshis: 1000, outputId: 15628 },
839
+ { satoshis: 1000, outputId: 15629 },
840
+ { satoshis: 1000, outputId: 15631 },
841
+ { satoshis: 1000, outputId: 15632 },
842
+ { satoshis: 1001, outputId: 15633 },
843
+ { satoshis: 1001, outputId: 15634 },
844
+ { satoshis: 1000, outputId: 15635 },
845
+ { satoshis: 1000, outputId: 15637 },
846
+ { satoshis: 1001, outputId: 15638 },
847
+ { satoshis: 1000, outputId: 15639 },
848
+ { satoshis: 1000, outputId: 15640 },
849
+ { satoshis: 1000, outputId: 15641 },
850
+ { satoshis: 1000, outputId: 15642 },
851
+ { satoshis: 1000, outputId: 15643 },
852
+ { satoshis: 1000, outputId: 15645 },
853
+ { satoshis: 1000, outputId: 15646 },
854
+ { satoshis: 1000, outputId: 15647 },
855
+ { satoshis: 1000, outputId: 15648 },
856
+ { satoshis: 1001, outputId: 15649 },
857
+ { satoshis: 1000, outputId: 15650 },
858
+ { satoshis: 604, outputId: 16421 },
859
+ { satoshis: 958, outputId: 16429 },
860
+ { satoshis: 724, outputId: 16431 },
861
+ { satoshis: 413, outputId: 16433 },
862
+ { satoshis: 915, outputId: 16439 },
863
+ { satoshis: 842, outputId: 16441 },
864
+ { satoshis: 348, outputId: 16451 },
865
+ { satoshis: 339, outputId: 16453 },
866
+ { satoshis: 334, outputId: 16455 },
867
+ { satoshis: 331, outputId: 16457 },
868
+ { satoshis: 330, outputId: 16459 },
869
+ { satoshis: 327, outputId: 16461 },
870
+ { satoshis: 323, outputId: 16463 },
871
+ { satoshis: 311, outputId: 16465 }
872
+ ]
873
+ }
874
+ const d10: TestCase = {
875
+ p: {
876
+ fixedInputs: [],
877
+ fixedOutputs: [
878
+ { satoshis: 1, lockingScriptLength: 25 },
879
+ { satoshis: 200, lockingScriptLength: 25 }
880
+ ],
881
+ feeModel: { model: 'sat/kb', value: 110 },
882
+ changeInitialSatoshis: 1000,
883
+ changeFirstSatoshis: 285,
884
+ changeLockingScriptLength: 25,
885
+ changeUnlockingScriptLength: 107
886
+ },
887
+ availableChange: [
888
+ { satoshis: 268076, outputId: 16671 },
889
+ { satoshis: 2999799, outputId: 16677 },
890
+ { satoshis: 14030, outputId: 21194 },
891
+ { satoshis: 100925, outputId: 21224 }
892
+ ]
893
+ }
894
+ const d11: TestCase = {
895
+ p: {
896
+ fixedInputs: [],
897
+ fixedOutputs: [
898
+ { satoshis: 1, lockingScriptLength: 25 },
899
+ { satoshis: 200, lockingScriptLength: 25 }
900
+ ],
901
+ feeModel: { model: 'sat/kb', value: 110 },
902
+ changeInitialSatoshis: 1000,
903
+ changeFirstSatoshis: 285,
904
+ changeLockingScriptLength: 25,
905
+ changeUnlockingScriptLength: 107
906
+ },
907
+ availableChange: [
908
+ { satoshis: 268076, outputId: 16671 },
909
+ { satoshis: 2999799, outputId: 16677 },
910
+ { satoshis: 1396, outputId: 21307 },
911
+ { satoshis: 1023, outputId: 21308 },
912
+ { satoshis: 1000, outputId: 21309 },
913
+ { satoshis: 1000, outputId: 21310 },
914
+ { satoshis: 1000, outputId: 21311 },
915
+ { satoshis: 1220, outputId: 21312 },
916
+ { satoshis: 5573, outputId: 21313 },
917
+ { satoshis: 1000, outputId: 21314 },
918
+ { satoshis: 1000, outputId: 21315 },
919
+ { satoshis: 5926, outputId: 21316 },
920
+ { satoshis: 30814, outputId: 21317 },
921
+ { satoshis: 24441, outputId: 21318 },
922
+ { satoshis: 285, outputId: 21319 },
923
+ { satoshis: 1325, outputId: 21320 },
924
+ { satoshis: 1000, outputId: 21321 },
925
+ { satoshis: 1002, outputId: 21322 },
926
+ { satoshis: 1000, outputId: 21324 },
927
+ { satoshis: 1057, outputId: 21325 },
928
+ { satoshis: 1000, outputId: 21326 },
929
+ { satoshis: 1159, outputId: 21327 },
930
+ { satoshis: 1061, outputId: 21328 },
931
+ { satoshis: 1000, outputId: 21329 },
932
+ { satoshis: 1000, outputId: 21330 },
933
+ { satoshis: 1000, outputId: 21331 },
934
+ { satoshis: 8873, outputId: 21332 },
935
+ { satoshis: 1001, outputId: 21333 },
936
+ { satoshis: 1011, outputId: 21334 },
937
+ { satoshis: 1000, outputId: 21335 },
938
+ { satoshis: 13699, outputId: 21336 }
939
+ ]
940
+ }
941
+ const d12: TestCase = {
942
+ p: {
943
+ fixedInputs: [],
944
+ fixedOutputs: [
945
+ { satoshis: 1, lockingScriptLength: 25 },
946
+ { satoshis: 200, lockingScriptLength: 25 }
947
+ ],
948
+ feeModel: { model: 'sat/kb', value: 110 },
949
+ changeInitialSatoshis: 1000,
950
+ changeFirstSatoshis: 285,
951
+ changeLockingScriptLength: 25,
952
+ changeUnlockingScriptLength: 107
953
+ },
954
+ availableChange: [
955
+ { satoshis: 268076, outputId: 16671 },
956
+ { satoshis: 2999799, outputId: 16677 },
957
+ { satoshis: 14030, outputId: 21194 },
958
+ { satoshis: 100925, outputId: 21224 }
959
+ ]
960
+ }
961
+ const d13: TestCase = {
962
+ p: {
963
+ fixedInputs: [],
964
+ fixedOutputs: [
965
+ { satoshis: 500, lockingScriptLength: 194 },
966
+ { satoshis: 2, lockingScriptLength: 25 }
967
+ ],
968
+ feeModel: { model: 'sat/kb', value: 2 },
969
+ changeInitialSatoshis: 1000,
970
+ changeFirstSatoshis: 285,
971
+ changeLockingScriptLength: 25,
972
+ changeUnlockingScriptLength: 107
973
+ },
974
+ availableChange: [
975
+ { satoshis: 285, outputId: 16190 },
976
+ { satoshis: 1012, outputId: 18487 },
977
+ { satoshis: 1013, outputId: 18488 },
978
+ { satoshis: 1000, outputId: 18489 },
979
+ { satoshis: 1087, outputId: 18490 },
980
+ { satoshis: 290, outputId: 18491 },
981
+ { satoshis: 1034, outputId: 18492 }
982
+ ]
983
+ }
984
+
985
+ test('8 paramsText d5 d6 d7 d8 d9 d10 d11 d12 d13', async () => {
986
+ for (const { n, d, er } of [
987
+ {
988
+ n: 13,
989
+ d: d13,
990
+ er: '{"allocatedChangeInputs":[{"satoshis":1000,"outputId":18489,"spendable":false}],"changeOutputs":[{"satoshis":497,"lockingScriptLength":25}],"size":429,"fee":1,"satsPerKb":2}'
991
+ },
992
+ {
993
+ n: 12,
994
+ d: d12,
995
+ er: '{"allocatedChangeInputs":[{"satoshis":14030,"outputId":21194,"spendable":false}],"changeOutputs":[{"satoshis":13800,"lockingScriptLength":25}],"size":260,"fee":29,"satsPerKb":110}'
996
+ },
997
+ {
998
+ n: 11,
999
+ d: d11,
1000
+ er: '{"allocatedChangeInputs":[{"satoshis":285,"outputId":21319,"spendable":false},{"satoshis":1000,"outputId":21309,"spendable":false}],"changeOutputs":[{"satoshis":1039,"lockingScriptLength":25}],"size":408,"fee":45,"satsPerKb":110}'
1001
+ },
1002
+ {
1003
+ n: 10,
1004
+ d: d10,
1005
+ er: '{"allocatedChangeInputs":[{"satoshis":14030,"outputId":21194,"spendable":false}],"changeOutputs":[{"satoshis":13800,"lockingScriptLength":25}],"size":260,"fee":29,"satsPerKb":110}'
1006
+ },
1007
+ {
1008
+ n: 9,
1009
+ d: d9,
1010
+ er: '{"allocatedChangeInputs":[{"satoshis":4571,"outputId":15626,"spendable":false}],"changeOutputs":[{"satoshis":3368,"lockingScriptLength":25}],"size":1373,"fee":3,"satsPerKb":2}'
1011
+ },
1012
+ {
1013
+ n: 8,
1014
+ d: d8,
1015
+ er: '{"allocatedChangeInputs":[{"satoshis":1817,"outputId":15658,"spendable":false}],"changeOutputs":[{"satoshis":52,"lockingScriptLength":25}],"size":260,"fee":1,"satsPerKb":2}'
1016
+ },
1017
+ {
1018
+ n: 7,
1019
+ d: d7,
1020
+ er: '{"allocatedChangeInputs":[{"satoshis":1817,"outputId":15658,"spendable":false}],"changeOutputs":[{"satoshis":46,"lockingScriptLength":25}],"size":260,"fee":1,"satsPerKb":2}'
1021
+ },
1022
+ {
1023
+ n: 6,
1024
+ d: d6,
1025
+ er: '{"allocatedChangeInputs":[{"satoshis":1000,"outputId":16346,"spendable":false}],"changeOutputs":[{"satoshis":298,"lockingScriptLength":25}],"size":673,"fee":2,"satsPerKb":2}'
1026
+ },
1027
+ {
1028
+ n: 5,
1029
+ d: d5,
1030
+ er: '{"allocatedChangeInputs":[],"changeOutputs":[{"satoshis":799,"lockingScriptLength":25}],"size":191,"fee":1,"satsPerKb":2}'
1031
+ }
1032
+ ]) {
1033
+ const params: GenerateChangeSdkParams = { ...d.p }
1034
+ const availableChange: GenerateChangeSdkChangeInput[] = [
1035
+ ...d.availableChange
1036
+ ]
1037
+
1038
+ const { allocateChangeInput, releaseChangeInput } =
1039
+ generateChangeSdkMakeStorage(availableChange)
1040
+
1041
+ const r = await generateChangeSdk(
1042
+ params,
1043
+ allocateChangeInput,
1044
+ releaseChangeInput
1045
+ )
1046
+ expect(JSON.stringify(r)).toBe(er)
1047
+ expectTransactionSize(params, r)
1048
+ }
1049
+ })
1050
+ })
1051
+
1052
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1053
+ async function expectToThrowWERR<R>(
1054
+ expectedClass: new (...args: any[]) => any,
1055
+ fn: () => Promise<R>
1056
+ ): Promise<void> {
1057
+ try {
1058
+ await fn()
1059
+ } catch (eu: unknown) {
1060
+ const e = sdk.WalletError.fromUnknown(eu)
1061
+ expect(e.name).toBe(expectedClass.name)
1062
+ expect(e.isError).toBe(true)
1063
+ return
1064
+ }
1065
+ throw new Error(`${expectedClass.name} was not thrown`)
1066
+ }
1067
+
1068
+ function makeTransaction(
1069
+ params: GenerateChangeSdkParams,
1070
+ results: GenerateChangeSdkResult
1071
+ ): BsvTransaction {
1072
+ const tx = new BsvTransaction()
1073
+ for (const i of params.fixedInputs) {
1074
+ tx.inputs.push({
1075
+ unlockingScript: Script.fromBinary(
1076
+ Array(i.unlockingScriptLength).fill(0)
1077
+ ),
1078
+ sourceOutputIndex: 0,
1079
+ sourceTXID: '00'.repeat(32)
1080
+ })
1081
+ }
1082
+ for (const i of results.allocatedChangeInputs) {
1083
+ tx.inputs.push({
1084
+ unlockingScript: Script.fromBinary(
1085
+ Array(params.changeUnlockingScriptLength).fill(0)
1086
+ ),
1087
+ sourceOutputIndex: 0,
1088
+ sourceTXID: '00'.repeat(32)
1089
+ })
1090
+ }
1091
+ for (const o of params.fixedOutputs) {
1092
+ tx.outputs.push({
1093
+ lockingScript: Script.fromBinary(Array(o.lockingScriptLength).fill(0)),
1094
+ satoshis: o.satoshis
1095
+ })
1096
+ }
1097
+ for (const o of results.changeOutputs) {
1098
+ tx.outputs.push({
1099
+ lockingScript: Script.fromBinary(Array(o.lockingScriptLength).fill(0)),
1100
+ satoshis: o.satoshis
1101
+ })
1102
+ }
1103
+ return tx
1104
+ }
1105
+
1106
+ function expectTransactionSize(
1107
+ params: GenerateChangeSdkParams,
1108
+ results: GenerateChangeSdkResult
1109
+ ) {
1110
+ const tx = makeTransaction(params, results)
1111
+ const size = tx.toBinary().length
1112
+ if (size !== results.size)
1113
+ throw new sdk.WERR_INTERNAL(
1114
+ `expectTransaction actual ${size} expected ${results.size}`
1115
+ )
1116
+ }
1117
+
1118
+ const defParams: GenerateChangeSdkParams = {
1119
+ fixedInputs: [],
1120
+ fixedOutputs: [],
1121
+ feeModel: { model: 'sat/kb', value: 2 },
1122
+ changeInitialSatoshis: 1000,
1123
+ changeFirstSatoshis: 285,
1124
+ changeLockingScriptLength: 25,
1125
+ changeUnlockingScriptLength: 107,
1126
+ randomVals: [...randomValsUsed1]
1127
+ }
1128
+
1129
+ const _defAvailableChange: GenerateChangeSdkChangeInput[] = [
1130
+ { satoshis: 6323, outputId: 15005 },
1131
+ { satoshis: 1004, outputId: 15011 },
1132
+ { satoshis: 1000, outputId: 15013 },
1133
+ { satoshis: 1000, outputId: 15017 },
1134
+ { satoshis: 1000, outputId: 15023 },
1135
+ { satoshis: 1000, outputId: 15027 },
1136
+ { satoshis: 1000, outputId: 15034 },
1137
+ { satoshis: 1575097, outputId: 15101 },
1138
+ { satoshis: 16417, outputId: 15103 },
1139
+ { satoshis: 3377, outputId: 15104 },
1140
+ { satoshis: 10735, outputId: 15106 }
1141
+ ]
1142
+ const defAvailableChange = (): GenerateChangeSdkChangeInput[] =>
1143
+ JSON.parse(JSON.stringify(_defAvailableChange))