@arkade-os/sdk 0.4.27 → 0.4.29

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 (532) hide show
  1. package/README.md +45 -116
  2. package/dist/adapters/asyncStorage.cjs +48 -0
  3. package/dist/adapters/asyncStorage.cjs.map +1 -0
  4. package/dist/adapters/asyncStorage.d.cts +16 -0
  5. package/dist/{types/storage → adapters}/asyncStorage.d.ts +5 -2
  6. package/dist/adapters/asyncStorage.js +46 -0
  7. package/dist/adapters/asyncStorage.js.map +1 -0
  8. package/dist/adapters/expo.cjs +19 -0
  9. package/dist/adapters/expo.cjs.map +1 -0
  10. package/dist/adapters/expo.d.cts +48 -0
  11. package/dist/adapters/expo.d.ts +48 -0
  12. package/dist/adapters/expo.js +6 -0
  13. package/dist/adapters/expo.js.map +1 -0
  14. package/dist/adapters/fileSystem.cjs +116 -0
  15. package/dist/adapters/fileSystem.cjs.map +1 -0
  16. package/dist/adapters/fileSystem.d.cts +17 -0
  17. package/dist/{types/storage → adapters}/fileSystem.d.ts +5 -2
  18. package/dist/adapters/fileSystem.js +93 -0
  19. package/dist/adapters/fileSystem.js.map +1 -0
  20. package/dist/adapters/indexedDB.cjs +103 -0
  21. package/dist/adapters/indexedDB.cjs.map +1 -0
  22. package/dist/adapters/indexedDB.d.cts +18 -0
  23. package/dist/{types/storage → adapters}/indexedDB.d.ts +5 -2
  24. package/dist/adapters/indexedDB.js +101 -0
  25. package/dist/adapters/indexedDB.js.map +1 -0
  26. package/dist/adapters/localStorage.cjs +50 -0
  27. package/dist/adapters/localStorage.cjs.map +1 -0
  28. package/dist/{types/storage/inMemory.d.ts → adapters/localStorage.d.cts} +6 -3
  29. package/dist/{types/storage → adapters}/localStorage.d.ts +5 -2
  30. package/dist/adapters/localStorage.js +48 -0
  31. package/dist/adapters/localStorage.js.map +1 -0
  32. package/dist/ark-ChhTwpLf.d.cts +3892 -0
  33. package/dist/ark-ChhTwpLf.d.ts +3892 -0
  34. package/dist/asyncStorageTaskQueue-DW1-BpI7.d.cts +49 -0
  35. package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-DZ0nUuEJ.d.ts} +6 -3
  36. package/dist/chunk-5BLDMQED.cjs +18 -0
  37. package/dist/chunk-5BLDMQED.cjs.map +1 -0
  38. package/dist/chunk-6FLL2Q36.cjs +2701 -0
  39. package/dist/chunk-6FLL2Q36.cjs.map +1 -0
  40. package/dist/chunk-6NWNOLL3.js +2671 -0
  41. package/dist/chunk-6NWNOLL3.js.map +1 -0
  42. package/dist/chunk-ABWRLTX5.js +210 -0
  43. package/dist/chunk-ABWRLTX5.js.map +1 -0
  44. package/dist/chunk-BVP2U66Q.js +13943 -0
  45. package/dist/chunk-BVP2U66Q.js.map +1 -0
  46. package/dist/chunk-GDCTOSMV.cjs +14058 -0
  47. package/dist/chunk-GDCTOSMV.cjs.map +1 -0
  48. package/dist/chunk-GIGILVVP.cjs +213 -0
  49. package/dist/chunk-GIGILVVP.cjs.map +1 -0
  50. package/dist/chunk-IEO3XDKI.cjs +838 -0
  51. package/dist/chunk-IEO3XDKI.cjs.map +1 -0
  52. package/dist/chunk-NSBPE2FW.js +15 -0
  53. package/dist/chunk-NSBPE2FW.js.map +1 -0
  54. package/dist/chunk-PJUFOJ2L.cjs +100 -0
  55. package/dist/chunk-PJUFOJ2L.cjs.map +1 -0
  56. package/dist/chunk-TH6T23XG.js +95 -0
  57. package/dist/chunk-TH6T23XG.js.map +1 -0
  58. package/dist/chunk-TU3LVAPX.js +769 -0
  59. package/dist/chunk-TU3LVAPX.js.map +1 -0
  60. package/dist/chunk-WMIPYZSB.cjs +803 -0
  61. package/dist/chunk-WMIPYZSB.cjs.map +1 -0
  62. package/dist/chunk-YA4G7RFB.js +829 -0
  63. package/dist/chunk-YA4G7RFB.js.map +1 -0
  64. package/dist/contracts/handlers/index.cjs +26 -0
  65. package/dist/contracts/handlers/index.cjs.map +1 -0
  66. package/dist/contracts/handlers/index.d.cts +7 -0
  67. package/dist/contracts/handlers/index.d.ts +7 -0
  68. package/dist/contracts/handlers/index.js +5 -0
  69. package/dist/contracts/handlers/index.js.map +1 -0
  70. package/dist/delegate-4JBUkUhR.d.cts +84 -0
  71. package/dist/delegate-DN7RELL1.d.ts +84 -0
  72. package/dist/{types/storage/index.d.ts → index-C0IanN1m.d.cts} +3 -1
  73. package/dist/index-C0IanN1m.d.ts +11 -0
  74. package/dist/index-Cn82bBUu.d.ts +199 -0
  75. package/dist/index-DfT5xzgY.d.cts +199 -0
  76. package/dist/index.cjs +504 -0
  77. package/dist/index.cjs.map +1 -0
  78. package/dist/index.d.cts +3469 -0
  79. package/dist/index.d.ts +3469 -0
  80. package/dist/index.js +7 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/repositories/realm/index.cjs +513 -0
  83. package/dist/repositories/realm/index.cjs.map +1 -0
  84. package/dist/repositories/realm/index.d.cts +217 -0
  85. package/dist/{types/repositories/realm/schemas.d.ts → repositories/realm/index.d.ts} +80 -112
  86. package/dist/repositories/realm/index.js +507 -0
  87. package/dist/repositories/realm/index.js.map +1 -0
  88. package/dist/repositories/sqlite/index.cjs +588 -0
  89. package/dist/repositories/sqlite/index.cjs.map +1 -0
  90. package/dist/repositories/sqlite/index.d.cts +118 -0
  91. package/dist/{types/repositories/sqlite/walletRepository.d.ts → repositories/sqlite/index.d.ts} +58 -5
  92. package/dist/repositories/sqlite/index.js +585 -0
  93. package/dist/repositories/sqlite/index.js.map +1 -0
  94. package/dist/taskRunner-B-aPfHhK.d.cts +114 -0
  95. package/dist/taskRunner-B-vG08pX.d.ts +114 -0
  96. package/dist/wallet/expo/background.cjs +93 -0
  97. package/dist/wallet/expo/background.cjs.map +1 -0
  98. package/dist/wallet/expo/background.d.cts +84 -0
  99. package/dist/wallet/expo/background.d.ts +84 -0
  100. package/dist/wallet/expo/background.js +68 -0
  101. package/dist/wallet/expo/background.js.map +1 -0
  102. package/dist/wallet/expo/index.cjs +175 -0
  103. package/dist/wallet/expo/index.cjs.map +1 -0
  104. package/dist/wallet/expo/index.d.cts +124 -0
  105. package/dist/wallet/expo/index.d.ts +124 -0
  106. package/dist/wallet/expo/index.js +173 -0
  107. package/dist/wallet/expo/index.js.map +1 -0
  108. package/dist/wallet-CCtqT2Wb.d.ts +778 -0
  109. package/dist/wallet-DjgFb_4T.d.cts +778 -0
  110. package/dist/worker/expo/index.cjs +140 -0
  111. package/dist/worker/expo/index.cjs.map +1 -0
  112. package/dist/worker/expo/index.d.cts +29 -0
  113. package/dist/worker/expo/index.d.ts +29 -0
  114. package/dist/worker/expo/index.js +121 -0
  115. package/dist/worker/expo/index.js.map +1 -0
  116. package/package.json +110 -76
  117. package/dist/cjs/adapters/asyncStorage.js +0 -5
  118. package/dist/cjs/adapters/expo.js +0 -8
  119. package/dist/cjs/adapters/fileSystem.js +0 -5
  120. package/dist/cjs/adapters/indexedDB.js +0 -5
  121. package/dist/cjs/adapters/localStorage.js +0 -5
  122. package/dist/cjs/arkfee/celenv.js +0 -43
  123. package/dist/cjs/arkfee/estimator.js +0 -143
  124. package/dist/cjs/arkfee/index.js +0 -5
  125. package/dist/cjs/arkfee/types.js +0 -26
  126. package/dist/cjs/arknote/index.js +0 -128
  127. package/dist/cjs/bip322/index.js +0 -270
  128. package/dist/cjs/contracts/arkcontract.js +0 -147
  129. package/dist/cjs/contracts/contractManager.js +0 -649
  130. package/dist/cjs/contracts/contractWatcher.js +0 -598
  131. package/dist/cjs/contracts/handlers/default.js +0 -93
  132. package/dist/cjs/contracts/handlers/delegate.js +0 -90
  133. package/dist/cjs/contracts/handlers/helpers.js +0 -115
  134. package/dist/cjs/contracts/handlers/index.js +0 -19
  135. package/dist/cjs/contracts/handlers/registry.js +0 -89
  136. package/dist/cjs/contracts/handlers/vhtlc.js +0 -194
  137. package/dist/cjs/contracts/index.js +0 -41
  138. package/dist/cjs/contracts/types.js +0 -2
  139. package/dist/cjs/contracts/vtxoOwnership.js +0 -78
  140. package/dist/cjs/extension/asset/assetGroup.js +0 -228
  141. package/dist/cjs/extension/asset/assetId.js +0 -152
  142. package/dist/cjs/extension/asset/assetInput.js +0 -222
  143. package/dist/cjs/extension/asset/assetOutput.js +0 -174
  144. package/dist/cjs/extension/asset/assetRef.js +0 -148
  145. package/dist/cjs/extension/asset/index.js +0 -23
  146. package/dist/cjs/extension/asset/metadata.js +0 -187
  147. package/dist/cjs/extension/asset/packet.js +0 -114
  148. package/dist/cjs/extension/asset/types.js +0 -22
  149. package/dist/cjs/extension/asset/utils.js +0 -105
  150. package/dist/cjs/extension/index.js +0 -254
  151. package/dist/cjs/extension/packet.js +0 -20
  152. package/dist/cjs/forfeit.js +0 -45
  153. package/dist/cjs/identity/descriptor.js +0 -169
  154. package/dist/cjs/identity/descriptorProvider.js +0 -2
  155. package/dist/cjs/identity/hdCapableIdentity.js +0 -20
  156. package/dist/cjs/identity/index.js +0 -40
  157. package/dist/cjs/identity/seedIdentity.js +0 -477
  158. package/dist/cjs/identity/serialize.js +0 -171
  159. package/dist/cjs/identity/singleKey.js +0 -126
  160. package/dist/cjs/identity/staticDescriptorProvider.js +0 -65
  161. package/dist/cjs/index.js +0 -202
  162. package/dist/cjs/intent/index.js +0 -259
  163. package/dist/cjs/musig2/index.js +0 -11
  164. package/dist/cjs/musig2/keys.js +0 -57
  165. package/dist/cjs/musig2/nonces.js +0 -48
  166. package/dist/cjs/musig2/sign.js +0 -102
  167. package/dist/cjs/networks.js +0 -26
  168. package/dist/cjs/package.json +0 -3
  169. package/dist/cjs/providers/ark.js +0 -577
  170. package/dist/cjs/providers/delegator.js +0 -85
  171. package/dist/cjs/providers/electrum.js +0 -869
  172. package/dist/cjs/providers/errors.js +0 -59
  173. package/dist/cjs/providers/expoArk.js +0 -82
  174. package/dist/cjs/providers/expoIndexer.js +0 -111
  175. package/dist/cjs/providers/expoUtils.js +0 -124
  176. package/dist/cjs/providers/indexer.js +0 -630
  177. package/dist/cjs/providers/onchain.js +0 -262
  178. package/dist/cjs/providers/utils.js +0 -121
  179. package/dist/cjs/repositories/contractRepository.js +0 -2
  180. package/dist/cjs/repositories/inMemory/contractRepository.js +0 -55
  181. package/dist/cjs/repositories/inMemory/walletRepository.js +0 -115
  182. package/dist/cjs/repositories/index.js +0 -34
  183. package/dist/cjs/repositories/indexedDB/contractRepository.js +0 -187
  184. package/dist/cjs/repositories/indexedDB/db.js +0 -19
  185. package/dist/cjs/repositories/indexedDB/manager.js +0 -100
  186. package/dist/cjs/repositories/indexedDB/schema.js +0 -204
  187. package/dist/cjs/repositories/indexedDB/walletRepository.js +0 -474
  188. package/dist/cjs/repositories/indexedDB/websqlAdapter.js +0 -144
  189. package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +0 -127
  190. package/dist/cjs/repositories/migrations/fromStorageAdapter.js +0 -66
  191. package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +0 -184
  192. package/dist/cjs/repositories/realm/contractRepository.js +0 -116
  193. package/dist/cjs/repositories/realm/index.js +0 -11
  194. package/dist/cjs/repositories/realm/schemas.js +0 -157
  195. package/dist/cjs/repositories/realm/types.js +0 -7
  196. package/dist/cjs/repositories/realm/walletRepository.js +0 -305
  197. package/dist/cjs/repositories/scriptFromAddress.js +0 -16
  198. package/dist/cjs/repositories/serialization.js +0 -82
  199. package/dist/cjs/repositories/sqlite/contractRepository.js +0 -135
  200. package/dist/cjs/repositories/sqlite/index.js +0 -7
  201. package/dist/cjs/repositories/sqlite/types.js +0 -2
  202. package/dist/cjs/repositories/sqlite/walletRepository.js +0 -441
  203. package/dist/cjs/repositories/walletRepository.js +0 -2
  204. package/dist/cjs/script/address.js +0 -108
  205. package/dist/cjs/script/base.js +0 -185
  206. package/dist/cjs/script/default.js +0 -57
  207. package/dist/cjs/script/delegate.js +0 -53
  208. package/dist/cjs/script/tapscript.js +0 -619
  209. package/dist/cjs/script/vhtlc.js +0 -170
  210. package/dist/cjs/storage/asyncStorage.js +0 -50
  211. package/dist/cjs/storage/fileSystem.js +0 -141
  212. package/dist/cjs/storage/inMemory.js +0 -24
  213. package/dist/cjs/storage/index.js +0 -2
  214. package/dist/cjs/storage/indexedDB.js +0 -101
  215. package/dist/cjs/storage/localStorage.js +0 -51
  216. package/dist/cjs/tree/signingSession.js +0 -229
  217. package/dist/cjs/tree/txTree.js +0 -192
  218. package/dist/cjs/tree/validation.js +0 -107
  219. package/dist/cjs/utils/anchor.js +0 -35
  220. package/dist/cjs/utils/arkTransaction.js +0 -271
  221. package/dist/cjs/utils/bip21.js +0 -127
  222. package/dist/cjs/utils/syncCursors.js +0 -128
  223. package/dist/cjs/utils/timelock.js +0 -59
  224. package/dist/cjs/utils/transaction.js +0 -28
  225. package/dist/cjs/utils/transactionHistory.js +0 -183
  226. package/dist/cjs/utils/txSizeEstimator.js +0 -132
  227. package/dist/cjs/utils/unknownFields.js +0 -174
  228. package/dist/cjs/wallet/asset-manager.js +0 -330
  229. package/dist/cjs/wallet/asset.js +0 -119
  230. package/dist/cjs/wallet/batch.js +0 -183
  231. package/dist/cjs/wallet/delegator.js +0 -308
  232. package/dist/cjs/wallet/expo/background.js +0 -116
  233. package/dist/cjs/wallet/expo/index.js +0 -9
  234. package/dist/cjs/wallet/expo/wallet.js +0 -230
  235. package/dist/cjs/wallet/hdDescriptorProvider.js +0 -188
  236. package/dist/cjs/wallet/index.js +0 -82
  237. package/dist/cjs/wallet/inputSignerRouter.js +0 -98
  238. package/dist/cjs/wallet/onchain.js +0 -290
  239. package/dist/cjs/wallet/ramps.js +0 -216
  240. package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +0 -953
  241. package/dist/cjs/wallet/serviceWorker/wallet.js +0 -1174
  242. package/dist/cjs/wallet/signingErrors.js +0 -32
  243. package/dist/cjs/wallet/unroll.js +0 -293
  244. package/dist/cjs/wallet/utils.js +0 -111
  245. package/dist/cjs/wallet/validation.js +0 -154
  246. package/dist/cjs/wallet/vtxo-manager.js +0 -1142
  247. package/dist/cjs/wallet/wallet.js +0 -2195
  248. package/dist/cjs/wallet/walletReceiveRotator.js +0 -547
  249. package/dist/cjs/worker/browser/service-worker-manager.js +0 -183
  250. package/dist/cjs/worker/browser/utils.js +0 -67
  251. package/dist/cjs/worker/errors.js +0 -16
  252. package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +0 -78
  253. package/dist/cjs/worker/expo/index.js +0 -13
  254. package/dist/cjs/worker/expo/processors/contractPollProcessor.js +0 -62
  255. package/dist/cjs/worker/expo/processors/index.js +0 -6
  256. package/dist/cjs/worker/expo/taskQueue.js +0 -41
  257. package/dist/cjs/worker/expo/taskRunner.js +0 -73
  258. package/dist/cjs/worker/messageBus.js +0 -474
  259. package/dist/esm/adapters/asyncStorage.js +0 -1
  260. package/dist/esm/adapters/expo.js +0 -3
  261. package/dist/esm/adapters/fileSystem.js +0 -1
  262. package/dist/esm/adapters/indexedDB.js +0 -1
  263. package/dist/esm/adapters/localStorage.js +0 -1
  264. package/dist/esm/arkfee/celenv.js +0 -40
  265. package/dist/esm/arkfee/estimator.js +0 -139
  266. package/dist/esm/arkfee/index.js +0 -1
  267. package/dist/esm/arkfee/types.js +0 -22
  268. package/dist/esm/arknote/index.js +0 -124
  269. package/dist/esm/bip322/index.js +0 -267
  270. package/dist/esm/contracts/arkcontract.js +0 -140
  271. package/dist/esm/contracts/contractManager.js +0 -645
  272. package/dist/esm/contracts/contractWatcher.js +0 -594
  273. package/dist/esm/contracts/handlers/default.js +0 -90
  274. package/dist/esm/contracts/handlers/delegate.js +0 -87
  275. package/dist/esm/contracts/handlers/helpers.js +0 -110
  276. package/dist/esm/contracts/handlers/index.js +0 -12
  277. package/dist/esm/contracts/handlers/registry.js +0 -86
  278. package/dist/esm/contracts/handlers/vhtlc.js +0 -191
  279. package/dist/esm/contracts/index.js +0 -13
  280. package/dist/esm/contracts/types.js +0 -1
  281. package/dist/esm/contracts/vtxoOwnership.js +0 -69
  282. package/dist/esm/extension/asset/assetGroup.js +0 -224
  283. package/dist/esm/extension/asset/assetId.js +0 -148
  284. package/dist/esm/extension/asset/assetInput.js +0 -217
  285. package/dist/esm/extension/asset/assetOutput.js +0 -169
  286. package/dist/esm/extension/asset/assetRef.js +0 -144
  287. package/dist/esm/extension/asset/index.js +0 -8
  288. package/dist/esm/extension/asset/metadata.js +0 -182
  289. package/dist/esm/extension/asset/packet.js +0 -110
  290. package/dist/esm/extension/asset/types.js +0 -19
  291. package/dist/esm/extension/asset/utils.js +0 -99
  292. package/dist/esm/extension/index.js +0 -248
  293. package/dist/esm/extension/packet.js +0 -16
  294. package/dist/esm/forfeit.js +0 -41
  295. package/dist/esm/identity/descriptor.js +0 -161
  296. package/dist/esm/identity/descriptorProvider.js +0 -1
  297. package/dist/esm/identity/hdCapableIdentity.js +0 -17
  298. package/dist/esm/identity/index.js +0 -13
  299. package/dist/esm/identity/seedIdentity.js +0 -469
  300. package/dist/esm/identity/serialize.js +0 -164
  301. package/dist/esm/identity/singleKey.js +0 -121
  302. package/dist/esm/identity/staticDescriptorProvider.js +0 -61
  303. package/dist/esm/index.js +0 -87
  304. package/dist/esm/intent/index.js +0 -255
  305. package/dist/esm/musig2/index.js +0 -3
  306. package/dist/esm/musig2/keys.js +0 -21
  307. package/dist/esm/musig2/nonces.js +0 -11
  308. package/dist/esm/musig2/sign.js +0 -63
  309. package/dist/esm/networks.js +0 -22
  310. package/dist/esm/package.json +0 -3
  311. package/dist/esm/providers/ark.js +0 -572
  312. package/dist/esm/providers/delegator.js +0 -81
  313. package/dist/esm/providers/electrum.js +0 -864
  314. package/dist/esm/providers/errors.js +0 -54
  315. package/dist/esm/providers/expoArk.js +0 -78
  316. package/dist/esm/providers/expoIndexer.js +0 -107
  317. package/dist/esm/providers/expoUtils.js +0 -87
  318. package/dist/esm/providers/indexer.js +0 -626
  319. package/dist/esm/providers/onchain.js +0 -258
  320. package/dist/esm/providers/utils.js +0 -117
  321. package/dist/esm/repositories/contractRepository.js +0 -1
  322. package/dist/esm/repositories/inMemory/contractRepository.js +0 -51
  323. package/dist/esm/repositories/inMemory/walletRepository.js +0 -111
  324. package/dist/esm/repositories/index.js +0 -10
  325. package/dist/esm/repositories/indexedDB/contractRepository.js +0 -183
  326. package/dist/esm/repositories/indexedDB/db.js +0 -4
  327. package/dist/esm/repositories/indexedDB/manager.js +0 -95
  328. package/dist/esm/repositories/indexedDB/schema.js +0 -199
  329. package/dist/esm/repositories/indexedDB/walletRepository.js +0 -470
  330. package/dist/esm/repositories/indexedDB/websqlAdapter.js +0 -138
  331. package/dist/esm/repositories/migrations/contractRepositoryImpl.js +0 -121
  332. package/dist/esm/repositories/migrations/fromStorageAdapter.js +0 -58
  333. package/dist/esm/repositories/migrations/walletRepositoryImpl.js +0 -180
  334. package/dist/esm/repositories/realm/contractRepository.js +0 -112
  335. package/dist/esm/repositories/realm/index.js +0 -3
  336. package/dist/esm/repositories/realm/schemas.js +0 -153
  337. package/dist/esm/repositories/realm/types.js +0 -6
  338. package/dist/esm/repositories/realm/walletRepository.js +0 -301
  339. package/dist/esm/repositories/scriptFromAddress.js +0 -13
  340. package/dist/esm/repositories/serialization.js +0 -67
  341. package/dist/esm/repositories/sqlite/contractRepository.js +0 -131
  342. package/dist/esm/repositories/sqlite/index.js +0 -2
  343. package/dist/esm/repositories/sqlite/types.js +0 -1
  344. package/dist/esm/repositories/sqlite/walletRepository.js +0 -437
  345. package/dist/esm/repositories/walletRepository.js +0 -1
  346. package/dist/esm/script/address.js +0 -104
  347. package/dist/esm/script/base.js +0 -179
  348. package/dist/esm/script/default.js +0 -54
  349. package/dist/esm/script/delegate.js +0 -50
  350. package/dist/esm/script/tapscript.js +0 -615
  351. package/dist/esm/script/vhtlc.js +0 -167
  352. package/dist/esm/storage/asyncStorage.js +0 -46
  353. package/dist/esm/storage/fileSystem.js +0 -104
  354. package/dist/esm/storage/inMemory.js +0 -20
  355. package/dist/esm/storage/index.js +0 -1
  356. package/dist/esm/storage/indexedDB.js +0 -97
  357. package/dist/esm/storage/localStorage.js +0 -47
  358. package/dist/esm/tree/signingSession.js +0 -191
  359. package/dist/esm/tree/txTree.js +0 -188
  360. package/dist/esm/tree/validation.js +0 -101
  361. package/dist/esm/utils/anchor.js +0 -31
  362. package/dist/esm/utils/arkTransaction.js +0 -264
  363. package/dist/esm/utils/bip21.js +0 -123
  364. package/dist/esm/utils/syncCursors.js +0 -119
  365. package/dist/esm/utils/timelock.js +0 -22
  366. package/dist/esm/utils/transaction.js +0 -24
  367. package/dist/esm/utils/transactionHistory.js +0 -180
  368. package/dist/esm/utils/txSizeEstimator.js +0 -128
  369. package/dist/esm/utils/unknownFields.js +0 -169
  370. package/dist/esm/wallet/asset-manager.js +0 -325
  371. package/dist/esm/wallet/asset.js +0 -113
  372. package/dist/esm/wallet/batch.js +0 -180
  373. package/dist/esm/wallet/delegator.js +0 -303
  374. package/dist/esm/wallet/expo/background.js +0 -111
  375. package/dist/esm/wallet/expo/index.js +0 -2
  376. package/dist/esm/wallet/expo/wallet.js +0 -193
  377. package/dist/esm/wallet/hdDescriptorProvider.js +0 -184
  378. package/dist/esm/wallet/index.js +0 -75
  379. package/dist/esm/wallet/inputSignerRouter.js +0 -94
  380. package/dist/esm/wallet/onchain.js +0 -285
  381. package/dist/esm/wallet/ramps.js +0 -212
  382. package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +0 -946
  383. package/dist/esm/wallet/serviceWorker/wallet.js +0 -1169
  384. package/dist/esm/wallet/signingErrors.js +0 -27
  385. package/dist/esm/wallet/unroll.js +0 -289
  386. package/dist/esm/wallet/utils.js +0 -103
  387. package/dist/esm/wallet/validation.js +0 -142
  388. package/dist/esm/wallet/vtxo-manager.js +0 -1136
  389. package/dist/esm/wallet/wallet.js +0 -2186
  390. package/dist/esm/wallet/walletReceiveRotator.js +0 -540
  391. package/dist/esm/worker/browser/service-worker-manager.js +0 -177
  392. package/dist/esm/worker/browser/utils.js +0 -63
  393. package/dist/esm/worker/errors.js +0 -11
  394. package/dist/esm/worker/expo/asyncStorageTaskQueue.js +0 -74
  395. package/dist/esm/worker/expo/index.js +0 -4
  396. package/dist/esm/worker/expo/processors/contractPollProcessor.js +0 -59
  397. package/dist/esm/worker/expo/processors/index.js +0 -1
  398. package/dist/esm/worker/expo/taskQueue.js +0 -37
  399. package/dist/esm/worker/expo/taskRunner.js +0 -69
  400. package/dist/esm/worker/messageBus.js +0 -470
  401. package/dist/types/adapters/asyncStorage.d.ts +0 -2
  402. package/dist/types/adapters/expo.d.ts +0 -4
  403. package/dist/types/adapters/fileSystem.d.ts +0 -2
  404. package/dist/types/adapters/indexedDB.d.ts +0 -2
  405. package/dist/types/adapters/localStorage.d.ts +0 -2
  406. package/dist/types/arkfee/celenv.d.ts +0 -25
  407. package/dist/types/arkfee/estimator.d.ts +0 -49
  408. package/dist/types/arkfee/index.d.ts +0 -2
  409. package/dist/types/arkfee/types.d.ts +0 -38
  410. package/dist/types/arknote/index.d.ts +0 -84
  411. package/dist/types/bip322/index.d.ts +0 -55
  412. package/dist/types/contracts/arkcontract.d.ts +0 -99
  413. package/dist/types/contracts/contractManager.d.ts +0 -411
  414. package/dist/types/contracts/contractWatcher.d.ts +0 -217
  415. package/dist/types/contracts/handlers/default.d.ts +0 -19
  416. package/dist/types/contracts/handlers/delegate.d.ts +0 -21
  417. package/dist/types/contracts/handlers/helpers.d.ts +0 -19
  418. package/dist/types/contracts/handlers/index.d.ts +0 -7
  419. package/dist/types/contracts/handlers/registry.d.ts +0 -65
  420. package/dist/types/contracts/handlers/vhtlc.d.ts +0 -32
  421. package/dist/types/contracts/index.d.ts +0 -14
  422. package/dist/types/contracts/types.d.ts +0 -250
  423. package/dist/types/contracts/vtxoOwnership.d.ts +0 -33
  424. package/dist/types/extension/asset/assetGroup.d.ts +0 -119
  425. package/dist/types/extension/asset/assetId.d.ts +0 -83
  426. package/dist/types/extension/asset/assetInput.d.ts +0 -64
  427. package/dist/types/extension/asset/assetOutput.d.ts +0 -54
  428. package/dist/types/extension/asset/assetRef.d.ts +0 -91
  429. package/dist/types/extension/asset/index.d.ts +0 -8
  430. package/dist/types/extension/asset/metadata.d.ts +0 -52
  431. package/dist/types/extension/asset/packet.d.ts +0 -41
  432. package/dist/types/extension/asset/types.d.ts +0 -16
  433. package/dist/types/extension/asset/utils.d.ts +0 -21
  434. package/dist/types/extension/index.d.ts +0 -56
  435. package/dist/types/extension/packet.d.ts +0 -21
  436. package/dist/types/forfeit.d.ts +0 -18
  437. package/dist/types/identity/descriptor.d.ts +0 -61
  438. package/dist/types/identity/descriptorProvider.d.ts +0 -42
  439. package/dist/types/identity/hdCapableIdentity.d.ts +0 -71
  440. package/dist/types/identity/index.d.ts +0 -57
  441. package/dist/types/identity/seedIdentity.d.ts +0 -270
  442. package/dist/types/identity/serialize.d.ts +0 -96
  443. package/dist/types/identity/singleKey.d.ts +0 -62
  444. package/dist/types/identity/staticDescriptorProvider.d.ts +0 -18
  445. package/dist/types/index.d.ts +0 -59
  446. package/dist/types/intent/index.d.ts +0 -86
  447. package/dist/types/musig2/index.d.ts +0 -4
  448. package/dist/types/musig2/keys.d.ts +0 -9
  449. package/dist/types/musig2/nonces.d.ts +0 -14
  450. package/dist/types/musig2/sign.d.ts +0 -27
  451. package/dist/types/networks.d.ts +0 -16
  452. package/dist/types/providers/ark.d.ts +0 -369
  453. package/dist/types/providers/delegator.d.ts +0 -82
  454. package/dist/types/providers/electrum.d.ts +0 -312
  455. package/dist/types/providers/errors.d.ts +0 -13
  456. package/dist/types/providers/expoArk.d.ts +0 -22
  457. package/dist/types/providers/expoIndexer.d.ts +0 -18
  458. package/dist/types/providers/expoUtils.d.ts +0 -18
  459. package/dist/types/providers/indexer.d.ts +0 -301
  460. package/dist/types/providers/onchain.d.ts +0 -148
  461. package/dist/types/providers/utils.d.ts +0 -12
  462. package/dist/types/repositories/contractRepository.d.ts +0 -32
  463. package/dist/types/repositories/inMemory/contractRepository.d.ts +0 -17
  464. package/dist/types/repositories/inMemory/walletRepository.d.ts +0 -29
  465. package/dist/types/repositories/index.d.ts +0 -9
  466. package/dist/types/repositories/indexedDB/contractRepository.d.ts +0 -21
  467. package/dist/types/repositories/indexedDB/db.d.ts +0 -4
  468. package/dist/types/repositories/indexedDB/manager.d.ts +0 -25
  469. package/dist/types/repositories/indexedDB/schema.d.ts +0 -9
  470. package/dist/types/repositories/indexedDB/walletRepository.d.ts +0 -28
  471. package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +0 -49
  472. package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +0 -24
  473. package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +0 -19
  474. package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +0 -27
  475. package/dist/types/repositories/realm/contractRepository.d.ts +0 -24
  476. package/dist/types/repositories/realm/index.d.ts +0 -4
  477. package/dist/types/repositories/realm/types.d.ts +0 -16
  478. package/dist/types/repositories/realm/walletRepository.d.ts +0 -34
  479. package/dist/types/repositories/scriptFromAddress.d.ts +0 -9
  480. package/dist/types/repositories/serialization.d.ts +0 -65
  481. package/dist/types/repositories/sqlite/contractRepository.d.ts +0 -33
  482. package/dist/types/repositories/sqlite/index.d.ts +0 -3
  483. package/dist/types/repositories/sqlite/types.d.ts +0 -18
  484. package/dist/types/repositories/walletRepository.d.ts +0 -72
  485. package/dist/types/script/address.d.ts +0 -67
  486. package/dist/types/script/base.d.ts +0 -105
  487. package/dist/types/script/default.d.ts +0 -44
  488. package/dist/types/script/delegate.d.ts +0 -40
  489. package/dist/types/script/tapscript.d.ts +0 -169
  490. package/dist/types/script/vhtlc.d.ts +0 -66
  491. package/dist/types/tree/signingSession.d.ts +0 -37
  492. package/dist/types/tree/txTree.d.ts +0 -28
  493. package/dist/types/tree/validation.d.ts +0 -15
  494. package/dist/types/utils/anchor.d.ts +0 -19
  495. package/dist/types/utils/arkTransaction.d.ts +0 -49
  496. package/dist/types/utils/bip21.d.ts +0 -38
  497. package/dist/types/utils/syncCursors.d.ts +0 -60
  498. package/dist/types/utils/timelock.d.ts +0 -9
  499. package/dist/types/utils/transaction.d.ts +0 -13
  500. package/dist/types/utils/transactionHistory.d.ts +0 -15
  501. package/dist/types/utils/txSizeEstimator.d.ts +0 -40
  502. package/dist/types/utils/unknownFields.d.ts +0 -83
  503. package/dist/types/wallet/asset-manager.d.ts +0 -69
  504. package/dist/types/wallet/asset.d.ts +0 -21
  505. package/dist/types/wallet/batch.d.ts +0 -107
  506. package/dist/types/wallet/delegator.d.ts +0 -48
  507. package/dist/types/wallet/expo/background.d.ts +0 -66
  508. package/dist/types/wallet/expo/index.d.ts +0 -4
  509. package/dist/types/wallet/expo/wallet.d.ts +0 -99
  510. package/dist/types/wallet/hdDescriptorProvider.d.ts +0 -114
  511. package/dist/types/wallet/index.d.ts +0 -789
  512. package/dist/types/wallet/inputSignerRouter.d.ts +0 -35
  513. package/dist/types/wallet/onchain.d.ts +0 -109
  514. package/dist/types/wallet/ramps.d.ts +0 -64
  515. package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
  516. package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -248
  517. package/dist/types/wallet/signingErrors.d.ts +0 -19
  518. package/dist/types/wallet/unroll.d.ts +0 -114
  519. package/dist/types/wallet/utils.d.ts +0 -36
  520. package/dist/types/wallet/validation.d.ts +0 -24
  521. package/dist/types/wallet/vtxo-manager.d.ts +0 -476
  522. package/dist/types/wallet/wallet.d.ts +0 -409
  523. package/dist/types/wallet/walletReceiveRotator.d.ts +0 -306
  524. package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
  525. package/dist/types/worker/browser/utils.d.ts +0 -17
  526. package/dist/types/worker/errors.d.ts +0 -7
  527. package/dist/types/worker/expo/index.d.ts +0 -7
  528. package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
  529. package/dist/types/worker/expo/processors/index.d.ts +0 -1
  530. package/dist/types/worker/expo/taskQueue.d.ts +0 -50
  531. package/dist/types/worker/expo/taskRunner.d.ts +0 -66
  532. package/dist/types/worker/messageBus.d.ts +0 -189
