@arkade-os/sdk 0.4.27 → 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 (531) hide show
  1. package/README.md +31 -100
  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 -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/hdDescriptorProvider.d.ts +0 -114
  510. package/dist/types/wallet/index.d.ts +0 -789
  511. package/dist/types/wallet/inputSignerRouter.d.ts +0 -35
  512. package/dist/types/wallet/onchain.d.ts +0 -109
  513. package/dist/types/wallet/ramps.d.ts +0 -64
  514. package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
  515. package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -248
  516. package/dist/types/wallet/signingErrors.d.ts +0 -19
  517. package/dist/types/wallet/unroll.d.ts +0 -114
  518. package/dist/types/wallet/utils.d.ts +0 -36
  519. package/dist/types/wallet/validation.d.ts +0 -24
  520. package/dist/types/wallet/vtxo-manager.d.ts +0 -476
  521. package/dist/types/wallet/wallet.d.ts +0 -409
  522. package/dist/types/wallet/walletReceiveRotator.d.ts +0 -306
  523. package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
  524. package/dist/types/worker/browser/utils.d.ts +0 -17
  525. package/dist/types/worker/errors.d.ts +0 -7
  526. package/dist/types/worker/expo/index.d.ts +0 -7
  527. package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
  528. package/dist/types/worker/expo/processors/index.d.ts +0 -1
  529. package/dist/types/worker/expo/taskQueue.d.ts +0 -50
  530. package/dist/types/worker/expo/taskRunner.d.ts +0 -66
  531. package/dist/types/worker/messageBus.d.ts +0 -189
