@arkade-os/sdk 0.4.26 → 0.4.28

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