@@ -0,0 +1,803 @@
1
+ 'use strict';
2
+
3
+ var bip68 = require('bip68');
4
+ var utils_js = require('@scure/btc-signer/utils.js');
5
+ var base = require('@scure/base');
6
+ var script_js = require('@scure/btc-signer/script.js');
7
+ var btcSigner = require('@scure/btc-signer');
8
+ var payment_js = require('@scure/btc-signer/payment.js');
9
+ var psbt_js = require('@scure/btc-signer/psbt.js');
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var bip68__namespace = /*#__PURE__*/_interopNamespace(bip68);
30
+
31
+ // src/utils/timelock.ts
32
+ function timelockToSequence(timelock) {
33
+ return bip68__namespace.encode(
34
+ timelock.type === "blocks" ? { blocks: Number(timelock.value) } : { seconds: Number(timelock.value) }
35
+ );
36
+ }
37
+ function sequenceToTimelock(sequence) {
38
+ const decoded = bip68__namespace.decode(sequence);
39
+ if ("blocks" in decoded && decoded.blocks !== void 0) {
40
+ return { type: "blocks", value: BigInt(decoded.blocks) };
41
+ }
42
+ if ("seconds" in decoded && decoded.seconds !== void 0) {
43
+ return { type: "seconds", value: BigInt(decoded.seconds) };
44
+ }
45
+ throw new Error(`Invalid BIP68 sequence: ${sequence}`);
46
+ }
47
+ var getNetwork = (network) => {
48
+ return networks[network];
49
+ };
50
+ var networks = {
51
+ bitcoin: withArkPrefix(utils_js.NETWORK, "ark"),
52
+ testnet: withArkPrefix(utils_js.TEST_NETWORK, "tark"),
53
+ signet: withArkPrefix(utils_js.TEST_NETWORK, "tark"),
54
+ mutinynet: withArkPrefix(utils_js.TEST_NETWORK, "tark"),
55
+ regtest: withArkPrefix(
56
+ {
57
+ ...utils_js.TEST_NETWORK,
58
+ bech32: "bcrt",
59
+ pubKeyHash: 111,
60
+ scriptHash: 196
61
+ },
62
+ "tark"
63
+ )
64
+ };
65
+ function withArkPrefix(network, prefix) {
66
+ return {
67
+ ...network,
68
+ hrp: prefix
69
+ };
70
+ }
71
+ var DEFAULT_ARKADE_SERVER_URL = "https://arkade.computer";
72
+ var DEFAULT_NETWORK = networks.bitcoin;
73
+ var DEFAULT_NETWORK_NAME = "bitcoin";
74
+ var ArkAddress = class _ArkAddress {
75
+ /**
76
+ * Create an Arkade address from its server public key, Taproot output key, and prefix.
77
+ *
78
+ * @param serverPubKey - 32-byte Arkade server public key
79
+ * @param vtxoTaprootKey - 32-byte Taproot output key (a.k.a. tweaked public key)
80
+ * @param hrp - Bech32 human-readable prefix
81
+ * @param version - Address version byte
82
+ * @defaultValue `version = 0`
83
+ * @throws Error if either public key is not 32 bytes long
84
+ */
85
+ constructor(serverPubKey, vtxoTaprootKey, hrp = DEFAULT_NETWORK.hrp, version = 0) {
86
+ this.serverPubKey = serverPubKey;
87
+ this.vtxoTaprootKey = vtxoTaprootKey;
88
+ this.hrp = hrp;
89
+ this.version = version;
90
+ if (serverPubKey.length !== 32) {
91
+ throw new Error(
92
+ "Invalid server public key length, expected 32 bytes, got " + serverPubKey.length
93
+ );
94
+ }
95
+ if (vtxoTaprootKey.length !== 32) {
96
+ throw new Error(
97
+ "Invalid vtxo taproot public key length, expected 32 bytes, got " + vtxoTaprootKey.length
98
+ );
99
+ }
100
+ }
101
+ /**
102
+ * Decode an Arkade address from its bech32m string form.
103
+ *
104
+ * @param address - Bech32m-encoded Arkade address
105
+ * @returns Decoded Arkade address
106
+ * @throws Error if the address is malformed or has an invalid payload length
107
+ * @see encode
108
+ */
109
+ static decode(address) {
110
+ const decoded = base.bech32m.decodeUnsafe(address, 1023);
111
+ if (!decoded) {
112
+ throw new Error("Invalid address");
113
+ }
114
+ const data = new Uint8Array(base.bech32m.fromWords(decoded.words));
115
+ if (data.length !== 1 + 32 + 32) {
116
+ throw new Error("Invalid data length, expected 65 bytes, got " + data.length);
117
+ }
118
+ const version = data[0];
119
+ const serverPubKey = data.slice(1, 33);
120
+ const vtxoTaprootPubKey = data.slice(33, 65);
121
+ return new _ArkAddress(serverPubKey, vtxoTaprootPubKey, decoded.prefix, version);
122
+ }
123
+ /**
124
+ * Encode the address to its bech32m string form.
125
+ *
126
+ * @returns Bech32m-encoded Arkade address
127
+ * @see decode
128
+ */
129
+ encode() {
130
+ const data = new Uint8Array(1 + 32 + 32);
131
+ data[0] = this.version;
132
+ data.set(this.serverPubKey, 1);
133
+ data.set(this.vtxoTaprootKey, 33);
134
+ const words = base.bech32m.toWords(data);
135
+ return base.bech32m.encode(this.hrp, words, 1023);
136
+ }
137
+ /** ScriptPubKey used to send non-dust funds to the address. */
138
+ get pkScript() {
139
+ return script_js.Script.encode(["OP_1", this.vtxoTaprootKey]);
140
+ }
141
+ /** ScriptPubKey used to send sub-dust funds to the address. */
142
+ get subdustPkScript() {
143
+ return script_js.Script.encode(["RETURN", this.vtxoTaprootKey]);
144
+ }
145
+ };
146
+ var MinimalScriptNum = btcSigner.ScriptNum(void 0, true);
147
+ function decodeTapscript(script) {
148
+ const types = [
149
+ exports.MultisigTapscript,
150
+ exports.CSVMultisigTapscript,
151
+ exports.ConditionCSVMultisigTapscript,
152
+ exports.ConditionMultisigTapscript,
153
+ exports.CLTVMultisigTapscript
154
+ ];
155
+ for (const type of types) {
156
+ try {
157
+ return type.decode(script);
158
+ } catch (error) {
159
+ continue;
160
+ }
161
+ }
162
+ throw new Error(`Failed to decode: script ${base.hex.encode(script)} is not a valid tapscript`);
163
+ }
164
+ exports.MultisigTapscript = void 0;
165
+ ((MultisigTapscript2) => {
166
+ ((MultisigType2) => {
167
+ MultisigType2[MultisigType2["CHECKSIG"] = 0] = "CHECKSIG";
168
+ MultisigType2[MultisigType2["CHECKSIGADD"] = 1] = "CHECKSIGADD";
169
+ })(MultisigTapscript2.MultisigType || (MultisigTapscript2.MultisigType = {}));
170
+ function encode2(params) {
171
+ if (params.pubkeys.length === 0) {
172
+ throw new Error("At least 1 pubkey is required");
173
+ }
174
+ for (const pubkey of params.pubkeys) {
175
+ if (pubkey.length !== 32) {
176
+ throw new Error(`Invalid pubkey length: expected 32, got ${pubkey.length}`);
177
+ }
178
+ }
179
+ if (!params.type) {
180
+ params.type = 0 /* CHECKSIG */;
181
+ }
182
+ if (params.type === 1 /* CHECKSIGADD */) {
183
+ return {
184
+ type: "multisig" /* Multisig */,
185
+ params,
186
+ script: btcSigner.p2tr_ms(params.pubkeys.length, params.pubkeys).script
187
+ };
188
+ }
189
+ const asm = [];
190
+ for (let i = 0; i < params.pubkeys.length; i++) {
191
+ asm.push(params.pubkeys[i]);
192
+ if (i < params.pubkeys.length - 1) {
193
+ asm.push("CHECKSIGVERIFY");
194
+ } else {
195
+ asm.push("CHECKSIG");
196
+ }
197
+ }
198
+ return {
199
+ type: "multisig" /* Multisig */,
200
+ params,
201
+ script: btcSigner.Script.encode(asm)
202
+ };
203
+ }
204
+ MultisigTapscript2.encode = encode2;
205
+ function decode2(script) {
206
+ if (script.length === 0) {
207
+ throw new Error("Failed to decode: script is empty");
208
+ }
209
+ try {
210
+ return decodeChecksigAdd(script);
211
+ } catch (error) {
212
+ try {
213
+ return decodeChecksig(script);
214
+ } catch (error2) {
215
+ throw new Error(
216
+ `Failed to decode script: ${error2 instanceof Error ? error2.message : String(error2)}`
217
+ );
218
+ }
219
+ }
220
+ }
221
+ MultisigTapscript2.decode = decode2;
222
+ function decodeChecksigAdd(script) {
223
+ const asm = btcSigner.Script.decode(script);
224
+ const pubkeys = [];
225
+ let foundNumEqual = false;
226
+ for (let i = 0; i < asm.length; i++) {
227
+ const op = asm[i];
228
+ if (typeof op !== "string" && typeof op !== "number") {
229
+ if (op.length !== 32) {
230
+ throw new Error(`Invalid pubkey length: expected 32, got ${op.length}`);
231
+ }
232
+ pubkeys.push(op);
233
+ if (i + 1 >= asm.length || asm[i + 1] !== "CHECKSIGADD" && asm[i + 1] !== "CHECKSIG") {
234
+ throw new Error("Expected CHECKSIGADD or CHECKSIG after pubkey");
235
+ }
236
+ i++;
237
+ continue;
238
+ }
239
+ if (i === asm.length - 1) {
240
+ if (op !== "NUMEQUAL") {
241
+ throw new Error("Expected NUMEQUAL at end of script");
242
+ }
243
+ foundNumEqual = true;
244
+ }
245
+ }
246
+ if (!foundNumEqual) {
247
+ throw new Error("Missing NUMEQUAL operation");
248
+ }
249
+ if (pubkeys.length === 0) {
250
+ throw new Error("Invalid script: must have at least 1 pubkey");
251
+ }
252
+ const reconstructed = encode2({
253
+ pubkeys,
254
+ type: 1 /* CHECKSIGADD */
255
+ });
256
+ if (base.hex.encode(reconstructed.script) !== base.hex.encode(script)) {
257
+ throw new Error("Invalid script format: script reconstruction mismatch");
258
+ }
259
+ return {
260
+ type: "multisig" /* Multisig */,
261
+ params: { pubkeys, type: 1 /* CHECKSIGADD */ },
262
+ script
263
+ };
264
+ }
265
+ function decodeChecksig(script) {
266
+ const asm = btcSigner.Script.decode(script);
267
+ const pubkeys = [];
268
+ for (let i = 0; i < asm.length; i++) {
269
+ const op = asm[i];
270
+ if (typeof op !== "string" && typeof op !== "number") {
271
+ if (op.length !== 32) {
272
+ throw new Error(`Invalid pubkey length: expected 32, got ${op.length}`);
273
+ }
274
+ pubkeys.push(op);
275
+ if (i + 1 >= asm.length) {
276
+ throw new Error("Unexpected end of script");
277
+ }
278
+ const nextOp = asm[i + 1];
279
+ if (nextOp !== "CHECKSIGVERIFY" && nextOp !== "CHECKSIG") {
280
+ throw new Error("Expected CHECKSIGVERIFY or CHECKSIG after pubkey");
281
+ }
282
+ if (i === asm.length - 2 && nextOp !== "CHECKSIG") {
283
+ throw new Error("Last operation must be CHECKSIG");
284
+ }
285
+ i++;
286
+ continue;
287
+ }
288
+ }
289
+ if (pubkeys.length === 0) {
290
+ throw new Error("Invalid script: must have at least 1 pubkey");
291
+ }
292
+ const reconstructed = encode2({ pubkeys, type: 0 /* CHECKSIG */ });
293
+ if (base.hex.encode(reconstructed.script) !== base.hex.encode(script)) {
294
+ throw new Error("Invalid script format: script reconstruction mismatch");
295
+ }
296
+ return {
297
+ type: "multisig" /* Multisig */,
298
+ params: { pubkeys, type: 0 /* CHECKSIG */ },
299
+ script
300
+ };
301
+ }
302
+ function is(tapscript) {
303
+ return tapscript.type === "multisig" /* Multisig */;
304
+ }
305
+ MultisigTapscript2.is = is;
306
+ })(exports.MultisigTapscript || (exports.MultisigTapscript = {}));
307
+ exports.CSVMultisigTapscript = void 0;
308
+ ((CSVMultisigTapscript2) => {
309
+ function encode2(params) {
310
+ for (const pubkey of params.pubkeys) {
311
+ if (pubkey.length !== 32) {
312
+ throw new Error(`Invalid pubkey length: expected 32, got ${pubkey.length}`);
313
+ }
314
+ }
315
+ const sequence = MinimalScriptNum.encode(BigInt(timelockToSequence(params.timelock)));
316
+ const asm = [
317
+ sequence.length === 1 ? sequence[0] : sequence,
318
+ "CHECKSEQUENCEVERIFY",
319
+ "DROP"
320
+ ];
321
+ const multisigScript = exports.MultisigTapscript.encode(params);
322
+ const script = new Uint8Array([...btcSigner.Script.encode(asm), ...multisigScript.script]);
323
+ return {
324
+ type: "csv-multisig" /* CSVMultisig */,
325
+ params,
326
+ script
327
+ };
328
+ }
329
+ CSVMultisigTapscript2.encode = encode2;
330
+ function decode2(script) {
331
+ if (script.length === 0) {
332
+ throw new Error("Failed to decode: script is empty");
333
+ }
334
+ const isValid = isScriptValid(script);
335
+ if (isValid instanceof Error) {
336
+ throw isValid;
337
+ }
338
+ const asm = btcSigner.Script.decode(script);
339
+ const sequence = asm[0];
340
+ const multisigScript = new Uint8Array(btcSigner.Script.encode(asm.slice(3)));
341
+ let multisig;
342
+ try {
343
+ multisig = exports.MultisigTapscript.decode(multisigScript);
344
+ } catch (error) {
345
+ throw new Error(
346
+ `Invalid multisig script: ${error instanceof Error ? error.message : String(error)}`
347
+ );
348
+ }
349
+ let sequenceNum;
350
+ if (typeof sequence === "number") {
351
+ sequenceNum = sequence;
352
+ } else {
353
+ sequenceNum = Number(MinimalScriptNum.decode(sequence));
354
+ }
355
+ const timelock = sequenceToTimelock(sequenceNum);
356
+ const reconstructed = encode2({
357
+ timelock,
358
+ ...multisig.params
359
+ });
360
+ if (base.hex.encode(reconstructed.script) !== base.hex.encode(script)) {
361
+ throw new Error("Invalid script format: script reconstruction mismatch");
362
+ }
363
+ return {
364
+ type: "csv-multisig" /* CSVMultisig */,
365
+ params: {
366
+ timelock,
367
+ ...multisig.params
368
+ },
369
+ script
370
+ };
371
+ }
372
+ CSVMultisigTapscript2.decode = decode2;
373
+ function is(tapscript) {
374
+ return tapscript.type === "csv-multisig" /* CSVMultisig */;
375
+ }
376
+ CSVMultisigTapscript2.is = is;
377
+ function isScriptValid(script) {
378
+ const asm = btcSigner.Script.decode(script);
379
+ if (asm.length < 3) {
380
+ return new Error(`Invalid script: too short (expected at least 3)`);
381
+ }
382
+ const sequence = asm[0];
383
+ if (typeof sequence === "string") {
384
+ return new Error("Invalid script: expected sequence number");
385
+ }
386
+ if (asm[1] !== "CHECKSEQUENCEVERIFY" || asm[2] !== "DROP") {
387
+ return new Error("Invalid script: expected CHECKSEQUENCEVERIFY DROP");
388
+ }
389
+ return true;
390
+ }
391
+ CSVMultisigTapscript2.isScriptValid = isScriptValid;
392
+ })(exports.CSVMultisigTapscript || (exports.CSVMultisigTapscript = {}));
393
+ exports.ConditionCSVMultisigTapscript = void 0;
394
+ ((ConditionCSVMultisigTapscript2) => {
395
+ function encode2(params) {
396
+ const script = new Uint8Array([
397
+ ...params.conditionScript,
398
+ ...btcSigner.Script.encode(["VERIFY"]),
399
+ ...exports.CSVMultisigTapscript.encode(params).script
400
+ ]);
401
+ return {
402
+ type: "condition-csv-multisig" /* ConditionCSVMultisig */,
403
+ params,
404
+ script
405
+ };
406
+ }
407
+ ConditionCSVMultisigTapscript2.encode = encode2;
408
+ function decode2(script) {
409
+ if (script.length === 0) {
410
+ throw new Error("Failed to decode: script is empty");
411
+ }
412
+ const isValid = isScriptValid(script);
413
+ if (isValid instanceof Error) {
414
+ throw isValid;
415
+ }
416
+ const asm = btcSigner.Script.decode(script);
417
+ let verifyIndex = getVerifyIndex(asm);
418
+ if (verifyIndex === -1) {
419
+ throw Error("Invalid script: missing VERIFY operation");
420
+ }
421
+ const conditionScript = new Uint8Array(btcSigner.Script.encode(asm.slice(0, verifyIndex)));
422
+ const csvMultisigScript = new Uint8Array(btcSigner.Script.encode(asm.slice(verifyIndex + 1)));
423
+ let csvMultisig;
424
+ try {
425
+ csvMultisig = exports.CSVMultisigTapscript.decode(csvMultisigScript);
426
+ } catch (error) {
427
+ throw new Error(
428
+ `Invalid CSV multisig script: ${error instanceof Error ? error.message : String(error)}`
429
+ );
430
+ }
431
+ const reconstructed = encode2({
432
+ conditionScript,
433
+ ...csvMultisig.params
434
+ });
435
+ if (base.hex.encode(reconstructed.script) !== base.hex.encode(script)) {
436
+ throw new Error("Invalid script format: script reconstruction mismatch");
437
+ }
438
+ return {
439
+ type: "condition-csv-multisig" /* ConditionCSVMultisig */,
440
+ params: {
441
+ conditionScript,
442
+ ...csvMultisig.params
443
+ },
444
+ script
445
+ };
446
+ }
447
+ ConditionCSVMultisigTapscript2.decode = decode2;
448
+ function is(tapscript) {
449
+ return tapscript.type === "condition-csv-multisig" /* ConditionCSVMultisig */;
450
+ }
451
+ ConditionCSVMultisigTapscript2.is = is;
452
+ function getVerifyIndex(asm) {
453
+ let verifyIndex = -1;
454
+ for (let i = asm.length - 1; i >= 0; i--) {
455
+ if (asm[i] === "VERIFY") {
456
+ verifyIndex = i;
457
+ return verifyIndex;
458
+ }
459
+ }
460
+ return verifyIndex;
461
+ }
462
+ function isScriptValid(script) {
463
+ const asm = btcSigner.Script.decode(script);
464
+ if (asm.length < 1) {
465
+ return new Error(`Invalid script: too short (expected at least 1)`);
466
+ }
467
+ let verifyIndex = getVerifyIndex(asm);
468
+ if (verifyIndex === -1) {
469
+ return new Error("Invalid script: missing VERIFY operation");
470
+ }
471
+ return true;
472
+ }
473
+ ConditionCSVMultisigTapscript2.isScriptValid = isScriptValid;
474
+ })(exports.ConditionCSVMultisigTapscript || (exports.ConditionCSVMultisigTapscript = {}));
475
+ exports.ConditionMultisigTapscript = void 0;
476
+ ((ConditionMultisigTapscript2) => {
477
+ function encode2(params) {
478
+ const script = new Uint8Array([
479
+ ...params.conditionScript,
480
+ ...btcSigner.Script.encode(["VERIFY"]),
481
+ ...exports.MultisigTapscript.encode(params).script
482
+ ]);
483
+ return {
484
+ type: "condition-multisig" /* ConditionMultisig */,
485
+ params,
486
+ script
487
+ };
488
+ }
489
+ ConditionMultisigTapscript2.encode = encode2;
490
+ function decode2(script) {
491
+ if (script.length === 0) {
492
+ throw new Error("Failed to decode: script is empty");
493
+ }
494
+ const isValid = isScriptValid(script);
495
+ if (isValid instanceof Error) {
496
+ throw isValid;
497
+ }
498
+ const asm = btcSigner.Script.decode(script);
499
+ let verifyIndex = getVerifyIndex(asm);
500
+ if (verifyIndex === -1) {
501
+ throw Error("Invalid script: missing VERIFY operation");
502
+ }
503
+ const conditionScript = new Uint8Array(btcSigner.Script.encode(asm.slice(0, verifyIndex)));
504
+ const multisigScript = new Uint8Array(btcSigner.Script.encode(asm.slice(verifyIndex + 1)));
505
+ let multisig;
506
+ try {
507
+ multisig = exports.MultisigTapscript.decode(multisigScript);
508
+ } catch (error) {
509
+ throw new Error(
510
+ `Invalid multisig script: ${error instanceof Error ? error.message : String(error)}`
511
+ );
512
+ }
513
+ const reconstructed = encode2({
514
+ conditionScript,
515
+ ...multisig.params
516
+ });
517
+ if (base.hex.encode(reconstructed.script) !== base.hex.encode(script)) {
518
+ throw new Error("Invalid script format: script reconstruction mismatch");
519
+ }
520
+ return {
521
+ type: "condition-multisig" /* ConditionMultisig */,
522
+ params: {
523
+ conditionScript,
524
+ ...multisig.params
525
+ },
526
+ script
527
+ };
528
+ }
529
+ ConditionMultisigTapscript2.decode = decode2;
530
+ function is(tapscript) {
531
+ return tapscript.type === "condition-multisig" /* ConditionMultisig */;
532
+ }
533
+ ConditionMultisigTapscript2.is = is;
534
+ function getVerifyIndex(asm) {
535
+ let verifyIndex = -1;
536
+ for (let i = asm.length - 1; i >= 0; i--) {
537
+ if (asm[i] === "VERIFY") {
538
+ verifyIndex = i;
539
+ return verifyIndex;
540
+ }
541
+ }
542
+ return verifyIndex;
543
+ }
544
+ function isScriptValid(script) {
545
+ const asm = btcSigner.Script.decode(script);
546
+ if (asm.length < 1) {
547
+ return new Error(`Invalid script: too short (expected at least 1)`);
548
+ }
549
+ let verifyIndex = getVerifyIndex(asm);
550
+ if (verifyIndex === -1) {
551
+ return new Error("Invalid script: missing VERIFY operation");
552
+ }
553
+ return true;
554
+ }
555
+ ConditionMultisigTapscript2.isScriptValid = isScriptValid;
556
+ })(exports.ConditionMultisigTapscript || (exports.ConditionMultisigTapscript = {}));
557
+ exports.CLTVMultisigTapscript = void 0;
558
+ ((CLTVMultisigTapscript2) => {
559
+ function encode2(params) {
560
+ const locktime = MinimalScriptNum.encode(params.absoluteTimelock);
561
+ const asm = [
562
+ locktime.length === 1 ? locktime[0] : locktime,
563
+ "CHECKLOCKTIMEVERIFY",
564
+ "DROP"
565
+ ];
566
+ const timelockedScript = btcSigner.Script.encode(asm);
567
+ const script = new Uint8Array([
568
+ ...timelockedScript,
569
+ ...exports.MultisigTapscript.encode(params).script
570
+ ]);
571
+ return {
572
+ type: "cltv-multisig" /* CLTVMultisig */,
573
+ params,
574
+ script
575
+ };
576
+ }
577
+ CLTVMultisigTapscript2.encode = encode2;
578
+ function decode2(script) {
579
+ if (script.length === 0) {
580
+ throw new Error("Failed to decode: script is empty");
581
+ }
582
+ const isValid = isScriptValid(script);
583
+ if (isValid instanceof Error) {
584
+ throw isValid;
585
+ }
586
+ const asm = btcSigner.Script.decode(script);
587
+ const locktime = asm[0];
588
+ if (typeof locktime === "string") {
589
+ throw new Error("Invalid script: expected locktime number");
590
+ }
591
+ if (asm[1] !== "CHECKLOCKTIMEVERIFY" || asm[2] !== "DROP") {
592
+ throw new Error("Invalid script: expected CHECKLOCKTIMEVERIFY DROP");
593
+ }
594
+ const multisigScript = new Uint8Array(btcSigner.Script.encode(asm.slice(3)));
595
+ let multisig;
596
+ try {
597
+ multisig = exports.MultisigTapscript.decode(multisigScript);
598
+ } catch (error) {
599
+ throw new Error(
600
+ `Invalid multisig script: ${error instanceof Error ? error.message : String(error)}`
601
+ );
602
+ }
603
+ let absoluteTimelock;
604
+ if (typeof locktime === "number") {
605
+ absoluteTimelock = BigInt(locktime);
606
+ } else {
607
+ absoluteTimelock = MinimalScriptNum.decode(locktime);
608
+ }
609
+ const reconstructed = encode2({
610
+ absoluteTimelock,
611
+ ...multisig.params
612
+ });
613
+ if (base.hex.encode(reconstructed.script) !== base.hex.encode(script)) {
614
+ throw new Error("Invalid script format: script reconstruction mismatch");
615
+ }
616
+ return {
617
+ type: "cltv-multisig" /* CLTVMultisig */,
618
+ params: {
619
+ absoluteTimelock,
620
+ ...multisig.params
621
+ },
622
+ script
623
+ };
624
+ }
625
+ CLTVMultisigTapscript2.decode = decode2;
626
+ function is(tapscript) {
627
+ return tapscript.type === "cltv-multisig" /* CLTVMultisig */;
628
+ }
629
+ CLTVMultisigTapscript2.is = is;
630
+ function isScriptValid(script) {
631
+ const asm = btcSigner.Script.decode(script);
632
+ if (asm.length < 3) {
633
+ return new Error(`Invalid script: too short (expected at least 3)`);
634
+ }
635
+ const locktime = asm[0];
636
+ if (typeof locktime === "string") {
637
+ return new Error("Invalid script: expected locktime as number or bytes");
638
+ }
639
+ if (asm[1] !== "CHECKLOCKTIMEVERIFY" || asm[2] !== "DROP") {
640
+ return new Error("Invalid script: expected CHECKLOCKTIMEVERIFY DROP");
641
+ }
642
+ return true;
643
+ }
644
+ CLTVMultisigTapscript2.isScriptValid = isScriptValid;
645
+ })(exports.CLTVMultisigTapscript || (exports.CLTVMultisigTapscript = {}));
646
+ var TapTreeCoder = psbt_js.PSBTOutput.tapTree[2];
647
+ function scriptFromTapLeafScript(leaf) {
648
+ return leaf[1].subarray(0, leaf[1].length - 1);
649
+ }
650
+ var VtxoScript = class _VtxoScript {
651
+ /**
652
+ * Create a virtual output script from its tapleaf scripts.
653
+ *
654
+ * @param scripts - Raw tapscript bytes for each leaf
655
+ * @throws Error if the provided leaves cannot produce a valid Taproot tree
656
+ */
657
+ constructor(scripts) {
658
+ this.scripts = scripts;
659
+ const list = scripts.length % 2 !== 0 ? scripts.slice().reverse() : scripts;
660
+ const tapTree = btcSigner.taprootListToTree(
661
+ list.map((script) => ({
662
+ script,
663
+ leafVersion: payment_js.TAP_LEAF_VERSION
664
+ }))
665
+ );
666
+ const payment = btcSigner.p2tr(btcSigner.TAPROOT_UNSPENDABLE_KEY, tapTree, void 0, true);
667
+ if (!payment.tapLeafScript || payment.tapLeafScript.length !== scripts.length) {
668
+ throw new Error("invalid scripts");
669
+ }
670
+ this.leaves = payment.tapLeafScript;
671
+ this.tweakedPublicKey = payment.tweakedPubkey;
672
+ }
673
+ leaves;
674
+ tweakedPublicKey;
675
+ /**
676
+ * Decode a virtual output script from an encoded TapTree.
677
+ *
678
+ * @param tapTree - Encoded TapTree bytes
679
+ * @returns Decoded virtual output script
680
+ * @throws Error if the TapTree cannot be decoded into a valid script set
681
+ * @see encode
682
+ */
683
+ static decode(tapTree) {
684
+ const leaves = TapTreeCoder.decode(tapTree);
685
+ const scripts = leaves.map((leaf) => leaf.script);
686
+ return new _VtxoScript(scripts);
687
+ }
688
+ /**
689
+ * Encode the virtual output script to a TapTree byte representation.
690
+ *
691
+ * @returns Encoded TapTree bytes
692
+ * @see decode
693
+ */
694
+ encode() {
695
+ const tapTree = TapTreeCoder.encode(
696
+ this.scripts.map((script) => ({
697
+ depth: 1,
698
+ version: payment_js.TAP_LEAF_VERSION,
699
+ script
700
+ }))
701
+ );
702
+ return tapTree;
703
+ }
704
+ /**
705
+ * Build the Arkade address corresponding to this virtual output script.
706
+ *
707
+ * @param prefix - Bech32 human-readable prefix
708
+ * @param serverPubKey - 32-byte Arkade server public key
709
+ * @returns Arkade address for this script
710
+ * @see ArkAddress
711
+ */
712
+ address(prefix = DEFAULT_NETWORK.hrp, serverPubKey) {
713
+ return new ArkAddress(serverPubKey, this.tweakedPublicKey, prefix);
714
+ }
715
+ get pkScript() {
716
+ return btcSigner.Script.encode(["OP_1", this.tweakedPublicKey]);
717
+ }
718
+ /**
719
+ * Build the Taproot onchain address corresponding to this virtual output script.
720
+ *
721
+ * @param network - Bitcoin network descriptor
722
+ * @returns Taproot onchain address
723
+ * @see address
724
+ */
725
+ onchainAddress(network = DEFAULT_NETWORK) {
726
+ return btcSigner.Address(network).encode({
727
+ type: "tr",
728
+ pubkey: this.tweakedPublicKey
729
+ });
730
+ }
731
+ /**
732
+ * Look up a tapleaf script by its hex-encoded tapscript body.
733
+ *
734
+ * @param scriptHex - Hex-encoded tapscript body without the leaf version byte
735
+ * @returns Matching tapleaf script
736
+ * @throws Error if no matching leaf exists
737
+ */
738
+ findLeaf(scriptHex) {
739
+ const leaf = this.leaves.find(
740
+ (leaf2) => base.hex.encode(scriptFromTapLeafScript(leaf2)) === scriptHex
741
+ );
742
+ if (!leaf) {
743
+ throw new Error(`leaf '${scriptHex}' not found`);
744
+ }
745
+ return leaf;
746
+ }
747
+ /**
748
+ * Return all unilateral exit paths embedded in the virtual output script.
749
+ *
750
+ * @returns CSV-based exit paths found in the leaves
751
+ * @see getSequence
752
+ */
753
+ exitPaths() {
754
+ const paths = [];
755
+ for (const leaf of this.leaves) {
756
+ try {
757
+ const script = scriptFromTapLeafScript(leaf);
758
+ if (exports.CSVMultisigTapscript.isScriptValid(script) === true) {
759
+ const tapScript = exports.CSVMultisigTapscript.decode(script);
760
+ paths.push(tapScript);
761
+ } else if (exports.ConditionCSVMultisigTapscript.isScriptValid(script) === true) {
762
+ const tapScript = exports.ConditionCSVMultisigTapscript.decode(script);
763
+ paths.push(tapScript);
764
+ }
765
+ } catch (e) {
766
+ console.debug("Failed to decode script", e);
767
+ }
768
+ }
769
+ return paths;
770
+ }
771
+ };
772
+ function getSequence(tapLeafScript) {
773
+ let sequence = void 0;
774
+ try {
775
+ const scriptWithLeafVersion = tapLeafScript[1];
776
+ const script = scriptWithLeafVersion.subarray(0, scriptWithLeafVersion.length - 1);
777
+ try {
778
+ const params = exports.CSVMultisigTapscript.decode(script).params;
779
+ sequence = timelockToSequence(params.timelock);
780
+ } catch {
781
+ const params = exports.CLTVMultisigTapscript.decode(script).params;
782
+ sequence = Number(params.absoluteTimelock);
783
+ }
784
+ } catch {
785
+ }
786
+ return sequence;
787
+ }
788
+
789
+ exports.ArkAddress = ArkAddress;
790
+ exports.DEFAULT_ARKADE_SERVER_URL = DEFAULT_ARKADE_SERVER_URL;
791
+ exports.DEFAULT_NETWORK = DEFAULT_NETWORK;
792
+ exports.DEFAULT_NETWORK_NAME = DEFAULT_NETWORK_NAME;
793
+ exports.TapTreeCoder = TapTreeCoder;
794
+ exports.VtxoScript = VtxoScript;
795
+ exports.decodeTapscript = decodeTapscript;
796
+ exports.getNetwork = getNetwork;
797
+ exports.getSequence = getSequence;
798
+ exports.networks = networks;
799
+ exports.scriptFromTapLeafScript = scriptFromTapLeafScript;
800
+ exports.sequenceToTimelock = sequenceToTimelock;
801
+ exports.timelockToSequence = timelockToSequence;
802
+ //# sourceMappingURL=chunk-WMIPYZSB.cjs.map
803
+ //# sourceMappingURL=chunk-WMIPYZSB.cjs.map