@@ -0,0 +1,3343 @@
1
+ import { M as ReadonlyIdentity, a as Identity, a5 as DescriptorSigningRequest, a6 as Transaction, a2 as SignerSession, W as WalletRepository, E as ExtendedVirtualCoin, s as VtxoRepositoryKey, d as ExtendedCoin, A as ArkTransaction, t as WalletState, r as Contract, C as ContractRepository, u as ContractFilter, a7 as IntentFeeConfig, a8 as OffchainInput, a9 as FeeAmount, aa as OnchainInput, ab as FeeOutput, m as ArkProvider, a0 as SettlementConfig, ac as ContractWatcherConfig, I as IWallet, ad as FeeInfo, h as SettlementEvent, J as DescriptorProvider, g as SettleParams, S as SendBitcoinParams, G as GetVtxosFilter, ae as CreateContractParams, af as GetContractsFilter, q as VirtualCoin, ag as GetSpendablePathsOptions, ah as GetAllSpendingPathsOptions, R as Recipient, ai as IssuanceParams, aj as ReissuanceParams, ak as BurnParams, c as WalletBalance, al as ContractWithVtxos, am as PathSelection, an as ContractEvent, ao as AssetDetails, ap as IssuanceResult, aq as DelegateInfo, L as IReadonlyWallet, U as IReadonlyAssetManager, ar as StorageConfig, e as IContractManager, i as IAssetManager, f as IDelegatorManager, as as IVtxoManager, O as OnchainProvider, N as Network, X as NetworkName, K as Coin, at as ExplorerTransaction, p as TapLeafScript, au as EncodedVtxoScript, $ as CSVMultisigTapscript, o as RelativeTimelock, V as VtxoScript, av as Status, aw as Outpoint, ax as ChainTx, n as IndexerProvider, w as TxTree } from './ark-TZ1gXAXU.cjs';
2
+ export { Z as ArkAddress, Y as ArkInfo, ay as ArkTapscript, az as Asset, aA as AssetMetadata, aB as BaseWalletConfig, D as BatchFailedEvent, y as BatchFinalizationEvent, z as BatchFinalizedEvent, aC as BatchInfo, aD as BatchSignableIdentity, B as BatchStartedEvent, aE as CLTVMultisigTapscript, aF as ChainTxType, aG as CommitmentTx, aH as ConditionCSVMultisigTapscript, aI as ConditionMultisigTapscript, aJ as ContractBalance, aK as ContractEventCallback, aL as ContractHandler, _ as ContractManager, aM as ContractManagerConfig, aN as ContractState, aO as ContractVtxo, aP as ContractWatcher, aQ as DelegateOptions, aR as DelegatorManagerImpl, P as DelegatorProvider, aS as Discoverable, aT as DiscoveredContract, aU as DiscoveryDeps, aV as ESPLORA_URL, aW as EsploraProvider, aX as ExtendedContractVtxo, aY as HandlerError, aZ as IndexerTxType, a4 as Intent, a_ as KnownMetadata, a$ as MultisigTapscript, b0 as Nonces, b1 as Output, b2 as PageResponse, b3 as PaginationOptions, b4 as PartialSig, b5 as PathContext, b6 as ProviderClass, Q as ReadonlyWalletConfig, j as RestArkProvider, b7 as RestDelegatorProvider, k as RestIndexerProvider, b8 as ScanContractsOptions, b9 as ScanResult, ba as ScheduledSession, bb as SettlementEventType, bc as SignRequest, a3 as SignedIntent, bd as SubscriptionEvent, be as SubscriptionHeartbeat, l as SubscriptionResponse, bf as TapLeaves, bg as TapTreeCoder, bh as TapscriptType, bi as TreeNonces, x as TreeNoncesEvent, bj as TreePartialSigs, H as TreeSignatureEvent, v as TreeSigningStartedEvent, F as TreeTxEvent, bk as Tx, bl as TxHistoryRecord, bm as TxKey, T as TxNotification, bn as TxTreeNode, bo as TxType, bp as VirtualStatus, bq as Vtxo, br as VtxoChain, a1 as VtxoManager, bs as VtxoType, b as WalletConfig, bt as WalletMode, bu as decodeTapscript, bv as getSequence, bw as isBatchSignable, bx as isDiscoverable, by as isExpired, bz as isRecoverable, bA as isSpendable, bB as isSubdust, bC as isVtxoExpiringSoon, bD as networks } from './ark-TZ1gXAXU.cjs';
3
+ export { D as DefaultContractHandler, a as DefaultContractParams, b as DelegateContractHandler, c as DelegateContractParams, V as VHTLC, d as VHTLCContractHandler, e as VHTLCContractParams, f as contractHandlers } from './index-B22cA64m.cjs';
4
+ export { D as DefaultVtxo, a as DelegateVtxo } from './delegate-BFZs69hp.cjs';
5
+ import { W as Wallet, R as ReadonlyWallet, a as ReceiveRotatorFactory, b as ReceiveRotatorBootOpts, c as ReceiveRotatorBoot } from './wallet-AF-p-OWj.cjs';
6
+ export { B as Batch, I as IncomingFunds, w as waitForIncomingFunds } from './wallet-AF-p-OWj.cjs';
7
+ import { P2TR } from '@scure/btc-signer/payment.js';
8
+ import { Transaction as Transaction$1 } from '@scure/btc-signer';
9
+ import { ElectrumWS } from 'ws-electrumx-client';
10
+ import { TransactionOutput, TransactionInputUpdate } from '@scure/btc-signer/psbt.js';
11
+ import { BTC_NETWORK, Bytes } from '@scure/btc-signer/utils.js';
12
+ import { Transaction as Transaction$2 } from '@scure/btc-signer/transaction.js';
13
+ import { S as StorageAdapter } from './index-C0IanN1m.cjs';
14
+
15
+ /**
16
+ * Tagged envelope for a signing identity transported across the
17
+ * service-worker boundary. All variants are structured-clone safe
18
+ * (plain strings only — no functions or prototypes).
19
+ *
20
+ * `descriptor` carries the wildcard *template* (e.g.
21
+ * `tr([fp/86'/0'/0']xpub.../0/*)`), not a concrete index — the
22
+ * receiving factories require a template, and storing it directly
23
+ * means nothing here has to convert concrete → template on rehydrate.
24
+ *
25
+ * Adding a new variant is a source change in every worker build; keep
26
+ * old variants around until all deployed workers handle them.
27
+ */
28
+ type SerializedSigningIdentity = {
29
+ type: "single-key";
30
+ privateKey: string;
31
+ } | {
32
+ type: "seed";
33
+ seed: string;
34
+ descriptor: string;
35
+ } | {
36
+ type: "mnemonic";
37
+ mnemonic: string;
38
+ descriptor: string;
39
+ passphrase?: string;
40
+ };
41
+ /**
42
+ * Tagged envelope for a readonly identity transported across the
43
+ * service-worker boundary. All variants are structured-clone safe.
44
+ * `descriptor` is the wildcard template (see
45
+ * {@link SerializedSigningIdentity}).
46
+ */
47
+ type SerializedReadonlyIdentity = {
48
+ type: "readonly-single-key";
49
+ publicKey: string;
50
+ } | {
51
+ type: "readonly-descriptor";
52
+ descriptor: string;
53
+ };
54
+ type SerializedIdentity = SerializedSigningIdentity | SerializedReadonlyIdentity;
55
+ /**
56
+ * Legacy untagged shape emitted by page builds prior to the tagged
57
+ * SerializedIdentity envelope. Retained so newer workers can still accept
58
+ * older pages during a rolling upgrade. Slated for removal in the next major.
59
+ *
60
+ * @deprecated Use {@link SerializedIdentity}.
61
+ */
62
+ type LegacySerializedIdentity = {
63
+ privateKey: string;
64
+ } | {
65
+ publicKey: string;
66
+ };
67
+
68
+ /**
69
+ * Read-side HD capability marker. Exposes the wildcard-suffixed account
70
+ * descriptor *template* and the descriptor-membership predicate, but no
71
+ * signing primitives — suitable for watch-only identities backed by an
72
+ * xpub.
73
+ *
74
+ * Extracted from {@link HDCapableIdentity} so that
75
+ * `ReadonlyDescriptorIdentity` can stand in for an HD wallet's read-only
76
+ * surface (template-aware, derives pubkeys at any index) without having
77
+ * to claim signing capability it cannot honour.
78
+ */
79
+ interface ReadonlyHDCapableIdentity extends ReadonlyIdentity {
80
+ /**
81
+ * The wildcard-suffixed account descriptor template
82
+ * (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). Consumers materialize a
83
+ * concrete descriptor by replacing the `*` with a derivation index.
84
+ */
85
+ readonly descriptor: string;
86
+ /**
87
+ * True iff `descriptor` derives from this identity's xpub/seed.
88
+ *
89
+ * @deprecated Prefer `DescriptorProvider.isOurs()` via
90
+ * `HDDescriptorProvider` for rotating HD wallets or
91
+ * `StaticDescriptorProvider` for legacy single-key wallets.
92
+ */
93
+ isOurs(descriptor: string): boolean;
94
+ }
95
+ /**
96
+ * Capability marker for identities that can be rotated through an HD
97
+ * derivation tree AND can sign at each rotated index.
98
+ *
99
+ * Deliberately does NOT extend `DescriptorProvider`: if an HD-capable
100
+ * identity were silently usable as a concrete descriptor source, callers
101
+ * could bypass receive rotation and unknowingly reuse a single address
102
+ * forever. To use this identity as a wallet's descriptor source, wrap
103
+ * it explicitly:
104
+ *
105
+ * - `HDDescriptorProvider` — rotating, recommended for new wallets.
106
+ * - `StaticDescriptorProvider` — pinned to a single key, for legacy or
107
+ * explicitly-non-rotating use cases.
108
+ */
109
+ interface HDCapableIdentity extends ReadonlyHDCapableIdentity, Identity {
110
+ /**
111
+ * Signs each request with the key derived from its descriptor.
112
+ *
113
+ * @deprecated Prefer `DescriptorProvider.signWithDescriptor()` via
114
+ * `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
115
+ * this method only as backing implementation for descriptor providers.
116
+ */
117
+ signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
118
+ /**
119
+ * Signs a message using the key derived from `descriptor`.
120
+ *
121
+ * @deprecated Prefer `DescriptorProvider.signMessageWithDescriptor()` via
122
+ * `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
123
+ * this method only as backing implementation for descriptor providers.
124
+ */
125
+ signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
126
+ }
127
+
128
+ /** Used for default BIP86 derivation with network selection. */
129
+ interface NetworkOptions {
130
+ /**
131
+ * Mainnet (coin type 0) or testnet (coin type 1).
132
+ *
133
+ * @defaultValue `true`
134
+ */
135
+ isMainnet?: boolean;
136
+ }
137
+ /** Used for a caller-supplied account-descriptor template. */
138
+ interface DescriptorOptions {
139
+ /**
140
+ * Account-descriptor *template* — must end with the BIP-32 wildcard
141
+ * suffix `/*)`. Stored as-is on {@link SeedIdentity.descriptor} and
142
+ * read by HD providers to rotate through derivation indices.
143
+ */
144
+ descriptor: string;
145
+ }
146
+ /** Either default BIP86 derivation (with optional network selection) or a caller-supplied template. */
147
+ type SeedIdentityOptions = NetworkOptions | DescriptorOptions;
148
+ /** Used for deriving an identity from a BIP39 mnemonic. */
149
+ type MnemonicOptions = SeedIdentityOptions & {
150
+ /** Optional BIP39 passphrase for additional seed entropy. */
151
+ passphrase?: string;
152
+ };
153
+ /**
154
+ * Seed-based identity derived from a raw seed and an account descriptor
155
+ * *template*.
156
+ *
157
+ * This is the recommended identity type for most applications. It uses
158
+ * standard BIP86 (Taproot) derivation by default; callers that need a
159
+ * different path supply the wildcard template directly.
160
+ *
161
+ * Prefer this (or @see MnemonicIdentity) over `SingleKey` for new
162
+ * integrations — `SingleKey` exists for backward compatibility with
163
+ * raw nsec-style keys.
164
+ *
165
+ * The identity holds the wildcard *template* (e.g.
166
+ * `tr([fp/86'/0'/0']xpub/0/*)`) on its public {@link descriptor}
167
+ * field. HD rotation reads it directly; consumers that need a
168
+ * concrete descriptor at a specific index materialize it themselves
169
+ * (see `HDDescriptorProvider` in the wallet layer).
170
+ *
171
+ * Exposes seed-level primitives (signing, derivation, the template)
172
+ * but is deliberately NOT a `DescriptorProvider`. Wrap it explicitly
173
+ * to get one:
174
+ * - `HDDescriptorProvider` for rotating receive addresses.
175
+ * - {@link StaticDescriptorProvider} for legacy, single-key behaviour.
176
+ *
177
+ * The split prevents a SeedIdentity from being silently used as a
178
+ * concrete descriptor source, which would defeat HD rotation without
179
+ * any compile-time signal that something was wrong.
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * const seed = mnemonicToSeedSync(mnemonic);
184
+ *
185
+ * // Testnet (BIP86 wildcard descriptor m/86'/1'/0'/0/*)
186
+ * const identity = SeedIdentity.fromSeed(seed, { isMainnet: false });
187
+ *
188
+ * // Mainnet (BIP86 wildcard descriptor m/86'/0'/0'/0/*)
189
+ * const identity = SeedIdentity.fromSeed(seed, { isMainnet: true });
190
+ *
191
+ * // Caller-supplied wildcard descriptor (must end in `/*)`).
192
+ * const identity = SeedIdentity.fromSeed(seed, { descriptor });
193
+ * ```
194
+ */
195
+ declare class SeedIdentity implements HDCapableIdentity {
196
+ private readonly derivedKey;
197
+ /**
198
+ * Wildcard account-descriptor template (e.g.
199
+ * `tr([fp/86'/0'/0']xpub/0/*)`). The canonical thing to pass
200
+ * through the system; consumers materialize a concrete descriptor
201
+ * at a specific index themselves (see `HDDescriptorProvider` in
202
+ * the wallet layer for the rotating-counter use case).
203
+ */
204
+ readonly descriptor: string;
205
+ /**
206
+ * Constructs a SeedIdentity from a 64-byte seed and either a
207
+ * caller-supplied wildcard descriptor (`{ descriptor }`) or the
208
+ * default BIP86 path at the requested network (`{ isMainnet }`).
209
+ * Prefer the {@link fromSeed} factory for symmetry with
210
+ * {@link MnemonicIdentity.fromMnemonic}.
211
+ *
212
+ * Throws on a non-wildcard descriptor, an xpub mismatch with the
213
+ * seed, or a missing derivation path.
214
+ */
215
+ constructor(seed: Uint8Array, opts?: SeedIdentityOptions);
216
+ /**
217
+ * Creates a SeedIdentity from a raw 64-byte seed.
218
+ *
219
+ * Pass `{ isMainnet }` for default BIP86 derivation, or
220
+ * `{ descriptor }` for a caller-supplied account-descriptor
221
+ * template (the option's value must end with `/*)`).
222
+ *
223
+ * @param seed - 64-byte seed (typically from mnemonicToSeedSync)
224
+ * @param opts - Network selection or descriptor template.
225
+ */
226
+ static fromSeed(seed: Uint8Array, opts?: SeedIdentityOptions): SeedIdentity;
227
+ xOnlyPublicKey(): Promise<Uint8Array>;
228
+ compressedPublicKey(): Promise<Uint8Array>;
229
+ sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
230
+ signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
231
+ signerSession(): SignerSession;
232
+ /**
233
+ * Converts to a watch-only identity that cannot sign. Carries the
234
+ * template forward, so the readonly side stays HD-capable (can
235
+ * derive descriptors at any index without seed access).
236
+ */
237
+ toReadonly(): Promise<ReadonlyDescriptorIdentity>;
238
+ /**
239
+ * Returns true when `descriptor` is derived from this identity's seed.
240
+ * HD descriptors match by account xpub; bare `tr(pubkey)` descriptors
241
+ * match by raw pubkey. See {@link descriptorIsOurs}.
242
+ *
243
+ * @deprecated Prefer `DescriptorProvider.isOurs()` via
244
+ * `HDDescriptorProvider` for rotating HD wallets or
245
+ * `StaticDescriptorProvider` for legacy single-key wallets.
246
+ */
247
+ isOurs(descriptor: string): boolean;
248
+ /**
249
+ * Signs each request with the key derived from its descriptor.
250
+ * Each descriptor must share this identity's seed ({@link isOurs}).
251
+ *
252
+ * @deprecated Prefer `DescriptorProvider.signWithDescriptor()` via
253
+ * `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
254
+ * this method only as backing implementation for descriptor providers.
255
+ */
256
+ signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
257
+ /**
258
+ * Signs a message with the key derived from `descriptor`.
259
+ *
260
+ * @deprecated Prefer `DescriptorProvider.signMessageWithDescriptor()` via
261
+ * `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
262
+ * this method only as backing implementation for descriptor providers.
263
+ */
264
+ signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
265
+ private derivePrivateKeyForDescriptor;
266
+ private signTxWithKey;
267
+ private signMessageWithKey;
268
+ }
269
+ /**
270
+ * Mnemonic-based identity derived from a BIP39 phrase.
271
+ *
272
+ * This is the most user-friendly identity type — recommended for wallet
273
+ * applications where users manage their own backup phrase. Extends
274
+ * @see SeedIdentity with mnemonic validation and optional passphrase
275
+ * support.
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * const identity = MnemonicIdentity.fromMnemonic(
280
+ * 'abandon abandon abandon ...',
281
+ * { isMainnet: true, passphrase: 'secret' }
282
+ * );
283
+ * ```
284
+ */
285
+ declare class MnemonicIdentity extends SeedIdentity {
286
+ private constructor();
287
+ /**
288
+ * Creates a MnemonicIdentity from a BIP39 mnemonic phrase.
289
+ *
290
+ * Pass `{ isMainnet }` for default BIP86 derivation, or
291
+ * `{ descriptor }` for a caller-supplied account-descriptor
292
+ * template (the option's value must end with `/*)`).
293
+ *
294
+ * @param phrase - BIP39 mnemonic phrase (12 or 24 words)
295
+ * @param opts - Network selection or descriptor template, plus optional passphrase
296
+ */
297
+ static fromMnemonic(phrase: string, opts?: MnemonicOptions): MnemonicIdentity;
298
+ }
299
+ /**
300
+ * Watch-only HD identity from a descriptor *template*.
301
+ *
302
+ * Can derive public keys but cannot sign transactions. Use this for
303
+ * watch-only wallets — given just an xpub-based template, the readonly
304
+ * side still rotates through HD indices.
305
+ *
306
+ * Constructed from a wildcard template (e.g.
307
+ * `tr([fp/86'/0'/0']xpub.../0/*)`); the {@link descriptor} field
308
+ * holds it for HD providers to consume.
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * const ro = ReadonlyDescriptorIdentity.fromDescriptor(
313
+ * "tr([fp/86'/0'/0']xpub.../0/*)"
314
+ * );
315
+ * ro.descriptor;
316
+ * // => "tr([fp/86'/0'/0']xpub.../0/*)" — the template
317
+ * ```
318
+ */
319
+ declare class ReadonlyDescriptorIdentity implements ReadonlyHDCapableIdentity {
320
+ /**
321
+ * Index-0 expansion of {@link descriptor}. Both the x-only pubkey
322
+ * (taproot, returned by the library as 32 bytes) and the compressed
323
+ * pubkey (derived through the bip32 node when needed) are read off
324
+ * this on demand — no separate caches.
325
+ */
326
+ private readonly indexZero;
327
+ /**
328
+ * Wildcard account-descriptor template (e.g.
329
+ * `tr([fp/86'/0'/0']xpub/0/*)`). HD rotation consumers materialize
330
+ * a concrete descriptor at a specific index themselves.
331
+ */
332
+ readonly descriptor: string;
333
+ private constructor();
334
+ /**
335
+ * Creates a ReadonlyDescriptorIdentity from an account-descriptor
336
+ * *template* (must end with the BIP-32 wildcard suffix `/*)`).
337
+ *
338
+ * @param descriptor - Wildcard-suffixed Taproot template
339
+ * (`tr([fp/path']xpub.../child/*)`).
340
+ */
341
+ static fromDescriptor(descriptor: string): ReadonlyDescriptorIdentity;
342
+ xOnlyPublicKey(): Promise<Uint8Array>;
343
+ compressedPublicKey(): Promise<Uint8Array>;
344
+ /**
345
+ * Returns true when `descriptor` derives from this identity's xpub.
346
+ * HD descriptors match by account xpub; bare `tr(pubkey)` descriptors
347
+ * fall back to comparing against the index-0 x-only pubkey. See
348
+ * {@link descriptorIsOurs}.
349
+ *
350
+ * @deprecated Prefer `DescriptorProvider.isOurs()` via
351
+ * `HDDescriptorProvider` for rotating HD wallets or
352
+ * `StaticDescriptorProvider` for legacy single-key wallets.
353
+ */
354
+ isOurs(descriptor: string): boolean;
355
+ }
356
+
357
+ /**
358
+ * In-memory single key implementation for Bitcoin transaction signing.
359
+ *
360
+ * @example
361
+ * ```typescript
362
+ * // Create from hex string
363
+ * const key = SingleKey.fromHex('your_private_key_hex');
364
+ *
365
+ * // Create from raw bytes
366
+ * const key = SingleKey.fromPrivateKey(privateKeyBytes);
367
+ *
368
+ * // Create random key
369
+ * const randomKey = SingleKey.fromRandomBytes();
370
+ *
371
+ * // Sign a transaction
372
+ * const signedTx = await key.sign(transaction);
373
+ * ```
374
+ */
375
+ declare class SingleKey implements Identity {
376
+ private key;
377
+ private constructor();
378
+ /** Create a signing identity from raw private key bytes. */
379
+ static fromPrivateKey(privateKey: Uint8Array): SingleKey;
380
+ /** Create a signing identity from a hex-encoded private key. */
381
+ static fromHex(privateKeyHex: string): SingleKey;
382
+ /** Create a signing identity with a freshly generated random private key. */
383
+ static fromRandomBytes(): SingleKey;
384
+ /**
385
+ * Export the private key as a hex string.
386
+ *
387
+ * @returns The private key as a hex string
388
+ */
389
+ toHex(): string;
390
+ sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
391
+ compressedPublicKey(): Promise<Uint8Array>;
392
+ xOnlyPublicKey(): Promise<Uint8Array>;
393
+ signerSession(): SignerSession;
394
+ signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
395
+ toReadonly(): Promise<ReadonlySingleKey>;
396
+ }
397
+ declare class ReadonlySingleKey implements ReadonlyIdentity {
398
+ private readonly publicKey;
399
+ /** Create a readonly identity from a compressed public key. */
400
+ constructor(publicKey: Uint8Array);
401
+ /**
402
+ * Create a ReadonlySingleKey from a compressed public key.
403
+ *
404
+ * @param publicKey - 33-byte compressed public key (02/03 prefix + 32-byte x coordinate)
405
+ * @returns A new ReadonlySingleKey instance
406
+ * @example
407
+ * ```typescript
408
+ * const pubkey = new Uint8Array(33); // your compressed public key
409
+ * const readonlyKey = ReadonlySingleKey.fromPublicKey(pubkey);
410
+ * ```
411
+ */
412
+ static fromPublicKey(publicKey: Uint8Array): ReadonlySingleKey;
413
+ xOnlyPublicKey(): Promise<Uint8Array>;
414
+ compressedPublicKey(): Promise<Uint8Array>;
415
+ }
416
+
417
+ /**
418
+ * In-memory implementation of WalletRepository.
419
+ * Data is ephemeral and scoped to the instance.
420
+ */
421
+ declare class InMemoryWalletRepository implements WalletRepository {
422
+ readonly version: 1;
423
+ private readonly vtxosByAddress;
424
+ private readonly utxosByAddress;
425
+ private readonly txsByAddress;
426
+ private walletState;
427
+ getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
428
+ saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
429
+ deleteVtxos(address: string): Promise<void>;
430
+ getVtxosForScript(script: string): Promise<ExtendedVirtualCoin[]>;
431
+ saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
432
+ deleteVtxosForScript(script: string): Promise<void>;
433
+ getUtxos(address: string): Promise<ExtendedCoin[]>;
434
+ saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
435
+ deleteUtxos(address: string): Promise<void>;
436
+ getTransactionHistory(address: string): Promise<ArkTransaction[]>;
437
+ saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
438
+ deleteTransactions(address: string): Promise<void>;
439
+ getWalletState(): Promise<WalletState | null>;
440
+ saveWalletState(state: WalletState): Promise<void>;
441
+ clear(): Promise<void>;
442
+ [Symbol.asyncDispose](): Promise<void>;
443
+ }
444
+
445
+ /**
446
+ * Encode a contract to the arkcontract string format.
447
+ *
448
+ * Format: arkcontract={type}&{key1}={value1}&{key2}={value2}...
449
+ *
450
+ * This format is compatible with NArk and allows contracts to be
451
+ * shared/imported across different Arkade SDKs.
452
+ *
453
+ * @example
454
+ * ```typescript
455
+ * const contract: Contract = {
456
+ * type: "vhtlc",
457
+ * params: { sender: "ab12...", receiver: "cd34...", ... },
458
+ * // ...
459
+ * };
460
+ *
461
+ * const encoded = encodeArkContract(contract);
462
+ * // "arkcontract=vhtlc&sender=ab12...&receiver=cd34...&..."
463
+ * ```
464
+ */
465
+ declare function encodeArkContract(contract: Contract): string;
466
+ /**
467
+ * Parsed result from decoding an arkcontract string.
468
+ *
469
+ * This is a low-level representation. For type-safe contract creation,
470
+ * use `contractFromArkContract` or `contractFromArkContractWithAddress`
471
+ * which validate params through the handler system.
472
+ */
473
+ interface ParsedArkContract {
474
+ /** Contract type (e.g., "vhtlc", "default") */
475
+ type: string;
476
+ /** All key-value pairs from the string */
477
+ data: Record<string, string>;
478
+ }
479
+ /**
480
+ * Decode an arkcontract string into raw type and data.
481
+ *
482
+ * This is a low-level function that parses the URL-encoded format.
483
+ * For creating typed Contract objects, use `contractFromArkContract`
484
+ * or `contractFromArkContractWithAddress` instead.
485
+ *
486
+ * @param encoded - The arkcontract string
487
+ * @returns Parsed type and key-value data
488
+ * @throws If the string is not a valid arkcontract
489
+ *
490
+ * @example
491
+ * ```typescript
492
+ * const parsed = decodeArkContract("arkcontract=vhtlc&sender=ab12...");
493
+ * // { type: "vhtlc", data: { sender: "ab12...", ... } }
494
+ * ```
495
+ */
496
+ declare function decodeArkContract(encoded: string): ParsedArkContract;
497
+ /**
498
+ * Create a Contract from an arkcontract string.
499
+ *
500
+ * This requires a handler to be registered for the contract type.
501
+ *
502
+ * @param encoded - The arkcontract string
503
+ * @param options - Additional options for the contract
504
+ * @returns A Contract object
505
+ * @throws If the string is invalid or no handler exists for the type
506
+ *
507
+ * @example
508
+ * ```typescript
509
+ * const contract = contractFromArkContract(
510
+ * "arkcontract=vhtlc&sender=ab12...",
511
+ * {
512
+ * label: "Lightning Receive",
513
+ * }
514
+ * );
515
+ * ```
516
+ */
517
+ declare function contractFromArkContract(encoded: string, options?: {
518
+ label?: string;
519
+ state?: "active" | "inactive";
520
+ metadata?: Record<string, unknown>;
521
+ }): Omit<Contract, "script" | "address"> & {
522
+ script?: string;
523
+ address?: string;
524
+ };
525
+ /**
526
+ * Create a full Contract with derived script and address.
527
+ *
528
+ * @param encoded - The arkcontract string
529
+ * @param serverPubKey - Server public key (for address derivation)
530
+ * @param addressPrefix - Address prefix (e.g., "tark" for testnet)
531
+ * @param options - Additional options
532
+ * @returns A complete Contract object
533
+ */
534
+ declare function contractFromArkContractWithAddress(encoded: string, serverPubKey: Uint8Array, addressPrefix?: string, options?: {
535
+ label?: string;
536
+ state?: "active" | "inactive";
537
+ metadata?: Record<string, unknown>;
538
+ }): Contract;
539
+ /**
540
+ * Check if a string is an arkcontract.
541
+ */
542
+ declare function isArkContract(str: string): boolean;
543
+
544
+ /**
545
+ * In-memory implementation of ContractRepository.
546
+ * Data is ephemeral and scoped to the instance.
547
+ */
548
+ declare class InMemoryContractRepository implements ContractRepository {
549
+ readonly version: 1;
550
+ private readonly contractData;
551
+ private readonly collections;
552
+ private readonly contractsByScript;
553
+ clear(): Promise<void>;
554
+ getContracts(filter?: ContractFilter): Promise<Contract[]>;
555
+ saveContract(contract: Contract): Promise<void>;
556
+ deleteContract(script: string): Promise<void>;
557
+ [Symbol.asyncDispose](): Promise<void>;
558
+ }
559
+
560
+ /**
561
+ * IndexedDB-based implementation of ContractRepository.
562
+ *
563
+ * Data is stored as JSON strings in key/value stores.
564
+ */
565
+ declare class IndexedDBContractRepository implements ContractRepository {
566
+ private readonly dbName;
567
+ readonly version: 1;
568
+ private db;
569
+ constructor(dbName?: string);
570
+ clear(): Promise<void>;
571
+ getContracts(filter?: ContractFilter): Promise<Contract[]>;
572
+ saveContract(contract: Contract): Promise<void>;
573
+ deleteContract(script: string): Promise<void>;
574
+ private getContractsByIndexValues;
575
+ private applyContractFilter;
576
+ private getDB;
577
+ [Symbol.asyncDispose](): Promise<void>;
578
+ }
579
+
580
+ /**
581
+ * IndexedDB-based implementation of WalletRepository.
582
+ */
583
+ declare class IndexedDBWalletRepository implements WalletRepository {
584
+ private readonly dbName;
585
+ readonly version: 1;
586
+ private db;
587
+ constructor(dbName?: string);
588
+ clear(): Promise<void>;
589
+ [Symbol.asyncDispose](): Promise<void>;
590
+ getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
591
+ saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
592
+ deleteVtxos(address: string): Promise<void>;
593
+ getVtxosForScript(script: string): Promise<ExtendedVirtualCoin[]>;
594
+ saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
595
+ deleteVtxosForScript(script: string): Promise<void>;
596
+ getUtxos(address: string): Promise<ExtendedCoin[]>;
597
+ saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
598
+ deleteUtxos(address: string): Promise<void>;
599
+ getTransactionHistory(address: string): Promise<ArkTransaction[]>;
600
+ saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
601
+ deleteTransactions(address: string): Promise<void>;
602
+ getWalletState(): Promise<WalletState | null>;
603
+ saveWalletState(state: WalletState): Promise<void>;
604
+ private getDB;
605
+ }
606
+
607
+ declare const MIGRATION_KEY: (repoType: "wallet" | "contract") => string;
608
+ type MigrationStatus = "pending" | "in-progress" | "done" | "not-needed";
609
+ declare function getMigrationStatus(repoType: "wallet" | "contract", storageAdapter: StorageAdapter): Promise<MigrationStatus>;
610
+ declare function requiresMigration(repoType: "wallet" | "contract", storageAdapter: StorageAdapter): Promise<boolean>;
611
+ declare function rollbackMigration(repoType: "wallet" | "contract", storageAdapter: StorageAdapter): Promise<void>;
612
+ /**
613
+ * Migrate wallet data from the legacy storage adapter to the new one.
614
+ * It accepts both onchain and offchain addresses, make sure to pass both.
615
+ *
616
+ * @param storageAdapter
617
+ * @param fresh
618
+ * @param addresses
619
+ */
620
+ declare function migrateWalletRepository(storageAdapter: StorageAdapter, fresh: WalletRepository, addresses: {
621
+ onchain: string[];
622
+ offchain: string[];
623
+ }): Promise<void>;
624
+
625
+ /**
626
+ * @deprecated This is only to be used in migration from storage V1
627
+ */
628
+ declare class WalletRepositoryImpl implements WalletRepository {
629
+ readonly version: 1;
630
+ private storage;
631
+ constructor(storage: StorageAdapter);
632
+ getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
633
+ saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
634
+ clearVtxos(address: string): Promise<void>;
635
+ deleteVtxos(address: string): Promise<void>;
636
+ getUtxos(address: string): Promise<ExtendedCoin[]>;
637
+ saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
638
+ clearUtxos(address: string): Promise<void>;
639
+ deleteUtxos(address: string): Promise<void>;
640
+ getTransactionHistory(address: string): Promise<ArkTransaction[]>;
641
+ saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
642
+ clearTransactions(address: string): Promise<void>;
643
+ deleteTransactions(address: string): Promise<void>;
644
+ getWalletState(): Promise<WalletState | null>;
645
+ saveWalletState(state: WalletState): Promise<void>;
646
+ clear(): Promise<void>;
647
+ [Symbol.asyncDispose](): Promise<void>;
648
+ }
649
+
650
+ /**
651
+ * @deprecated This is only to be used in migration from storage V1
652
+ */
653
+ declare class ContractRepositoryImpl implements ContractRepository {
654
+ readonly version: 1;
655
+ private storage;
656
+ constructor(storage: StorageAdapter);
657
+ getContractData<T>(contractId: string, key: string): Promise<T | null>;
658
+ setContractData<T>(contractId: string, key: string, data: T): Promise<void>;
659
+ deleteContractData(contractId: string, key: string): Promise<void>;
660
+ getContractCollection<T>(contractType: string): Promise<ReadonlyArray<T>>;
661
+ saveToContractCollection<T, K extends keyof T>(contractType: string, item: T, idField: K): Promise<void>;
662
+ removeFromContractCollection<T, K extends keyof T>(contractType: string, id: T[K], idField: K): Promise<void>;
663
+ getContracts(_?: ContractFilter): Promise<Contract[]>;
664
+ saveContract(_: Contract): Promise<void>;
665
+ deleteContract(_: string): Promise<void>;
666
+ clear(): Promise<void>;
667
+ [Symbol.asyncDispose](): Promise<void>;
668
+ }
669
+
670
+ /**
671
+ * Estimator evaluates CEL expressions to calculate fees for Arkade intents
672
+ */
673
+ declare class Estimator {
674
+ readonly config: IntentFeeConfig;
675
+ private intentOffchainInput?;
676
+ private intentOnchainInput?;
677
+ private intentOffchainOutput?;
678
+ private intentOnchainOutput?;
679
+ /**
680
+ * Creates a new Estimator with the given config
681
+ * @param config - Configuration containing CEL programs for fee calculation
682
+ */
683
+ constructor(config: IntentFeeConfig);
684
+ /**
685
+ * Evaluates the fee for a given vtxo input
686
+ * @param input - The offchain input to evaluate
687
+ * @returns The fee amount for this input
688
+ */
689
+ evalOffchainInput(input: OffchainInput): FeeAmount;
690
+ /**
691
+ * Evaluates the fee for a given boarding input
692
+ * @param input - The onchain input to evaluate
693
+ * @returns The fee amount for this input
694
+ */
695
+ evalOnchainInput(input: OnchainInput): FeeAmount;
696
+ /**
697
+ * Evaluates the fee for a given vtxo output
698
+ * @param output - The output to evaluate
699
+ * @returns The fee amount for this output
700
+ */
701
+ evalOffchainOutput(output: FeeOutput): FeeAmount;
702
+ /**
703
+ * Evaluates the fee for a given collaborative exit output
704
+ * @param output - The output to evaluate
705
+ * @returns The fee amount for this output
706
+ */
707
+ evalOnchainOutput(output: FeeOutput): FeeAmount;
708
+ /**
709
+ * Evaluates the fee for a given set of inputs and outputs
710
+ * @param offchainInputs - Array of offchain inputs to evaluate
711
+ * @param onchainInputs - Array of onchain inputs to evaluate
712
+ * @param offchainOutputs - Array of offchain outputs to evaluate
713
+ * @param onchainOutputs - Array of onchain outputs to evaluate
714
+ * @returns The total fee amount
715
+ */
716
+ eval(offchainInputs: OffchainInput[], onchainInputs: OnchainInput[], offchainOutputs: FeeOutput[], onchainOutputs: FeeOutput[]): FeeAmount;
717
+ }
718
+
719
+ /**
720
+ * Thrown when a rotated contract (default or delegate) is missing the
721
+ * metadata.signingDescriptor required to route it to a descriptor-aware
722
+ * signer.
723
+ */
724
+ declare class MissingSigningDescriptorError extends Error {
725
+ readonly contractScript: string;
726
+ readonly contractType: "default" | "delegate";
727
+ readonly name = "MissingSigningDescriptorError";
728
+ constructor(contractScript: string, contractType: "default" | "delegate");
729
+ }
730
+ /**
731
+ * Thrown when an input needs descriptor-aware signing but no
732
+ * DescriptorProvider was wired into the wallet.
733
+ */
734
+ declare class DescriptorSigningProviderMissingError extends Error {
735
+ readonly name = "DescriptorSigningProviderMissingError";
736
+ constructor();
737
+ }
738
+
739
+ type RequestEnvelope = {
740
+ tag: string;
741
+ id: string;
742
+ broadcast?: boolean;
743
+ };
744
+ type ResponseEnvelope = {
745
+ tag: string;
746
+ id?: string;
747
+ error?: Error;
748
+ broadcast?: boolean;
749
+ };
750
+ interface MessageHandler<REQ extends RequestEnvelope = RequestEnvelope, RES extends ResponseEnvelope = ResponseEnvelope> {
751
+ /**
752
+ * A unique identifier for the updater.
753
+ * This is used to route messages to the correct updater.
754
+ */
755
+ readonly messageTag: string;
756
+ /**
757
+ * Called once when the SW is starting up
758
+ * @param services - Providers and wallet instances available to the handler.
759
+ * @param repositories - Repositories available to the handler.
760
+ **/
761
+ start(services: {
762
+ arkProvider: ArkProvider;
763
+ wallet?: Wallet;
764
+ readonlyWallet: ReadonlyWallet;
765
+ }, repositories: {
766
+ walletRepository: WalletRepository;
767
+ }): Promise<void>;
768
+ /** Called once when the SW is shutting down */
769
+ stop(): Promise<void>;
770
+ /**
771
+ * Called by the scheduler to perform a tick.
772
+ * Can be used by the updater to perform periodic tasks or return
773
+ * delayed responses (eg: subscriptions).
774
+ * @param now The current time in milliseconds since the epoch.
775
+ **/
776
+ tick(now: number): Promise<RES[]>;
777
+ /**
778
+ * Handle routed messages from the clients
779
+ **/
780
+ handleMessage(message: REQ): Promise<RES | null>;
781
+ /**
782
+ * Optional opt-out from the bus-level message timeout.
783
+ *
784
+ * Long-running flows (e.g. settlement) surrender control to remote peers
785
+ * and can legitimately sit idle for longer than `messageTimeoutMs`. When
786
+ * this returns true, the bus awaits `handleMessage` without a deadline.
787
+ * Defaults to false.
788
+ */
789
+ isLongRunning?(message: REQ): boolean;
790
+ }
791
+ type Options = {
792
+ messageHandlers: MessageHandler[];
793
+ tickIntervalMs?: number;
794
+ messageTimeoutMs?: number;
795
+ /**
796
+ * Per-operation timeout overrides. Keys are either message types
797
+ * (e.g. "SETTLE") or handler tags (e.g. "WALLET_UPDATER"). Message-type
798
+ * matches take precedence over tag matches. Unspecified operations use
799
+ * `messageTimeoutMs`. These are treated as defaults: any map supplied
800
+ * via `INITIALIZE_MESSAGE_BUS` overrides per-key and is re-applied on
801
+ * every (re-)init.
802
+ */
803
+ messageTimeoutOverrides?: Record<string, number>;
804
+ debug?: boolean;
805
+ buildServices?: (config: Initialize["config"]) => Promise<{
806
+ arkProvider: ArkProvider;
807
+ wallet?: Wallet;
808
+ readonlyWallet: ReadonlyWallet;
809
+ }>;
810
+ };
811
+ type Initialize = {
812
+ type: "INITIALIZE_MESSAGE_BUS";
813
+ id: string;
814
+ config: {
815
+ wallet: SerializedIdentity | LegacySerializedIdentity;
816
+ arkServer: {
817
+ url: string;
818
+ publicKey?: string;
819
+ };
820
+ delegatorUrl?: string;
821
+ indexerUrl?: string;
822
+ esploraUrl?: string;
823
+ settlementConfig?: SettlementConfig | false;
824
+ walletMode?: "auto" | "static" | "hd";
825
+ watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
826
+ /**
827
+ * Page-supplied per-operation timeout map. Keys are message types
828
+ * (e.g. "SETTLE"). Overrides constructor-supplied
829
+ * `messageTimeoutOverrides` per-key; re-applied on every init.
830
+ */
831
+ messageTimeouts?: Record<string, number>;
832
+ };
833
+ };
834
+ declare class MessageBus {
835
+ private readonly walletRepository;
836
+ private readonly contractRepository;
837
+ private handlers;
838
+ private tickIntervalMs;
839
+ private messageTimeoutMs;
840
+ private readonly constructorTimeoutOverrides;
841
+ private messageTimeoutOverrides;
842
+ private lateDeliveries;
843
+ private running;
844
+ private tickTimeout;
845
+ private tickInProgress;
846
+ private debug;
847
+ private initialized;
848
+ private readonly buildServicesFn;
849
+ private readonly boundOnMessage;
850
+ /** Create the service-worker message bus with repositories and handler configuration. */
851
+ constructor(walletRepository: WalletRepository, contractRepository: ContractRepository, { messageHandlers, tickIntervalMs, messageTimeoutMs, messageTimeoutOverrides, debug, buildServices, }: Options);
852
+ /** Start the message bus and attach service-worker event listeners. */
853
+ start(): Promise<void>;
854
+ /** Stop the message bus, cancel ticks, and stop all registered handlers. */
855
+ stop(): Promise<void>;
856
+ private scheduleNextTick;
857
+ private runTick;
858
+ private waitForInit;
859
+ private buildServices;
860
+ private onMessage;
861
+ private processMessage;
862
+ /**
863
+ * Race `promise` against a timeout. Note: this does NOT cancel the
864
+ * underlying work — the original promise keeps running. Call
865
+ * `attachLateDelivery` after catching the timeout to surface the
866
+ * eventual result so the message id does not go silent.
867
+ */
868
+ private withTimeout;
869
+ /**
870
+ * Extract the declared `type` from a request envelope (e.g. "SETTLE").
871
+ * Not every envelope carries a type (PING/INIT are special cased
872
+ * earlier), so this returns undefined for envelopes that lack one.
873
+ */
874
+ private extractMessageType;
875
+ /**
876
+ * Resolve the timeout for an operation. Message-type overrides take
877
+ * precedence over handler-tag overrides, with the bus-wide default
878
+ * (`messageTimeoutMs`) as the final fallback.
879
+ */
880
+ private resolveTimeoutMs;
881
+ /**
882
+ * Build a human-readable label for timeout errors. Format:
883
+ * `"<MESSAGE_TYPE> via <HANDLER_TAG>"` when both are known, else the
884
+ * handler tag alone. Used so timeout errors name the operation the
885
+ * client actually triggered (e.g. SETTLE) rather than just the
886
+ * handler that received it (e.g. WALLET_UPDATER).
887
+ */
888
+ private labelFor;
889
+ /**
890
+ * Post a response to the originating client. When `source` is null
891
+ * (client tab closed, detached frame, etc.) the response cannot be
892
+ * delivered; we log the drop in debug mode so it is not invisible.
893
+ */
894
+ private deliverResponse;
895
+ /**
896
+ * After a handler times out the client has already received a timeout
897
+ * error, but the handler keeps running. Attach a follow-up so the
898
+ * handler's eventual result (or error) is delivered under the same
899
+ * message id, or — if the handler never completes within
900
+ * {@link LATE_DELIVERY_GRACE_MS} — an "Operation abandoned" error is
901
+ * sent so the client's listener (if still attached) does not hang.
902
+ */
903
+ private attachLateDelivery;
904
+ /**
905
+ * Returns the registered SW for the path.
906
+ * It uses the functions in `service-worker-manager.ts` module.
907
+ * @param path
908
+ * @return the Service Worker
909
+ * @throws if not running in a browser environment
910
+ */
911
+ static getServiceWorker(path?: string): Promise<ServiceWorker>;
912
+ /**
913
+ * Set up and register the Service Worker, ensuring it's done once at most.
914
+ * It uses the functions in `service-worker-manager.ts` module.
915
+ * @param path
916
+ * @return the Service Worker
917
+ * @throws if not running in a browser environment
918
+ */
919
+ static setup(path: string): Promise<ServiceWorker>;
920
+ }
921
+
922
+ /**
923
+ * Ramps is a class wrapping `settle` method to provide a more convenient interface for onboarding and offboarding operations.
924
+ *
925
+ * @see IWallet.settle
926
+ * @see onboard
927
+ * @see offboard
928
+ *
929
+ * @example
930
+ * ```typescript
931
+ * const ramps = new Ramps(wallet);
932
+ * const feeInfo = { intentFee: {}, txFeeRate: '1' };
933
+ * await ramps.onboard(feeInfo); // onboard all boarding inputs
934
+ * await ramps.offboard('bc1q...', feeInfo); // collaboratively exit all virtual outputs to an onchain address
935
+ * ```
936
+ */
937
+ declare class Ramps {
938
+ readonly wallet: IWallet;
939
+ /**
940
+ * Create convenience wrappers for onboarding and offboarding flows.
941
+ *
942
+ * @param wallet - Wallet used to query funds and execute settlement transactions
943
+ */
944
+ constructor(wallet: IWallet);
945
+ /**
946
+ * Onboard boarding inputs.
947
+ *
948
+ * @param feeInfo - The fee info to deduct from the onboard amount.
949
+ * @param boardingUtxos - Specific boarding inputs to onboard. If not provided, all boarding inputs will be used.
950
+ * @param amount - Amount to onboard. If not provided, the total amount of boarding inputs will be onboarded.
951
+ * @param eventCallback - Optional callback that receives settlement events
952
+ * @returns The Arkade transaction id created by settlement
953
+ * @throws Error if no boarding inputs remain after fee deduction or if `amount` exceeds available value
954
+ * @see IWallet.getBoardingUtxos
955
+ * @see IWallet.settle
956
+ * @example
957
+ * ```typescript
958
+ * const feeInfo = { intentFee: {}, txFeeRate: '1' };
959
+ * const ramps = new Ramps(wallet);
960
+ * await ramps.onboard(feeInfo);
961
+ * ```
962
+ */
963
+ onboard(feeInfo: FeeInfo, boardingUtxos?: ExtendedCoin[], amount?: bigint, eventCallback?: (event: SettlementEvent) => void): ReturnType<IWallet["settle"]>;
964
+ /**
965
+ * Offboard virtual outputs, or collaboratively exit them to an onchain address.
966
+ *
967
+ * @param destinationAddress - The destination address to offboard to.
968
+ * @param feeInfo - The fee info to deduct from the offboard amount.
969
+ * @param amount - The amount to offboard. If not provided, the total amount of virtual outputs will be offboarded.
970
+ * @param eventCallback - Optional callback that receives settlement events
971
+ * @returns The Arkade transaction id created by settlement
972
+ * @throws Error if no virtual outputs remain after fee deduction or the destination address cannot be decoded
973
+ * @see IWallet.getVtxos
974
+ * @see IWallet.settle
975
+ * @example
976
+ * ```typescript
977
+ * const feeInfo = { intentFee: {}, txFeeRate: '1' };
978
+ * const ramps = new Ramps(wallet);
979
+ * await ramps.offboard('bc1q...', feeInfo);
980
+ * ```
981
+ */
982
+ offboard(destinationAddress: string, feeInfo: FeeInfo, amount?: bigint, eventCallback?: (event: SettlementEvent) => void): ReturnType<IWallet["settle"]>;
983
+ }
984
+
985
+ /**
986
+ * HD-wallet {@link DescriptorProvider} that allocates a fresh signing
987
+ * descriptor on every call. The provider holds no notion of "current" — it
988
+ * is a pure rotating allocator. The question of "which descriptor is the
989
+ * wallet currently bound to?" is answered by querying the contract
990
+ * repository for active contracts, not by asking this provider.
991
+ *
992
+ * State is persisted under `WalletRepository.getWalletState().settings.hd` so
993
+ * that no storage-schema migration is required when switching a wallet from
994
+ * single-key to HD. The provider is backed by an {@link HDCapableIdentity},
995
+ * which carries the wildcard account descriptor template (for derivation)
996
+ * and the signing primitives.
997
+ *
998
+ * The read-modify-write of the persisted index runs inside the shared per-
999
+ * repo `updateWalletState` mutex, so two `getNextSigningDescriptor` callers
1000
+ * — including those driving separate `HDDescriptorProvider` instances on
1001
+ * the same repo — can never observe the same index.
1002
+ *
1003
+ * @example
1004
+ * ```ts
1005
+ * const provider = await HDDescriptorProvider.create(identity, walletRepo);
1006
+ * const descriptor = await provider.getNextSigningDescriptor();
1007
+ * // descriptor: tr([fp/86'/0'/0']xpub/0/0)
1008
+ * const next = await provider.getNextSigningDescriptor();
1009
+ * // next: tr([fp/86'/0'/0']xpub/0/1)
1010
+ * ```
1011
+ */
1012
+ declare class HDDescriptorProvider implements DescriptorProvider, ReceiveRotatorFactory {
1013
+ private readonly identity;
1014
+ private readonly walletRepository;
1015
+ private constructor();
1016
+ /**
1017
+ * Construct an HDDescriptorProvider. No I/O is performed here;
1018
+ * persisted state is read lazily on the first call to
1019
+ * `getNextSigningDescriptor`. A descriptor-mismatch error surfaces on
1020
+ * first use rather than at boot.
1021
+ */
1022
+ static create(identity: HDCapableIdentity, walletRepository: WalletRepository): Promise<HDDescriptorProvider>;
1023
+ /**
1024
+ * Allocate the next descriptor and return it. The first call on a fresh
1025
+ * wallet returns descriptor at index 0; subsequent calls return 1, 2, 3,
1026
+ * ... in order. Each call is atomic with respect to other rotations on
1027
+ * the same repo: two concurrent callers can never observe the same
1028
+ * index.
1029
+ */
1030
+ getNextSigningDescriptor(): Promise<string>;
1031
+ /**
1032
+ * Re-derive the descriptor at the most recently allocated index
1033
+ * WITHOUT advancing — i.e. read the same descriptor
1034
+ * `getNextSigningDescriptor` last returned. Returns `undefined`
1035
+ * when no descriptor has ever been allocated on this repo.
1036
+ *
1037
+ * Used by the boot path to keep the wallet's display address
1038
+ * stable across restarts: when no tagged display contract exists
1039
+ * (e.g. a fresh wallet that hasn't rotated yet, or a wallet whose
1040
+ * baseline-only repo carries no rotation history), the boot should
1041
+ * re-derive the existing index rather than burn a new one.
1042
+ */
1043
+ getCurrentSigningDescriptor(): Promise<string | undefined>;
1044
+ /**
1045
+ * Monotonically advance the allocation watermark so the next
1046
+ * `getNextSigningDescriptor()` skips indices discovered by a restore
1047
+ * scan. Never rewinds: a lower or equal `index` is a no-op.
1048
+ *
1049
+ * An invalid `index` (non-integer / negative) is ignored (no-op):
1050
+ * persisting it would corrupt `lastIndexUsed` and make the next
1051
+ * `parseSettings()` throw, mirroring the validation parseSettings
1052
+ * already enforces.
1053
+ */
1054
+ advanceLastIndexUsed(index: number): Promise<void>;
1055
+ /**
1056
+ * Returns true when the given descriptor is derivable from this wallet's
1057
+ * seed. Delegates to the underlying identity, which handles both HD and
1058
+ * simple `tr(pubkey)` descriptors.
1059
+ */
1060
+ isOurs(descriptor: string): boolean;
1061
+ /**
1062
+ * Signs each request with the key derived from its descriptor. Delegates
1063
+ * to the identity's signing primitives — the identity, not the provider,
1064
+ * holds the seed.
1065
+ */
1066
+ signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
1067
+ /** Signs a message using the key derived from `descriptor`. */
1068
+ signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
1069
+ /**
1070
+ * HD providers participate in receive rotation. The default
1071
+ * factory boot (contract-repo lookup → allocate fresh descriptor)
1072
+ * is exactly what we want, so this just delegates to
1073
+ * {@link WalletReceiveRotator.defaultBoot}.
1074
+ */
1075
+ createReceiveRotator(opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot | undefined>;
1076
+ /**
1077
+ * Substitute the wildcard in the identity's account-descriptor template
1078
+ * with a concrete index, going through the descriptors-scure parser
1079
+ * rather than ad-hoc string substitution. The parser's `expand({ index })`
1080
+ * call validates that the input is a ranged template AND produces a
1081
+ * canonical materialized key expression at the given index.
1082
+ *
1083
+ * This is a pure read: it does NOT advance the allocation watermark.
1084
+ * Used by restore's gap-scan to peek descriptors at arbitrary indices
1085
+ * without side-effects.
1086
+ */
1087
+ materializeDescriptorAt(index: number): string;
1088
+ /**
1089
+ * Run the read-modify-write of HD settings inside the shared per-repo
1090
+ * wallet-state mutex. The closure receives a freshly-validated settings
1091
+ * snapshot, mutates it, and returns whatever value the caller wants to
1092
+ * surface; the mutated settings are then persisted as part of the same
1093
+ * atomic update.
1094
+ *
1095
+ * Doing the read inside the lock is what prevents two providers (or two
1096
+ * concurrent callers on the same provider) from racing on a stale index.
1097
+ */
1098
+ private mutate;
1099
+ /**
1100
+ * Validate the persisted HD settings (or initialize a fresh record when
1101
+ * absent) and return a clone safe for the caller to mutate.
1102
+ *
1103
+ * The cast to `HDWalletSettings` trusts storage; a corrupted or
1104
+ * partially-migrated repo could otherwise produce `NaN` descriptors.
1105
+ * Fail loud rather than silently derive garbage.
1106
+ */
1107
+ private parseSettings;
1108
+ }
1109
+
1110
+ declare class WalletNotInitializedError extends Error {
1111
+ constructor();
1112
+ }
1113
+ declare class ReadonlyWalletError extends Error {
1114
+ constructor();
1115
+ }
1116
+ declare class DelegatorNotConfiguredError extends Error {
1117
+ constructor();
1118
+ }
1119
+ type RequestInitWallet = RequestEnvelope & {
1120
+ type: "INIT_WALLET";
1121
+ payload: {
1122
+ /**
1123
+ * Legacy per-request key material. Ignored by the current handler —
1124
+ * identity hydration happens during INITIALIZE_MESSAGE_BUS. Retained
1125
+ * for wire compatibility with older workers that may still read it.
1126
+ * Slated for removal in the next major.
1127
+ *
1128
+ * @deprecated Identity is now carried by INITIALIZE_MESSAGE_BUS.
1129
+ */
1130
+ key?: {
1131
+ privateKey: string;
1132
+ } | {
1133
+ publicKey: string;
1134
+ } | {};
1135
+ arkServerUrl: string;
1136
+ arkServerPublicKey?: string;
1137
+ };
1138
+ };
1139
+ type ResponseInitWallet = ResponseEnvelope & {
1140
+ type: "WALLET_INITIALIZED";
1141
+ };
1142
+ type RequestSettle = RequestEnvelope & {
1143
+ type: "SETTLE";
1144
+ payload: {
1145
+ params?: SettleParams;
1146
+ };
1147
+ };
1148
+ type ResponseSettle = ResponseEnvelope & {
1149
+ type: "SETTLE_SUCCESS";
1150
+ payload: {
1151
+ txid: string;
1152
+ };
1153
+ };
1154
+ type RequestSendBitcoin = RequestEnvelope & {
1155
+ type: "SEND_BITCOIN";
1156
+ payload: SendBitcoinParams;
1157
+ };
1158
+ type ResponseSendBitcoin = ResponseEnvelope & {
1159
+ type: "SEND_BITCOIN_SUCCESS";
1160
+ payload: {
1161
+ txid: string;
1162
+ };
1163
+ };
1164
+ type RequestGetAddress = RequestEnvelope & {
1165
+ type: "GET_ADDRESS";
1166
+ };
1167
+ type ResponseGetAddress = ResponseEnvelope & {
1168
+ type: "ADDRESS";
1169
+ payload: {
1170
+ address: string;
1171
+ };
1172
+ };
1173
+ type RequestGetBoardingAddress = RequestEnvelope & {
1174
+ type: "GET_BOARDING_ADDRESS";
1175
+ };
1176
+ type ResponseGetBoardingAddress = ResponseEnvelope & {
1177
+ type: "BOARDING_ADDRESS";
1178
+ payload: {
1179
+ address: string;
1180
+ };
1181
+ };
1182
+ type RequestGetBalance = RequestEnvelope & {
1183
+ type: "GET_BALANCE";
1184
+ };
1185
+ type ResponseGetBalance = ResponseEnvelope & {
1186
+ type: "BALANCE";
1187
+ payload: WalletBalance;
1188
+ };
1189
+ type RequestGetVtxos = RequestEnvelope & {
1190
+ type: "GET_VTXOS";
1191
+ payload: {
1192
+ filter?: GetVtxosFilter;
1193
+ };
1194
+ };
1195
+ type ResponseGetVtxos = ResponseEnvelope & {
1196
+ type: "VTXOS";
1197
+ payload: {
1198
+ vtxos: Awaited<ReturnType<IWallet["getVtxos"]>>;
1199
+ };
1200
+ };
1201
+ type RequestGetBoardingUtxos = RequestEnvelope & {
1202
+ type: "GET_BOARDING_UTXOS";
1203
+ };
1204
+ type ResponseGetBoardingUtxos = ResponseEnvelope & {
1205
+ type: "BOARDING_UTXOS";
1206
+ payload: {
1207
+ utxos: ExtendedCoin[];
1208
+ };
1209
+ };
1210
+ type RequestGetTransactionHistory = RequestEnvelope & {
1211
+ type: "GET_TRANSACTION_HISTORY";
1212
+ };
1213
+ type ResponseGetTransactionHistory = ResponseEnvelope & {
1214
+ type: "TRANSACTION_HISTORY";
1215
+ payload: {
1216
+ transactions: ArkTransaction[];
1217
+ };
1218
+ };
1219
+ type RequestGetStatus = RequestEnvelope & {
1220
+ type: "GET_STATUS";
1221
+ };
1222
+ type ResponseGetStatus = ResponseEnvelope & {
1223
+ type: "WALLET_STATUS";
1224
+ payload: {
1225
+ walletInitialized: boolean;
1226
+ xOnlyPublicKey: Uint8Array | undefined;
1227
+ };
1228
+ };
1229
+ type RequestClear = RequestEnvelope & {
1230
+ type: "CLEAR";
1231
+ };
1232
+ type ResponseClear = ResponseEnvelope & {
1233
+ type: "CLEAR_SUCCESS";
1234
+ payload: {
1235
+ cleared: boolean;
1236
+ };
1237
+ };
1238
+ type RequestSignTransaction = RequestEnvelope & {
1239
+ type: "SIGN_TRANSACTION";
1240
+ payload: {
1241
+ tx: Transaction;
1242
+ inputIndexes?: number[];
1243
+ };
1244
+ };
1245
+ type ResponseSignTransaction = ResponseEnvelope & {
1246
+ type: "SIGN_TRANSACTION";
1247
+ payload: {
1248
+ tx: Transaction;
1249
+ };
1250
+ };
1251
+ type RequestReloadWallet = RequestEnvelope & {
1252
+ type: "RELOAD_WALLET";
1253
+ };
1254
+ type ResponseReloadWallet = ResponseEnvelope & {
1255
+ type: "RELOAD_SUCCESS";
1256
+ payload: {
1257
+ reloaded: boolean;
1258
+ };
1259
+ };
1260
+ type RequestCreateContract = RequestEnvelope & {
1261
+ type: "CREATE_CONTRACT";
1262
+ payload: CreateContractParams;
1263
+ };
1264
+ type ResponseCreateContract = ResponseEnvelope & {
1265
+ type: "CONTRACT_CREATED";
1266
+ payload: {
1267
+ contract: Contract;
1268
+ };
1269
+ };
1270
+ type RequestGetContracts = RequestEnvelope & {
1271
+ type: "GET_CONTRACTS";
1272
+ payload: {
1273
+ filter?: GetContractsFilter;
1274
+ };
1275
+ };
1276
+ type ResponseGetContracts = ResponseEnvelope & {
1277
+ type: "CONTRACTS";
1278
+ payload: {
1279
+ contracts: Contract[];
1280
+ };
1281
+ };
1282
+ type RequestGetContractsWithVtxos = RequestEnvelope & {
1283
+ type: "GET_CONTRACTS_WITH_VTXOS";
1284
+ payload: {
1285
+ filter?: GetContractsFilter;
1286
+ };
1287
+ };
1288
+ type ResponseGetContractsWithVtxos = ResponseEnvelope & {
1289
+ type: "CONTRACTS_WITH_VTXOS";
1290
+ payload: {
1291
+ contracts: ContractWithVtxos[];
1292
+ };
1293
+ };
1294
+ type RequestAnnotateVtxos = RequestEnvelope & {
1295
+ type: "ANNOTATE_VTXOS";
1296
+ payload: {
1297
+ vtxos: VirtualCoin[];
1298
+ };
1299
+ };
1300
+ type ResponseAnnotateVtxos = ResponseEnvelope & {
1301
+ type: "ANNOTATED_VTXOS";
1302
+ payload: {
1303
+ vtxos: ExtendedVirtualCoin[];
1304
+ };
1305
+ };
1306
+ type RequestUpdateContract = RequestEnvelope & {
1307
+ type: "UPDATE_CONTRACT";
1308
+ payload: {
1309
+ script: string;
1310
+ updates: Partial<Omit<Contract, "id" | "createdAt">>;
1311
+ };
1312
+ };
1313
+ type ResponseUpdateContract = ResponseEnvelope & {
1314
+ type: "CONTRACT_UPDATED";
1315
+ payload: {
1316
+ contract: Contract;
1317
+ };
1318
+ };
1319
+ type RequestDeleteContract = RequestEnvelope & {
1320
+ type: "DELETE_CONTRACT";
1321
+ payload: {
1322
+ script: string;
1323
+ };
1324
+ };
1325
+ type ResponseDeleteContract = ResponseEnvelope & {
1326
+ type: "CONTRACT_DELETED";
1327
+ payload: {
1328
+ deleted: boolean;
1329
+ };
1330
+ };
1331
+ type RequestGetSpendablePaths = RequestEnvelope & {
1332
+ type: "GET_SPENDABLE_PATHS";
1333
+ payload: {
1334
+ options: GetSpendablePathsOptions;
1335
+ };
1336
+ };
1337
+ type ResponseGetSpendablePaths = ResponseEnvelope & {
1338
+ type: "SPENDABLE_PATHS";
1339
+ payload: {
1340
+ paths: PathSelection[];
1341
+ };
1342
+ };
1343
+ type RequestIsContractManagerWatching = RequestEnvelope & {
1344
+ type: "IS_CONTRACT_MANAGER_WATCHING";
1345
+ };
1346
+ type ResponseIsContractManagerWatching = ResponseEnvelope & {
1347
+ type: "CONTRACT_WATCHING";
1348
+ payload: {
1349
+ isWatching: boolean;
1350
+ };
1351
+ };
1352
+ type RequestRefreshVtxos = RequestEnvelope & {
1353
+ type: "REFRESH_VTXOS";
1354
+ payload?: {
1355
+ scripts?: string[];
1356
+ after?: number;
1357
+ before?: number;
1358
+ };
1359
+ };
1360
+ type ResponseRefreshVtxos = ResponseEnvelope & {
1361
+ type: "REFRESH_VTXOS_SUCCESS";
1362
+ };
1363
+ type RequestRefreshOutpoints = RequestEnvelope & {
1364
+ type: "REFRESH_OUTPOINTS";
1365
+ payload: {
1366
+ outpoints: {
1367
+ txid: string;
1368
+ vout: number;
1369
+ }[];
1370
+ };
1371
+ };
1372
+ type ResponseRefreshOutpoints = ResponseEnvelope & {
1373
+ type: "REFRESH_OUTPOINTS_SUCCESS";
1374
+ };
1375
+ type RequestGetAllSpendingPaths = RequestEnvelope & {
1376
+ type: "GET_ALL_SPENDING_PATHS";
1377
+ payload: {
1378
+ options: GetAllSpendingPathsOptions;
1379
+ };
1380
+ };
1381
+ type ResponseGetAllSpendingPaths = ResponseEnvelope & {
1382
+ type: "ALL_SPENDING_PATHS";
1383
+ payload: {
1384
+ paths: PathSelection[];
1385
+ };
1386
+ };
1387
+ type ResponseSettleEvent = ResponseEnvelope & {
1388
+ broadcast: true;
1389
+ type: "SETTLE_EVENT";
1390
+ payload: SettlementEvent;
1391
+ };
1392
+ type ResponseRecoverVtxosEvent = ResponseEnvelope & {
1393
+ type: "RECOVER_VTXOS_EVENT";
1394
+ payload: SettlementEvent;
1395
+ };
1396
+ type ResponseRenewVtxosEvent = ResponseEnvelope & {
1397
+ type: "RENEW_VTXOS_EVENT";
1398
+ payload: SettlementEvent;
1399
+ };
1400
+ type ResponseUtxoUpdate = ResponseEnvelope & {
1401
+ broadcast: true;
1402
+ type: "UTXO_UPDATE";
1403
+ payload: {
1404
+ coins: ExtendedCoin[];
1405
+ };
1406
+ };
1407
+ type ResponseVtxoUpdate = ResponseEnvelope & {
1408
+ broadcast: true;
1409
+ type: "VTXO_UPDATE";
1410
+ payload: {
1411
+ newVtxos: ExtendedCoin[];
1412
+ spentVtxos: ExtendedCoin[];
1413
+ };
1414
+ };
1415
+ type ResponseContractEvent = ResponseEnvelope & {
1416
+ tag: string;
1417
+ broadcast: true;
1418
+ type: "CONTRACT_EVENT";
1419
+ payload: {
1420
+ event: ContractEvent;
1421
+ };
1422
+ };
1423
+ type RequestSend = RequestEnvelope & {
1424
+ type: "SEND";
1425
+ payload: {
1426
+ recipients: [Recipient, ...Recipient[]];
1427
+ };
1428
+ };
1429
+ type ResponseSend = ResponseEnvelope & {
1430
+ type: "SEND_SUCCESS";
1431
+ payload: {
1432
+ txid: string;
1433
+ };
1434
+ };
1435
+ type RequestGetAssetDetails = RequestEnvelope & {
1436
+ type: "GET_ASSET_DETAILS";
1437
+ payload: {
1438
+ assetId: string;
1439
+ };
1440
+ };
1441
+ type ResponseGetAssetDetails = ResponseEnvelope & {
1442
+ type: "ASSET_DETAILS";
1443
+ payload: {
1444
+ assetDetails: AssetDetails;
1445
+ };
1446
+ };
1447
+ type RequestIssue = RequestEnvelope & {
1448
+ type: "ISSUE";
1449
+ payload: {
1450
+ params: IssuanceParams;
1451
+ };
1452
+ };
1453
+ type ResponseIssue = ResponseEnvelope & {
1454
+ type: "ISSUE_SUCCESS";
1455
+ payload: {
1456
+ result: IssuanceResult;
1457
+ };
1458
+ };
1459
+ type RequestReissue = RequestEnvelope & {
1460
+ type: "REISSUE";
1461
+ payload: {
1462
+ params: ReissuanceParams;
1463
+ };
1464
+ };
1465
+ type ResponseReissue = ResponseEnvelope & {
1466
+ type: "REISSUE_SUCCESS";
1467
+ payload: {
1468
+ txid: string;
1469
+ };
1470
+ };
1471
+ type RequestBurn = RequestEnvelope & {
1472
+ type: "BURN";
1473
+ payload: {
1474
+ params: BurnParams;
1475
+ };
1476
+ };
1477
+ type ResponseBurn = ResponseEnvelope & {
1478
+ type: "BURN_SUCCESS";
1479
+ payload: {
1480
+ txid: string;
1481
+ };
1482
+ };
1483
+ type RequestDelegate = RequestEnvelope & {
1484
+ type: "DELEGATE";
1485
+ payload: {
1486
+ vtxoOutpoints: {
1487
+ txid: string;
1488
+ vout: number;
1489
+ }[];
1490
+ destination: string;
1491
+ delegateAt?: number;
1492
+ };
1493
+ };
1494
+ type ResponseDelegate = ResponseEnvelope & {
1495
+ type: "DELEGATE_SUCCESS";
1496
+ payload: {
1497
+ delegated: {
1498
+ txid: string;
1499
+ vout: number;
1500
+ }[];
1501
+ failed: {
1502
+ outpoints: {
1503
+ txid: string;
1504
+ vout: number;
1505
+ }[];
1506
+ error: string;
1507
+ }[];
1508
+ };
1509
+ };
1510
+ type RequestGetDelegateInfo = RequestEnvelope & {
1511
+ type: "GET_DELEGATE_INFO";
1512
+ };
1513
+ type ResponseGetDelegateInfo = ResponseEnvelope & {
1514
+ type: "DELEGATE_INFO";
1515
+ payload: {
1516
+ info: DelegateInfo;
1517
+ };
1518
+ };
1519
+ type RequestRecoverVtxos = RequestEnvelope & {
1520
+ type: "RECOVER_VTXOS";
1521
+ };
1522
+ type ResponseRecoverVtxos = ResponseEnvelope & {
1523
+ type: "RECOVER_VTXOS_SUCCESS";
1524
+ payload: {
1525
+ txid: string;
1526
+ };
1527
+ };
1528
+ type RequestGetRecoverableBalance = RequestEnvelope & {
1529
+ type: "GET_RECOVERABLE_BALANCE";
1530
+ };
1531
+ type ResponseGetRecoverableBalance = ResponseEnvelope & {
1532
+ type: "RECOVERABLE_BALANCE";
1533
+ payload: {
1534
+ recoverable: string;
1535
+ subdust: string;
1536
+ includesSubdust: boolean;
1537
+ vtxoCount: number;
1538
+ };
1539
+ };
1540
+ type RequestGetExpiringVtxos = RequestEnvelope & {
1541
+ type: "GET_EXPIRING_VTXOS";
1542
+ payload: {
1543
+ thresholdMs?: number;
1544
+ };
1545
+ };
1546
+ type ResponseGetExpiringVtxos = ResponseEnvelope & {
1547
+ type: "EXPIRING_VTXOS";
1548
+ payload: {
1549
+ vtxos: ExtendedVirtualCoin[];
1550
+ };
1551
+ };
1552
+ type RequestRenewVtxos = RequestEnvelope & {
1553
+ type: "RENEW_VTXOS";
1554
+ };
1555
+ type ResponseRenewVtxos = ResponseEnvelope & {
1556
+ type: "RENEW_VTXOS_SUCCESS";
1557
+ payload: {
1558
+ txid: string;
1559
+ };
1560
+ };
1561
+ type RequestGetExpiredBoardingUtxos = RequestEnvelope & {
1562
+ type: "GET_EXPIRED_BOARDING_UTXOS";
1563
+ };
1564
+ type ResponseGetExpiredBoardingUtxos = ResponseEnvelope & {
1565
+ type: "EXPIRED_BOARDING_UTXOS";
1566
+ payload: {
1567
+ utxos: ExtendedCoin[];
1568
+ };
1569
+ };
1570
+ type RequestSweepExpiredBoardingUtxos = RequestEnvelope & {
1571
+ type: "SWEEP_EXPIRED_BOARDING_UTXOS";
1572
+ };
1573
+ type ResponseSweepExpiredBoardingUtxos = ResponseEnvelope & {
1574
+ type: "SWEEP_EXPIRED_BOARDING_UTXOS_SUCCESS";
1575
+ payload: {
1576
+ txid: string;
1577
+ };
1578
+ };
1579
+ type WalletUpdaterRequest = RequestInitWallet | RequestSettle | RequestSendBitcoin | RequestGetAddress | RequestGetBoardingAddress | RequestGetBalance | RequestGetVtxos | RequestGetBoardingUtxos | RequestGetTransactionHistory | RequestGetStatus | RequestClear | RequestReloadWallet | RequestSignTransaction | RequestCreateContract | RequestGetContracts | RequestGetContractsWithVtxos | RequestAnnotateVtxos | RequestUpdateContract | RequestDeleteContract | RequestGetSpendablePaths | RequestGetAllSpendingPaths | RequestIsContractManagerWatching | RequestRefreshVtxos | RequestRefreshOutpoints | RequestSend | RequestGetAssetDetails | RequestIssue | RequestReissue | RequestBurn | RequestDelegate | RequestGetDelegateInfo | RequestRecoverVtxos | RequestGetRecoverableBalance | RequestGetExpiringVtxos | RequestRenewVtxos | RequestGetExpiredBoardingUtxos | RequestSweepExpiredBoardingUtxos;
1580
+ type WalletUpdaterResponse = ResponseEnvelope & (ResponseInitWallet | ResponseSettle | ResponseSettleEvent | ResponseSendBitcoin | ResponseGetAddress | ResponseGetBoardingAddress | ResponseGetBalance | ResponseGetVtxos | ResponseGetBoardingUtxos | ResponseGetTransactionHistory | ResponseGetStatus | ResponseClear | ResponseReloadWallet | ResponseUtxoUpdate | ResponseVtxoUpdate | ResponseSignTransaction | ResponseCreateContract | ResponseGetContracts | ResponseGetContractsWithVtxos | ResponseAnnotateVtxos | ResponseUpdateContract | ResponseDeleteContract | ResponseGetSpendablePaths | ResponseGetAllSpendingPaths | ResponseIsContractManagerWatching | ResponseRefreshVtxos | ResponseRefreshOutpoints | ResponseContractEvent | ResponseSend | ResponseGetAssetDetails | ResponseIssue | ResponseReissue | ResponseBurn | ResponseDelegate | ResponseGetDelegateInfo | ResponseRecoverVtxos | ResponseRecoverVtxosEvent | ResponseGetRecoverableBalance | ResponseGetExpiringVtxos | ResponseRenewVtxos | ResponseRenewVtxosEvent | ResponseGetExpiredBoardingUtxos | ResponseSweepExpiredBoardingUtxos);
1581
+ declare class WalletMessageHandler implements MessageHandler<WalletUpdaterRequest, WalletUpdaterResponse> {
1582
+ readonly messageTag: string;
1583
+ private wallet;
1584
+ private readonlyWallet;
1585
+ private arkProvider;
1586
+ private indexerProvider;
1587
+ private walletRepository;
1588
+ private incomingFundsSubscription;
1589
+ private contractEventsSubscription;
1590
+ private onNextTick;
1591
+ /**
1592
+ * Instantiate a new WalletUpdater.
1593
+ * Can override the default `messageTag` allowing more than one updater to run in parallel.
1594
+ * Note that the default ServiceWorkerWallet sends messages to the default WalletUpdater tag.
1595
+ */
1596
+ constructor(options?: {
1597
+ messageTag?: string;
1598
+ });
1599
+ start(...params: Parameters<MessageHandler["start"]>): Promise<void>;
1600
+ stop(): Promise<void>;
1601
+ tick(_now: number): Promise<WalletUpdaterResponse[]>;
1602
+ private scheduleForNextTick;
1603
+ private requireWallet;
1604
+ private tagged;
1605
+ isLongRunning(message: WalletUpdaterRequest): boolean;
1606
+ handleMessage(message: WalletUpdaterRequest): Promise<WalletUpdaterResponse>;
1607
+ private handleInitWallet;
1608
+ private handleGetBalance;
1609
+ private getAllBoardingUtxos;
1610
+ /**
1611
+ * Get spendable vtxos from the repository
1612
+ */
1613
+ private getSpendableVtxos;
1614
+ private onWalletInitialized;
1615
+ /**
1616
+ * Refresh virtual outputs, boarding inputs, and transaction history from cache.
1617
+ * Shared by onWalletInitialized (full bootstrap) and reloadWallet
1618
+ * (post-refresh), avoiding duplicate subscriptions and VtxoManager restarts.
1619
+ */
1620
+ private refreshCachedData;
1621
+ /**
1622
+ * Force a full VTXO refresh from the indexer, then refresh cached data.
1623
+ * Used by RELOAD_WALLET to ensure fresh data without re-subscribing
1624
+ * to incoming funds or restarting the VtxoManager.
1625
+ */
1626
+ private reloadWallet;
1627
+ private handleSettle;
1628
+ private handleSendBitcoin;
1629
+ private handleSignTransaction;
1630
+ private handleDelegate;
1631
+ private handleGetVtxos;
1632
+ private clear;
1633
+ /**
1634
+ * Read all virtual outputs from the repository, aggregated across all contract
1635
+ * addresses and the wallet's primary address, with deduplication.
1636
+ */
1637
+ private getVtxosFromRepo;
1638
+ /**
1639
+ * Build transaction history from cached virtual outputs without hitting the indexer.
1640
+ * Falls back to indexer only for uncached transaction timestamps.
1641
+ */
1642
+ private buildTransactionHistoryFromCache;
1643
+ private ensureContractEventBroadcasting;
1644
+ }
1645
+
1646
+ type RequestType = WalletUpdaterRequest["type"];
1647
+ type MessageTimeouts = Partial<Record<RequestType, number>>;
1648
+ type ServiceWorkerWalletMode = "auto" | "static" | "hd";
1649
+ declare const DEFAULT_MESSAGE_TIMEOUTS: Readonly<Record<RequestType, number>>;
1650
+ /**
1651
+ * Service Worker-based wallet implementation for browser environments.
1652
+ *
1653
+ * This wallet uses a service worker as a backend to handle wallet logic,
1654
+ * providing secure key storage and transaction signing in web applications.
1655
+ * The service worker runs in a separate thread and can persist data between
1656
+ * browser sessions.
1657
+ *
1658
+ * @example
1659
+ * ```typescript
1660
+ * // SIMPLE: Recommended approach
1661
+ * const wallet = await ServiceWorkerWallet.setup({
1662
+ * serviceWorkerPath: '/service-worker.js',
1663
+ * arkServerUrl: 'https://arkade.computer',
1664
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
1665
+ * });
1666
+ *
1667
+ * // ADVANCED: Manual setup with service worker control
1668
+ * const serviceWorker = await setupServiceWorker("/service-worker.js");
1669
+ * const wallet = await ServiceWorkerWallet.create({
1670
+ * serviceWorker,
1671
+ * arkServerUrl: 'https://arkade.computer',
1672
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
1673
+ * });
1674
+ *
1675
+ * // Use like any other wallet
1676
+ * const address = await wallet.getAddress();
1677
+ * const balance = await wallet.getBalance();
1678
+ * ```
1679
+ */
1680
+ interface ServiceWorkerWalletOptions {
1681
+ /** Optional Arkade server public key used to construct and validate Arkade addresses. */
1682
+ arkServerPublicKey?: string;
1683
+ /** Base URL of the Arkade server. */
1684
+ arkServerUrl?: string;
1685
+ /** Optional override for the indexer URL. */
1686
+ indexerUrl?: string;
1687
+ /** Optional override for the Esplora API URL. */
1688
+ esploraUrl?: string;
1689
+ /**
1690
+ * Repository-backed storage configuration overrides.
1691
+ * Defaults to IndexedDB if unset.
1692
+ */
1693
+ storage?: StorageConfig;
1694
+ /** Identity used to derive addresses and optionally sign operations. */
1695
+ identity: ReadonlyIdentity | Identity;
1696
+ /** Optional delegation service URL. */
1697
+ delegatorUrl?: string;
1698
+ /**
1699
+ * Override the default tag used for messages sent to and received from the service worker.
1700
+ * @see DEFAULT_MESSAGE_TAG
1701
+ */
1702
+ walletUpdaterTag?: string;
1703
+ /** Timeout used while bootstrapping the message bus inside the service worker. */
1704
+ messageBusTimeoutMs?: number;
1705
+ /** Optional settlement configuration forwarded to the worker wallet. */
1706
+ settlementConfig?: SettlementConfig | false;
1707
+ /**
1708
+ * Receive-address strategy forwarded to the worker wallet.
1709
+ *
1710
+ * Service workers can only receive serializable configuration, so the
1711
+ * descriptor-provider object form accepted by `Wallet.create()` is not
1712
+ * supported here.
1713
+ */
1714
+ walletMode?: ServiceWorkerWalletMode;
1715
+ /** Optional contract watcher configuration forwarded to the worker wallet. */
1716
+ watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
1717
+ /**
1718
+ * Per-request timeout overrides for wallet-updater messages.
1719
+ * @see DEFAULT_MESSAGE_TIMEOUTS
1720
+ */
1721
+ messageTimeouts?: MessageTimeouts;
1722
+ }
1723
+ /**
1724
+ * Options for creating a service-worker wallet with an existing worker instance.
1725
+ *
1726
+ * @see ServiceWorkerReadonlyWallet.create
1727
+ * @see ServiceWorkerWallet.create
1728
+ */
1729
+ type ServiceWorkerWalletCreateOptions = ServiceWorkerWalletOptions & {
1730
+ /** Existing service worker instance used for messaging. */
1731
+ serviceWorker: ServiceWorker;
1732
+ };
1733
+ /**
1734
+ * Options for registering a service worker and then creating a wallet around it.
1735
+ *
1736
+ * @see ServiceWorkerReadonlyWallet.setup
1737
+ * @see ServiceWorkerWallet.setup
1738
+ */
1739
+ type ServiceWorkerWalletSetupOptions = ServiceWorkerWalletOptions & {
1740
+ /** Path to the service worker script to register. */
1741
+ serviceWorkerPath: string;
1742
+ /** Timeout while waiting for the service worker to activate. */
1743
+ serviceWorkerActivationTimeoutMs?: number;
1744
+ };
1745
+ type MessageBusInitConfig = {
1746
+ wallet: SerializedIdentity | LegacySerializedIdentity;
1747
+ arkServer: {
1748
+ url: string;
1749
+ publicKey?: string;
1750
+ };
1751
+ delegatorUrl?: string;
1752
+ indexerUrl?: string;
1753
+ esploraUrl?: string;
1754
+ timeoutMs?: number;
1755
+ settlementConfig?: SettlementConfig | false;
1756
+ walletMode?: ServiceWorkerWalletMode;
1757
+ watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
1758
+ messageTimeouts?: Record<string, number>;
1759
+ };
1760
+ declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
1761
+ readonly serviceWorker: ServiceWorker;
1762
+ protected readonly messageTag: string;
1763
+ readonly walletRepository: WalletRepository;
1764
+ readonly contractRepository: ContractRepository;
1765
+ readonly identity: ReadonlyIdentity;
1766
+ private readonly _readonlyAssetManager;
1767
+ protected initConfig: MessageBusInitConfig | null;
1768
+ protected initWalletPayload: RequestInitWallet["payload"] | null;
1769
+ protected messageBusTimeoutMs?: number;
1770
+ protected messageTimeouts: Record<RequestType, number>;
1771
+ protected arkServerUrl?: string;
1772
+ protected arkServerPublicKey?: string;
1773
+ protected delegatorUrl?: string;
1774
+ protected indexerUrl?: string;
1775
+ protected esploraUrl?: string;
1776
+ protected watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
1777
+ protected settlementConfig?: SettlementConfig | false;
1778
+ private reinitPromise;
1779
+ private pingPromise;
1780
+ private inflightRequests;
1781
+ get assetManager(): IReadonlyAssetManager;
1782
+ protected constructor(serviceWorker: ServiceWorker, identity: ReadonlyIdentity, walletRepository: WalletRepository, contractRepository: ContractRepository, messageTag: string);
1783
+ private getTimeoutForRequest;
1784
+ /**
1785
+ * Create a readonly service-worker wallet bound to an already-registered worker.
1786
+ *
1787
+ * @param options - Service worker, identity, and backend configuration
1788
+ * @returns Initialized readonly service-worker wallet
1789
+ * @throws Error if service-worker initialization fails
1790
+ */
1791
+ static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerReadonlyWallet>;
1792
+ /**
1793
+ * Simplified setup method that handles service worker registration
1794
+ * and wallet initialization automatically.
1795
+ *
1796
+ * @see ServiceWorkerReadonlyWallet.create
1797
+ *
1798
+ * @example
1799
+ * ```typescript
1800
+ * const wallet = await ServiceWorkerReadonlyWallet.setup({
1801
+ * serviceWorkerPath: '/service-worker.js',
1802
+ * arkServerUrl: 'https://arkade.computer',
1803
+ * identity: ReadonlySingleKey.fromPublicKey('your_public_key_hex')
1804
+ * });
1805
+ * ```
1806
+ */
1807
+ static setup(options: ServiceWorkerWalletSetupOptions): Promise<ServiceWorkerReadonlyWallet>;
1808
+ private sendMessageDirect;
1809
+ private sendMessageStreaming;
1810
+ protected sendMessage(request: WalletUpdaterRequest): Promise<WalletUpdaterResponse>;
1811
+ private pingServiceWorker;
1812
+ private sendMessageWithRetry;
1813
+ protected sendMessageWithEvents(request: WalletUpdaterRequest, onEvent: (response: WalletUpdaterResponse) => void, isComplete: (response: WalletUpdaterResponse) => boolean): Promise<WalletUpdaterResponse>;
1814
+ /**
1815
+ * Produce a serialized envelope for the wallet's identity. The base
1816
+ * class always emits a readonly envelope; `ServiceWorkerWallet`
1817
+ * overrides to emit a signing envelope.
1818
+ */
1819
+ protected serializeIdentity(): Promise<SerializedIdentity>;
1820
+ /**
1821
+ * Return the cached init config, or rebuild one from live instance
1822
+ * state when the cache was never populated. Recovery path for
1823
+ * SDK-factory-created wallets; manual constructor bypasses do not
1824
+ * retain enough state here and will hit the "never initialized" throw.
1825
+ */
1826
+ protected buildInitConfig(): Promise<MessageBusInitConfig>;
1827
+ /** Minimal INIT_WALLET payload used on reinitialize when the cache is gone. */
1828
+ protected buildInitWalletPayload(): RequestInitWallet["payload"];
1829
+ private reinitialize;
1830
+ /** Clear cached wallet state from both the page and service worker storage. */
1831
+ clear(): Promise<void>;
1832
+ getAddress(): Promise<string>;
1833
+ getBoardingAddress(): Promise<string>;
1834
+ getBalance(): Promise<WalletBalance>;
1835
+ getBoardingUtxos(): Promise<ExtendedCoin[]>;
1836
+ /**
1837
+ * Return service-worker wallet status, including connectivity and sync state.
1838
+ *
1839
+ * @returns Current service-worker wallet status payload including `walletInitalized` and `xOnlyPublicKey`
1840
+ */
1841
+ getStatus(): Promise<ResponseGetStatus["payload"]>;
1842
+ getTransactionHistory(): Promise<ArkTransaction[]>;
1843
+ getVtxos(filter?: GetVtxosFilter): Promise<ExtendedVirtualCoin[]>;
1844
+ /**
1845
+ * Trigger a wallet reload inside the service worker.
1846
+ *
1847
+ * @returns `true` when the wallet was reloaded
1848
+ */
1849
+ reload(): Promise<boolean>;
1850
+ getContractManager(): Promise<IContractManager>;
1851
+ }
1852
+ declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet implements IWallet {
1853
+ readonly serviceWorker: ServiceWorker;
1854
+ readonly walletRepository: WalletRepository;
1855
+ readonly contractRepository: ContractRepository;
1856
+ readonly identity: Identity;
1857
+ private readonly _assetManager;
1858
+ private readonly hasDelegator;
1859
+ protected constructor(serviceWorker: ServiceWorker, identity: Identity, walletRepository: WalletRepository, contractRepository: ContractRepository, messageTag: string, hasDelegator: boolean);
1860
+ get assetManager(): IAssetManager;
1861
+ protected serializeIdentity(): Promise<SerializedIdentity>;
1862
+ static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerWallet>;
1863
+ /**
1864
+ * Simplified setup method that handles service worker registration
1865
+ * and wallet initialization automatically.
1866
+ *
1867
+ * @example
1868
+ * ```typescript
1869
+ * const wallet = await ServiceWorkerWallet.setup({
1870
+ * serviceWorkerPath: '/service-worker.js',
1871
+ * arkServerUrl: 'https://arkade.computer',
1872
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
1873
+ * });
1874
+ * ```
1875
+ */
1876
+ static setup(options: ServiceWorkerWalletSetupOptions): Promise<ServiceWorkerWallet>;
1877
+ sendBitcoin(params: SendBitcoinParams): Promise<string>;
1878
+ settle(params?: SettleParams, callback?: (event: SettlementEvent) => void): Promise<string>;
1879
+ send(...recipients: [Recipient, ...Recipient[]]): Promise<string>;
1880
+ getDelegatorManager(): Promise<IDelegatorManager | undefined>;
1881
+ getVtxoManager(): Promise<IVtxoManager>;
1882
+ }
1883
+
1884
+ /**
1885
+ * A zero-value anchor output.
1886
+ */
1887
+ declare const P2A: {
1888
+ script: Uint8Array<ArrayBuffer>;
1889
+ amount: bigint;
1890
+ };
1891
+ interface AnchorBumper {
1892
+ bumpP2A(parent: Transaction$1): Promise<[string, string]>;
1893
+ }
1894
+
1895
+ /**
1896
+ * Onchain Bitcoin wallet implementation for traditional Bitcoin transactions.
1897
+ *
1898
+ * This wallet handles regular Bitcoin transactions on the blockchain without
1899
+ * using the Arkade protocol. It supports P2TR (Pay-to-Taproot) addresses and
1900
+ * provides basic Bitcoin wallet functionality.
1901
+ *
1902
+ * @example
1903
+ * ```typescript
1904
+ * const wallet = await OnchainWallet.create(identity, 'mainnet');
1905
+ * const balance = await wallet.getBalance();
1906
+ * const txid = await wallet.send({
1907
+ * address: 'bc1...',
1908
+ * amount: 50000
1909
+ * });
1910
+ * ```
1911
+ */
1912
+ declare class OnchainWallet implements AnchorBumper {
1913
+ private identity;
1914
+ static MIN_FEE_RATE: number;
1915
+ readonly onchainP2TR: P2TR;
1916
+ readonly provider: OnchainProvider;
1917
+ readonly network: Network;
1918
+ private constructor();
1919
+ /**
1920
+ * Create an onchain wallet for the given identity and Bitcoin network.
1921
+ *
1922
+ * @param identity - Identity used to derive the Taproot key and sign transactions
1923
+ * @param networkName - Bitcoin network name, @see NetworkName
1924
+ * @param provider - Optional onchain provider override, @see OnchainProvider
1925
+ * @returns Configured onchain wallet
1926
+ * @defaultValue `provider = new EsploraProvider('https://mempool.space/api')`
1927
+ * @throws Error if the configured identity cannot produce a valid x-only public key
1928
+ */
1929
+ static create(identity: Identity, networkName?: NetworkName, provider?: OnchainProvider): Promise<OnchainWallet>;
1930
+ get address(): string;
1931
+ /**
1932
+ * Fetch spendable onchain outputs for the wallet address.
1933
+ *
1934
+ * @returns Spendable onchain outputs for the wallet address
1935
+ * @see getBalance
1936
+ */
1937
+ getCoins(): Promise<Coin[]>;
1938
+ /**
1939
+ * Return the wallet's total onchain balance in satoshis.
1940
+ *
1941
+ * @returns Confirmed plus unconfirmed onchain balance
1942
+ * @see getCoins
1943
+ */
1944
+ getBalance(): Promise<number>;
1945
+ /**
1946
+ * Iteratively selects coins and estimates transaction fees until convergence.
1947
+ *
1948
+ * This method handles the circular dependency between output selection and fee
1949
+ * estimation: the fee depends on transaction size, which depends on the number
1950
+ * of inputs (selected outputs) and whether a change output is needed.
1951
+ *
1952
+ * The algorithm iterates up to 10 times, refining the fee estimate based on
1953
+ * the actual transaction structure. It resolves dust oscillation loops that
1954
+ * occur when the change amount hovers near the dust threshold—adding/removing
1955
+ * the change output causes the fee to fluctuate, preventing convergence.
1956
+ * When a lower fee is computed (indicating the change output was dropped),
1957
+ * the function accepts this state to guarantee termination.
1958
+ *
1959
+ * @param coins - Available onchain outputs to select from
1960
+ * @param amount - Target send amount in satoshis
1961
+ * @param feeRate - Fee rate in sat/vbyte
1962
+ * @param recipientAddress - Destination address for size estimation
1963
+ * @returns Selected inputs, change amount, and calculated fee
1964
+ * @throws Error if fee estimation fails to converge within max iterations
1965
+ */
1966
+ private estimateFeesAndSelectCoins;
1967
+ /**
1968
+ * Send bitcoin to a single onchain address.
1969
+ *
1970
+ * @param params - destination `address`, `amount` (in satoshis), and optional `feeRate` override (other fields ignored)
1971
+ * @returns Broadcast transaction id
1972
+ * @throws Error if the amount is non-positive, below dust, or cannot be funded
1973
+ * @see SendBitcoinParams
1974
+ */
1975
+ send(params: SendBitcoinParams): Promise<string>;
1976
+ /**
1977
+ * CPFP-bump a parent transaction that contains a pay-to-anchor output.
1978
+ *
1979
+ * @param parent - Parent transaction containing a pay-to-anchor output
1980
+ * @returns Tuple of parent transaction id and child transaction id
1981
+ * @throws Error if the parent transaction has no pay-to-anchor output or bumping cannot be funded
1982
+ * @see send
1983
+ */
1984
+ bumpP2A(parent: Transaction): Promise<[string, string]>;
1985
+ }
1986
+
1987
+ type SetupServiceWorkerOptions = {
1988
+ path: string;
1989
+ activationTimeoutMs?: number;
1990
+ };
1991
+ /**
1992
+ * setupServiceWorker sets up the service worker.
1993
+ * @param pathOrOptions - the path to the service worker script or setup options
1994
+ * @throws if service workers are not supported or activation fails
1995
+ * @example
1996
+ * ```typescript
1997
+ * const worker = await setupServiceWorker("/service-worker.js");
1998
+ * ```
1999
+ */
2000
+ declare function setupServiceWorker(pathOrOptions: string | SetupServiceWorkerOptions): Promise<ServiceWorker>;
2001
+
2002
+ /**
2003
+ * Default WebSocket Electrum endpoints. Mainnet, mutinynet, and signet
2004
+ * point at Ark Labs–operated Fulcrum 2.1 deployments (which support
2005
+ * `blockchain.transaction.broadcast_package` for atomic 1P1C TRUC
2006
+ * relay; see `ElectrumOnchainProvider.broadcastTransaction`). Testnet
2007
+ * defaults to Blockstream's public Fulcrum because Ark doesn't host
2008
+ * it. Regtest assumes the `electrum-ws` websocat bridge from
2009
+ * `vulpemventures/nigiri`.
2010
+ *
2011
+ * @example
2012
+ * ```typescript
2013
+ * import { ElectrumWS } from "ws-electrumx-client";
2014
+ * import { ELECTRUM_WS_URL, ElectrumOnchainProvider, networks } from "@arkade-os/sdk";
2015
+ *
2016
+ * const ws = new ElectrumWS(ELECTRUM_WS_URL.bitcoin);
2017
+ * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
2018
+ * ```
2019
+ */
2020
+ declare const ELECTRUM_WS_URL: Record<NetworkName, string>;
2021
+ /**
2022
+ * Hostnames for Electrum endpoints reachable over raw TCP. Provided as
2023
+ * a reference for Node-side consumers — the SDK's
2024
+ * {@link ElectrumOnchainProvider} only speaks WebSocket because it has
2025
+ * to run in browsers, so this map is informational only and not
2026
+ * consumed by any built-in provider.
2027
+ *
2028
+ * Public Ark Labs Fulcrum instances expose:
2029
+ * - port 50001 — plain TCP (Electrum protocol)
2030
+ * - port 50002 — TCP + TLS (Electrum protocol)
2031
+ * - port 50003 — WebSocket (Electrum-over-WS, see {@link ELECTRUM_WS_URL})
2032
+ */
2033
+ declare const ELECTRUM_TCP_HOST: Record<NetworkName, string | null>;
2034
+ type TransactionHistory = {
2035
+ tx_hash: string;
2036
+ height: number;
2037
+ fee?: number;
2038
+ };
2039
+ type BlockHeader = {
2040
+ height: number;
2041
+ hex: string;
2042
+ };
2043
+ type Unspent = {
2044
+ txid: string;
2045
+ vout: number;
2046
+ witnessUtxo: {
2047
+ script: Uint8Array;
2048
+ value: bigint;
2049
+ };
2050
+ };
2051
+ type VerboseTransaction = {
2052
+ txid: string;
2053
+ confirmations: number;
2054
+ blockhash?: string;
2055
+ blocktime?: number;
2056
+ time?: number;
2057
+ /** Raw transaction hex. Bitcoin Core's getrawtransaction <tx> 1 always
2058
+ * includes this; we use it to derive exact satoshi amounts instead of
2059
+ * multiplying the floating-point `value` field by 1e8. */
2060
+ hex?: string;
2061
+ vout: {
2062
+ n: number;
2063
+ value: number;
2064
+ scriptPubKey: {
2065
+ addresses?: string[];
2066
+ address?: string;
2067
+ hex: string;
2068
+ };
2069
+ }[];
2070
+ vin: {
2071
+ txid: string;
2072
+ vout: number;
2073
+ }[];
2074
+ };
2075
+ type HeaderSubscribeResult = {
2076
+ height: number;
2077
+ hex: string;
2078
+ };
2079
+ /**
2080
+ * WebSocket-based Electrum chain source using ws-electrumx-client.
2081
+ * Provides low-level methods for the Electrum protocol.
2082
+ *
2083
+ * @example
2084
+ * ```typescript
2085
+ * import { ElectrumWS } from "ws-electrumx-client";
2086
+ * import { WsElectrumChainSource } from "./providers/electrum";
2087
+ * import { networks } from "./networks";
2088
+ *
2089
+ * const ws = new ElectrumWS("wss://electrum.blockstream.info:50004");
2090
+ * const chain = new WsElectrumChainSource(ws, networks.bitcoin);
2091
+ *
2092
+ * const history = await chain.fetchHistories([script]);
2093
+ * await chain.close();
2094
+ * ```
2095
+ */
2096
+ declare class WsElectrumChainSource {
2097
+ private ws;
2098
+ private network;
2099
+ private cachedTip;
2100
+ private headersSubscribePromise;
2101
+ constructor(ws: ElectrumWS, network: Network);
2102
+ /**
2103
+ * Send N requests in parallel and aggregate the results, replacement
2104
+ * for `ws.batchRequest`. The library's batchRequest is implemented as
2105
+ * `Promise.all` over individual request promises — when one element
2106
+ * rejects, the others remain pending. When their (often error)
2107
+ * responses arrive later, the library rejects them too, and nobody is
2108
+ * awaiting them: the rejections become unhandled and crash the test
2109
+ * runner / pollute production logs.
2110
+ *
2111
+ * `safeBatchRequest` issues each request through `ws.request` (so each
2112
+ * has its own request-promise lifecycle), waits for all of them via
2113
+ * `Promise.allSettled` (every promise gets an explicit handler), and
2114
+ * then surfaces the first error if any failed. Same wall-clock cost
2115
+ * as the library's batch (parallel send), no orphan rejections.
2116
+ *
2117
+ * Use this in place of `ws.batchRequest` for any call where one or
2118
+ * more elements may legitimately error (e.g. electrs index lag
2119
+ * surfacing as `missingheight` for a subset of heights/txids).
2120
+ */
2121
+ safeBatchRequest<T>(requests: {
2122
+ method: string;
2123
+ params: unknown[];
2124
+ }[]): Promise<T[]>;
2125
+ fetchTransactions(txids: string[]): Promise<{
2126
+ txID: string;
2127
+ hex: string;
2128
+ }[]>;
2129
+ fetchVerboseTransaction(txid: string): Promise<VerboseTransaction>;
2130
+ fetchVerboseTransactions(txids: string[]): Promise<VerboseTransaction[]>;
2131
+ /**
2132
+ * Look up the block height of a confirmed transaction without relying
2133
+ * on the verbose-tx endpoint. `blockchain.transaction.get_merkle` is
2134
+ * part of the standard SPV protocol and is supported by both Fulcrum
2135
+ * and electrs (whereas `blockchain.transaction.get` with verbose=true
2136
+ * is Fulcrum-only). Returns `null` when the tx is in the mempool —
2137
+ * electrs in that case rejects with a "not yet in a block" error.
2138
+ */
2139
+ fetchTxMerkle(txid: string): Promise<{
2140
+ blockHeight: number;
2141
+ } | null>;
2142
+ unsubscribeScriptStatus(script: Uint8Array): Promise<void>;
2143
+ subscribeScriptStatus(script: Uint8Array, callback: (scripthash: string, status: string | null) => void): Promise<void>;
2144
+ fetchHistories(scripts: Uint8Array[]): Promise<TransactionHistory[][]>;
2145
+ fetchHistory(script: Uint8Array): Promise<TransactionHistory[]>;
2146
+ fetchBlockHeaders(heights: number[]): Promise<BlockHeader[]>;
2147
+ fetchBlockHeader(height: number): Promise<BlockHeader>;
2148
+ /**
2149
+ * Returns the current chain tip and keeps it fresh via a single
2150
+ * server-side subscription. Subsequent calls return the cached tip
2151
+ * (updated by background notifications) without round-tripping to the
2152
+ * server. Previously each call issued `blockchain.headers.subscribe` as
2153
+ * a regular request, leaving a stale subscription on the server every
2154
+ * time — under polling that adds up. ws-electrumx-client deduplicates
2155
+ * `subscribe()` by method+params, so registering once is enough.
2156
+ */
2157
+ subscribeHeaders(): Promise<HeaderSubscribeResult>;
2158
+ estimateFees(targetNumberBlocks: number): Promise<number>;
2159
+ broadcastTransaction(txHex: string): Promise<string>;
2160
+ /**
2161
+ * Submit a package of raw transactions atomically via Fulcrum's
2162
+ * `blockchain.transaction.broadcast_package` method, the on-the-wire
2163
+ * equivalent of bitcoind's `submitpackage` RPC.
2164
+ *
2165
+ * Required for TRUC (BIP 431) 1P1C relay where the parent has zero
2166
+ * (or below-minfee) fee and depends on the child to pay for both via
2167
+ * CPFP — sequential broadcast cannot work in that case because the
2168
+ * parent would be rejected from the mempool on its own.
2169
+ *
2170
+ * @param txHexes - Topologically sorted raw transactions; child must
2171
+ * be the last element. Currently must be a 1P1C pair
2172
+ * (length 2). Parents may not depend on each other.
2173
+ * @returns The child transaction id (the last entry in the array),
2174
+ * computed locally — `broadcast_package` itself returns
2175
+ * `{success, errors}` rather than a txid.
2176
+ * @throws If the server does not implement `broadcast_package` (e.g.
2177
+ * ElectrumX, or older Fulcrum, or Fulcrum backed by bitcoind
2178
+ * < v28.0.0). Callers must surface this clearly to users —
2179
+ * this method does NOT silently fall back to sequential
2180
+ * broadcasts because doing so would let TRUC packages fail
2181
+ * in subtle ways.
2182
+ * @throws If the server returns `success=false`, surfacing the
2183
+ * underlying mempool rejection in the error message.
2184
+ */
2185
+ broadcastPackage(txHexes: string[]): Promise<string>;
2186
+ getRelayFee(): Promise<number>;
2187
+ close(): Promise<void>;
2188
+ waitForAddressReceivesTx(addr: string): Promise<void>;
2189
+ listUnspents(addr: string): Promise<Unspent[]>;
2190
+ /**
2191
+ * Get the address string for a script output, if decodable.
2192
+ */
2193
+ addressForScript(scriptHex: string): string | undefined;
2194
+ }
2195
+ /**
2196
+ * Electrum-based implementation of the {@link OnchainProvider} interface.
2197
+ *
2198
+ * Built around the subset of the Electrum protocol that both **Fulcrum**
2199
+ * and **electrs** support — listunspent, get_history, transaction.get
2200
+ * (non-verbose), transaction.get_merkle, block.header,
2201
+ * headers.subscribe, scripthash.subscribe, estimatefee, relayfee, and
2202
+ * broadcast. The verbose form of `transaction.get` is **not** used (it's
2203
+ * Fulcrum-only and rejected by electrs); confirmation status is derived
2204
+ * from `transaction.get_merkle` plus parsed block headers.
2205
+ *
2206
+ * Output amounts are derived from parsed raw transaction bytes (exact
2207
+ * bigints), never the floating-point `value` fields some servers return.
2208
+ *
2209
+ * Atomic 1P1C package broadcast (TRUC / BIP 431) is supported via
2210
+ * Fulcrum's `blockchain.transaction.broadcast_package`. There is **no
2211
+ * fallback** to sequential parent-then-child broadcasts — TRUC packages
2212
+ * with a zero-fee parent would silently fail, so the call surfaces an
2213
+ * error against servers that don't support the method.
2214
+ *
2215
+ * @example Default URL via {@link ELECTRUM_WS_URL}
2216
+ * ```typescript
2217
+ * import { ElectrumWS } from "ws-electrumx-client";
2218
+ * import {
2219
+ * ElectrumOnchainProvider,
2220
+ * ELECTRUM_WS_URL,
2221
+ * networks,
2222
+ * } from "@arkade-os/sdk";
2223
+ *
2224
+ * const ws = new ElectrumWS(ELECTRUM_WS_URL.bitcoin);
2225
+ * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
2226
+ *
2227
+ * const coins = await provider.getCoins("bc1q...");
2228
+ * await provider.close();
2229
+ * ```
2230
+ *
2231
+ * @example Custom server
2232
+ * ```typescript
2233
+ * const ws = new ElectrumWS("wss://my-fulcrum.example:50004");
2234
+ * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
2235
+ * ```
2236
+ */
2237
+ declare class ElectrumOnchainProvider implements OnchainProvider {
2238
+ private ws;
2239
+ private network;
2240
+ private chain;
2241
+ constructor(ws: ElectrumWS, network: Network);
2242
+ getCoins(address: string): Promise<Coin[]>;
2243
+ getFeeRate(): Promise<number | undefined>;
2244
+ /**
2245
+ * Broadcast a single transaction or a TRUC (BIP 431) 1P1C package
2246
+ * atomically.
2247
+ *
2248
+ * **Server requirements for 1P1C packages:** the backing Electrum
2249
+ * server must implement `blockchain.transaction.broadcast_package`
2250
+ * (Fulcrum ≥ 1.10) and be backed by bitcoind ≥ v28.0.0. ElectrumX
2251
+ * does not implement this method. There is **no fallback** to
2252
+ * sequential parent-then-child broadcast: TRUC packages typically
2253
+ * have a zero-fee parent and would be rejected from the mempool on
2254
+ * their own, so a fallback would silently fail in subtle ways.
2255
+ * Callers receiving a "method not found" error here should route
2256
+ * through a different provider for that submission.
2257
+ *
2258
+ * @param txs - One transaction (single broadcast) or two
2259
+ * topologically-sorted transactions (parent first,
2260
+ * child last) for 1P1C package relay.
2261
+ * @returns The broadcast txid (or the child txid for 1P1C packages).
2262
+ */
2263
+ broadcastTransaction(...txs: string[]): Promise<string>;
2264
+ getTxOutspends(txid: string): Promise<{
2265
+ spent: boolean;
2266
+ txid: string;
2267
+ }[]>;
2268
+ getTransactions(address: string): Promise<ExplorerTransaction[]>;
2269
+ /**
2270
+ * Resolve a list of `{tx_hash, height}` entries (as returned by the
2271
+ * scripthash history endpoint) into ExplorerTransaction shape **without
2272
+ * using the verbose-tx endpoint**, which only Fulcrum implements. We
2273
+ * reconstruct everything the verbose response would have given us:
2274
+ * - vouts ← parse the raw tx (exact sat amounts, no float precision risk)
2275
+ * - block_time ← batch-fetch the block headers for the heights present
2276
+ * - addresses ← decode each output's scriptPubKey via @scure/btc-signer
2277
+ */
2278
+ private historyToExplorerTxs;
2279
+ /**
2280
+ * Build an ExplorerTransaction from a history entry plus the raw tx hex
2281
+ * (when known) and a height→block_time map. Parse errors propagate —
2282
+ * silently returning an empty vout would hide real outputs (e.g. a
2283
+ * deposit) and is far worse for protocol-level money handling than
2284
+ * failing the whole batch.
2285
+ */
2286
+ private buildExplorerTx;
2287
+ /**
2288
+ * Decode `address` into its scriptPubKey, throwing a clear error if the
2289
+ * input is malformed. @scure/btc-signer raises a generic decode error
2290
+ * which is hard to map back to user input — this wraps it.
2291
+ */
2292
+ private encodeAddress;
2293
+ getTxStatus(txid: string): Promise<{
2294
+ confirmed: false;
2295
+ } | {
2296
+ confirmed: true;
2297
+ blockTime: number;
2298
+ blockHeight: number;
2299
+ }>;
2300
+ getChainTip(): Promise<{
2301
+ height: number;
2302
+ time: number;
2303
+ hash: string;
2304
+ }>;
2305
+ watchAddresses(addresses: string[], eventCallback: (txs: ExplorerTransaction[]) => void): Promise<() => void>;
2306
+ /** Close the underlying WebSocket connection. */
2307
+ close(): Promise<void>;
2308
+ }
2309
+
2310
+ type ArkTxInput = {
2311
+ tapLeafScript: TapLeafScript;
2312
+ } & EncodedVtxoScript & Pick<VirtualCoin, "txid" | "vout" | "value">;
2313
+ type OffchainTx = {
2314
+ arkTx: Transaction;
2315
+ checkpoints: Transaction[];
2316
+ };
2317
+ /**
2318
+ * Builds an offchain transaction with checkpoint transactions.
2319
+ *
2320
+ * Creates one checkpoint transaction per input and a virtual transaction that
2321
+ * combines all the checkpoints, sending to the specified outputs. This is the
2322
+ * core function for creating Arkade transactions.
2323
+ *
2324
+ * @param inputs - Array of virtual transaction inputs
2325
+ * @param outputs - Array of transaction outputs
2326
+ * @param serverUnrollScript - Server unroll script for checkpoint transactions
2327
+ * @returns Object containing the virtual transaction and checkpoint transactions
2328
+ */
2329
+ declare function buildOffchainTx(inputs: ArkTxInput[], outputs: TransactionOutput[], serverUnrollScript: CSVMultisigTapscript.Type): OffchainTx;
2330
+ declare function hasBoardingTxExpired(coin: ExtendedCoin, boardingTimelock: RelativeTimelock, chainTipHeight?: number): boolean;
2331
+ /**
2332
+ * Verify tapscript signatures on a transaction input
2333
+ * @param tx Transaction to verify
2334
+ * @param inputIndex Index of the input to verify
2335
+ * @param requiredSigners List of required signer pubkeys (hex encoded)
2336
+ * @param excludePubkeys List of pubkeys to exclude from verification (hex encoded, e.g., server key not yet signed)
2337
+ * @param allowedSighashTypes List of allowed sighash types (defaults to [SigHash.DEFAULT])
2338
+ * @throws Error if verification fails
2339
+ */
2340
+ declare function verifyTapscriptSignatures(tx: Transaction, inputIndex: number, requiredSigners: string[], excludePubkeys?: string[], allowedSighashTypes?: number[]): void;
2341
+ /**
2342
+ * Merges the signed transaction with the original transaction
2343
+ * @param signedTx signed transaction
2344
+ * @param originalTx original transaction
2345
+ */
2346
+ declare function combineTapscriptSigs(signedTx: Transaction, originalTx: Transaction): Transaction;
2347
+ /**
2348
+ * Validates if a given string is a valid Arkade address by attempting to decode it.
2349
+ * @param address The Arkade address to validate.
2350
+ * @returns True if the address is valid, false otherwise.
2351
+ */
2352
+ declare function isValidArkAddress(address: string): boolean;
2353
+
2354
+ declare function getRandomId(): string;
2355
+
2356
+ /**
2357
+ * ArkPsbtFieldKey are the available key names for the Arkade PSBT custom fields.
2358
+ */
2359
+ declare enum ArkPsbtFieldKey {
2360
+ VtxoTaprootTree = "taptree",
2361
+ VtxoTreeExpiry = "expiry",
2362
+ Cosigner = "cosigner",
2363
+ ConditionWitness = "condition"
2364
+ }
2365
+ /**
2366
+ * ArkPsbtFieldKeyType is the key type of the Arkade PSBT custom field.
2367
+ * Every Arkade PSBT field has key type 222.
2368
+ */
2369
+ declare const ArkPsbtFieldKeyType = 222;
2370
+ /**
2371
+ * ArkPsbtFieldCoder is the coder for the Arkade PSBT custom fields.
2372
+ * Each type has its own coder.
2373
+ */
2374
+ interface ArkPsbtFieldCoder<T> {
2375
+ key: ArkPsbtFieldKey;
2376
+ encode: (value: T) => NonNullable<TransactionInputUpdate["unknown"]>[number];
2377
+ decode: (value: NonNullable<TransactionInputUpdate["unknown"]>[number]) => T | null;
2378
+ }
2379
+ /**
2380
+ * setArkPsbtField appends a new unknown field to the input at inputIndex
2381
+ *
2382
+ * @example
2383
+ * ```typescript
2384
+ * setArkPsbtField(tx, 0, VtxoTaprootTree, myTaprootTree);
2385
+ * setArkPsbtField(tx, 0, VtxoTreeExpiry, myVtxoTreeExpiry);
2386
+ * ```
2387
+ */
2388
+ declare function setArkPsbtField<T>(tx: Transaction$1, inputIndex: number, coder: ArkPsbtFieldCoder<T>, value: T): void;
2389
+ /**
2390
+ * getArkPsbtFields returns all the values of the given coder for the input at inputIndex
2391
+ * Multiple fields of the same type can exist in a single input.
2392
+ *
2393
+ * @example
2394
+ * ```typescript
2395
+ * const vtxoTaprootTreeFields = getArkPsbtFields(tx, 0, VtxoTaprootTree);
2396
+ * console.log(`input has ${vtxoTaprootTreeFields.length} vtxoTaprootTree fields`);
2397
+ */
2398
+ declare function getArkPsbtFields<T>(tx: Transaction$1, inputIndex: number, coder: ArkPsbtFieldCoder<T>): T[];
2399
+ /**
2400
+ * VtxoTaprootTree is set to pass all spending leaves of the vtxo input
2401
+ *
2402
+ * @example
2403
+ * ```typescript
2404
+ * const vtxoTaprootTree = VtxoTaprootTree.encode(myTaprootTree);
2405
+ */
2406
+ declare const VtxoTaprootTree: ArkPsbtFieldCoder<Uint8Array>;
2407
+ /**
2408
+ * ConditionWitness is set to pass the witness data used to finalize the conditionMultisigClosure
2409
+ *
2410
+ * @example
2411
+ * ```typescript
2412
+ * const conditionWitness = ConditionWitness.encode(myConditionWitness);
2413
+ */
2414
+ declare const ConditionWitness: ArkPsbtFieldCoder<Uint8Array[]>;
2415
+ /**
2416
+ * CosignerPublicKey is set on every TxGraph transactions to identify the musig2 public keys
2417
+ *
2418
+ * @example
2419
+ * ```typescript
2420
+ * const cosignerPublicKey = CosignerPublicKey.encode(myCosignerPublicKey);
2421
+ */
2422
+ declare const CosignerPublicKey: ArkPsbtFieldCoder<{
2423
+ index: number;
2424
+ key: Uint8Array;
2425
+ }>;
2426
+ /**
2427
+ * VtxoTreeExpiry is set to pass the expiry time of the input
2428
+ *
2429
+ * @example
2430
+ * ```typescript
2431
+ * const vtxoTreeExpiry = VtxoTreeExpiry.encode(myVtxoTreeExpiry);
2432
+ */
2433
+ declare const VtxoTreeExpiry: ArkPsbtFieldCoder<{
2434
+ type: "blocks" | "seconds";
2435
+ value: bigint;
2436
+ }>;
2437
+
2438
+ /**
2439
+ * BIP-322 simple message signing and verification.
2440
+ *
2441
+ * Supports P2TR (Taproot) signing and verification, P2WPKH verification,
2442
+ * and legacy P2PKH verification (Bitcoin Core signmessage format).
2443
+ *
2444
+ * Reuses the same toSpend/toSign transaction construction as Intent proofs,
2445
+ * but with the standard BIP-322 tagged hash ("BIP0322-signed-message")
2446
+ * instead of the Arkade-specific tag.
2447
+ *
2448
+ * @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
2449
+ *
2450
+ * @example
2451
+ * ```typescript
2452
+ * // Sign a message (P2TR)
2453
+ * const signature = await BIP322.sign("Hello Bitcoin!", identity);
2454
+ *
2455
+ * // Verify a signature (P2TR or P2WPKH)
2456
+ * const valid = BIP322.verify("Hello Bitcoin!", signature, "bc1p...");
2457
+ * const valid2 = BIP322.verify("Hello Bitcoin!", signature, "bc1q...");
2458
+ * ```
2459
+ */
2460
+ declare namespace BIP322 {
2461
+ /**
2462
+ * Sign a message using the BIP-322 simple signature scheme.
2463
+ *
2464
+ * Constructs the standard BIP-322 toSpend and toSign transactions,
2465
+ * signs via the Identity interface, and returns the base64-encoded
2466
+ * witness stack.
2467
+ *
2468
+ * @param message - The message to sign
2469
+ * @param identity - Identity instance (holds the private key internally)
2470
+ * @param network - Optional Bitcoin network for P2TR address derivation
2471
+ * @returns Base64-encoded BIP-322 simple signature (witness stack)
2472
+ */
2473
+ function sign(message: string, identity: Identity, network?: BTC_NETWORK): Promise<string>;
2474
+ /**
2475
+ * Verify a BIP-322 signature for a P2TR, P2WPKH, or legacy P2PKH address.
2476
+ *
2477
+ * For segwit addresses (P2TR, P2WPKH), reconstructs the BIP-322
2478
+ * toSpend/toSign transactions and verifies the witness signature.
2479
+ *
2480
+ * For P2PKH addresses, verifies using the Bitcoin Core legacy
2481
+ * `signmessage` format (compact recoverable ECDSA signature).
2482
+ *
2483
+ * @param message - The original message that was signed
2484
+ * @param signature - Base64-encoded signature (BIP-322 witness or legacy compact)
2485
+ * @param address - P2TR, P2WPKH, or P2PKH address of the signer
2486
+ * @param network - Optional Bitcoin network for address decoding
2487
+ * @returns true if the signature is valid
2488
+ */
2489
+ function verify(message: string, signature: string, address: string, network?: BTC_NETWORK): boolean;
2490
+ }
2491
+
2492
+ /**
2493
+ * ArkNotes are special virtual outputs in the Arkade protocol that
2494
+ * can be created and spent without requiring any transactions.
2495
+ * The server mints them, and they are encoded as base58 strings
2496
+ * with a human-readable prefix, a preimage and a value.
2497
+ *
2498
+ * @see VtxoScript
2499
+ *
2500
+ * @example
2501
+ * ```typescript
2502
+ * // Create an ArkNote
2503
+ * const note = new ArkNote(preimage, 50000);
2504
+ *
2505
+ * // Encode to string
2506
+ * const noteString = note.toString();
2507
+ *
2508
+ * // Decode from string
2509
+ * const decodedNote = ArkNote.fromString(noteString);
2510
+ * ```
2511
+ */
2512
+ declare class ArkNote implements ExtendedCoin {
2513
+ preimage: Uint8Array;
2514
+ value: number;
2515
+ HRP: string;
2516
+ static readonly DefaultHRP = "arknote";
2517
+ static readonly PreimageLength = 32;
2518
+ static readonly ValueLength = 4;
2519
+ static readonly Length: number;
2520
+ static readonly FakeOutpointIndex = 0;
2521
+ readonly vtxoScript: VtxoScript;
2522
+ /** Hashlock script backing the note. */
2523
+ readonly txid: string;
2524
+ readonly vout = 0;
2525
+ readonly forfeitTapLeafScript: TapLeafScript;
2526
+ readonly intentTapLeafScript: TapLeafScript;
2527
+ readonly tapTree: Bytes;
2528
+ readonly status: Status;
2529
+ readonly extraWitness?: Bytes[] | undefined;
2530
+ /**
2531
+ * Create an ArkNote from a preimage and value.
2532
+ *
2533
+ * @param preimage - 32-byte preimage revealed to spend the note
2534
+ * @param value - Note value in satoshis
2535
+ * @param HRP - Optional human-readable prefix for string encoding
2536
+ */
2537
+ constructor(preimage: Uint8Array, value: number, HRP?: string);
2538
+ /**
2539
+ * Encode the note as raw bytes.
2540
+ *
2541
+ * @returns Serialized note bytes
2542
+ * @see decode
2543
+ */
2544
+ encode(): Uint8Array;
2545
+ /**
2546
+ * Decode a note from raw bytes.
2547
+ *
2548
+ * @param data - Serialized note bytes
2549
+ * @param hrp - Human-readable prefix expected for future string encoding
2550
+ * @returns Decoded ArkNote
2551
+ * @throws Error if the payload length is invalid
2552
+ * @see encode
2553
+ */
2554
+ static decode(data: Uint8Array, hrp?: string): ArkNote;
2555
+ /**
2556
+ * Decode a note from its base58 string form.
2557
+ *
2558
+ * @param noteStr - Base58-encoded note string
2559
+ * @param hrp - Human-readable prefix expected on the note string
2560
+ * @returns Decoded ArkNote
2561
+ * @throws Error if the prefix or base58 payload is invalid
2562
+ * @see toString
2563
+ */
2564
+ static fromString(noteStr: string, hrp?: string): ArkNote;
2565
+ /**
2566
+ * Encode the note to its human-readable base58 string form.
2567
+ *
2568
+ * @returns Base58-encoded note string
2569
+ * @see fromString
2570
+ */
2571
+ toString(): string;
2572
+ }
2573
+
2574
+ type VSize = {
2575
+ value: bigint;
2576
+ fee(feeRate: bigint): bigint;
2577
+ };
2578
+ declare class TxWeightEstimator {
2579
+ static readonly P2PKH_SCRIPT_SIG_SIZE: number;
2580
+ static readonly INPUT_SIZE: number;
2581
+ static readonly BASE_CONTROL_BLOCK_SIZE: number;
2582
+ static readonly OUTPUT_SIZE: number;
2583
+ static readonly P2WPKH_OUTPUT_SIZE: number;
2584
+ static readonly BASE_TX_SIZE: number;
2585
+ static readonly WITNESS_HEADER_SIZE = 2;
2586
+ static readonly WITNESS_SCALE_FACTOR = 4;
2587
+ static readonly P2TR_OUTPUT_SIZE: number;
2588
+ hasWitness: boolean;
2589
+ inputCount: number;
2590
+ outputCount: number;
2591
+ inputSize: number;
2592
+ inputWitnessSize: number;
2593
+ outputSize: number;
2594
+ private constructor();
2595
+ static create(): TxWeightEstimator;
2596
+ addP2AInput(): TxWeightEstimator;
2597
+ addKeySpendInput(isDefault?: boolean): TxWeightEstimator;
2598
+ addP2PKHInput(): TxWeightEstimator;
2599
+ addTapscriptInput(leafWitnessSize: number, leafScriptSize: number, leafControlBlockSize: number): TxWeightEstimator;
2600
+ addP2WPKHOutput(): TxWeightEstimator;
2601
+ addP2TROutput(): TxWeightEstimator;
2602
+ /**
2603
+ * Adds an output given a raw script.
2604
+ * Cost = 8 bytes (amount) + varint(scriptLen) + scriptLen
2605
+ */
2606
+ addOutputScript(script: Uint8Array): TxWeightEstimator;
2607
+ /**
2608
+ * Adds an output by decoding the address to get the exact script size.
2609
+ */
2610
+ addOutputAddress(address: string, network: Network): TxWeightEstimator;
2611
+ vsize(): VSize;
2612
+ }
2613
+
2614
+ declare namespace Unroll {
2615
+ enum StepType {
2616
+ UNROLL = 0,
2617
+ WAIT = 1,
2618
+ DONE = 2
2619
+ }
2620
+ /**
2621
+ * Unroll step where the transaction has to be broadcasted in a 1C1P package
2622
+ */
2623
+ type UnrollStep = {
2624
+ tx: Transaction;
2625
+ pkg: [parent: string, child: string];
2626
+ };
2627
+ /**
2628
+ * Wait step where the transaction has to be confirmed onchain
2629
+ */
2630
+ type WaitStep = {
2631
+ txid: string;
2632
+ };
2633
+ /**
2634
+ * Done step where the unrolling process is complete
2635
+ */
2636
+ type DoneStep = {
2637
+ vtxoTxid: string;
2638
+ };
2639
+ type Step = ({
2640
+ type: StepType.DONE;
2641
+ } & DoneStep) | ({
2642
+ type: StepType.UNROLL;
2643
+ } & UnrollStep) | ({
2644
+ type: StepType.WAIT;
2645
+ } & WaitStep);
2646
+ /**
2647
+ * Manages the unrolling process of a virtual output back to the Bitcoin blockchain.
2648
+ *
2649
+ * The Session class implements an async iterator that processes the unrolling steps:
2650
+ * 1. **WAIT**: Waits for a transaction to be confirmed onchain (if it's in mempool)
2651
+ * 2. **UNROLL**: Broadcasts the next transaction in the chain to the blockchain
2652
+ * 3. **DONE**: Indicates the unrolling process is complete
2653
+ *
2654
+ * The unrolling process works by traversing the transaction chain from the root (most recent)
2655
+ * to the leaf (oldest), broadcasting each transaction that isn't already onchain.
2656
+ *
2657
+ * @example
2658
+ * ```typescript
2659
+ * const session = await Unroll.Session.create(vtxoOutpoint, bumper, explorer, indexer);
2660
+ *
2661
+ * // iterate over the steps
2662
+ * for await (const doneStep of session) {
2663
+ * switch (doneStep.type) {
2664
+ * case Unroll.StepType.WAIT:
2665
+ * console.log(`Transaction ${doneStep.txid} confirmed`);
2666
+ * break;
2667
+ * case Unroll.StepType.UNROLL:
2668
+ * console.log(`Broadcasting transaction ${doneStep.tx.id}`);
2669
+ * break;
2670
+ * case Unroll.StepType.DONE:
2671
+ * console.log(`Unrolling complete for virtual output ${doneStep.vtxoTxid}`);
2672
+ * break;
2673
+ * }
2674
+ * }
2675
+ * ```
2676
+ **/
2677
+ class Session implements AsyncIterable<Step> {
2678
+ readonly toUnroll: Outpoint & {
2679
+ chain: ChainTx[];
2680
+ };
2681
+ readonly bumper: AnchorBumper;
2682
+ readonly explorer: OnchainProvider;
2683
+ readonly indexer: IndexerProvider;
2684
+ /** Create an unroll session from a virtual output outpoint and its dependency chain. */
2685
+ constructor(toUnroll: Outpoint & {
2686
+ chain: ChainTx[];
2687
+ }, bumper: AnchorBumper, explorer: OnchainProvider, indexer: IndexerProvider);
2688
+ /** Create an unroll session by loading the virtual output chain from the indexer. */
2689
+ static create(toUnroll: Outpoint, bumper: AnchorBumper, explorer: OnchainProvider, indexer: IndexerProvider): Promise<Session>;
2690
+ /**
2691
+ * Get the next step to be executed
2692
+ * @returns The next step to be executed + the function to execute it
2693
+ */
2694
+ next(): Promise<Step & {
2695
+ do: () => Promise<void>;
2696
+ }>;
2697
+ /**
2698
+ * Iterate over the steps to be executed and execute them
2699
+ * @returns An async iterator over the executed steps
2700
+ */
2701
+ [Symbol.asyncIterator](): AsyncIterator<Step>;
2702
+ }
2703
+ /**
2704
+ * Complete the unroll of a virtual output by broadcasting the transaction that spends the CSV path.
2705
+ * @param wallet the wallet owning the virtual output(s)
2706
+ * @param vtxoTxids the txids of the virtual output(s) to complete unroll
2707
+ * @param outputAddress the address to send the unrolled funds to
2708
+ * @throws if the virtual output(s) are not fully unrolled, if the txids are not found, if the tx is not confirmed, if no exit path is found or not available
2709
+ * @returns the txid of the transaction spending the unrolled funds
2710
+ */
2711
+ function completeUnroll(wallet: Wallet, vtxoTxids: string[], outputAddress: string): Promise<string>;
2712
+ }
2713
+
2714
+ declare class ArkError extends Error {
2715
+ readonly code: number;
2716
+ readonly message: string;
2717
+ readonly name: string;
2718
+ readonly metadata?: Record<string, string> | undefined;
2719
+ constructor(code: number, message: string, name: string, metadata?: Record<string, string> | undefined);
2720
+ }
2721
+ /**
2722
+ * Try to convert an error to an ArkError class, returning undefined if the error is not an ArkError
2723
+ * @param error - The error to parse
2724
+ * @returns The parsed ArkError, or undefined if the error is not an ArkError
2725
+ */
2726
+ declare function maybeArkError(error: any): ArkError | undefined;
2727
+
2728
+ declare function validateConnectorsTxGraph(settlementTxB64: string, connectorsGraph: TxTree): void;
2729
+ declare function validateVtxoTxGraph(graph: TxTree, roundTransaction: Transaction$2, sweepTapTreeRoot: Uint8Array): void;
2730
+
2731
+ /**
2732
+ * Build a forfeit transaction that spends the provided inputs to a single forfeit output.
2733
+ *
2734
+ * @param inputs - Inputs to include in the forfeit transaction
2735
+ * @param forfeitPkScript - ScriptPubKey for the forfeit output
2736
+ * @param txLocktime - Optional locktime to apply to the transaction
2737
+ */
2738
+ declare function buildForfeitTx(inputs: TransactionInputUpdate[], forfeitPkScript: Uint8Array, txLocktime?: number): Transaction;
2739
+
2740
+ declare enum AssetInputType {
2741
+ Unspecified = 0,
2742
+ Local = 1,
2743
+ Intent = 2
2744
+ }
2745
+ declare enum AssetRefType {
2746
+ Unspecified = 0,
2747
+ ByID = 1,
2748
+ ByGroup = 2
2749
+ }
2750
+
2751
+ declare class BufferWriter {
2752
+ private buffer;
2753
+ write(data: Uint8Array): void;
2754
+ writeByte(byte: number): void;
2755
+ writeUint16LE(value: number): void;
2756
+ writeVarUint(value: bigint | number): void;
2757
+ writeVarSlice(data: Uint8Array): void;
2758
+ toBytes(): Uint8Array;
2759
+ }
2760
+ declare class BufferReader {
2761
+ private view;
2762
+ private offset;
2763
+ constructor(data: Uint8Array);
2764
+ remaining(): number;
2765
+ readByte(): number;
2766
+ readSlice(size: number): Uint8Array;
2767
+ readUint16LE(): number;
2768
+ readVarUint(): bigint;
2769
+ readVarSlice(): Uint8Array;
2770
+ }
2771
+
2772
+ /**
2773
+ * AssetId identifies a specific asset.
2774
+ *
2775
+ * @remarks
2776
+ * Asset ids are derived from the genesis transaction id plus the asset group index.
2777
+ *
2778
+ * @see AssetRef
2779
+ *
2780
+ * @example
2781
+ * ```typescript
2782
+ * const assetId = AssetId.create('00'.repeat(32), 0)
2783
+ * const encoded = assetId.toString()
2784
+ * const decoded = AssetId.fromString(encoded)
2785
+ * ```
2786
+ */
2787
+ declare class AssetId {
2788
+ readonly txid: Uint8Array;
2789
+ readonly groupIndex: number;
2790
+ private constructor();
2791
+ /**
2792
+ * Create an asset id from a genesis transaction id and group index.
2793
+ *
2794
+ * @param txid - Hex-encoded genesis transaction id
2795
+ * @param groupIndex - Asset group index within the genesis transaction
2796
+ * @returns A validated asset id
2797
+ * @throws Error if the txid is missing, malformed, or not 32 bytes long
2798
+ * @see fromString
2799
+ */
2800
+ static create(txid: string, groupIndex: number): AssetId;
2801
+ /**
2802
+ * Decode an asset id from its hex string representation.
2803
+ *
2804
+ * @param s - Hex-encoded asset id
2805
+ * @returns Decoded asset id
2806
+ * @throws Error if the string is not valid hex or does not encode a valid asset id
2807
+ * @see toString
2808
+ */
2809
+ static fromString(s: string): AssetId;
2810
+ /**
2811
+ * Decode an asset id from its serialized bytes.
2812
+ *
2813
+ * @param buf - Serialized asset id bytes
2814
+ * @returns Decoded asset id
2815
+ * @throws Error if the buffer length is invalid
2816
+ */
2817
+ static fromBytes(buf: Uint8Array): AssetId;
2818
+ /**
2819
+ * Serialize the asset id to raw bytes.
2820
+ *
2821
+ * @returns Serialized asset id bytes
2822
+ * @see fromBytes
2823
+ */
2824
+ serialize(): Uint8Array;
2825
+ /**
2826
+ * Encode the asset id to a hex string.
2827
+ *
2828
+ * @returns Hex-encoded asset id
2829
+ * @see fromString
2830
+ */
2831
+ toString(): string;
2832
+ /**
2833
+ * Validate the asset id fields.
2834
+ *
2835
+ * @throws Error if the txid is empty or the group index is out of range
2836
+ */
2837
+ validate(): void;
2838
+ /**
2839
+ * Decode an asset id from a binary reader.
2840
+ *
2841
+ * @param reader - Reader positioned at an asset id
2842
+ * @returns Decoded asset id
2843
+ * @throws Error if the reader does not contain enough bytes
2844
+ */
2845
+ static fromReader(reader: BufferReader): AssetId;
2846
+ /**
2847
+ * Serialize the asset id into an existing binary writer.
2848
+ *
2849
+ * @param writer - Writer to append the asset id to
2850
+ * @see serialize
2851
+ */
2852
+ serializeTo(writer: BufferWriter): void;
2853
+ }
2854
+
2855
+ type AssetRefByID = {
2856
+ type: AssetRefType.ByID;
2857
+ assetId: AssetId;
2858
+ };
2859
+ type AssetRefByGroup = {
2860
+ type: AssetRefType.ByGroup;
2861
+ groupIndex: number;
2862
+ };
2863
+ /**
2864
+ * Reference to either an explicit asset id or another asset group in the same packet.
2865
+ *
2866
+ * @see AssetId
2867
+ *
2868
+ * @example
2869
+ * ```typescript
2870
+ * const refById = AssetRef.fromId(assetId)
2871
+ * const refByGroup = AssetRef.fromGroupIndex(0)
2872
+ * ```
2873
+ */
2874
+ declare class AssetRef {
2875
+ readonly ref: AssetRefByID | AssetRefByGroup;
2876
+ private constructor();
2877
+ /** Reference type discriminator. */
2878
+ get type(): AssetRefType;
2879
+ /**
2880
+ * Create an asset reference that points to a specific asset id.
2881
+ *
2882
+ * @param assetId - Asset id referenced by this pointer
2883
+ * @returns Asset reference by id
2884
+ * @see fromGroupIndex
2885
+ */
2886
+ static fromId(assetId: AssetId): AssetRef;
2887
+ /**
2888
+ * Create an asset reference that points to another asset group by index.
2889
+ *
2890
+ * @param groupIndex - Zero-based asset group index in the packet
2891
+ * @returns Asset reference by group index
2892
+ * @see fromId
2893
+ */
2894
+ static fromGroupIndex(groupIndex: number): AssetRef;
2895
+ /**
2896
+ * Decode an asset reference from its hex string form.
2897
+ *
2898
+ * @param s - Hex-encoded asset reference
2899
+ * @returns Decoded asset reference
2900
+ * @throws Error if the string is not valid hex or does not encode a valid asset reference
2901
+ * @see toString
2902
+ */
2903
+ static fromString(s: string): AssetRef;
2904
+ /**
2905
+ * Decode an asset reference from its serialized bytes.
2906
+ *
2907
+ * @param buf - Serialized asset reference bytes
2908
+ * @returns Decoded asset reference
2909
+ * @throws Error if the buffer is empty or malformed
2910
+ */
2911
+ static fromBytes(buf: Uint8Array): AssetRef;
2912
+ /**
2913
+ * Serialize the asset reference to raw bytes.
2914
+ *
2915
+ * @returns Serialized asset reference bytes
2916
+ * @see fromBytes
2917
+ */
2918
+ serialize(): Uint8Array;
2919
+ /**
2920
+ * Encode the asset reference to a hex string.
2921
+ *
2922
+ * @returns Hex-encoded asset reference
2923
+ * @see fromString
2924
+ */
2925
+ toString(): string;
2926
+ /**
2927
+ * Decode an asset reference from a binary reader.
2928
+ *
2929
+ * @param reader - Reader positioned at an asset reference
2930
+ * @returns Decoded asset reference
2931
+ * @throws Error if the type is unknown or the reader does not contain enough bytes
2932
+ */
2933
+ static fromReader(reader: BufferReader): AssetRef;
2934
+ /**
2935
+ * Serialize the asset reference into an existing binary writer.
2936
+ *
2937
+ * @param writer - Writer to append the asset reference to
2938
+ * @see serialize
2939
+ */
2940
+ serializeTo(writer: BufferWriter): void;
2941
+ }
2942
+
2943
+ type AssetInputLocal = {
2944
+ type: AssetInputType.Local;
2945
+ vin: number;
2946
+ amount: bigint;
2947
+ };
2948
+ type AssetInputIntent = Pick<AssetInputLocal, "vin" | "amount"> & {
2949
+ type: AssetInputType.Intent;
2950
+ txid: Uint8Array;
2951
+ };
2952
+ /**
2953
+ * AssetInput represents an input of an asset group.
2954
+ * a local input references a real transaction input and specify the amount in satoshis.
2955
+ * an intent input references an external intent transaction. It is created by the server to handle batch leaf transaction.
2956
+ */
2957
+ declare class AssetInput {
2958
+ readonly input: AssetInputLocal | AssetInputIntent;
2959
+ private constructor();
2960
+ /** Gets the transaction input index for an asset input, e.g. 0 */
2961
+ get vin(): number;
2962
+ /** Gets the amount for an input (in most cases, 330 sats) */
2963
+ get amount(): bigint;
2964
+ /** Create a local asset input that points at a transaction input index. */
2965
+ static create(vin: number, amount: bigint | number): AssetInput;
2966
+ /** Create an intent-backed asset input referencing an external intent transaction. */
2967
+ static createIntent(txid: string, vin: number, amount: bigint | number): AssetInput;
2968
+ /** Decode an asset input from its hex string form. */
2969
+ static fromString(s: string): AssetInput;
2970
+ /** Decode an asset input from its serialized bytes. */
2971
+ static fromBytes(buf: Uint8Array): AssetInput;
2972
+ /** Serialize the asset input to raw bytes. */
2973
+ serialize(): Uint8Array;
2974
+ /** Encode the asset input to a hex string. */
2975
+ toString(): string;
2976
+ /** Validate the asset input fields. */
2977
+ validate(): void;
2978
+ /** Decode an asset input from a buffer reader. */
2979
+ static fromReader(reader: BufferReader): AssetInput;
2980
+ /** Serialize the asset input into an existing buffer writer. */
2981
+ serializeTo(writer: BufferWriter): void;
2982
+ }
2983
+ /**
2984
+ * AssetInputs represents a list of asset inputs.
2985
+ */
2986
+ declare class AssetInputs {
2987
+ readonly inputs: AssetInput[];
2988
+ private constructor();
2989
+ /** Create a validated list of asset inputs. */
2990
+ static create(inputs: AssetInput[]): AssetInputs;
2991
+ /** Decode an asset input list from its hex string form. */
2992
+ static fromString(s: string): AssetInputs;
2993
+ /** Serialize the asset input list to raw bytes. */
2994
+ serialize(): Uint8Array;
2995
+ /** Encode the asset input list to a hex string. */
2996
+ toString(): string;
2997
+ /** Validate the asset input list. */
2998
+ validate(): void;
2999
+ /** Decode an asset input list from a buffer reader. */
3000
+ static fromReader(reader: BufferReader): AssetInputs;
3001
+ /** Serialize the asset input list into an existing buffer writer. */
3002
+ serializeTo(writer: BufferWriter): void;
3003
+ }
3004
+
3005
+ /**
3006
+ * AssetOutput references a real transaction output and specify the amount in satoshis.
3007
+ * it must be present in an AssetGroup.
3008
+ *
3009
+ * @param vout - the output index in the transaction
3010
+ * @param amount - asset amount in satoshis
3011
+ */
3012
+ declare class AssetOutput {
3013
+ readonly vout: number;
3014
+ readonly amount: bigint;
3015
+ static readonly TYPE_LOCAL = 1;
3016
+ private constructor();
3017
+ /** Create a local asset output referencing a transaction output index. */
3018
+ static create(vout: number, amount: bigint | number): AssetOutput;
3019
+ /** Decode an asset output from its hex string form. */
3020
+ static fromString(s: string): AssetOutput;
3021
+ /** Decode an asset output from its serialized bytes. */
3022
+ static fromBytes(buf: Uint8Array): AssetOutput;
3023
+ /** Serialize the asset output to raw bytes. */
3024
+ serialize(): Uint8Array;
3025
+ /** Encode the asset output to a hex string. */
3026
+ toString(): string;
3027
+ /** Validate the asset output fields. */
3028
+ validate(): void;
3029
+ /** Decode an asset output from a buffer reader. */
3030
+ static fromReader(reader: BufferReader): AssetOutput;
3031
+ /** Serialize the asset output into an existing buffer writer. */
3032
+ serializeTo(writer: BufferWriter): void;
3033
+ }
3034
+ /**
3035
+ * AssetOutputs is a list of AssetOutput references.
3036
+ * it must be present in an AssetGroup.
3037
+ *
3038
+ * @param outputs - the list of asset outputs
3039
+ */
3040
+ declare class AssetOutputs {
3041
+ readonly outputs: AssetOutput[];
3042
+ private constructor();
3043
+ /** Create a validated list of asset outputs. */
3044
+ static create(outputs: AssetOutput[]): AssetOutputs;
3045
+ /** Decode an asset output list from its hex string form. */
3046
+ static fromString(s: string): AssetOutputs;
3047
+ /** Serialize the asset output list to raw bytes. */
3048
+ serialize(): Uint8Array;
3049
+ /** Encode the asset output list to a hex string. */
3050
+ toString(): string;
3051
+ /** Validate the asset output list. */
3052
+ validate(): void;
3053
+ /** Decode an asset output list from a buffer reader. */
3054
+ static fromReader(reader: BufferReader): AssetOutputs;
3055
+ /** Serialize the asset output list into an existing buffer writer. */
3056
+ serializeTo(writer: BufferWriter): void;
3057
+ }
3058
+
3059
+ /**
3060
+ * Metadata represents a key-value pair.
3061
+ * @param key - the key
3062
+ * @param value - the value
3063
+ */
3064
+ declare class Metadata {
3065
+ readonly key: Uint8Array;
3066
+ readonly value: Uint8Array;
3067
+ private constructor();
3068
+ /** Create a metadata entry from raw key and value bytes. */
3069
+ static create(key: Bytes, value: Bytes): Metadata;
3070
+ /** Decode metadata from its hex string form. */
3071
+ static fromString(s: string): Metadata;
3072
+ /** Decode metadata from its serialized bytes. */
3073
+ static fromBytes(buf: Uint8Array): Metadata;
3074
+ /** Serialize metadata to raw bytes. */
3075
+ serialize(): Uint8Array;
3076
+ /** Encode metadata to a hex string. */
3077
+ toString(): string;
3078
+ get keyString(): string;
3079
+ get valueString(): string;
3080
+ /** Validate the metadata key and value. */
3081
+ validate(): void;
3082
+ /** Decode metadata from a buffer reader. */
3083
+ static fromReader(reader: BufferReader): Metadata;
3084
+ /** Serialize metadata into an existing buffer writer. */
3085
+ serializeTo(writer: BufferWriter): void;
3086
+ }
3087
+ declare class MetadataList {
3088
+ readonly items: Metadata[];
3089
+ static readonly ARK_LEAF_TAG = "ArkadeAssetLeaf";
3090
+ static readonly ARK_BRANCH_TAG = "ArkadeAssetBranch";
3091
+ static readonly ARK_LEAF_VERSION = 0;
3092
+ constructor(items: Metadata[]);
3093
+ /** Create a metadata list from its hex string form. */
3094
+ static fromString(s: string): MetadataList;
3095
+ /** Decode a metadata list from its serialized bytes. */
3096
+ static fromBytes(buf: Uint8Array): MetadataList;
3097
+ /** Decode a metadata list from a buffer reader. */
3098
+ static fromReader(reader: BufferReader): MetadataList;
3099
+ /** Serialize the metadata list into an existing buffer writer. */
3100
+ serializeTo(writer: BufferWriter): void;
3101
+ /** Serialize the metadata list to raw bytes. */
3102
+ serialize(): Uint8Array;
3103
+ /** Iterate through metadata entries in insertion order. */
3104
+ [Symbol.iterator](): Iterator<Metadata>;
3105
+ get length(): number;
3106
+ /** Compute the tagged Merkle root for the metadata list. */
3107
+ hash(): Uint8Array;
3108
+ }
3109
+
3110
+ /**
3111
+ * An asset group contains inputs, outputs, and all data related to a given asset id.
3112
+ *
3113
+ * @see Packet
3114
+ * @see AssetId
3115
+ * @see AssetRef
3116
+ *
3117
+ * @example
3118
+ * ```typescript
3119
+ * const group = AssetGroup.create(
3120
+ * null, // asset ID: null for new issuance
3121
+ * null, // control asset ID: null when reissuance not needed
3122
+ * [], // asset inputs: empty for new issuance
3123
+ * [AssetOutput.create(0, 1000)], // asset outputs: 1000 units at vout index 0
3124
+ * [] // metadata: can be empty
3125
+ * )
3126
+ * ```
3127
+ */
3128
+ declare class AssetGroup {
3129
+ readonly assetId: AssetId | null;
3130
+ readonly controlAsset: AssetRef | null;
3131
+ readonly inputs: AssetInput[];
3132
+ readonly outputs: AssetOutput[];
3133
+ private readonly metadataList;
3134
+ /** @see create */
3135
+ constructor(assetId: AssetId | null, controlAsset: AssetRef | null, inputs: AssetInput[], outputs: AssetOutput[], metadata: Metadata[]);
3136
+ /**
3137
+ * Create and validate an asset group.
3138
+ *
3139
+ * @param assetId - Asset id for this group, or `null` for fresh issuance
3140
+ * @param controlAsset - Optional control asset reference for (re) issuance
3141
+ * @param inputs - Asset inputs in the group
3142
+ * @param outputs - Asset outputs in the group
3143
+ * @param metadata - Metadata entries associated with the group
3144
+ * @returns A validated asset group
3145
+ * @throws Error if the group fails validation
3146
+ * @see validate
3147
+ */
3148
+ static create(assetId: AssetId | null, controlAsset: AssetRef | null, inputs: AssetInput[], outputs: AssetOutput[], metadata: Metadata[]): AssetGroup;
3149
+ /**
3150
+ * Decode an asset group from its hex string form.
3151
+ *
3152
+ * @param s - Hex-encoded asset group
3153
+ * @returns Decoded asset group
3154
+ * @throws Error if the string is not valid hex or does not encode a valid asset group
3155
+ * @see toString
3156
+ */
3157
+ static fromString(s: string): AssetGroup;
3158
+ /**
3159
+ * Decode an asset group from its serialized bytes.
3160
+ *
3161
+ * @param buf - Serialized asset group bytes
3162
+ * @returns Decoded asset group
3163
+ * @throws Error if the buffer is empty or malformed
3164
+ */
3165
+ static fromBytes(buf: Uint8Array): AssetGroup;
3166
+ /**
3167
+ * Return true when the group represents an issuance.
3168
+ *
3169
+ * @returns `true` when the group has no asset id
3170
+ */
3171
+ isIssuance(): boolean;
3172
+ /**
3173
+ * Return true when the group represents a reissuance.
3174
+ *
3175
+ * @returns `true` when the group has an asset id and outputs exceed local inputs
3176
+ * @remarks
3177
+ * Only local inputs contribute to the comparison; intent-backed inputs contribute `0` here.
3178
+ */
3179
+ isReissuance(): boolean;
3180
+ /**
3181
+ * Serialize the asset group to raw bytes.
3182
+ *
3183
+ * @returns Serialized asset group bytes
3184
+ * @see fromBytes
3185
+ */
3186
+ serialize(): Uint8Array;
3187
+ /**
3188
+ * Validate the asset group and its child structures.
3189
+ *
3190
+ * @throws Error if the group is empty or violates issuance invariants
3191
+ */
3192
+ validate(): void;
3193
+ /**
3194
+ * Convert the group into its batch-leaf representation for the given intent txid.
3195
+ *
3196
+ * @param intentTxid - Intent transaction id used to build the leaf input reference
3197
+ * @returns Batch-leaf asset group
3198
+ * @see AssetInput.createIntent
3199
+ */
3200
+ toBatchLeafAssetGroup(intentTxid: Uint8Array): AssetGroup;
3201
+ /**
3202
+ * Encode the asset group to a hex string.
3203
+ *
3204
+ * @returns Hex-encoded asset group
3205
+ * @see fromString
3206
+ */
3207
+ toString(): string;
3208
+ /**
3209
+ * Decode an asset group from a binary reader.
3210
+ *
3211
+ * @param reader - Reader positioned at an asset group
3212
+ * @returns Decoded asset group
3213
+ * @throws Error if the encoded group is malformed
3214
+ */
3215
+ static fromReader(reader: BufferReader): AssetGroup;
3216
+ /**
3217
+ * Serialize the asset group into an existing binary writer.
3218
+ *
3219
+ * @param writer - Writer to append the asset group to
3220
+ */
3221
+ serializeTo(writer: BufferWriter): void;
3222
+ }
3223
+
3224
+ /**
3225
+ * ExtensionPacket is the interface that all extension packets must implement.
3226
+ * It mirrors the Go extension.Packet interface.
3227
+ */
3228
+ interface ExtensionPacket {
3229
+ /** type returns the 1-byte packet type tag */
3230
+ type(): number;
3231
+ /** serialize returns the raw bytes of the packet (without type or length prefix) */
3232
+ serialize(): Uint8Array;
3233
+ }
3234
+
3235
+ /**
3236
+ * Packet represents a collection of asset groups.
3237
+ * It encodes/decodes as raw bytes only — OP_RETURN framing is handled by the Extension module.
3238
+ */
3239
+ declare class Packet implements ExtensionPacket {
3240
+ readonly groups: AssetGroup[];
3241
+ /** PACKET_TYPE is the 1-byte TLV type tag used in the Extension envelope. */
3242
+ static readonly PACKET_TYPE = 0;
3243
+ private constructor();
3244
+ /** Create a validated asset packet from a list of asset groups. */
3245
+ static create(groups: AssetGroup[]): Packet;
3246
+ /**
3247
+ * fromBytes parses a Packet from raw bytes.
3248
+ */
3249
+ static fromBytes(buf: Uint8Array): Packet;
3250
+ /**
3251
+ * fromString parses a Packet from a raw hex string (not an OP_RETURN script).
3252
+ */
3253
+ static fromString(s: string): Packet;
3254
+ /**
3255
+ * type returns the TLV packet type tag. Implements ExtensionPacket interface.
3256
+ */
3257
+ type(): number;
3258
+ /** Convert the packet into the batch-leaf form for a specific intent transaction id. */
3259
+ leafTxPacket(intentTxid: Uint8Array): Packet;
3260
+ /**
3261
+ * serialize encodes the packet as raw bytes (varint group count + group data).
3262
+ * Does NOT include OP_RETURN, Arkade magic bytes (`ARK`), or TLV type/length; those are
3263
+ * added by the Extension module.
3264
+ */
3265
+ serialize(): Uint8Array;
3266
+ /**
3267
+ * toString returns the hex-encoded raw packet bytes.
3268
+ */
3269
+ toString(): string;
3270
+ /** Validate packet structure and cross-group references. */
3271
+ validate(): void;
3272
+ private static fromReader;
3273
+ }
3274
+
3275
+ type index_AssetGroup = AssetGroup;
3276
+ declare const index_AssetGroup: typeof AssetGroup;
3277
+ type index_AssetId = AssetId;
3278
+ declare const index_AssetId: typeof AssetId;
3279
+ type index_AssetInput = AssetInput;
3280
+ declare const index_AssetInput: typeof AssetInput;
3281
+ type index_AssetInputType = AssetInputType;
3282
+ declare const index_AssetInputType: typeof AssetInputType;
3283
+ type index_AssetInputs = AssetInputs;
3284
+ declare const index_AssetInputs: typeof AssetInputs;
3285
+ type index_AssetOutput = AssetOutput;
3286
+ declare const index_AssetOutput: typeof AssetOutput;
3287
+ type index_AssetOutputs = AssetOutputs;
3288
+ declare const index_AssetOutputs: typeof AssetOutputs;
3289
+ type index_AssetRef = AssetRef;
3290
+ declare const index_AssetRef: typeof AssetRef;
3291
+ type index_AssetRefType = AssetRefType;
3292
+ declare const index_AssetRefType: typeof AssetRefType;
3293
+ type index_Metadata = Metadata;
3294
+ declare const index_Metadata: typeof Metadata;
3295
+ type index_MetadataList = MetadataList;
3296
+ declare const index_MetadataList: typeof MetadataList;
3297
+ type index_Packet = Packet;
3298
+ declare const index_Packet: typeof Packet;
3299
+ declare namespace index {
3300
+ export { index_AssetGroup as AssetGroup, index_AssetId as AssetId, index_AssetInput as AssetInput, index_AssetInputType as AssetInputType, index_AssetInputs as AssetInputs, index_AssetOutput as AssetOutput, index_AssetOutputs as AssetOutputs, index_AssetRef as AssetRef, index_AssetRefType as AssetRefType, index_Metadata as Metadata, index_MetadataList as MetadataList, index_Packet as Packet };
3301
+ }
3302
+
3303
+ /**
3304
+ * Convert RelativeTimelock to BIP68 sequence number.
3305
+ */
3306
+ declare function timelockToSequence(timelock: RelativeTimelock): number;
3307
+ /**
3308
+ * Convert BIP68 sequence number back to RelativeTimelock.
3309
+ */
3310
+ declare function sequenceToTimelock(sequence: number): RelativeTimelock;
3311
+
3312
+ /**
3313
+ * Opens an IndexedDB database and increments the reference count.
3314
+ * Handles global object detection and callbacks.
3315
+ *
3316
+ * @param dbName The name of the database to open.
3317
+ * @param dbVersion The database version to open.
3318
+ * @param initDatabase A function that migrates the database schema, called
3319
+ * on `onupgradeneeded` only. Receives the database, the previous version
3320
+ * (0 for fresh installs), and the upgrade transaction — the transaction is
3321
+ * required for data migrations (cursor/update on existing stores).
3322
+ *
3323
+ * @returns A promise that resolves to the database instance.
3324
+ */
3325
+ declare function openDatabase(dbName: string, dbVersion: number, initDatabase: (db: IDBDatabase, oldVersion: number, transaction: IDBTransaction | null) => void): Promise<IDBDatabase>;
3326
+ /**
3327
+ * Decrements the reference count and closes the database when no references remain.
3328
+ *
3329
+ * @param dbName The name of the database to close.
3330
+ *
3331
+ * @returns True if the database was closed, false otherwise.
3332
+ */
3333
+ declare function closeDatabase(dbName: string): Promise<boolean>;
3334
+
3335
+ declare const MESSAGE_BUS_NOT_INITIALIZED = "MessageBus not initialized";
3336
+ declare class MessageBusNotInitializedError extends Error {
3337
+ constructor();
3338
+ }
3339
+ declare class ServiceWorkerTimeoutError extends Error {
3340
+ constructor(detail: string);
3341
+ }
3342
+
3343
+ export { type AnchorBumper, ArkError, ArkNote, ArkProvider, type ArkPsbtFieldCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, ArkTransaction, type ArkTxInput, AssetDetails, BIP322, BurnParams, CSVMultisigTapscript, ChainTx, Coin, ConditionWitness, Contract, ContractEvent, ContractRepository, ContractRepositoryImpl, ContractWatcherConfig, ContractWithVtxos, CosignerPublicKey, CreateContractParams, DEFAULT_MESSAGE_TIMEOUTS, DelegateInfo, DelegatorNotConfiguredError, type DescriptorOptions, DescriptorSigningProviderMissingError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, type BlockHeader as ElectrumBlockHeader, ElectrumOnchainProvider, type TransactionHistory as ElectrumTransactionHistory, type Unspent as ElectrumUnspent, EncodedVtxoScript, Estimator, ExplorerTransaction, ExtendedCoin, ExtendedVirtualCoin, FeeAmount, FeeInfo, FeeOutput, GetVtxosFilter, HDDescriptorProvider, IContractManager, IDelegatorManager, IReadonlyWallet, IVtxoManager, IWallet, Identity, InMemoryContractRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBWalletRepository, IndexerProvider, IntentFeeConfig, IssuanceParams, IssuanceResult, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MessageBus, MessageBusNotInitializedError, type MessageHandler, type MessageTimeouts, type MigrationStatus, MissingSigningDescriptorError, MnemonicIdentity, type MnemonicOptions, Network, NetworkName, type NetworkOptions, OffchainInput, type OffchainTx, OnchainInput, OnchainProvider, OnchainWallet, Outpoint, P2A, type ParsedArkContract, PathSelection, Ramps, ReadonlyDescriptorIdentity, ReadonlyIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, Recipient, ReissuanceParams, RelativeTimelock, type RequestEnvelope, type ResponseEnvelope, SeedIdentity, type SeedIdentityOptions, SendBitcoinParams, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, type ServiceWorkerWalletMode, SettleParams, SettlementConfig, SettlementEvent, SignerSession, SingleKey, Status, StorageConfig, TapLeafScript, Transaction, TxTree, TxWeightEstimator, Unroll, type VSize, VirtualCoin, VtxoScript, VtxoTaprootTree, VtxoTreeExpiry, Wallet, WalletBalance, WalletMessageHandler, WalletNotInitializedError, WalletRepository, WalletRepositoryImpl, WsElectrumChainSource, index as asset, buildForfeitTx, buildOffchainTx, closeDatabase, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, decodeArkContract, encodeArkContract, getArkPsbtFields, getMigrationStatus, getRandomId, hasBoardingTxExpired, isArkContract, isValidArkAddress, maybeArkError, migrateWalletRepository, openDatabase, requiresMigration, rollbackMigration, sequenceToTimelock, setArkPsbtField, setupServiceWorker, timelockToSequence, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures };