@arkade-os/sdk 0.4.27 → 0.4.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (532) hide show
  1. package/README.md +45 -116
  2. package/dist/adapters/asyncStorage.cjs +48 -0
  3. package/dist/adapters/asyncStorage.cjs.map +1 -0
  4. package/dist/adapters/asyncStorage.d.cts +16 -0
  5. package/dist/{types/storage → adapters}/asyncStorage.d.ts +5 -2
  6. package/dist/adapters/asyncStorage.js +46 -0
  7. package/dist/adapters/asyncStorage.js.map +1 -0
  8. package/dist/adapters/expo.cjs +19 -0
  9. package/dist/adapters/expo.cjs.map +1 -0
  10. package/dist/adapters/expo.d.cts +48 -0
  11. package/dist/adapters/expo.d.ts +48 -0
  12. package/dist/adapters/expo.js +6 -0
  13. package/dist/adapters/expo.js.map +1 -0
  14. package/dist/adapters/fileSystem.cjs +116 -0
  15. package/dist/adapters/fileSystem.cjs.map +1 -0
  16. package/dist/adapters/fileSystem.d.cts +17 -0
  17. package/dist/{types/storage → adapters}/fileSystem.d.ts +5 -2
  18. package/dist/adapters/fileSystem.js +93 -0
  19. package/dist/adapters/fileSystem.js.map +1 -0
  20. package/dist/adapters/indexedDB.cjs +103 -0
  21. package/dist/adapters/indexedDB.cjs.map +1 -0
  22. package/dist/adapters/indexedDB.d.cts +18 -0
  23. package/dist/{types/storage → adapters}/indexedDB.d.ts +5 -2
  24. package/dist/adapters/indexedDB.js +101 -0
  25. package/dist/adapters/indexedDB.js.map +1 -0
  26. package/dist/adapters/localStorage.cjs +50 -0
  27. package/dist/adapters/localStorage.cjs.map +1 -0
  28. package/dist/{types/storage/inMemory.d.ts → adapters/localStorage.d.cts} +6 -3
  29. package/dist/{types/storage → adapters}/localStorage.d.ts +5 -2
  30. package/dist/adapters/localStorage.js +48 -0
  31. package/dist/adapters/localStorage.js.map +1 -0
  32. package/dist/ark-ChhTwpLf.d.cts +3892 -0
  33. package/dist/ark-ChhTwpLf.d.ts +3892 -0
  34. package/dist/asyncStorageTaskQueue-DW1-BpI7.d.cts +49 -0
  35. package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-DZ0nUuEJ.d.ts} +6 -3
  36. package/dist/chunk-5BLDMQED.cjs +18 -0
  37. package/dist/chunk-5BLDMQED.cjs.map +1 -0
  38. package/dist/chunk-6FLL2Q36.cjs +2701 -0
  39. package/dist/chunk-6FLL2Q36.cjs.map +1 -0
  40. package/dist/chunk-6NWNOLL3.js +2671 -0
  41. package/dist/chunk-6NWNOLL3.js.map +1 -0
  42. package/dist/chunk-ABWRLTX5.js +210 -0
  43. package/dist/chunk-ABWRLTX5.js.map +1 -0
  44. package/dist/chunk-BVP2U66Q.js +13943 -0
  45. package/dist/chunk-BVP2U66Q.js.map +1 -0
  46. package/dist/chunk-GDCTOSMV.cjs +14058 -0
  47. package/dist/chunk-GDCTOSMV.cjs.map +1 -0
  48. package/dist/chunk-GIGILVVP.cjs +213 -0
  49. package/dist/chunk-GIGILVVP.cjs.map +1 -0
  50. package/dist/chunk-IEO3XDKI.cjs +838 -0
  51. package/dist/chunk-IEO3XDKI.cjs.map +1 -0
  52. package/dist/chunk-NSBPE2FW.js +15 -0
  53. package/dist/chunk-NSBPE2FW.js.map +1 -0
  54. package/dist/chunk-PJUFOJ2L.cjs +100 -0
  55. package/dist/chunk-PJUFOJ2L.cjs.map +1 -0
  56. package/dist/chunk-TH6T23XG.js +95 -0
  57. package/dist/chunk-TH6T23XG.js.map +1 -0
  58. package/dist/chunk-TU3LVAPX.js +769 -0
  59. package/dist/chunk-TU3LVAPX.js.map +1 -0
  60. package/dist/chunk-WMIPYZSB.cjs +803 -0
  61. package/dist/chunk-WMIPYZSB.cjs.map +1 -0
  62. package/dist/chunk-YA4G7RFB.js +829 -0
  63. package/dist/chunk-YA4G7RFB.js.map +1 -0
  64. package/dist/contracts/handlers/index.cjs +26 -0
  65. package/dist/contracts/handlers/index.cjs.map +1 -0
  66. package/dist/contracts/handlers/index.d.cts +7 -0
  67. package/dist/contracts/handlers/index.d.ts +7 -0
  68. package/dist/contracts/handlers/index.js +5 -0
  69. package/dist/contracts/handlers/index.js.map +1 -0
  70. package/dist/delegate-4JBUkUhR.d.cts +84 -0
  71. package/dist/delegate-DN7RELL1.d.ts +84 -0
  72. package/dist/{types/storage/index.d.ts → index-C0IanN1m.d.cts} +3 -1
  73. package/dist/index-C0IanN1m.d.ts +11 -0
  74. package/dist/index-Cn82bBUu.d.ts +199 -0
  75. package/dist/index-DfT5xzgY.d.cts +199 -0
  76. package/dist/index.cjs +504 -0
  77. package/dist/index.cjs.map +1 -0
  78. package/dist/index.d.cts +3469 -0
  79. package/dist/index.d.ts +3469 -0
  80. package/dist/index.js +7 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/repositories/realm/index.cjs +513 -0
  83. package/dist/repositories/realm/index.cjs.map +1 -0
  84. package/dist/repositories/realm/index.d.cts +217 -0
  85. package/dist/{types/repositories/realm/schemas.d.ts → repositories/realm/index.d.ts} +80 -112
  86. package/dist/repositories/realm/index.js +507 -0
  87. package/dist/repositories/realm/index.js.map +1 -0
  88. package/dist/repositories/sqlite/index.cjs +588 -0
  89. package/dist/repositories/sqlite/index.cjs.map +1 -0
  90. package/dist/repositories/sqlite/index.d.cts +118 -0
  91. package/dist/{types/repositories/sqlite/walletRepository.d.ts → repositories/sqlite/index.d.ts} +58 -5
  92. package/dist/repositories/sqlite/index.js +585 -0
  93. package/dist/repositories/sqlite/index.js.map +1 -0
  94. package/dist/taskRunner-B-aPfHhK.d.cts +114 -0
  95. package/dist/taskRunner-B-vG08pX.d.ts +114 -0
  96. package/dist/wallet/expo/background.cjs +93 -0
  97. package/dist/wallet/expo/background.cjs.map +1 -0
  98. package/dist/wallet/expo/background.d.cts +84 -0
  99. package/dist/wallet/expo/background.d.ts +84 -0
  100. package/dist/wallet/expo/background.js +68 -0
  101. package/dist/wallet/expo/background.js.map +1 -0
  102. package/dist/wallet/expo/index.cjs +175 -0
  103. package/dist/wallet/expo/index.cjs.map +1 -0
  104. package/dist/wallet/expo/index.d.cts +124 -0
  105. package/dist/wallet/expo/index.d.ts +124 -0
  106. package/dist/wallet/expo/index.js +173 -0
  107. package/dist/wallet/expo/index.js.map +1 -0
  108. package/dist/wallet-CCtqT2Wb.d.ts +778 -0
  109. package/dist/wallet-DjgFb_4T.d.cts +778 -0
  110. package/dist/worker/expo/index.cjs +140 -0
  111. package/dist/worker/expo/index.cjs.map +1 -0
  112. package/dist/worker/expo/index.d.cts +29 -0
  113. package/dist/worker/expo/index.d.ts +29 -0
  114. package/dist/worker/expo/index.js +121 -0
  115. package/dist/worker/expo/index.js.map +1 -0
  116. package/package.json +110 -76
  117. package/dist/cjs/adapters/asyncStorage.js +0 -5
  118. package/dist/cjs/adapters/expo.js +0 -8
  119. package/dist/cjs/adapters/fileSystem.js +0 -5
  120. package/dist/cjs/adapters/indexedDB.js +0 -5
  121. package/dist/cjs/adapters/localStorage.js +0 -5
  122. package/dist/cjs/arkfee/celenv.js +0 -43
  123. package/dist/cjs/arkfee/estimator.js +0 -143
  124. package/dist/cjs/arkfee/index.js +0 -5
  125. package/dist/cjs/arkfee/types.js +0 -26
  126. package/dist/cjs/arknote/index.js +0 -128
  127. package/dist/cjs/bip322/index.js +0 -270
  128. package/dist/cjs/contracts/arkcontract.js +0 -147
  129. package/dist/cjs/contracts/contractManager.js +0 -649
  130. package/dist/cjs/contracts/contractWatcher.js +0 -598
  131. package/dist/cjs/contracts/handlers/default.js +0 -93
  132. package/dist/cjs/contracts/handlers/delegate.js +0 -90
  133. package/dist/cjs/contracts/handlers/helpers.js +0 -115
  134. package/dist/cjs/contracts/handlers/index.js +0 -19
  135. package/dist/cjs/contracts/handlers/registry.js +0 -89
  136. package/dist/cjs/contracts/handlers/vhtlc.js +0 -194
  137. package/dist/cjs/contracts/index.js +0 -41
  138. package/dist/cjs/contracts/types.js +0 -2
  139. package/dist/cjs/contracts/vtxoOwnership.js +0 -78
  140. package/dist/cjs/extension/asset/assetGroup.js +0 -228
  141. package/dist/cjs/extension/asset/assetId.js +0 -152
  142. package/dist/cjs/extension/asset/assetInput.js +0 -222
  143. package/dist/cjs/extension/asset/assetOutput.js +0 -174
  144. package/dist/cjs/extension/asset/assetRef.js +0 -148
  145. package/dist/cjs/extension/asset/index.js +0 -23
  146. package/dist/cjs/extension/asset/metadata.js +0 -187
  147. package/dist/cjs/extension/asset/packet.js +0 -114
  148. package/dist/cjs/extension/asset/types.js +0 -22
  149. package/dist/cjs/extension/asset/utils.js +0 -105
  150. package/dist/cjs/extension/index.js +0 -254
  151. package/dist/cjs/extension/packet.js +0 -20
  152. package/dist/cjs/forfeit.js +0 -45
  153. package/dist/cjs/identity/descriptor.js +0 -169
  154. package/dist/cjs/identity/descriptorProvider.js +0 -2
  155. package/dist/cjs/identity/hdCapableIdentity.js +0 -20
  156. package/dist/cjs/identity/index.js +0 -40
  157. package/dist/cjs/identity/seedIdentity.js +0 -477
  158. package/dist/cjs/identity/serialize.js +0 -171
  159. package/dist/cjs/identity/singleKey.js +0 -126
  160. package/dist/cjs/identity/staticDescriptorProvider.js +0 -65
  161. package/dist/cjs/index.js +0 -202
  162. package/dist/cjs/intent/index.js +0 -259
  163. package/dist/cjs/musig2/index.js +0 -11
  164. package/dist/cjs/musig2/keys.js +0 -57
  165. package/dist/cjs/musig2/nonces.js +0 -48
  166. package/dist/cjs/musig2/sign.js +0 -102
  167. package/dist/cjs/networks.js +0 -26
  168. package/dist/cjs/package.json +0 -3
  169. package/dist/cjs/providers/ark.js +0 -577
  170. package/dist/cjs/providers/delegator.js +0 -85
  171. package/dist/cjs/providers/electrum.js +0 -869
  172. package/dist/cjs/providers/errors.js +0 -59
  173. package/dist/cjs/providers/expoArk.js +0 -82
  174. package/dist/cjs/providers/expoIndexer.js +0 -111
  175. package/dist/cjs/providers/expoUtils.js +0 -124
  176. package/dist/cjs/providers/indexer.js +0 -630
  177. package/dist/cjs/providers/onchain.js +0 -262
  178. package/dist/cjs/providers/utils.js +0 -121
  179. package/dist/cjs/repositories/contractRepository.js +0 -2
  180. package/dist/cjs/repositories/inMemory/contractRepository.js +0 -55
  181. package/dist/cjs/repositories/inMemory/walletRepository.js +0 -115
  182. package/dist/cjs/repositories/index.js +0 -34
  183. package/dist/cjs/repositories/indexedDB/contractRepository.js +0 -187
  184. package/dist/cjs/repositories/indexedDB/db.js +0 -19
  185. package/dist/cjs/repositories/indexedDB/manager.js +0 -100
  186. package/dist/cjs/repositories/indexedDB/schema.js +0 -204
  187. package/dist/cjs/repositories/indexedDB/walletRepository.js +0 -474
  188. package/dist/cjs/repositories/indexedDB/websqlAdapter.js +0 -144
  189. package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +0 -127
  190. package/dist/cjs/repositories/migrations/fromStorageAdapter.js +0 -66
  191. package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +0 -184
  192. package/dist/cjs/repositories/realm/contractRepository.js +0 -116
  193. package/dist/cjs/repositories/realm/index.js +0 -11
  194. package/dist/cjs/repositories/realm/schemas.js +0 -157
  195. package/dist/cjs/repositories/realm/types.js +0 -7
  196. package/dist/cjs/repositories/realm/walletRepository.js +0 -305
  197. package/dist/cjs/repositories/scriptFromAddress.js +0 -16
  198. package/dist/cjs/repositories/serialization.js +0 -82
  199. package/dist/cjs/repositories/sqlite/contractRepository.js +0 -135
  200. package/dist/cjs/repositories/sqlite/index.js +0 -7
  201. package/dist/cjs/repositories/sqlite/types.js +0 -2
  202. package/dist/cjs/repositories/sqlite/walletRepository.js +0 -441
  203. package/dist/cjs/repositories/walletRepository.js +0 -2
  204. package/dist/cjs/script/address.js +0 -108
  205. package/dist/cjs/script/base.js +0 -185
  206. package/dist/cjs/script/default.js +0 -57
  207. package/dist/cjs/script/delegate.js +0 -53
  208. package/dist/cjs/script/tapscript.js +0 -619
  209. package/dist/cjs/script/vhtlc.js +0 -170
  210. package/dist/cjs/storage/asyncStorage.js +0 -50
  211. package/dist/cjs/storage/fileSystem.js +0 -141
  212. package/dist/cjs/storage/inMemory.js +0 -24
  213. package/dist/cjs/storage/index.js +0 -2
  214. package/dist/cjs/storage/indexedDB.js +0 -101
  215. package/dist/cjs/storage/localStorage.js +0 -51
  216. package/dist/cjs/tree/signingSession.js +0 -229
  217. package/dist/cjs/tree/txTree.js +0 -192
  218. package/dist/cjs/tree/validation.js +0 -107
  219. package/dist/cjs/utils/anchor.js +0 -35
  220. package/dist/cjs/utils/arkTransaction.js +0 -271
  221. package/dist/cjs/utils/bip21.js +0 -127
  222. package/dist/cjs/utils/syncCursors.js +0 -128
  223. package/dist/cjs/utils/timelock.js +0 -59
  224. package/dist/cjs/utils/transaction.js +0 -28
  225. package/dist/cjs/utils/transactionHistory.js +0 -183
  226. package/dist/cjs/utils/txSizeEstimator.js +0 -132
  227. package/dist/cjs/utils/unknownFields.js +0 -174
  228. package/dist/cjs/wallet/asset-manager.js +0 -330
  229. package/dist/cjs/wallet/asset.js +0 -119
  230. package/dist/cjs/wallet/batch.js +0 -183
  231. package/dist/cjs/wallet/delegator.js +0 -308
  232. package/dist/cjs/wallet/expo/background.js +0 -116
  233. package/dist/cjs/wallet/expo/index.js +0 -9
  234. package/dist/cjs/wallet/expo/wallet.js +0 -230
  235. package/dist/cjs/wallet/hdDescriptorProvider.js +0 -188
  236. package/dist/cjs/wallet/index.js +0 -82
  237. package/dist/cjs/wallet/inputSignerRouter.js +0 -98
  238. package/dist/cjs/wallet/onchain.js +0 -290
  239. package/dist/cjs/wallet/ramps.js +0 -216
  240. package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +0 -953
  241. package/dist/cjs/wallet/serviceWorker/wallet.js +0 -1174
  242. package/dist/cjs/wallet/signingErrors.js +0 -32
  243. package/dist/cjs/wallet/unroll.js +0 -293
  244. package/dist/cjs/wallet/utils.js +0 -111
  245. package/dist/cjs/wallet/validation.js +0 -154
  246. package/dist/cjs/wallet/vtxo-manager.js +0 -1142
  247. package/dist/cjs/wallet/wallet.js +0 -2195
  248. package/dist/cjs/wallet/walletReceiveRotator.js +0 -547
  249. package/dist/cjs/worker/browser/service-worker-manager.js +0 -183
  250. package/dist/cjs/worker/browser/utils.js +0 -67
  251. package/dist/cjs/worker/errors.js +0 -16
  252. package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +0 -78
  253. package/dist/cjs/worker/expo/index.js +0 -13
  254. package/dist/cjs/worker/expo/processors/contractPollProcessor.js +0 -62
  255. package/dist/cjs/worker/expo/processors/index.js +0 -6
  256. package/dist/cjs/worker/expo/taskQueue.js +0 -41
  257. package/dist/cjs/worker/expo/taskRunner.js +0 -73
  258. package/dist/cjs/worker/messageBus.js +0 -474
  259. package/dist/esm/adapters/asyncStorage.js +0 -1
  260. package/dist/esm/adapters/expo.js +0 -3
  261. package/dist/esm/adapters/fileSystem.js +0 -1
  262. package/dist/esm/adapters/indexedDB.js +0 -1
  263. package/dist/esm/adapters/localStorage.js +0 -1
  264. package/dist/esm/arkfee/celenv.js +0 -40
  265. package/dist/esm/arkfee/estimator.js +0 -139
  266. package/dist/esm/arkfee/index.js +0 -1
  267. package/dist/esm/arkfee/types.js +0 -22
  268. package/dist/esm/arknote/index.js +0 -124
  269. package/dist/esm/bip322/index.js +0 -267
  270. package/dist/esm/contracts/arkcontract.js +0 -140
  271. package/dist/esm/contracts/contractManager.js +0 -645
  272. package/dist/esm/contracts/contractWatcher.js +0 -594
  273. package/dist/esm/contracts/handlers/default.js +0 -90
  274. package/dist/esm/contracts/handlers/delegate.js +0 -87
  275. package/dist/esm/contracts/handlers/helpers.js +0 -110
  276. package/dist/esm/contracts/handlers/index.js +0 -12
  277. package/dist/esm/contracts/handlers/registry.js +0 -86
  278. package/dist/esm/contracts/handlers/vhtlc.js +0 -191
  279. package/dist/esm/contracts/index.js +0 -13
  280. package/dist/esm/contracts/types.js +0 -1
  281. package/dist/esm/contracts/vtxoOwnership.js +0 -69
  282. package/dist/esm/extension/asset/assetGroup.js +0 -224
  283. package/dist/esm/extension/asset/assetId.js +0 -148
  284. package/dist/esm/extension/asset/assetInput.js +0 -217
  285. package/dist/esm/extension/asset/assetOutput.js +0 -169
  286. package/dist/esm/extension/asset/assetRef.js +0 -144
  287. package/dist/esm/extension/asset/index.js +0 -8
  288. package/dist/esm/extension/asset/metadata.js +0 -182
  289. package/dist/esm/extension/asset/packet.js +0 -110
  290. package/dist/esm/extension/asset/types.js +0 -19
  291. package/dist/esm/extension/asset/utils.js +0 -99
  292. package/dist/esm/extension/index.js +0 -248
  293. package/dist/esm/extension/packet.js +0 -16
  294. package/dist/esm/forfeit.js +0 -41
  295. package/dist/esm/identity/descriptor.js +0 -161
  296. package/dist/esm/identity/descriptorProvider.js +0 -1
  297. package/dist/esm/identity/hdCapableIdentity.js +0 -17
  298. package/dist/esm/identity/index.js +0 -13
  299. package/dist/esm/identity/seedIdentity.js +0 -469
  300. package/dist/esm/identity/serialize.js +0 -164
  301. package/dist/esm/identity/singleKey.js +0 -121
  302. package/dist/esm/identity/staticDescriptorProvider.js +0 -61
  303. package/dist/esm/index.js +0 -87
  304. package/dist/esm/intent/index.js +0 -255
  305. package/dist/esm/musig2/index.js +0 -3
  306. package/dist/esm/musig2/keys.js +0 -21
  307. package/dist/esm/musig2/nonces.js +0 -11
  308. package/dist/esm/musig2/sign.js +0 -63
  309. package/dist/esm/networks.js +0 -22
  310. package/dist/esm/package.json +0 -3
  311. package/dist/esm/providers/ark.js +0 -572
  312. package/dist/esm/providers/delegator.js +0 -81
  313. package/dist/esm/providers/electrum.js +0 -864
  314. package/dist/esm/providers/errors.js +0 -54
  315. package/dist/esm/providers/expoArk.js +0 -78
  316. package/dist/esm/providers/expoIndexer.js +0 -107
  317. package/dist/esm/providers/expoUtils.js +0 -87
  318. package/dist/esm/providers/indexer.js +0 -626
  319. package/dist/esm/providers/onchain.js +0 -258
  320. package/dist/esm/providers/utils.js +0 -117
  321. package/dist/esm/repositories/contractRepository.js +0 -1
  322. package/dist/esm/repositories/inMemory/contractRepository.js +0 -51
  323. package/dist/esm/repositories/inMemory/walletRepository.js +0 -111
  324. package/dist/esm/repositories/index.js +0 -10
  325. package/dist/esm/repositories/indexedDB/contractRepository.js +0 -183
  326. package/dist/esm/repositories/indexedDB/db.js +0 -4
  327. package/dist/esm/repositories/indexedDB/manager.js +0 -95
  328. package/dist/esm/repositories/indexedDB/schema.js +0 -199
  329. package/dist/esm/repositories/indexedDB/walletRepository.js +0 -470
  330. package/dist/esm/repositories/indexedDB/websqlAdapter.js +0 -138
  331. package/dist/esm/repositories/migrations/contractRepositoryImpl.js +0 -121
  332. package/dist/esm/repositories/migrations/fromStorageAdapter.js +0 -58
  333. package/dist/esm/repositories/migrations/walletRepositoryImpl.js +0 -180
  334. package/dist/esm/repositories/realm/contractRepository.js +0 -112
  335. package/dist/esm/repositories/realm/index.js +0 -3
  336. package/dist/esm/repositories/realm/schemas.js +0 -153
  337. package/dist/esm/repositories/realm/types.js +0 -6
  338. package/dist/esm/repositories/realm/walletRepository.js +0 -301
  339. package/dist/esm/repositories/scriptFromAddress.js +0 -13
  340. package/dist/esm/repositories/serialization.js +0 -67
  341. package/dist/esm/repositories/sqlite/contractRepository.js +0 -131
  342. package/dist/esm/repositories/sqlite/index.js +0 -2
  343. package/dist/esm/repositories/sqlite/types.js +0 -1
  344. package/dist/esm/repositories/sqlite/walletRepository.js +0 -437
  345. package/dist/esm/repositories/walletRepository.js +0 -1
  346. package/dist/esm/script/address.js +0 -104
  347. package/dist/esm/script/base.js +0 -179
  348. package/dist/esm/script/default.js +0 -54
  349. package/dist/esm/script/delegate.js +0 -50
  350. package/dist/esm/script/tapscript.js +0 -615
  351. package/dist/esm/script/vhtlc.js +0 -167
  352. package/dist/esm/storage/asyncStorage.js +0 -46
  353. package/dist/esm/storage/fileSystem.js +0 -104
  354. package/dist/esm/storage/inMemory.js +0 -20
  355. package/dist/esm/storage/index.js +0 -1
  356. package/dist/esm/storage/indexedDB.js +0 -97
  357. package/dist/esm/storage/localStorage.js +0 -47
  358. package/dist/esm/tree/signingSession.js +0 -191
  359. package/dist/esm/tree/txTree.js +0 -188
  360. package/dist/esm/tree/validation.js +0 -101
  361. package/dist/esm/utils/anchor.js +0 -31
  362. package/dist/esm/utils/arkTransaction.js +0 -264
  363. package/dist/esm/utils/bip21.js +0 -123
  364. package/dist/esm/utils/syncCursors.js +0 -119
  365. package/dist/esm/utils/timelock.js +0 -22
  366. package/dist/esm/utils/transaction.js +0 -24
  367. package/dist/esm/utils/transactionHistory.js +0 -180
  368. package/dist/esm/utils/txSizeEstimator.js +0 -128
  369. package/dist/esm/utils/unknownFields.js +0 -169
  370. package/dist/esm/wallet/asset-manager.js +0 -325
  371. package/dist/esm/wallet/asset.js +0 -113
  372. package/dist/esm/wallet/batch.js +0 -180
  373. package/dist/esm/wallet/delegator.js +0 -303
  374. package/dist/esm/wallet/expo/background.js +0 -111
  375. package/dist/esm/wallet/expo/index.js +0 -2
  376. package/dist/esm/wallet/expo/wallet.js +0 -193
  377. package/dist/esm/wallet/hdDescriptorProvider.js +0 -184
  378. package/dist/esm/wallet/index.js +0 -75
  379. package/dist/esm/wallet/inputSignerRouter.js +0 -94
  380. package/dist/esm/wallet/onchain.js +0 -285
  381. package/dist/esm/wallet/ramps.js +0 -212
  382. package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +0 -946
  383. package/dist/esm/wallet/serviceWorker/wallet.js +0 -1169
  384. package/dist/esm/wallet/signingErrors.js +0 -27
  385. package/dist/esm/wallet/unroll.js +0 -289
  386. package/dist/esm/wallet/utils.js +0 -103
  387. package/dist/esm/wallet/validation.js +0 -142
  388. package/dist/esm/wallet/vtxo-manager.js +0 -1136
  389. package/dist/esm/wallet/wallet.js +0 -2186
  390. package/dist/esm/wallet/walletReceiveRotator.js +0 -540
  391. package/dist/esm/worker/browser/service-worker-manager.js +0 -177
  392. package/dist/esm/worker/browser/utils.js +0 -63
  393. package/dist/esm/worker/errors.js +0 -11
  394. package/dist/esm/worker/expo/asyncStorageTaskQueue.js +0 -74
  395. package/dist/esm/worker/expo/index.js +0 -4
  396. package/dist/esm/worker/expo/processors/contractPollProcessor.js +0 -59
  397. package/dist/esm/worker/expo/processors/index.js +0 -1
  398. package/dist/esm/worker/expo/taskQueue.js +0 -37
  399. package/dist/esm/worker/expo/taskRunner.js +0 -69
  400. package/dist/esm/worker/messageBus.js +0 -470
  401. package/dist/types/adapters/asyncStorage.d.ts +0 -2
  402. package/dist/types/adapters/expo.d.ts +0 -4
  403. package/dist/types/adapters/fileSystem.d.ts +0 -2
  404. package/dist/types/adapters/indexedDB.d.ts +0 -2
  405. package/dist/types/adapters/localStorage.d.ts +0 -2
  406. package/dist/types/arkfee/celenv.d.ts +0 -25
  407. package/dist/types/arkfee/estimator.d.ts +0 -49
  408. package/dist/types/arkfee/index.d.ts +0 -2
  409. package/dist/types/arkfee/types.d.ts +0 -38
  410. package/dist/types/arknote/index.d.ts +0 -84
  411. package/dist/types/bip322/index.d.ts +0 -55
  412. package/dist/types/contracts/arkcontract.d.ts +0 -99
  413. package/dist/types/contracts/contractManager.d.ts +0 -411
  414. package/dist/types/contracts/contractWatcher.d.ts +0 -217
  415. package/dist/types/contracts/handlers/default.d.ts +0 -19
  416. package/dist/types/contracts/handlers/delegate.d.ts +0 -21
  417. package/dist/types/contracts/handlers/helpers.d.ts +0 -19
  418. package/dist/types/contracts/handlers/index.d.ts +0 -7
  419. package/dist/types/contracts/handlers/registry.d.ts +0 -65
  420. package/dist/types/contracts/handlers/vhtlc.d.ts +0 -32
  421. package/dist/types/contracts/index.d.ts +0 -14
  422. package/dist/types/contracts/types.d.ts +0 -250
  423. package/dist/types/contracts/vtxoOwnership.d.ts +0 -33
  424. package/dist/types/extension/asset/assetGroup.d.ts +0 -119
  425. package/dist/types/extension/asset/assetId.d.ts +0 -83
  426. package/dist/types/extension/asset/assetInput.d.ts +0 -64
  427. package/dist/types/extension/asset/assetOutput.d.ts +0 -54
  428. package/dist/types/extension/asset/assetRef.d.ts +0 -91
  429. package/dist/types/extension/asset/index.d.ts +0 -8
  430. package/dist/types/extension/asset/metadata.d.ts +0 -52
  431. package/dist/types/extension/asset/packet.d.ts +0 -41
  432. package/dist/types/extension/asset/types.d.ts +0 -16
  433. package/dist/types/extension/asset/utils.d.ts +0 -21
  434. package/dist/types/extension/index.d.ts +0 -56
  435. package/dist/types/extension/packet.d.ts +0 -21
  436. package/dist/types/forfeit.d.ts +0 -18
  437. package/dist/types/identity/descriptor.d.ts +0 -61
  438. package/dist/types/identity/descriptorProvider.d.ts +0 -42
  439. package/dist/types/identity/hdCapableIdentity.d.ts +0 -71
  440. package/dist/types/identity/index.d.ts +0 -57
  441. package/dist/types/identity/seedIdentity.d.ts +0 -270
  442. package/dist/types/identity/serialize.d.ts +0 -96
  443. package/dist/types/identity/singleKey.d.ts +0 -62
  444. package/dist/types/identity/staticDescriptorProvider.d.ts +0 -18
  445. package/dist/types/index.d.ts +0 -59
  446. package/dist/types/intent/index.d.ts +0 -86
  447. package/dist/types/musig2/index.d.ts +0 -4
  448. package/dist/types/musig2/keys.d.ts +0 -9
  449. package/dist/types/musig2/nonces.d.ts +0 -14
  450. package/dist/types/musig2/sign.d.ts +0 -27
  451. package/dist/types/networks.d.ts +0 -16
  452. package/dist/types/providers/ark.d.ts +0 -369
  453. package/dist/types/providers/delegator.d.ts +0 -82
  454. package/dist/types/providers/electrum.d.ts +0 -312
  455. package/dist/types/providers/errors.d.ts +0 -13
  456. package/dist/types/providers/expoArk.d.ts +0 -22
  457. package/dist/types/providers/expoIndexer.d.ts +0 -18
  458. package/dist/types/providers/expoUtils.d.ts +0 -18
  459. package/dist/types/providers/indexer.d.ts +0 -301
  460. package/dist/types/providers/onchain.d.ts +0 -148
  461. package/dist/types/providers/utils.d.ts +0 -12
  462. package/dist/types/repositories/contractRepository.d.ts +0 -32
  463. package/dist/types/repositories/inMemory/contractRepository.d.ts +0 -17
  464. package/dist/types/repositories/inMemory/walletRepository.d.ts +0 -29
  465. package/dist/types/repositories/index.d.ts +0 -9
  466. package/dist/types/repositories/indexedDB/contractRepository.d.ts +0 -21
  467. package/dist/types/repositories/indexedDB/db.d.ts +0 -4
  468. package/dist/types/repositories/indexedDB/manager.d.ts +0 -25
  469. package/dist/types/repositories/indexedDB/schema.d.ts +0 -9
  470. package/dist/types/repositories/indexedDB/walletRepository.d.ts +0 -28
  471. package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +0 -49
  472. package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +0 -24
  473. package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +0 -19
  474. package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +0 -27
  475. package/dist/types/repositories/realm/contractRepository.d.ts +0 -24
  476. package/dist/types/repositories/realm/index.d.ts +0 -4
  477. package/dist/types/repositories/realm/types.d.ts +0 -16
  478. package/dist/types/repositories/realm/walletRepository.d.ts +0 -34
  479. package/dist/types/repositories/scriptFromAddress.d.ts +0 -9
  480. package/dist/types/repositories/serialization.d.ts +0 -65
  481. package/dist/types/repositories/sqlite/contractRepository.d.ts +0 -33
  482. package/dist/types/repositories/sqlite/index.d.ts +0 -3
  483. package/dist/types/repositories/sqlite/types.d.ts +0 -18
  484. package/dist/types/repositories/walletRepository.d.ts +0 -72
  485. package/dist/types/script/address.d.ts +0 -67
  486. package/dist/types/script/base.d.ts +0 -105
  487. package/dist/types/script/default.d.ts +0 -44
  488. package/dist/types/script/delegate.d.ts +0 -40
  489. package/dist/types/script/tapscript.d.ts +0 -169
  490. package/dist/types/script/vhtlc.d.ts +0 -66
  491. package/dist/types/tree/signingSession.d.ts +0 -37
  492. package/dist/types/tree/txTree.d.ts +0 -28
  493. package/dist/types/tree/validation.d.ts +0 -15
  494. package/dist/types/utils/anchor.d.ts +0 -19
  495. package/dist/types/utils/arkTransaction.d.ts +0 -49
  496. package/dist/types/utils/bip21.d.ts +0 -38
  497. package/dist/types/utils/syncCursors.d.ts +0 -60
  498. package/dist/types/utils/timelock.d.ts +0 -9
  499. package/dist/types/utils/transaction.d.ts +0 -13
  500. package/dist/types/utils/transactionHistory.d.ts +0 -15
  501. package/dist/types/utils/txSizeEstimator.d.ts +0 -40
  502. package/dist/types/utils/unknownFields.d.ts +0 -83
  503. package/dist/types/wallet/asset-manager.d.ts +0 -69
  504. package/dist/types/wallet/asset.d.ts +0 -21
  505. package/dist/types/wallet/batch.d.ts +0 -107
  506. package/dist/types/wallet/delegator.d.ts +0 -48
  507. package/dist/types/wallet/expo/background.d.ts +0 -66
  508. package/dist/types/wallet/expo/index.d.ts +0 -4
  509. package/dist/types/wallet/expo/wallet.d.ts +0 -99
  510. package/dist/types/wallet/hdDescriptorProvider.d.ts +0 -114
  511. package/dist/types/wallet/index.d.ts +0 -789
  512. package/dist/types/wallet/inputSignerRouter.d.ts +0 -35
  513. package/dist/types/wallet/onchain.d.ts +0 -109
  514. package/dist/types/wallet/ramps.d.ts +0 -64
  515. package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
  516. package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -248
  517. package/dist/types/wallet/signingErrors.d.ts +0 -19
  518. package/dist/types/wallet/unroll.d.ts +0 -114
  519. package/dist/types/wallet/utils.d.ts +0 -36
  520. package/dist/types/wallet/validation.d.ts +0 -24
  521. package/dist/types/wallet/vtxo-manager.d.ts +0 -476
  522. package/dist/types/wallet/wallet.d.ts +0 -409
  523. package/dist/types/wallet/walletReceiveRotator.d.ts +0 -306
  524. package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
  525. package/dist/types/worker/browser/utils.d.ts +0 -17
  526. package/dist/types/worker/errors.d.ts +0 -7
  527. package/dist/types/worker/expo/index.d.ts +0 -7
  528. package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
  529. package/dist/types/worker/expo/processors/index.d.ts +0 -1
  530. package/dist/types/worker/expo/taskQueue.d.ts +0 -50
  531. package/dist/types/worker/expo/taskRunner.d.ts +0 -66
  532. package/dist/types/worker/messageBus.d.ts +0 -189
@@ -0,0 +1,3892 @@
1
+ import { TxOpts, Transaction as Transaction$2 } from '@scure/btc-signer/transaction.js';
2
+ import { Bytes } from '@scure/btc-signer/utils.js';
3
+ import { PSBTOutput, TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt.js';
4
+ import { Transaction as Transaction$1, NETWORK } from '@scure/btc-signer';
5
+
6
+ /**
7
+ * Transaction is a wrapper around the @scure/btc-signer Transaction class.
8
+ * It adds the Arkade protocol specific options to the transaction.
9
+ */
10
+ declare class Transaction extends Transaction$1 {
11
+ static ARK_TX_OPTS: TxOpts;
12
+ constructor(opts?: TxOpts);
13
+ static fromPSBT(psbt_: Bytes, opts?: TxOpts): Transaction;
14
+ static fromRaw(raw: Bytes, opts?: TxOpts): Transaction;
15
+ }
16
+
17
+ /**
18
+ * MuSig2 nonce pair containing public and secret values.
19
+ * Public nonces are two compressed points (33 bytes each).
20
+ * Secret nonces are the corresponding private scalars plus pubkey.
21
+ */
22
+ type Nonces = {
23
+ pubNonce: Uint8Array;
24
+ secNonce: Uint8Array;
25
+ };
26
+
27
+ declare class PartialSig {
28
+ s: Uint8Array;
29
+ R: Uint8Array;
30
+ constructor(s: Uint8Array, R: Uint8Array);
31
+ /**
32
+ * Encodes the partial signature into bytes
33
+ * Returns a 32-byte array containing just the s value
34
+ */
35
+ encode(): Uint8Array;
36
+ /**
37
+ * Decodes a partial signature from bytes
38
+ * @param bytes - 32-byte array containing s value
39
+ */
40
+ static decode(bytes: Uint8Array): PartialSig;
41
+ }
42
+
43
+ /**
44
+ * TxTreeNode is a node of the tree.
45
+ * It contains the transaction id, the transaction and the children.
46
+ * any TxTree can be serialized as a list of TxTreeNode.
47
+ */
48
+ type TxTreeNode = {
49
+ txid: string;
50
+ tx: string;
51
+ children: Record<number, string>;
52
+ };
53
+ /**
54
+ * TxTree is a graph of bitcoin transactions.
55
+ * It is used to represent batch tree created during settlement session
56
+ */
57
+ declare class TxTree {
58
+ readonly root: Transaction$2;
59
+ readonly children: Map<number, TxTree>;
60
+ constructor(root: Transaction$2, children?: Map<number, TxTree>);
61
+ static create(chunks: TxTreeNode[]): TxTree;
62
+ nbOfNodes(): number;
63
+ validate(): void;
64
+ leaves(): Transaction$2[];
65
+ get txid(): string;
66
+ find(txid: string): TxTree | null;
67
+ update(txid: string, fn: (tx: Transaction$2) => void): void;
68
+ iterator(): Generator<TxTree, void, unknown>;
69
+ }
70
+
71
+ type Musig2PublicNonce = Pick<Nonces, "pubNonce">;
72
+ type TreeNonces = Map<string, Musig2PublicNonce>;
73
+ type TreePartialSigs = Map<string, PartialSig>;
74
+ interface SignerSession {
75
+ getPublicKey(): Promise<Uint8Array>;
76
+ init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): Promise<void>;
77
+ getNonces(): Promise<TreeNonces>;
78
+ aggregatedNonces(txid: string, noncesByPubkey: TreeNonces): Promise<{
79
+ hasAllNonces: boolean;
80
+ }>;
81
+ sign(): Promise<TreePartialSigs>;
82
+ }
83
+
84
+ /** A signing request that pairs a descriptor with a transaction. */
85
+ interface DescriptorSigningRequest {
86
+ /** Descriptor identifying which key to sign with */
87
+ descriptor: string;
88
+ /** Transaction to sign */
89
+ tx: Transaction;
90
+ /** Specific input indexes to sign (signs all if omitted) */
91
+ inputIndexes?: number[];
92
+ }
93
+ /**
94
+ * Provider interface for descriptor-based signing.
95
+ *
96
+ * Implementations include:
97
+ * - {@link StaticDescriptorProvider}: wraps a legacy {@link Identity} with a single key.
98
+ * - {@link HDDescriptorProvider}: rotates through HD-derived descriptors.
99
+ *
100
+ * The provider has no read accessor for "current" — it is a pure descriptor
101
+ * allocator. "What addresses am I currently bound to?" is a question the
102
+ * contract repository answers, not the provider.
103
+ *
104
+ * Providers that want to participate in HD receive rotation can also
105
+ * implement the wallet-side `ReceiveRotatorFactory` interface (see
106
+ * `src/wallet/walletReceiveRotator.ts`). That extension is opt-in — the
107
+ * core `DescriptorProvider` contract intentionally stays free of
108
+ * wallet-specific concerns so HSM-backed and other minimal providers
109
+ * don't have to know about the receive-rotation lifecycle.
110
+ */
111
+ interface DescriptorProvider {
112
+ /**
113
+ * Allocate a new signing descriptor. For HD providers each call advances
114
+ * the internal index and returns a fresh descriptor; for single-key
115
+ * providers each call returns the same descriptor.
116
+ */
117
+ getNextSigningDescriptor(): Promise<string>;
118
+ /** Checks if a descriptor belongs to this provider. */
119
+ isOurs(descriptor: string): boolean;
120
+ /** Signs transactions, each with its own descriptor-derived key. */
121
+ signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
122
+ /** Signs a message using the key derived from the descriptor. */
123
+ signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
124
+ }
125
+
126
+ interface Identity extends ReadonlyIdentity {
127
+ /** Returns a signer session used for musig2 tree signing flows. */
128
+ signerSession(): SignerSession;
129
+ /** Sign an arbitrary message using the requested signature type. */
130
+ signMessage(message: Uint8Array, signatureType: "schnorr" | "ecdsa"): Promise<Uint8Array>;
131
+ /**
132
+ * Sign the provided transaction inputs.
133
+ *
134
+ * @param tx - Transaction to sign
135
+ * @param inputIndexes - Optional input indexes to sign. When omitted, the implementation should sign every signable input.
136
+ */
137
+ sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
138
+ }
139
+ interface ReadonlyIdentity {
140
+ /** Returns the x-only public key used by Taproot scripts. */
141
+ xOnlyPublicKey(): Promise<Uint8Array>;
142
+ /** Returns the compressed public key for this identity. */
143
+ compressedPublicKey(): Promise<Uint8Array>;
144
+ }
145
+ /** A single PSBT signing request within a batch. */
146
+ interface SignRequest {
147
+ tx: Transaction;
148
+ inputIndexes?: number[];
149
+ }
150
+ /**
151
+ * Identity that supports signing multiple PSBTs in a single wallet interaction.
152
+ * Browser wallet providers that support batch signing (e.g. Xverse, UniSat, OKX)
153
+ * should implement this interface to reduce the number of confirmation popups
154
+ * from N+1 to 1 during Arkade send transactions.
155
+ *
156
+ * Contract: implementations MUST return exactly one `Transaction` per request,
157
+ * in the same order as the input array. The SDK validates this at runtime and
158
+ * will throw if the lengths do not match.
159
+ */
160
+ interface BatchSignableIdentity extends Identity {
161
+ /**
162
+ * Sign multiple transactions in a single wallet interaction.
163
+ *
164
+ * @param requests - Transactions and optional input indexes to sign
165
+ * @returns Signed transactions in the same order as the input requests
166
+ */
167
+ signMultiple(requests: SignRequest[]): Promise<Transaction[]>;
168
+ }
169
+ /** Type guard for identities that support batch signing. */
170
+ declare function isBatchSignable(identity: Identity): identity is BatchSignableIdentity;
171
+
172
+ /**
173
+ * ArkAddress allows creating and decoding bech32m-encoded Arkade addresses.
174
+ *
175
+ * An Arkade address is composed of:
176
+ * - a human readable prefix (hrp)
177
+ * - a version byte (1 byte)
178
+ * - a server public key (32 bytes)
179
+ * - a vtxo taproot public key (32 bytes)
180
+ *
181
+ * @remarks
182
+ * This is an Arkade-specific address format.
183
+ * It is distinct from the Taproot onchain address returned by `VtxoScript.onchainAddress`.
184
+ *
185
+ * @see VtxoScript
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * const address = new ArkAddress(
190
+ * new Uint8Array(32), // server public key
191
+ * new Uint8Array(32), // vtxo taproot public key
192
+ * "ark"
193
+ * );
194
+ *
195
+ * const encoded = address.encode();
196
+ * console.log("address: ", encoded);
197
+ *
198
+ * const decoded = ArkAddress.decode(encoded);
199
+ * ```
200
+ */
201
+ declare class ArkAddress {
202
+ readonly serverPubKey: Bytes;
203
+ readonly vtxoTaprootKey: Bytes;
204
+ readonly hrp: string;
205
+ readonly version: number;
206
+ /**
207
+ * Create an Arkade address from its server public key, Taproot output key, and prefix.
208
+ *
209
+ * @param serverPubKey - 32-byte Arkade server public key
210
+ * @param vtxoTaprootKey - 32-byte Taproot output key (a.k.a. tweaked public key)
211
+ * @param hrp - Bech32 human-readable prefix
212
+ * @param version - Address version byte
213
+ * @defaultValue `version = 0`
214
+ * @throws Error if either public key is not 32 bytes long
215
+ */
216
+ constructor(serverPubKey: Bytes, vtxoTaprootKey: Bytes, hrp?: string, version?: number);
217
+ /**
218
+ * Decode an Arkade address from its bech32m string form.
219
+ *
220
+ * @param address - Bech32m-encoded Arkade address
221
+ * @returns Decoded Arkade address
222
+ * @throws Error if the address is malformed or has an invalid payload length
223
+ * @see encode
224
+ */
225
+ static decode(address: string): ArkAddress;
226
+ /**
227
+ * Encode the address to its bech32m string form.
228
+ *
229
+ * @returns Bech32m-encoded Arkade address
230
+ * @see decode
231
+ */
232
+ encode(): string;
233
+ /** ScriptPubKey used to send non-dust funds to the address. */
234
+ get pkScript(): Bytes;
235
+ /** ScriptPubKey used to send sub-dust funds to the address. */
236
+ get subdustPkScript(): Bytes;
237
+ }
238
+
239
+ /**
240
+ * RelativeTimelock lets to create timelocked with CHECKSEQUENCEVERIFY script.
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * const timelock = { value: 144n, type: "blocks" }; // 1 day in blocks
245
+ * const timelock = { value: 512n, type: "seconds" }; // 8 minutes in seconds
246
+ * ```
247
+ */
248
+ type RelativeTimelock = {
249
+ value: bigint;
250
+ type: "seconds" | "blocks";
251
+ };
252
+ declare enum TapscriptType {
253
+ Multisig = "multisig",
254
+ CSVMultisig = "csv-multisig",
255
+ ConditionCSVMultisig = "condition-csv-multisig",
256
+ ConditionMultisig = "condition-multisig",
257
+ CLTVMultisig = "cltv-multisig"
258
+ }
259
+ /**
260
+ * ArkTapscript is the base element of vtxo scripts.
261
+ * It is used to encode and decode the different types of vtxo scripts.
262
+ */
263
+ interface ArkTapscript<T extends TapscriptType, Params> {
264
+ type: T;
265
+ params: Params;
266
+ script: Uint8Array;
267
+ }
268
+ /**
269
+ * decodeTapscript is a function that decodes an Arkade tapscript from a raw script.
270
+ *
271
+ * @throws {Error} if the script is not a valid Arkade tapscript
272
+ * @example
273
+ * ```typescript
274
+ * const arkTapscript = decodeTapscript(new Uint8Array(32));
275
+ * console.log("type:", arkTapscript.type);
276
+ * ```
277
+ */
278
+ declare function decodeTapscript(script: Uint8Array): ArkTapscript<TapscriptType, any>;
279
+ /**
280
+ * Implements a multi-signature tapscript.
281
+ *
282
+ * <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * const multisigTapscript = MultisigTapscript.encode({ pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
287
+ * ```
288
+ */
289
+ declare namespace MultisigTapscript {
290
+ type Type = ArkTapscript<TapscriptType.Multisig, Params>;
291
+ enum MultisigType {
292
+ CHECKSIG = 0,
293
+ CHECKSIGADD = 1
294
+ }
295
+ type Params = {
296
+ pubkeys: Bytes[];
297
+ type?: MultisigType;
298
+ };
299
+ /** Encode a plain multisig tapscript. */
300
+ function encode(params: Params): Type;
301
+ /** Decode a plain multisig tapscript from raw script bytes. */
302
+ function decode(script: Uint8Array): Type;
303
+ /** Return true when the tapscript is a plain multisig tapscript. */
304
+ function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
305
+ }
306
+ /**
307
+ * Implements a relative timelock script that requires all specified pubkeys to sign
308
+ * after the relative timelock has expired. The timelock can be specified in blocks or seconds.
309
+ *
310
+ * This is the standard exit closure and it is also used for the sweep closure in vtxo trees.
311
+ *
312
+ * <sequence> CHECKSEQUENCEVERIFY DROP <pubkey> CHECKSIG
313
+ *
314
+ * @example
315
+ * ```typescript
316
+ * const csvMultisigTapscript = CSVMultisigTapscript.encode({ timelock: { type: "blocks", value: 144 }, pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
317
+ * ```
318
+ */
319
+ declare namespace CSVMultisigTapscript {
320
+ type Type = ArkTapscript<TapscriptType.CSVMultisig, Params>;
321
+ type Params = {
322
+ timelock: RelativeTimelock;
323
+ } & MultisigTapscript.Params;
324
+ /** Encode a CSV multisig tapscript. */
325
+ function encode(params: Params): Type;
326
+ /** Decode a CSV multisig tapscript from raw script bytes. */
327
+ function decode(script: Uint8Array): Type;
328
+ /** Return true when the tapscript is a CSV multisig tapscript. */
329
+ function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
330
+ function isScriptValid(script: Uint8Array): true | Error;
331
+ }
332
+ /**
333
+ * Combines a condition script with an exit closure. The resulting script requires
334
+ * the condition to be met, followed by the standard exit closure requirements
335
+ * (timelock and signatures).
336
+ *
337
+ * <conditionScript> VERIFY <sequence> CHECKSEQUENCEVERIFY DROP <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
338
+ *
339
+ * @example
340
+ * ```typescript
341
+ * const conditionCSVMultisigTapscript = ConditionCSVMultisigTapscript.encode({ conditionScript: new Uint8Array(32), pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
342
+ * ```
343
+ */
344
+ declare namespace ConditionCSVMultisigTapscript {
345
+ type Type = ArkTapscript<TapscriptType.ConditionCSVMultisig, Params>;
346
+ type Params = {
347
+ conditionScript: Bytes;
348
+ } & CSVMultisigTapscript.Params;
349
+ /** Encode a condition + CSV multisig tapscript. */
350
+ function encode(params: Params): Type;
351
+ /** Decode a condition + CSV multisig tapscript from raw script bytes. */
352
+ function decode(script: Uint8Array): Type;
353
+ /** Return true when the tapscript is a condition + CSV multisig tapscript. */
354
+ function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
355
+ function isScriptValid(script: Uint8Array): true | Error;
356
+ }
357
+ /**
358
+ * Combines a condition script with a forfeit closure. The resulting script requires
359
+ * the condition to be met, followed by the standard forfeit closure requirements
360
+ * (multi-signature).
361
+ *
362
+ * <conditionScript> VERIFY <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
363
+ *
364
+ * @example
365
+ * ```typescript
366
+ * const conditionMultisigTapscript = ConditionMultisigTapscript.encode({ conditionScript: new Uint8Array(32), pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
367
+ * ```
368
+ */
369
+ declare namespace ConditionMultisigTapscript {
370
+ type Type = ArkTapscript<TapscriptType.ConditionMultisig, Params>;
371
+ type Params = {
372
+ conditionScript: Bytes;
373
+ } & MultisigTapscript.Params;
374
+ /** Encode a condition + multisig tapscript. */
375
+ function encode(params: Params): Type;
376
+ /** Decode a condition + multisig tapscript from raw script bytes. */
377
+ function decode(script: Uint8Array): Type;
378
+ /** Return true when the tapscript is a condition + multisig tapscript. */
379
+ function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
380
+ function isScriptValid(script: Uint8Array): true | Error;
381
+ }
382
+ /**
383
+ * Implements an absolute timelock (CLTV) script combined with a forfeit closure.
384
+ * The script requires waiting until a specific block height/timestamp before the
385
+ * forfeit closure conditions can be met.
386
+ *
387
+ * <locktime> CHECKLOCKTIMEVERIFY DROP <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const cltvMultisigTapscript = CLTVMultisigTapscript.encode({ absoluteTimelock: 144, pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
392
+ * ```
393
+ */
394
+ declare namespace CLTVMultisigTapscript {
395
+ type Type = ArkTapscript<TapscriptType.CLTVMultisig, Params>;
396
+ type Params = {
397
+ absoluteTimelock: bigint;
398
+ } & MultisigTapscript.Params;
399
+ /** Encode a CLTV multisig tapscript. */
400
+ function encode(params: Params): Type;
401
+ /** Decode a CLTV multisig tapscript from raw script bytes. */
402
+ function decode(script: Uint8Array): Type;
403
+ /** Return true when the tapscript is a CLTV multisig tapscript. */
404
+ function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
405
+ function isScriptValid(script: Uint8Array): true | Error;
406
+ }
407
+
408
+ type TapLeafScript = [
409
+ {
410
+ version: number;
411
+ internalKey: Bytes;
412
+ merklePath: Bytes[];
413
+ },
414
+ Bytes
415
+ ];
416
+ declare const TapTreeCoder: (typeof PSBTOutput.tapTree)[2];
417
+ /**
418
+ * VtxoScript is a script that contains a list of tapleaf scripts.
419
+ * It is used to create virtual output scripts.
420
+ *
421
+ * @see ArkAddress
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * const vtxoScript = new VtxoScript([new Uint8Array(32), new Uint8Array(32)]);
426
+ * ```
427
+ */
428
+ declare class VtxoScript {
429
+ readonly scripts: Bytes[];
430
+ readonly leaves: TapLeafScript[];
431
+ readonly tweakedPublicKey: Bytes;
432
+ /**
433
+ * Decode a virtual output script from an encoded TapTree.
434
+ *
435
+ * @param tapTree - Encoded TapTree bytes
436
+ * @returns Decoded virtual output script
437
+ * @throws Error if the TapTree cannot be decoded into a valid script set
438
+ * @see encode
439
+ */
440
+ static decode(tapTree: Bytes): VtxoScript;
441
+ /**
442
+ * Create a virtual output script from its tapleaf scripts.
443
+ *
444
+ * @param scripts - Raw tapscript bytes for each leaf
445
+ * @throws Error if the provided leaves cannot produce a valid Taproot tree
446
+ */
447
+ constructor(scripts: Bytes[]);
448
+ /**
449
+ * Encode the virtual output script to a TapTree byte representation.
450
+ *
451
+ * @returns Encoded TapTree bytes
452
+ * @see decode
453
+ */
454
+ encode(): Bytes;
455
+ /**
456
+ * Build the Arkade address corresponding to this virtual output script.
457
+ *
458
+ * @param prefix - Bech32 human-readable prefix
459
+ * @param serverPubKey - 32-byte Arkade server public key
460
+ * @returns Arkade address for this script
461
+ * @see ArkAddress
462
+ */
463
+ address(prefix: string | undefined, serverPubKey: Bytes): ArkAddress;
464
+ get pkScript(): Bytes;
465
+ /**
466
+ * Build the Taproot onchain address corresponding to this virtual output script.
467
+ *
468
+ * @param network - Bitcoin network descriptor
469
+ * @returns Taproot onchain address
470
+ * @see address
471
+ */
472
+ onchainAddress(network?: typeof NETWORK): string;
473
+ /**
474
+ * Look up a tapleaf script by its hex-encoded tapscript body.
475
+ *
476
+ * @param scriptHex - Hex-encoded tapscript body without the leaf version byte
477
+ * @returns Matching tapleaf script
478
+ * @throws Error if no matching leaf exists
479
+ */
480
+ findLeaf(scriptHex: string): TapLeafScript;
481
+ /**
482
+ * Return all unilateral exit paths embedded in the virtual output script.
483
+ *
484
+ * @returns CSV-based exit paths found in the leaves
485
+ * @see getSequence
486
+ */
487
+ exitPaths(): Array<CSVMultisigTapscript.Type | ConditionCSVMultisigTapscript.Type>;
488
+ }
489
+ type EncodedVtxoScript = {
490
+ tapTree: Bytes;
491
+ };
492
+ /**
493
+ * Extract the timelock value encoded in a timelocked tapleaf, if any.
494
+ *
495
+ * The return value is unit-ambiguous: for a CSV leaf it is a BIP-68
496
+ * nSequence (relative timelock); for a CLTV leaf it is an absolute
497
+ * nLockTime. Callers must know which leaf shape they are inspecting to
498
+ * interpret the number correctly, and must not copy a CSV result into
499
+ * `Transaction.lockTime` (or vice versa).
500
+ *
501
+ * @param tapLeafScript - Tapleaf script to inspect
502
+ * @returns The encoded timelock value, or `undefined` when neither a CSV
503
+ * nor CLTV path is present
504
+ * @see VtxoScript.exitPaths
505
+ */
506
+ declare function getSequence(tapLeafScript: TapLeafScript): number | undefined;
507
+
508
+ /**
509
+ * Configuration options for automatic virtual output renewal
510
+ *
511
+ * @see DEFAULT_RENEWAL_CONFIG
512
+ * @deprecated Leave `renewalConfig` undefined and use `settlementConfig` instead.
513
+ * @see SettlementConfig
514
+ */
515
+ interface RenewalConfig {
516
+ /**
517
+ * Enable automatic renewal monitoring
518
+ *
519
+ * @defaultValue `false`
520
+ * @deprecated Explicitly set `settlementConfig` to `false` to disable VTXO renewal.
521
+ */
522
+ enabled?: boolean;
523
+ /**
524
+ * Threshold in milliseconds to use as threshold for renewal
525
+ * E.g., 86_400_000 means renew when 24 hours until expiry remains
526
+ *
527
+ * @defaultValue `259_200_000` (3 days).
528
+ * @deprecated Use `SettlementConfig.vtxoThreshold` (in seconds) instead.
529
+ */
530
+ thresholdMs?: number;
531
+ }
532
+ /**
533
+ * Configuration for automatic settlement and renewal.
534
+ *
535
+ * Controls two behaviors:
536
+ * 1. **VTXO renewal**: Automatically renew virtual outputs that are close to expiry
537
+ * 2. **Boarding UTXO sweep**: Sweep expired boarding inputs back to a fresh boarding address
538
+ * via the unilateral exit path (onchain self-spend to restart the timelock)
539
+ *
540
+ * Enabled by default when no config is provided.
541
+ * Pass `false` to explicitly disable all settlement behavior.
542
+ *
543
+ * @remarks
544
+ * VTXO renewal and boarding UTXO sweep are both coordinated by `VtxoManager`, which periodically
545
+ * inspects wallet virtual outputs and boarding inputs and decides whether action is needed.
546
+ *
547
+ * @see DEFAULT_SETTLEMENT_CONFIG
548
+ *
549
+ * @example
550
+ * ```typescript
551
+ * // Default behavior: virtual output renewal at 3 days, boarding sweep enabled, polling every minute
552
+ * const wallet = await Wallet.create({
553
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
554
+ * arkProvider: new RestArkProvider(),
555
+ * });
556
+ *
557
+ * // Custom expiry threshold of 24 hours
558
+ * const wallet = await Wallet.create({
559
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
560
+ * arkProvider: new RestArkProvider(),
561
+ * settlementConfig: {
562
+ * vtxoThreshold: 60 * 60 * 24, // 24 hours in seconds
563
+ * },
564
+ * });
565
+ *
566
+ * // Explicitly disable
567
+ * const wallet = await Wallet.create({
568
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
569
+ * arkProvider: new RestArkProvider(),
570
+ * settlementConfig: false,
571
+ * });
572
+ * ```
573
+ */
574
+ interface SettlementConfig {
575
+ /**
576
+ * Seconds before virtual output expiry to trigger renewal.
577
+ *
578
+ * @defaultValue `259_200` (3 days)
579
+ */
580
+ vtxoThreshold?: number;
581
+ /**
582
+ * Sweep expired boarding inputs back to a fresh boarding address
583
+ * via the unilateral exit path (onchain self-spend to restart the timelock).
584
+ *
585
+ * When enabled, expired boarding inputs are batched into a single onchain
586
+ * transaction with multiple inputs and one output.
587
+ *
588
+ * A dust check ensures the sweep is only performed when the output
589
+ * after fees is above dust.
590
+ *
591
+ * @defaultValue `true`
592
+ */
593
+ boardingUtxoSweep?: boolean;
594
+ /**
595
+ * Polling interval in milliseconds for checking boarding inputs.
596
+ * The poll loop auto-settles new boarding inputs into Arkade and
597
+ * sweeps expired ones (when boardingUtxoSweep is enabled).
598
+ *
599
+ * @defaultValue `60_000` (1 minute)
600
+ */
601
+ pollIntervalMs?: number;
602
+ }
603
+ /**
604
+ * Check if a virtual output is expiring soon based on threshold
605
+ *
606
+ * @param vtxo - The virtual output to check
607
+ * @param thresholdMs - Threshold in milliseconds from now
608
+ * @returns true if virtual output expires within threshold, false otherwise
609
+ */
610
+ declare function isVtxoExpiringSoon(vtxo: ExtendedVirtualCoin, thresholdMs: number): boolean;
611
+ /**
612
+ * VtxoManager is a unified class for managing virtual output lifecycle operations including
613
+ * recovery of swept/expired virtual outputs and renewal to prevent expiration.
614
+ *
615
+ * Key Features:
616
+ * - **Recovery**: Reclaim swept or expired virtual outputs back to the wallet
617
+ * - **Renewal**: Refresh virtual output expiration time before they expire
618
+ * - **Smart subdust handling**: Automatically includes subdust virtual outputs when economically viable
619
+ * - **Expiry monitoring**: Check for virtual outputs that are expiring soon
620
+ *
621
+ * Virtual outputs become recoverable when:
622
+ * - The Arkade server sweeps them (virtualStatus.state === "swept") and they remain spendable
623
+ * - They are preconfirmed subdust (to consolidate small amounts without locking liquidity on settled virtual outputs)
624
+ *
625
+ * @example
626
+ * ```typescript
627
+ * const wallet = await Wallet.create({
628
+ * identity,
629
+ * arkProvider: new RestArkProvider(),
630
+ * settlementConfig: {
631
+ * // Seconds before virtual output expiry to trigger renewal
632
+ * vtxoThreshold: 259_200, // 3 days
633
+ * // Whether to sweep expired boarding inputs back to a fresh boarding address
634
+ * boardingUtxoSweep: true,
635
+ * // Polling interval in milliseconds for checking boarding inputs
636
+ * pollIntervalMs: 60_000 // 1 minute
637
+ * },
638
+ * });
639
+ * const manager = await wallet.getVtxoManager();
640
+ *
641
+ * // Check recoverable balance
642
+ * const balance = await manager.getRecoverableBalance();
643
+ * if (balance.recoverable > 0n) {
644
+ * console.log(`Can recover ${balance.recoverable} sats`);
645
+ * const txid = await manager.recoverVtxos();
646
+ * }
647
+ *
648
+ * // Check for expiring virtual outputs
649
+ * const expiring = await manager.getExpiringVtxos();
650
+ * if (expiring.length > 0) {
651
+ * console.log(`${expiring.length} virtual outputs expiring soon`);
652
+ * const txid = await manager.renewVtxos();
653
+ * }
654
+ * ```
655
+ */
656
+ interface IVtxoManager {
657
+ recoverVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
658
+ getRecoverableBalance(): Promise<{
659
+ recoverable: bigint;
660
+ subdust: bigint;
661
+ includesSubdust: boolean;
662
+ vtxoCount: number;
663
+ }>;
664
+ getExpiringVtxos(thresholdMs?: number): Promise<ExtendedVirtualCoin[]>;
665
+ renewVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
666
+ getExpiredBoardingUtxos(): Promise<ExtendedCoin[]>;
667
+ sweepExpiredBoardingUtxos(): Promise<string>;
668
+ dispose(): Promise<void>;
669
+ }
670
+ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
671
+ readonly wallet: IWallet;
672
+ /** @deprecated Use settlementConfig instead */
673
+ readonly renewalConfig?: RenewalConfig | undefined;
674
+ readonly settlementConfig: SettlementConfig | false;
675
+ private contractEventsSubscription?;
676
+ private readonly contractEventsSubscriptionReady;
677
+ private disposePromise?;
678
+ private pollTimeoutId?;
679
+ private knownBoardingUtxos;
680
+ private sweptBoardingUtxos;
681
+ private pollInProgress;
682
+ private pollDone?;
683
+ private disposed;
684
+ private consecutivePollFailures;
685
+ private startupPollTimeoutId?;
686
+ private static readonly MAX_BACKOFF_MS;
687
+ private renewalInProgress;
688
+ private lastRenewalTimestamp;
689
+ private static readonly RENEWAL_COOLDOWN_MS;
690
+ private lastPeriodicSettleTimestamp;
691
+ private consecutivePeriodicSettleFailures;
692
+ private static readonly PERIODIC_SETTLE_COOLDOWN_MS;
693
+ private static readonly PERIODIC_SETTLE_MAX_BACKOFF_MS;
694
+ private lastVtxoSpentRefreshTimestamp;
695
+ private vtxoSpentRefreshPromise?;
696
+ private static readonly VTXO_SPENT_REFRESH_COOLDOWN_MS;
697
+ constructor(wallet: IWallet,
698
+ /** @deprecated Use settlementConfig instead */
699
+ renewalConfig?: RenewalConfig | undefined, settlementConfig?: SettlementConfig | false);
700
+ /**
701
+ * Recover swept/expired virtual outputs by settling them back to the wallet's Arkade address.
702
+ *
703
+ * This method:
704
+ * 1. Fetches all virtual outputs (including recoverable ones)
705
+ * 2. Filters for swept but still spendable virtual outputs and preconfirmed subdust
706
+ * 3. Includes subdust virtual outputs if the total value >= dust threshold
707
+ * 4. Settles everything back to the wallet's Arkade address
708
+ *
709
+ * Note: Settled virtual outputs with long expiry are NOT recovered to avoid locking liquidity unnecessarily.
710
+ * Only preconfirmed subdust is recovered to consolidate small amounts.
711
+ *
712
+ * @param eventCallback - Optional callback to receive settlement events
713
+ * @returns Settlement transaction ID
714
+ * @throws Error if no recoverable virtual outputs found
715
+ *
716
+ * @example
717
+ * ```typescript
718
+ * const manager = await wallet.getVtxoManager();
719
+ *
720
+ * // Simple recovery
721
+ * const txid = await manager.recoverVtxos();
722
+ *
723
+ * // With event callback
724
+ * const txid = await manager.recoverVtxos((event) => {
725
+ * console.log('Settlement event:', event.type);
726
+ * });
727
+ * ```
728
+ */
729
+ recoverVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
730
+ /**
731
+ * Get information about recoverable balance without executing recovery.
732
+ *
733
+ * Useful for displaying to users before they decide to recover funds.
734
+ *
735
+ * @returns Object containing recoverable amounts and subdust information
736
+ *
737
+ * @example
738
+ * ```typescript
739
+ * const manager = await wallet.getVtxoManager();
740
+ * const balance = await manager.getRecoverableBalance();
741
+ *
742
+ * if (balance.recoverable > 0n) {
743
+ * console.log(`You can recover ${balance.recoverable} sats`);
744
+ * if (balance.includesSubdust) {
745
+ * console.log(`This includes ${balance.subdust} sats from subdust virtual outputs`);
746
+ * }
747
+ * }
748
+ * ```
749
+ */
750
+ getRecoverableBalance(): Promise<{
751
+ recoverable: bigint;
752
+ subdust: bigint;
753
+ includesSubdust: boolean;
754
+ vtxoCount: number;
755
+ }>;
756
+ /**
757
+ * Get virtual outputs that are expiring soon based on renewal configuration
758
+ *
759
+ * @param thresholdMs - Optional override for threshold in milliseconds
760
+ * @returns Array of expiring virtual outputs, empty array if renewal is disabled or no virtual outputs expiring
761
+ *
762
+ * @example
763
+ * ```typescript
764
+ * const wallet = await Wallet.create({
765
+ * identity,
766
+ * arkProvider: new RestArkProvider(),
767
+ * settlementConfig: {
768
+ * vtxoThreshold: 86_400 // 24 hours
769
+ * },
770
+ * });
771
+ * const manager = await wallet.getVtxoManager();
772
+ * const expiringVtxos = await manager.getExpiringVtxos();
773
+ * if (expiringVtxos.length > 0) {
774
+ * console.log(`${expiringVtxos.length} virtual outputs expiring soon`);
775
+ * }
776
+ * ```
777
+ */
778
+ getExpiringVtxos(thresholdMs?: number): Promise<ExtendedVirtualCoin[]>;
779
+ /**
780
+ * Renew expiring virtual outputs by settling them back to the wallet's address
781
+ *
782
+ * This method collects all expiring spendable virtual outputs (including recoverable ones) and settles
783
+ * them back to the wallet, effectively refreshing their expiration time. This is the
784
+ * primary way to prevent virtual outputs from expiring.
785
+ *
786
+ * @param eventCallback - Optional callback for settlement events
787
+ * @returns Settlement transaction ID
788
+ * @throws Error if no virtual outputs available to renew
789
+ * @throws Error if total amount is below dust threshold
790
+ *
791
+ * @example
792
+ * ```typescript
793
+ * const manager = await wallet.getVtxoManager();
794
+ *
795
+ * // Simple renewal
796
+ * const txid = await manager.renewVtxos();
797
+ *
798
+ * // With event callback
799
+ * const txid = await manager.renewVtxos((event) => {
800
+ * console.log('Settlement event:', event.type);
801
+ * });
802
+ * ```
803
+ */
804
+ renewVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
805
+ /**
806
+ * Get boarding inputs whose timelock has expired.
807
+ *
808
+ * These inputs can no longer be onboarded cooperatively via `settle()` and
809
+ * must be swept back to a fresh boarding address using the unilateral exit path.
810
+ *
811
+ * @returns Array of expired boarding inputs
812
+ *
813
+ * @example
814
+ * ```typescript
815
+ * const manager = await wallet.getVtxoManager();
816
+ * const expired = await manager.getExpiredBoardingUtxos();
817
+ * if (expired.length > 0) {
818
+ * console.log(`${expired.length} expired boarding inputs to sweep`);
819
+ * }
820
+ * ```
821
+ */
822
+ getExpiredBoardingUtxos(prefetchedUtxos?: ExtendedCoin[]): Promise<ExtendedCoin[]>;
823
+ /**
824
+ * Sweep expired boarding inputs back to a fresh boarding address via
825
+ * the unilateral exit path (onchain self-spend).
826
+ *
827
+ * This builds a raw onchain transaction that:
828
+ * - Uses all expired boarding inputs as inputs (spent via the CSV exit script path)
829
+ * - Has a single output to the wallet's boarding address (restarts the timelock)
830
+ * - Batches multiple expired boarding inputs into one transaction
831
+ * - Skips the sweep if the output after fees would be below dust
832
+ *
833
+ * No Arkade server involvement is needed — this is a pure onchain transaction.
834
+ *
835
+ * @returns The broadcast transaction ID
836
+ * @throws Error if no expired boarding inputs are found
837
+ * @throws Error if output after fees is below dust (not economical to sweep)
838
+ * @throws Error if boarding input sweep is not enabled in settlementConfig
839
+ *
840
+ * @example
841
+ * ```typescript
842
+ * const wallet = await Wallet.create({
843
+ * identity,
844
+ * arkProvider: new RestArkProvider(),
845
+ * settlementConfig: {
846
+ * boardingUtxoSweep: true,
847
+ * },
848
+ * });
849
+ * const manager = await wallet.getVtxoManager();
850
+ *
851
+ * try {
852
+ * const txid = await manager.sweepExpiredBoardingUtxos();
853
+ * console.log('Swept expired boarding inputs:', txid);
854
+ * } catch (e) {
855
+ * console.log('No sweep needed or not economical');
856
+ * }
857
+ * ```
858
+ */
859
+ sweepExpiredBoardingUtxos(prefetchedUtxos?: ExtendedCoin[]): Promise<string>;
860
+ /** Asserts sweep capability and returns the typed wallet. */
861
+ private getSweepWallet;
862
+ /** Decodes the boarding tapscript exit path to extract the CSV timelock. */
863
+ private getBoardingTimelock;
864
+ /** Returns the TapLeafScript for the boarding tapscript's exit (CSV) path. */
865
+ private getBoardingExitLeaf;
866
+ /** Returns the pkScript (output script) of the boarding tapscript. */
867
+ private getBoardingOutputScript;
868
+ /** Returns the onchain provider for fee estimation and broadcasting. */
869
+ private getOnchainProvider;
870
+ /** Returns the Ark provider for intent fee and server info lookups. */
871
+ private getArkProvider;
872
+ /** Returns the Bitcoin network configuration from the wallet. */
873
+ private getNetwork;
874
+ /** Returns the wallet's identity for transaction signing. */
875
+ private getIdentity;
876
+ private initializeSubscription;
877
+ /**
878
+ * VTXO_ALREADY_SPENT means the server's authoritative view of VTXO state
879
+ * is ahead of ours — cross-instance race, pre-lock snapshot drift, or an
880
+ * SSE gap left stale data in the local cache. Silent-swallowing
881
+ * guarantees the same error on the next cycle because nothing
882
+ * reconciles the cache.
883
+ *
884
+ * The cursor-derived delta sync filters by `created_at`, so a VTXO that
885
+ * was created before the cursor but spent recently can never be
886
+ * reconciled by `refreshVtxos()`. Use `refreshOutpoints` for surgical
887
+ * recovery: query the indexer for the specific stale outpoint and
888
+ * upsert its authoritative state into the wallet repository.
889
+ *
890
+ * Throttled because the same VTXO can fire repeatedly before the
891
+ * upsert observably propagates through the renewal selector.
892
+ */
893
+ private maybeRefreshAfterVtxoSpent;
894
+ /**
895
+ * Extract the offending VTXO outpoint from a `VTXO_ALREADY_SPENT` error,
896
+ * if the server attached one in `metadata.vtxo_outpoint`. Returns
897
+ * `undefined` when the error isn't a parsed ArkError, isn't this code,
898
+ * or doesn't carry the metadata.
899
+ */
900
+ private extractSpentOutpoint;
901
+ /**
902
+ * Reconcile the chosen VTXOs with the indexer's authoritative state
903
+ * before submitting a settle intent. Pulls the canonical record for
904
+ * each candidate outpoint via {@link IContractManager.refreshOutpoints}
905
+ * (which upserts the result into the wallet repository), then
906
+ * re-selects through the standard expiring-vtxo filter so anything
907
+ * the refresh flagged as spent is dropped.
908
+ *
909
+ * Best-effort: a failed refresh just falls back to the original
910
+ * candidates and lets the post-submit `VTXO_ALREADY_SPENT` recovery
911
+ * handle whatever slipped through.
912
+ */
913
+ private revalidateBeforeSettle;
914
+ /** Computes the next poll delay, applying exponential backoff on failures. */
915
+ private getNextPollDelay;
916
+ /**
917
+ * Starts a polling loop that:
918
+ * 1. Auto-settles new boarding inputs into Arkade
919
+ * 2. Sweeps expired boarding inputs (when boardingUtxoSweep is enabled)
920
+ *
921
+ * Uses setTimeout chaining (not setInterval) so a slow/blocked poll
922
+ * cannot stack up and the next delay can incorporate backoff.
923
+ */
924
+ private startBoardingUtxoPoll;
925
+ private schedulePoll;
926
+ private pollBoardingUtxos;
927
+ /**
928
+ * Auto-settle new (unexpired) boarding inputs AND near-expiry VTXOs into
929
+ * Arkade in a single intent. Skips boarding UTXOs that are already expired
930
+ * (those are handled by sweep) and those already in-flight (tracked in
931
+ * knownBoardingUtxos). If the event-driven renewal path is currently
932
+ * running, VTXOs are omitted from this cycle to avoid double-spending.
933
+ *
934
+ * Failure bookkeeping: after every settle *attempt*, lastPeriodicSettleTimestamp
935
+ * is armed and consecutive failures are counted so the next attempt is
936
+ * blocked by an exponentially growing cooldown (capped). This stops a
937
+ * persistently failing input from producing identical RegisterIntent +
938
+ * DeleteIntent retries on every 60s poll.
939
+ */
940
+ private runPeriodicSettle;
941
+ dispose(): Promise<void>;
942
+ [Symbol.asyncDispose](): Promise<void>;
943
+ }
944
+
945
+ type NetworkName = "bitcoin" | "testnet" | "signet" | "mutinynet" | "regtest";
946
+ interface Network {
947
+ hrp: string;
948
+ bech32: string;
949
+ pubKeyHash: number;
950
+ scriptHash: number;
951
+ wif: number;
952
+ }
953
+ declare const networks: {
954
+ bitcoin: Network;
955
+ testnet: Network;
956
+ signet: Network;
957
+ mutinynet: Network;
958
+ regtest: Network;
959
+ };
960
+
961
+ /**
962
+ * The default base URLs for esplora API providers.
963
+ *
964
+ * Mainnet, mutinynet, and signet point at Ark Labs–operated
965
+ * mempool deployments (mempool.space-compatible esplora API).
966
+ * Testnet falls back to the public mempool.space deployment
967
+ * because Ark doesn't host it. Regtest assumes a local nigiri
968
+ * stack on the standard port.
969
+ */
970
+ declare const ESPLORA_URL: Record<NetworkName, string>;
971
+ type ExplorerTransaction = {
972
+ txid: string;
973
+ vout: {
974
+ scriptpubkey_address: string;
975
+ value: string;
976
+ }[];
977
+ status: {
978
+ confirmed: boolean;
979
+ block_time: number;
980
+ };
981
+ };
982
+ interface OnchainProvider {
983
+ /**
984
+ * Fetch spendable onchain outputs for an address.
985
+ *
986
+ * @param address - Bitcoin address to query
987
+ * @returns Spendable onchain outputs for the address
988
+ * @see Coin
989
+ */
990
+ getCoins(address: string): Promise<Coin[]>;
991
+ /**
992
+ * Fetch the current fastest fee rate estimate.
993
+ *
994
+ * @returns Fee rate in sats/vB, if available
995
+ * @remarks
996
+ * Implementations may return `undefined` when the backing service does not expose
997
+ * a usable fee estimate.
998
+ */
999
+ getFeeRate(): Promise<number | undefined>;
1000
+ /**
1001
+ * Broadcast a single transaction or a 1P1C package.
1002
+ *
1003
+ * @param txs - One or more raw transaction hex strings
1004
+ * @returns Broadcast transaction id
1005
+ * @throws Error if the broadcast request fails or the package shape is invalid
1006
+ */
1007
+ broadcastTransaction(...txs: string[]): Promise<string>;
1008
+ /**
1009
+ * Fetch outspend information for every output in a transaction.
1010
+ *
1011
+ * @param txid - Transaction id to inspect
1012
+ * @returns Per-output spend status information
1013
+ * @see getTxStatus
1014
+ */
1015
+ getTxOutspends(txid: string): Promise<{
1016
+ spent: boolean;
1017
+ txid: string;
1018
+ }[]>;
1019
+ /**
1020
+ * Fetch transactions associated with an address.
1021
+ *
1022
+ * @param address - Bitcoin address to query
1023
+ * @returns Transactions involving the address
1024
+ * @see ExplorerTransaction
1025
+ */
1026
+ getTransactions(address: string): Promise<ExplorerTransaction[]>;
1027
+ /**
1028
+ * Fetch confirmation status for a transaction.
1029
+ *
1030
+ * @param txid - Transaction id to inspect
1031
+ * @returns Confirmation status and block metadata when confirmed
1032
+ * @see getTxOutspends
1033
+ */
1034
+ getTxStatus(txid: string): Promise<{
1035
+ confirmed: false;
1036
+ } | {
1037
+ confirmed: true;
1038
+ blockTime: number;
1039
+ blockHeight: number;
1040
+ }>;
1041
+ /**
1042
+ * Fetch the current chain tip.
1043
+ *
1044
+ * @returns Current chain height, block time, and block hash
1045
+ */
1046
+ getChainTip(): Promise<{
1047
+ height: number;
1048
+ time: number;
1049
+ hash: string;
1050
+ }>;
1051
+ /**
1052
+ * Watch a set of addresses and invoke the callback when transactions are observed.
1053
+ *
1054
+ * @param addresses - Addresses to monitor
1055
+ * @param eventCallback - Callback invoked when matching transactions are seen
1056
+ * @returns Stop function that cancels the watch
1057
+ * @remarks
1058
+ * Implementations may use websockets, server-sent events, polling, or a hybrid strategy.
1059
+ * @see getTransactions
1060
+ */
1061
+ watchAddresses(addresses: string[], eventCallback: (txs: ExplorerTransaction[]) => void): Promise<() => void>;
1062
+ }
1063
+ /**
1064
+ * Implementation of the onchain provider interface for esplora REST API.
1065
+ *
1066
+ * @see https://mempool.space/docs/api/rest
1067
+ * @example
1068
+ * ```typescript
1069
+ * const provider = new EsploraProvider("https://mempool.space/api");
1070
+ * const outputs = await provider.getCoins("bcrt1q679zsd45msawvr7782r0twvmukns3drlstjt77");
1071
+ * ```
1072
+ */
1073
+ declare class EsploraProvider implements OnchainProvider {
1074
+ private baseUrl;
1075
+ readonly pollingInterval: number;
1076
+ readonly forcePolling: boolean;
1077
+ constructor(baseUrl?: string, opts?: {
1078
+ /** Polling interval in milliseconds. */
1079
+ pollingInterval?: number;
1080
+ /** Force polling even when websocket transport is available. */
1081
+ forcePolling?: boolean;
1082
+ });
1083
+ getCoins(address: string): Promise<Coin[]>;
1084
+ getFeeRate(): Promise<number | undefined>;
1085
+ broadcastTransaction(...txs: string[]): Promise<string>;
1086
+ getTxOutspends(txid: string): Promise<{
1087
+ spent: boolean;
1088
+ txid: string;
1089
+ }[]>;
1090
+ getTransactions(address: string): Promise<ExplorerTransaction[]>;
1091
+ getTxStatus(txid: string): Promise<{
1092
+ confirmed: false;
1093
+ } | {
1094
+ confirmed: true;
1095
+ blockTime: number;
1096
+ blockHeight: number;
1097
+ }>;
1098
+ watchAddresses(addresses: string[], callback: (txs: ExplorerTransaction[]) => void): Promise<() => void>;
1099
+ getChainTip(): Promise<{
1100
+ height: number;
1101
+ time: number;
1102
+ hash: string;
1103
+ }>;
1104
+ private broadcastPackage;
1105
+ private broadcastTx;
1106
+ }
1107
+
1108
+ interface WalletState {
1109
+ /** Arbitrary stored wallet settings. */
1110
+ settings?: Record<string, any>;
1111
+ /**
1112
+ * High-water mark for VTXO indexer syncs, in milliseconds.
1113
+ *
1114
+ * Reused the legacy `lastSyncTime` column name to avoid an
1115
+ * `ALTER TABLE` migration; the value is interpreted as the new
1116
+ * "max indexer `updatedAt`" cursor only after `settings.vtxoCursorMigrated`
1117
+ * is set, so pre-existing values written by the buggy pre-PR sync
1118
+ * are ignored and force a one-shot re-bootstrap on upgrade.
1119
+ */
1120
+ lastSyncTime?: number;
1121
+ }
1122
+ interface VtxoRepositoryKey {
1123
+ /** Authoritative ownership key. */
1124
+ script: string;
1125
+ /** Legacy storage bucket. Required by all current backends; throw if absent. */
1126
+ address?: string;
1127
+ }
1128
+ interface WalletRepository extends AsyncDisposable {
1129
+ readonly version: 1;
1130
+ /**
1131
+ * Clear all data from storage.
1132
+ */
1133
+ clear(): Promise<void>;
1134
+ /** Fetch stored virtual outputs for an address. */
1135
+ getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
1136
+ /** Save virtual outputs for an address. */
1137
+ saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
1138
+ /** Delete stored virtual outputs for an address. */
1139
+ deleteVtxos(address: string): Promise<void>;
1140
+ /**
1141
+ * Fetch stored virtual outputs for a script.
1142
+ * @optional SDK backends implement this; custom backends fall back to Tier 1.
1143
+ */
1144
+ getVtxosForScript?(script: string): Promise<ExtendedVirtualCoin[]>;
1145
+ /**
1146
+ * Save virtual outputs for a script.
1147
+ * @optional SDK backends implement this; custom backends fall back to Tier 1.
1148
+ */
1149
+ saveVtxosForScript?(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
1150
+ /**
1151
+ * Delete stored virtual outputs for a script.
1152
+ * @optional SDK backends implement this; custom backends fall back to Tier 1.
1153
+ */
1154
+ deleteVtxosForScript?(script: string): Promise<void>;
1155
+ /** Fetch stored boarding inputs for an address. */
1156
+ getUtxos(address: string): Promise<ExtendedCoin[]>;
1157
+ /** Save boarding inputs for an address. */
1158
+ saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
1159
+ /** Delete stored boarding inputs for an address. */
1160
+ deleteUtxos(address: string): Promise<void>;
1161
+ /** Fetch stored transaction history for an address. */
1162
+ getTransactionHistory(address: string): Promise<ArkTransaction[]>;
1163
+ /** Save transaction history for an address. */
1164
+ saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
1165
+ /** Delete stored transaction history for an address. */
1166
+ deleteTransactions(address: string): Promise<void>;
1167
+ /** Fetch stored wallet state. */
1168
+ getWalletState(): Promise<WalletState | null>;
1169
+ /** Save wallet state. */
1170
+ saveWalletState(state: WalletState): Promise<void>;
1171
+ }
1172
+
1173
+ /**
1174
+ * Filter options for querying contracts.
1175
+ */
1176
+ interface ContractFilter {
1177
+ /** Filter by script(s) */
1178
+ script?: string | string[];
1179
+ /** Filter by state(s) */
1180
+ state?: ContractState | ContractState[];
1181
+ /** Filter by contract type(s) */
1182
+ type?: string | string[];
1183
+ }
1184
+ interface ContractRepository extends AsyncDisposable {
1185
+ readonly version: 1;
1186
+ /**
1187
+ * Clear all data from storage.
1188
+ */
1189
+ clear(): Promise<void>;
1190
+ /**
1191
+ * Get contracts with optional filter.
1192
+ * Returns all contracts if no filter provided.
1193
+ */
1194
+ getContracts(filter?: ContractFilter): Promise<Contract[]>;
1195
+ /**
1196
+ * Save or update a contract.
1197
+ */
1198
+ saveContract(contract: Contract): Promise<void>;
1199
+ /**
1200
+ * Delete a contract by script.
1201
+ */
1202
+ deleteContract(script: string): Promise<void>;
1203
+ }
1204
+
1205
+ type RefreshVtxosOptions = {
1206
+ scripts?: string[];
1207
+ after?: number;
1208
+ before?: number;
1209
+ /**
1210
+ * When true and `scripts` is not set, refresh every contract in
1211
+ * the repository — including those marked `inactive` and those
1212
+ * that have dropped out of the watcher's active set. Useful for
1213
+ * "did anyone send funds to a stale rotated display address?"
1214
+ * audits.
1215
+ *
1216
+ * Because this is a *superset* of the watcher's watched set, the
1217
+ * cursor invariant still holds and the cursor advances normally
1218
+ * (unless an explicit `after` / `before` window is also supplied).
1219
+ *
1220
+ * Ignored when `scripts` is set (the explicit list already
1221
+ * specifies what to refresh, regardless of contract state).
1222
+ *
1223
+ * @defaultValue `false`
1224
+ */
1225
+ includeInactive?: boolean;
1226
+ };
1227
+ /**
1228
+ * A single `Discoverable` handler's `discoverAt` rejection, captured during
1229
+ * a {@link IContractManager.scanContracts} run instead of aborting the loop.
1230
+ */
1231
+ interface HandlerError {
1232
+ handler: string;
1233
+ index: number;
1234
+ error: unknown;
1235
+ }
1236
+ /**
1237
+ * Outcome of a {@link IContractManager.scanContracts} run.
1238
+ *
1239
+ * `lastIndexUsed` is the highest HD index at which any handler discovered a
1240
+ * contract (`-1` if nothing was found). `handlerErrors` collects per-handler
1241
+ * `discoverAt` failures — non-empty means the gap window may have closed
1242
+ * early and the caller should surface this (the scan itself still resolved).
1243
+ */
1244
+ interface ScanResult {
1245
+ lastIndexUsed: number;
1246
+ handlerErrors: HandlerError[];
1247
+ }
1248
+ /**
1249
+ * Options for {@link IContractManager.scanContracts}.
1250
+ */
1251
+ interface ScanContractsOptions {
1252
+ /** Default 20. A non-positive / non-integer value throws. */
1253
+ gapLimit?: number;
1254
+ /** HD mode → unbounded gap loop guided by the gap counter; false → probe only index 0 (single static pass). */
1255
+ hd: boolean;
1256
+ /**
1257
+ * Materialize the descriptor at an HD index. Pure derivation; a throw
1258
+ * here is structural/fatal and propagates out of `scanContracts`.
1259
+ */
1260
+ materialize: (index: number) => string;
1261
+ /** Read-only context injected into every `discoverAt` call. */
1262
+ deps: DiscoveryDeps;
1263
+ }
1264
+ interface IContractManager extends Disposable {
1265
+ /**
1266
+ * Create and register a new contract.
1267
+ *
1268
+ * Implementations may validate that:
1269
+ * - A handler exists for `params.type`
1270
+ * - `params.script` matches the script derived from `params.params`
1271
+ *
1272
+ * The contract script is used as the unique identifier.
1273
+ */
1274
+ createContract(params: CreateContractParams): Promise<Contract>;
1275
+ /**
1276
+ * List contracts with optional filters.
1277
+ *
1278
+ * @example
1279
+ * ```typescript
1280
+ * const vhtlcs = await manager.getContracts({ type: "vhtlc" });
1281
+ * const active = await manager.getContracts({ state: "active" });
1282
+ * ```
1283
+ */
1284
+ getContracts(filter?: GetContractsFilter): Promise<Contract[]>;
1285
+ /**
1286
+ * List contracts and their current virtual outputs.
1287
+ *
1288
+ * If no filter is provided, returns all contracts with their virtual outputs.
1289
+ */
1290
+ getContractsWithVtxos(filter?: GetContractsFilter): Promise<ContractWithVtxos[]>;
1291
+ /**
1292
+ * Stamp raw virtual outputs with the correct per-contract tapscripts
1293
+ * (forfeit, intent, tap tree).
1294
+ *
1295
+ * Resolves each vtxo's `script` to its owning contract via the contract
1296
+ * repository and attaches the matching tapscripts. Throws when any vtxo
1297
+ * references a script with no registered contract — callers are expected
1298
+ * to register the contract before asking for annotation. This is the
1299
+ * single shared path that replaces scattered `extendVirtualCoin*` calls
1300
+ * in wallet/handler code, and keeps the wallet from silently stamping the
1301
+ * default tapscript onto a non-default vtxo.
1302
+ */
1303
+ annotateVtxos(vtxos: VirtualCoin[]): Promise<ExtendedVirtualCoin[]>;
1304
+ /**
1305
+ * Update mutable contract fields.
1306
+ *
1307
+ * `script` and `createdAt` are immutable.
1308
+ */
1309
+ updateContract(script: string, updates: Partial<Omit<Contract, "script" | "createdAt">>): Promise<Contract>;
1310
+ /**
1311
+ * Convenience helper to update only the contract state.
1312
+ */
1313
+ setContractState(script: string, state: ContractState): Promise<void>;
1314
+ /**
1315
+ * Delete a contract by script and stop watching it (if applicable).
1316
+ */
1317
+ deleteContract(script: string): Promise<void>;
1318
+ /**
1319
+ * Get all currently spendable paths for a contract.
1320
+ *
1321
+ * Returns an empty array if the contract or its handler cannot be found.
1322
+ */
1323
+ getSpendablePaths(options: GetSpendablePathsOptions): Promise<PathSelection[]>;
1324
+ /**
1325
+ * Get all possible spending paths for a contract.
1326
+ *
1327
+ * Returns an empty array if the contract or its handler cannot be found.
1328
+ */
1329
+ getAllSpendingPaths(options: GetAllSpendingPathsOptions): Promise<PathSelection[]>;
1330
+ /**
1331
+ * Subscribe to contract events.
1332
+ *
1333
+ * @returns Unsubscribe function
1334
+ */
1335
+ onContractEvent(callback: ContractEventCallback): () => void;
1336
+ /**
1337
+ * Force a virtual output refresh from the indexer.
1338
+ *
1339
+ * Without options, refreshes all contracts from scratch.
1340
+ * With options, narrows the refresh to specific scripts and/or a time window.
1341
+ */
1342
+ refreshVtxos(opts?: RefreshVtxosOptions): Promise<void>;
1343
+ /**
1344
+ * Reconcile specific outpoints with the indexer's authoritative state and
1345
+ * upsert the result into the wallet repository.
1346
+ *
1347
+ * The cursor-derived delta sync filters by `created_at`, so a VTXO that
1348
+ * was created before the cursor but spent recently won't surface in a
1349
+ * standard `refreshVtxos()` call. This method is the surgical recovery
1350
+ * path for that case: when something hands us a stale outpoint (e.g. the
1351
+ * server returns `VTXO_ALREADY_SPENT` with a `vtxo_outpoint` in its
1352
+ * error metadata), call this to pull the latest state and unblock the
1353
+ * caller — no full re-scan, no cursor change.
1354
+ *
1355
+ * Outpoints not owned by any tracked contract are silently dropped.
1356
+ */
1357
+ refreshOutpoints(outpoints: Outpoint[]): Promise<void>;
1358
+ /**
1359
+ * Explicit, gap-limit contract discovery used by `wallet.restore()`.
1360
+ *
1361
+ * Walks HD indices from 0, asking every registered `Discoverable`
1362
+ * handler whether it owns a contract anchored at that index, and
1363
+ * registers each find via the idempotent {@link createContract}. A hit
1364
+ * at index `i` (by any handler, including an injected swap handler)
1365
+ * resets the gap counter, so swap discovery keeps the HD window open.
1366
+ *
1367
+ * Error contract (safety-critical — see spec §4):
1368
+ * - A handler's `discoverAt` rejecting is **collected** into
1369
+ * `handlerErrors` and the loop **continues**; it never aborts the
1370
+ * scan or throws.
1371
+ * - A fatal operational error — `materialize()` throwing, or
1372
+ * `createContract` rejecting — **propagates** out of `scanContracts`
1373
+ * (it invalidates the gap-window signal, so a silent truncation
1374
+ * would risk hiding user funds).
1375
+ *
1376
+ * @param opts See {@link ScanContractsOptions}.
1377
+ * @returns `{ lastIndexUsed, handlerErrors }` — the caller surfaces
1378
+ * `handlerErrors` *after* the inline VTXO pull.
1379
+ */
1380
+ scanContracts(opts: ScanContractsOptions): Promise<ScanResult>;
1381
+ /**
1382
+ * Whether the underlying watcher is currently active.
1383
+ */
1384
+ isWatching(): Promise<boolean>;
1385
+ /**
1386
+ * Release resources (stop watching, clear listeners).
1387
+ */
1388
+ dispose(): void;
1389
+ }
1390
+ /**
1391
+ * Options for getting spendable paths.
1392
+ */
1393
+ type GetSpendablePathsOptions = {
1394
+ /** The contract script */
1395
+ contractScript: string;
1396
+ /** The specific virtual output being evaluated */
1397
+ vtxo: VirtualCoin;
1398
+ /** Whether collaborative spending is available (default: true) */
1399
+ collaborative?: boolean;
1400
+ /** Wallet's public key (hex) to determine role */
1401
+ walletPubKey?: string;
1402
+ };
1403
+ /**
1404
+ * Options for getting all possible spending paths.
1405
+ */
1406
+ type GetAllSpendingPathsOptions = {
1407
+ /** The contract script */
1408
+ contractScript: string;
1409
+ /** Whether collaborative spending is available (default: true) */
1410
+ collaborative?: boolean;
1411
+ /** Wallet's public key (hex) to determine role */
1412
+ walletPubKey?: string;
1413
+ };
1414
+ /**
1415
+ * Configuration for the ContractManager.
1416
+ */
1417
+ interface ContractManagerConfig {
1418
+ /** The indexer provider */
1419
+ indexerProvider: IndexerProvider;
1420
+ /** The contract repository for persistence */
1421
+ contractRepository: ContractRepository;
1422
+ /** The wallet repository for virtual output storage (single source of truth) */
1423
+ walletRepository: WalletRepository;
1424
+ /** Watcher configuration */
1425
+ watcherConfig?: Partial<ContractWatcherConfig>;
1426
+ }
1427
+ /**
1428
+ * Parameters for creating a new contract.
1429
+ */
1430
+ type CreateContractParams = Omit<Contract, "createdAt" | "state"> & {
1431
+ /** Initial state (defaults to "active") */
1432
+ state?: ContractState;
1433
+ };
1434
+ /**
1435
+ * Central manager for contract lifecycle and operations.
1436
+ *
1437
+ * Responsibilities:
1438
+ * - Create and persist contracts
1439
+ * - Query stored contracts (optionally with their virtual outputs)
1440
+ * - Provide spendable path selection for a contract
1441
+ * - Emit contract-related events (virtual output received/spent, connection reset)
1442
+ *
1443
+ * Notes:
1444
+ * - Implementations typically start watching automatically during initialization
1445
+ * (so `onContractEvent()` is just for subscribing).
1446
+ *
1447
+ * @example
1448
+ * ```typescript
1449
+ * const manager = await ContractManager.create({
1450
+ * indexerProvider: wallet.indexerProvider,
1451
+ * contractRepository: wallet.contractRepository,
1452
+ * });
1453
+ *
1454
+ * // Create a new VHTLC contract
1455
+ * const contract = await manager.createContract({
1456
+ * label: "Lightning Receive",
1457
+ * type: "vhtlc",
1458
+ * params: { sender: "ark1q...", receiver: "ark1q...", ... },
1459
+ * script: "5120...",
1460
+ * address: "ark1q...",
1461
+ * });
1462
+ *
1463
+ * // Start watching for events
1464
+ * const unsubscribe = manager.onContractEvent((event) => {
1465
+ * console.log(`${event.type} on ${event.contractScript}`);
1466
+ * });
1467
+ *
1468
+ * // Query contracts together with their current virtual outputs
1469
+ * const contractsWithVtxos = await manager.getContractsWithVtxos();
1470
+ *
1471
+ * // Get balance across all contracts
1472
+ * const balances = contractsWithVtxos.flatMap(({vtxos}) => vtxos).reduce((acc, vtxo) => acc + vtxo.value, 0)
1473
+ *
1474
+ * // Later: unsubscribe from events
1475
+ * unsubscribe();
1476
+ *
1477
+ * // Clean up
1478
+ * manager.dispose();
1479
+ * ```
1480
+ */
1481
+ declare class ContractManager implements IContractManager {
1482
+ private config;
1483
+ private watcher;
1484
+ private initialized;
1485
+ private eventCallbacks;
1486
+ private stopWatcherFn?;
1487
+ private constructor();
1488
+ /**
1489
+ * Static factory method for creating a new ContractManager.
1490
+ * Initialize the manager by loading persisted contracts and starting to watch.
1491
+ *
1492
+ * After initialization, the manager automatically watches all active contracts
1493
+ * and contracts with virtual outputs. Use `onContractEvent()` to register event callbacks.
1494
+ *
1495
+ * @param config ContractManagerConfig
1496
+ */
1497
+ static create(config: ContractManagerConfig): Promise<ContractManager>;
1498
+ private initialize;
1499
+ /**
1500
+ * Delta-sync the full watched set and reconcile the pending frontier.
1501
+ *
1502
+ * Shared recovery path used on initial boot and after a subscription
1503
+ * reconnect. `syncContracts({})` scopes to the current watched set
1504
+ * (see {@link ContractWatcher.getWatchedContracts}), uses the
1505
+ * cursor-derived delta window, and advances the cursor on success.
1506
+ * `reconcilePendingFrontier` catches not-yet-finalized virtual
1507
+ * outputs that could sit outside any delta window.
1508
+ */
1509
+ private reconcileWatched;
1510
+ /**
1511
+ * Create and register a new contract.
1512
+ *
1513
+ * @param params - Contract parameters
1514
+ * @returns The created contract
1515
+ */
1516
+ createContract(params: CreateContractParams): Promise<Contract>;
1517
+ /**
1518
+ * Lightweight variant of {@link createContract} for batch discovery
1519
+ * paths (currently: {@link scanContracts}). Validates, dedupes, persists,
1520
+ * and registers the watcher — but skips the per-contract
1521
+ * `fetchContractVxosFromIndexer` round-trip. The caller is responsible
1522
+ * for hydrating VTXOs afterwards via a bulk `refreshVtxos(...)` so a
1523
+ * scan that finds N contracts costs one batched indexer call instead
1524
+ * of N + 1. Error semantics are identical to `createContract`:
1525
+ * validation / type-mismatch / persistence failures propagate.
1526
+ */
1527
+ private persistAndWatchContract;
1528
+ /**
1529
+ * Shared validate + check-existing + persist core for
1530
+ * {@link createContract} and {@link persistAndWatchContract}. Returns
1531
+ * the resolved contract and whether *this* call wrote it — callers
1532
+ * that need to attach hydration / watcher work do so only when
1533
+ * `persisted` is `true`.
1534
+ */
1535
+ private upsertContract;
1536
+ /**
1537
+ * Explicit, gap-limit contract discovery (see {@link IContractManager.scanContracts}).
1538
+ *
1539
+ * Each hit is routed through {@link persistAndWatchContract} — the same
1540
+ * dedupe + watcher-register path as {@link createContract} minus the
1541
+ * per-contract indexer round-trip. The caller (`Wallet.restore`) follows
1542
+ * up with a single bulk `refreshVtxos({ includeInactive: true })`, so a
1543
+ * scan that finds N contracts costs one batched indexer call instead of
1544
+ * N + 1.
1545
+ *
1546
+ * Safety-critical invariants (spec §2.C / §4):
1547
+ * - `opts.materialize(i)` throwing is structural/fatal: it is NOT
1548
+ * wrapped — it propagates and aborts the scan.
1549
+ * - A `discoverAt` rejection is collected into `handlerErrors` and the
1550
+ * loop continues (the gap counter still advances for that index if no
1551
+ * other handler hit it).
1552
+ * - `persistAndWatchContract` rejecting is operational/fatal and
1553
+ * propagates (only `discoverAt` is guarded).
1554
+ */
1555
+ scanContracts(opts: ScanContractsOptions): Promise<ScanResult>;
1556
+ /**
1557
+ * Get contracts with optional filters.
1558
+ *
1559
+ * @param filter - Optional filter criteria
1560
+ * @returns Filtered contracts TODO: filter spent/unspent
1561
+ *
1562
+ * @example
1563
+ * ```typescript
1564
+ * // Get all VHTLC contracts
1565
+ * const vhtlcs = await manager.getContracts({ type: 'vhtlc' });
1566
+ *
1567
+ * // Get all active contracts
1568
+ * const active = await manager.getContracts({ state: 'active' });
1569
+ * ```
1570
+ */
1571
+ getContracts(filter?: GetContractsFilter): Promise<Contract[]>;
1572
+ getContractsWithVtxos(filter?: GetContractsFilter, pageSize?: number): Promise<ContractWithVtxos[]>;
1573
+ annotateVtxos(vtxos: VirtualCoin[]): Promise<ExtendedVirtualCoin[]>;
1574
+ private buildContractsDbFilter;
1575
+ /**
1576
+ * Update a contract.
1577
+ * Nested fields like `params` and `metadata` are replaced with the provided values.
1578
+ * If you need to preserve existing fields, merge them manually.
1579
+ *
1580
+ * @param script - Contract script
1581
+ * @param updates - Fields to update
1582
+ */
1583
+ updateContract(script: string, updates: Partial<Omit<Contract, "script" | "createdAt">>): Promise<Contract>;
1584
+ /**
1585
+ * Update a contract's params.
1586
+ * This method preserves existing params by merging the provided values.
1587
+ *
1588
+ * @param script - Contract script
1589
+ * @param updates - The new values to merge with existing params
1590
+ */
1591
+ updateContractParams(script: string, updates: Contract["params"]): Promise<Contract>;
1592
+ /**
1593
+ * Set a contract's state.
1594
+ */
1595
+ setContractState(script: string, state: ContractState): Promise<void>;
1596
+ /**
1597
+ * Delete a contract.
1598
+ *
1599
+ * @param script - Contract script
1600
+ */
1601
+ deleteContract(script: string): Promise<void>;
1602
+ /**
1603
+ * Get currently spendable paths for a contract.
1604
+ *
1605
+ * @param options - Options for getting spendable paths
1606
+ */
1607
+ getSpendablePaths(options: GetSpendablePathsOptions): Promise<PathSelection[]>;
1608
+ /**
1609
+ * Get every currently valid spending path for a contract.
1610
+ *
1611
+ * @param options - Options for getting spending paths
1612
+ */
1613
+ getAllSpendingPaths(options: GetAllSpendingPathsOptions): Promise<PathSelection[]>;
1614
+ /**
1615
+ * Register a callback for contract events.
1616
+ *
1617
+ * The manager automatically watches after `initialize()`. This method
1618
+ * allows registering callbacks to receive events.
1619
+ *
1620
+ * @param callback - Event callback
1621
+ * @returns Unsubscribe function to remove this callback
1622
+ *
1623
+ * @example
1624
+ * ```typescript
1625
+ * const unsubscribe = manager.onContractEvent((event) => {
1626
+ * console.log(`${event.type} on ${event.contractScript}`);
1627
+ * });
1628
+ *
1629
+ * // Later: stop receiving events
1630
+ * unsubscribe();
1631
+ * ```
1632
+ */
1633
+ onContractEvent(callback: ContractEventCallback): () => void;
1634
+ /**
1635
+ * Force refresh virtual outputs from the indexer.
1636
+ *
1637
+ * Without options, re-fetches every contract in the watcher's
1638
+ * watched set and advances the global cursor.
1639
+ *
1640
+ * `scripts` narrows the refresh to a specific list (subset query —
1641
+ * cursor is not advanced because contracts outside the list may
1642
+ * have data we'd skip).
1643
+ *
1644
+ * `includeInactive: true` (and no `scripts`) widens the refresh to
1645
+ * every contract in the repository, including ones marked
1646
+ * `inactive` and ones that have dropped out of the watcher's
1647
+ * active set. This is a *superset* of the watched set, so the
1648
+ * cursor invariant still holds and the cursor advances normally.
1649
+ *
1650
+ * `after` / `before` apply a caller-supplied time window. The
1651
+ * cursor never advances on a windowed query because the window
1652
+ * may skip data outside its bounds.
1653
+ */
1654
+ refreshVtxos(opts?: RefreshVtxosOptions): Promise<void>;
1655
+ refreshOutpoints(outpoints: Outpoint[]): Promise<void>;
1656
+ /**
1657
+ * Check if currently watching.
1658
+ */
1659
+ isWatching(): Promise<boolean>;
1660
+ /**
1661
+ * Emit an event to all registered callbacks.
1662
+ */
1663
+ private emitEvent;
1664
+ /**
1665
+ * Handle events from the watcher.
1666
+ */
1667
+ private handleContractEvent;
1668
+ private getVtxosForContracts;
1669
+ /**
1670
+ * Sync virtual outputs for the given contracts against the indexer.
1671
+ *
1672
+ * When `options.contracts` is omitted the sync covers the full
1673
+ * watched set (active contracts plus any inactive contracts still
1674
+ * holding cached VTXOs) and the global cursor is advanced on
1675
+ * success. Passing an explicit subset leaves the cursor alone so a
1676
+ * narrow poll can't hide data that other contracts still need to
1677
+ * pick up.
1678
+ */
1679
+ private syncContracts;
1680
+ /**
1681
+ * Fetch all pending (unfinalized) virtual outputs and upsert them into the
1682
+ * repository. This catches virtual outputs whose state changed outside the delta
1683
+ * window (e.g. a spend that hasn't settled yet).
1684
+ */
1685
+ private reconcilePendingFrontier;
1686
+ private fetchContractVxosFromIndexer;
1687
+ private fetchContractVtxosBulk;
1688
+ /**
1689
+ * Dispose of the ContractManager and release all resources.
1690
+ *
1691
+ * Stops the watcher, clears callbacks, and marks
1692
+ * the manager as uninitialized.
1693
+ *
1694
+ * Implements the disposable pattern for cleanup.
1695
+ */
1696
+ dispose(): void;
1697
+ /**
1698
+ * Symbol.dispose implementation for using with `using` keyword.
1699
+ * @example
1700
+ * ```typescript
1701
+ * {
1702
+ * using manager = await wallet.getContractManager();
1703
+ * // ... use manager
1704
+ * } // automatically disposed
1705
+ * ```
1706
+ */
1707
+ [Symbol.dispose](): void;
1708
+ }
1709
+
1710
+ /**
1711
+ * Contract state indicating whether it should be actively monitored.
1712
+ */
1713
+ type ContractState = "active" | "inactive";
1714
+ /**
1715
+ * Represents a contract that can receive and manage virtual outputs.
1716
+ *
1717
+ * A contract is defined by its type and parameters, which together
1718
+ * determine the VtxoScript (spending paths). The wallet's default
1719
+ * receiving address is itself a contract of type "default".
1720
+ *
1721
+ * External services (Boltz swaps, atomic swaps, etc.) create additional
1722
+ * contracts with their own types and parameters.
1723
+ *
1724
+ * @example
1725
+ * ```typescript
1726
+ * const vhtlcContract: Contract = {
1727
+ * type: "vhtlc",
1728
+ * params: {
1729
+ * sender: "ab12...",
1730
+ * receiver: "cd34...",
1731
+ * server: "ef56...",
1732
+ * hash: "1234...",
1733
+ * refundLocktime: "800000",
1734
+ * // ... timelocks
1735
+ * },
1736
+ * script: "5120...",
1737
+ * address: "ark1q...",
1738
+ * state: "active",
1739
+ * createdAt: 1704067200000,
1740
+ * };
1741
+ * ```
1742
+ */
1743
+ interface Contract {
1744
+ /** Human-readable label for display purposes. */
1745
+ label?: string;
1746
+ /**
1747
+ * Contract type identifier.
1748
+ * Built-in types: "default", "vhtlc"
1749
+ * Custom types can be registered via ContractHandler.
1750
+ */
1751
+ type: string;
1752
+ /**
1753
+ * Type-specific parameters for constructing the VtxoScript.
1754
+ * All values are serialized as strings (hex for bytes, string for bigint).
1755
+ * The ContractHandler for this type knows how to interpret these.
1756
+ */
1757
+ params: Record<string, string>;
1758
+ /** The pkScript hex, used as the unique identifier and primary key for contracts. */
1759
+ script: string;
1760
+ /** Address derived from the contract script. */
1761
+ address: string;
1762
+ /** Current state of the contract. */
1763
+ state: ContractState;
1764
+ /** Unix timestamp in milliseconds when this contract was created. */
1765
+ createdAt: number;
1766
+ /**
1767
+ * Optional metadata for external integrations.
1768
+ */
1769
+ metadata?: Record<string, unknown>;
1770
+ }
1771
+ /**
1772
+ * A virtual output that has been associated with a specific contract.
1773
+ */
1774
+ type ContractVtxo = VirtualCoin & Partial<TapLeaves & EncodedVtxoScript> & {
1775
+ extraWitness?: Bytes[];
1776
+ contractScript: string;
1777
+ };
1778
+ /**
1779
+ * A {@link ContractVtxo} with all taproot annotation fields required.
1780
+ *
1781
+ * Mirrors the {@link ExtendedVirtualCoin} / {@link VirtualCoin} split:
1782
+ * - {@link ContractVtxo} carries `TapLeaves` and `EncodedVtxoScript` as
1783
+ * `Partial<>` because VTXOs fetched raw from the indexer do not yet have
1784
+ * taproot data.
1785
+ * - `ExtendedContractVtxo` narrows those fields to required, guaranteeing
1786
+ * that `annotateVtxos` has run and the taproot leaves are present.
1787
+ *
1788
+ * Use this type (instead of {@link ContractVtxo}) wherever the compiler
1789
+ * should enforce that annotation has happened — e.g. `saveVtxos` and
1790
+ * forfeit transaction construction.
1791
+ */
1792
+ type ExtendedContractVtxo = ExtendedVirtualCoin & {
1793
+ contractScript: string;
1794
+ };
1795
+ /**
1796
+ * Result of path selection, including the tapleaf to use and any extra witness data.
1797
+ */
1798
+ interface PathSelection {
1799
+ /** Tapleaf script to use for spending. */
1800
+ leaf: TapLeafScript;
1801
+ /** Additional witness elements, for example a preimage for HTLC-like paths. */
1802
+ extraWitness?: Bytes[];
1803
+ /**
1804
+ * nSequence for the spending input, BIP-68 encoded when the leaf
1805
+ * uses CSV. Decode with `sequenceToTimelock`; do NOT use as an
1806
+ * absolute `Transaction.lockTime`.
1807
+ */
1808
+ sequence?: number;
1809
+ }
1810
+ /**
1811
+ * Context for path selection decisions.
1812
+ */
1813
+ interface PathContext {
1814
+ /** Whether collaborative spending is available through server cooperation. */
1815
+ collaborative: boolean;
1816
+ /** Current time in milliseconds. */
1817
+ currentTime: number;
1818
+ /** Current block height, when known. */
1819
+ blockHeight?: number;
1820
+ /**
1821
+ * Wallet's descriptor for signing.
1822
+ * Format: tr(pubkey) for static keys, tr([fingerprint/path']xpub/0/{index}) for HD.
1823
+ * Used by handlers to determine wallet's role in multi-party contracts.
1824
+ */
1825
+ walletDescriptor?: string;
1826
+ /**
1827
+ * Wallet's public key (x-only, 32 bytes hex).
1828
+ * @deprecated Use walletDescriptor instead.
1829
+ */
1830
+ walletPubKey?: string;
1831
+ /**
1832
+ * Explicit role override for multi-party contracts such as VHTLC.
1833
+ * If not provided, the handler may derive the role by matching
1834
+ * {@link walletDescriptor} (preferred) — or {@link walletPubKey} as a
1835
+ * fallback — against the contract's sender/receiver params.
1836
+ */
1837
+ role?: string;
1838
+ /** The specific virtual output being evaluated. */
1839
+ vtxo?: VirtualCoin;
1840
+ }
1841
+ /**
1842
+ * Handler for a specific contract type.
1843
+ *
1844
+ * Each contract type (`default`, `vhtlc`, etc.) has a handler that knows how to:
1845
+ * 1. Create the VtxoScript from parameters
1846
+ * 2. Serialize/deserialize parameters for storage
1847
+ * 3. Select the appropriate spending path based on context
1848
+ *
1849
+ * @example
1850
+ * ```typescript
1851
+ * const vhtlcHandler: ContractHandler = {
1852
+ * type: "vhtlc",
1853
+ * createScript(params) {
1854
+ * return new VHTLC.Script(this.deserializeParams(params));
1855
+ * },
1856
+ * selectPath(script, contract, context) {
1857
+ * const vhtlc = script as VHTLC.Script;
1858
+ * const preimage = contract.data?.preimage;
1859
+ * if (context.collaborative && preimage) {
1860
+ * return { leaf: vhtlc.claim(), extraWitness: [hex.decode(preimage)] };
1861
+ * }
1862
+ * // ... other paths
1863
+ * },
1864
+ * // ...
1865
+ * };
1866
+ * ```
1867
+ */
1868
+ interface ContractHandler<P = Record<string, unknown>, S extends VtxoScript = VtxoScript> {
1869
+ /** Contract type managed by this handler. */
1870
+ readonly type: string;
1871
+ /**
1872
+ * Create the VtxoScript from serialized parameters.
1873
+ *
1874
+ * @param params - Serialized contract parameters
1875
+ * @returns Contract script instance
1876
+ */
1877
+ createScript(params: Record<string, string>): S;
1878
+ /**
1879
+ * Serialize typed parameters to string key-value pairs.
1880
+ *
1881
+ * @param params - Typed contract parameters
1882
+ * @returns Serialized key-value representation
1883
+ */
1884
+ serializeParams(params: P): Record<string, string>;
1885
+ /**
1886
+ * Deserialize string key-value pairs to typed parameters.
1887
+ */
1888
+ deserializeParams(params: Record<string, string>): P;
1889
+ /**
1890
+ * Select the preferred spending path based on contract state and context.
1891
+ * Returns the best available path (e.g., collaborative over unilateral).
1892
+ *
1893
+ * @returns PathSelection if a viable path exists, null otherwise
1894
+ */
1895
+ selectPath(script: S, contract: Contract, context: PathContext): PathSelection | null;
1896
+ /**
1897
+ * Get all possible spending paths for the current context.
1898
+ * Returns empty array if no paths are available.
1899
+ *
1900
+ * Useful for showing users which spending options exist regardless of
1901
+ * current spendability.
1902
+ */
1903
+ getAllSpendingPaths(script: S, contract: Contract, context: PathContext): PathSelection[];
1904
+ /**
1905
+ * Get all currently spendable paths.
1906
+ * Returns empty array if no paths are available.
1907
+ */
1908
+ getSpendablePaths(script: S, contract: Contract, context: PathContext): PathSelection[];
1909
+ }
1910
+ /**
1911
+ * What a {@link Discoverable.discoverAt} call returns — exactly the
1912
+ * shape `ContractManager.createContract` accepts (script-keyed,
1913
+ * idempotent on re-register).
1914
+ */
1915
+ interface DiscoveredContract {
1916
+ type: string;
1917
+ params: Record<string, string>;
1918
+ script: string;
1919
+ address: string;
1920
+ metadata?: Record<string, unknown>;
1921
+ label?: string;
1922
+ }
1923
+ /**
1924
+ * Read-only context the scanner injects into every `discoverAt` call.
1925
+ * The boltz/swap handler does NOT receive its Boltz client here — it
1926
+ * closes over its own client at registration time.
1927
+ */
1928
+ interface DiscoveryDeps {
1929
+ indexerProvider: IndexerProvider;
1930
+ onchainProvider: OnchainProvider;
1931
+ network: {
1932
+ hrp: string;
1933
+ };
1934
+ serverPubKey: Uint8Array;
1935
+ /** Relative timelocks the wallet treats as its baseline matrix. */
1936
+ csvTimelocks: RelativeTimelock[];
1937
+ /** Present only for delegate wallets. */
1938
+ delegatePubKey?: Uint8Array;
1939
+ }
1940
+ /**
1941
+ * Optional capability a {@link ContractHandler} implements to participate
1942
+ * in `wallet.restore()`'s gap-limit scan. The scanner owns the index
1943
+ * loop and the gap counter; the handler answers "do I own a contract
1944
+ * anchored to the pubkey/descriptor at this index?" — checked against
1945
+ * the indexer / explorer / (for swaps) the handler's own source. The
1946
+ * handler MAY batch/cache internally across calls.
1947
+ */
1948
+ interface Discoverable {
1949
+ discoverAt(index: number, descriptor: string, deps: DiscoveryDeps): Promise<DiscoveredContract[]>;
1950
+ }
1951
+ /** Duck-typed guard (mirrors `hasReceiveRotatorFactory`). */
1952
+ declare function isDiscoverable(handler: ContractHandler<unknown> | undefined): handler is ContractHandler<unknown> & Discoverable;
1953
+ /**
1954
+ * Event emitted when contract-related changes occur.
1955
+ */
1956
+ type ContractEvent = {
1957
+ type: "vtxo_received";
1958
+ contractScript: string;
1959
+ vtxos: ContractVtxo[];
1960
+ contract: Contract;
1961
+ timestamp: number;
1962
+ } | {
1963
+ type: "vtxo_spent";
1964
+ contractScript: string;
1965
+ vtxos: ContractVtxo[];
1966
+ contract: Contract;
1967
+ timestamp: number;
1968
+ } | {
1969
+ type: "connection_reset";
1970
+ timestamp: number;
1971
+ };
1972
+ /**
1973
+ * Callback for contract events.
1974
+ */
1975
+ type ContractEventCallback = (event: ContractEvent) => void;
1976
+ /**
1977
+ * Options for retrieving contracts from the Contract Manager.
1978
+ * Currently an alias of the repository's filter type but can be extended in the future.
1979
+ */
1980
+ type GetContractsFilter = ContractFilter;
1981
+ /**
1982
+ * Contract with its virtual outputs included.
1983
+ */
1984
+ type ContractWithVtxos = {
1985
+ contract: Contract;
1986
+ vtxos: ExtendedContractVtxo[];
1987
+ };
1988
+ /**
1989
+ * Summary of a contract's balance.
1990
+ */
1991
+ interface ContractBalance {
1992
+ /** Total balance (settled + pending) in satoshis */
1993
+ total: number;
1994
+ /** Spendable balance in satoshis */
1995
+ spendable: number;
1996
+ /** Number of virtual outputs in this contract */
1997
+ vtxoCount: number;
1998
+ }
1999
+
2000
+ /**
2001
+ * Configuration for the ContractWatcher.
2002
+ *
2003
+ * @see ContractWatcher
2004
+ *
2005
+ * @example
2006
+ * ```typescript
2007
+ * const watcher = new ContractWatcher({
2008
+ * indexerProvider,
2009
+ * walletRepository,
2010
+ * })
2011
+ * ```
2012
+ */
2013
+ interface ContractWatcherConfig {
2014
+ /** Indexer provider used for subscriptions and queries. */
2015
+ indexerProvider: IndexerProvider;
2016
+ /** Wallet repository used to store virtual output state between watcher updates. */
2017
+ walletRepository: WalletRepository;
2018
+ /**
2019
+ * Interval for failsafe polling (ms).
2020
+ * Polls even when subscription is active to catch missed events.
2021
+ *
2022
+ * @defaultValue `60_000` (1 minute)
2023
+ */
2024
+ failsafePollIntervalMs?: number;
2025
+ /**
2026
+ * Initial reconnection delay (ms).
2027
+ * Uses exponential backoff on repeated failures.
2028
+ *
2029
+ * @defaultValue `1_000` (1 second)
2030
+ */
2031
+ reconnectDelayMs?: number;
2032
+ /**
2033
+ * Maximum reconnection delay (ms).
2034
+ *
2035
+ * @defaultValue `30_000` (30 seconds)
2036
+ */
2037
+ maxReconnectDelayMs?: number;
2038
+ /**
2039
+ * Maximum reconnection attempts before giving up.
2040
+ * Set to 0 for unlimited attempts.
2041
+ *
2042
+ * @defaultValue `0` (unlimited)
2043
+ */
2044
+ maxReconnectAttempts?: number;
2045
+ }
2046
+ /**
2047
+ * Connection state for the watcher.
2048
+ */
2049
+ type ConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting";
2050
+ /**
2051
+ * Watches multiple contracts for virtual output state changes with resilient connection handling.
2052
+ *
2053
+ * Features:
2054
+ * - Automatic reconnection with exponential backoff
2055
+ * - Failsafe polling to catch missed events
2056
+ * - Polls immediately after (re)connection to sync state
2057
+ * - Graceful handling of subscription failures
2058
+ *
2059
+ * @example
2060
+ * ```typescript
2061
+ * const watcher = new ContractWatcher({
2062
+ * indexerProvider: wallet.indexerProvider,
2063
+ * });
2064
+ *
2065
+ * // Add the wallet's default contract
2066
+ * await watcher.addContract(defaultContract);
2067
+ *
2068
+ * // Add additional contracts (swaps, etc.)
2069
+ * await watcher.addContract(swapContract);
2070
+ *
2071
+ * // Start watching for events
2072
+ * const stop = await watcher.startWatching((event) => {
2073
+ * console.log(`${event.type} on contract ${event.contractScript}`);
2074
+ * });
2075
+ *
2076
+ * // Later: stop watching
2077
+ * stop();
2078
+ * ```
2079
+ */
2080
+ declare class ContractWatcher {
2081
+ private config;
2082
+ private contracts;
2083
+ private subscriptionId?;
2084
+ private abortController?;
2085
+ private isWatching;
2086
+ private eventCallback?;
2087
+ private connectionState;
2088
+ private reconnectAttempts;
2089
+ private reconnectTimeoutId?;
2090
+ private failsafePollIntervalId?;
2091
+ /**
2092
+ * Create a contract watcher with the given providers and polling settings.
2093
+ *
2094
+ * @param config - Contract watcher configuration
2095
+ * @see ContractWatcherConfig
2096
+ */
2097
+ constructor(config: ContractWatcherConfig);
2098
+ /**
2099
+ * Add a contract to be watched.
2100
+ *
2101
+ * Active contracts are immediately subscribed.
2102
+ *
2103
+ * All contracts are polled to discover any existing virtual outputs
2104
+ * (which may cause them to be watched even if inactive).
2105
+ */
2106
+ addContract(contract: Contract): Promise<void>;
2107
+ /**
2108
+ * Pre-populate `lastKnownVtxos` from the wallet repository.
2109
+ *
2110
+ * Runs on add (and can be re-run after reconnect) so polling always
2111
+ * compares the indexer's view against what is already persisted,
2112
+ * emitting only genuine deltas.
2113
+ */
2114
+ private seedLastKnownVtxos;
2115
+ /**
2116
+ * Update an existing contract.
2117
+ */
2118
+ updateContract(contract: Contract): Promise<void>;
2119
+ /**
2120
+ * Remove a contract from watching.
2121
+ */
2122
+ removeContract(contractScript: string): Promise<void>;
2123
+ /**
2124
+ * Get all in-memory contracts.
2125
+ */
2126
+ getAllContracts(): Contract[];
2127
+ /**
2128
+ * Contracts the watcher is actually tracking:
2129
+ * - all active contracts, plus
2130
+ * - inactive contracts that still hold known virtual outputs
2131
+ * (the subscription keeps watching them so `vtxo_spent` events for
2132
+ * those unspent outputs are still observed).
2133
+ *
2134
+ * This is the single source of truth for "contracts whose VTXO state
2135
+ * we still care about" — callers and the subscription itself fan out
2136
+ * over the same set so nothing is reconciled that isn't also watched.
2137
+ */
2138
+ getWatchedContracts(): Contract[];
2139
+ /**
2140
+ * Get virtual outputs for contracts, grouped by contract script.
2141
+ * @see WalletRepository for `repo`
2142
+ */
2143
+ private getContractVtxos;
2144
+ /**
2145
+ * Start watching for virtual output events across all active contracts.
2146
+ */
2147
+ startWatching(callback: ContractEventCallback): Promise<() => void>;
2148
+ /**
2149
+ * Stop watching for events.
2150
+ */
2151
+ stopWatching(): Promise<void>;
2152
+ /**
2153
+ * Check if currently watching.
2154
+ */
2155
+ isCurrentlyWatching(): boolean;
2156
+ /**
2157
+ * Get current connection state.
2158
+ */
2159
+ getConnectionState(): ConnectionState;
2160
+ /**
2161
+ * Force a poll of all active contracts.
2162
+ * Useful for manual refresh or after app resume.
2163
+ */
2164
+ forcePoll(): Promise<void>;
2165
+ /**
2166
+ * Connect to the subscription.
2167
+ *
2168
+ * @param skipUpdate - Skip the leading `updateSubscription` call when
2169
+ * the caller has already established `subscriptionId`.
2170
+ */
2171
+ private connect;
2172
+ /**
2173
+ * Schedule a reconnection attempt.
2174
+ */
2175
+ private scheduleReconnect;
2176
+ /**
2177
+ * Start the failsafe polling interval.
2178
+ */
2179
+ private startFailsafePolling;
2180
+ private pollAllContracts;
2181
+ /**
2182
+ * Poll specific contracts and emit events for changes.
2183
+ */
2184
+ private pollContracts;
2185
+ private tryUpdateSubscription;
2186
+ /**
2187
+ * Update the subscription with scripts that should be watched.
2188
+ *
2189
+ * Watches both active contracts and contracts with virtual outputs.
2190
+ */
2191
+ private updateSubscription;
2192
+ /**
2193
+ * Main listening loop for subscription events.
2194
+ */
2195
+ private listenLoop;
2196
+ /**
2197
+ * Handle a subscription update.
2198
+ */
2199
+ private handleSubscriptionUpdate;
2200
+ /**
2201
+ * Process virtual outputs from subscription and route each VTXO to the
2202
+ * single contract that actually locks it via `vtxo.script`. If the script
2203
+ * doesn't match any watched contract, skip the VTXO rather than fan it
2204
+ * out to every matching contract — fan-out produced phantom state in
2205
+ * non-owning contracts that then never reconciled.
2206
+ */
2207
+ private processSubscriptionVtxos;
2208
+ /**
2209
+ * Emit a virtual output event for a contract.
2210
+ */
2211
+ private emitVtxoEvent;
2212
+ }
2213
+
2214
+ /**
2215
+ * Intent proof implementation for Bitcoin message signing.
2216
+ *
2217
+ * Intent proof defines a standard for signing Bitcoin messages as well as proving
2218
+ * ownership of outputs.
2219
+ *
2220
+ * This namespace provides utilities for creating and validating Intent proof.
2221
+ *
2222
+ * It is greatly inspired by BIP322.
2223
+ * @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
2224
+ *
2225
+ * @example
2226
+ * ```typescript
2227
+ * // Create a Intent proof
2228
+ * const proof = Intent.create(
2229
+ * "Hello Bitcoin!",
2230
+ * [input],
2231
+ * [output]
2232
+ * );
2233
+ *
2234
+ * // Sign the proof
2235
+ * const signedProof = await identity.sign(proof);
2236
+ *
2237
+ */
2238
+ declare namespace Intent {
2239
+ type Proof = Transaction;
2240
+ /**
2241
+ * Creates a new Intent proof unsigned transaction.
2242
+ *
2243
+ * This function constructs a special transaction that can be signed to prove
2244
+ * ownership of onchain and virtual outputs. The proof includes the message to be
2245
+ * signed and the inputs/outputs that demonstrate ownership.
2246
+ *
2247
+ * @param message - The Intent message to be signed, either raw string of Message object
2248
+ * @param ins - Array of transaction inputs to prove ownership of
2249
+ * @param outputs - Optional array of transaction outputs
2250
+ * @returns An unsigned Intent proof transaction
2251
+ */
2252
+ function create(message: string | Message, ins: (TransactionInput | ExtendedCoin)[], outputs?: TransactionOutput[]): Proof;
2253
+ /**
2254
+ * Compute the fee paid by an intent proof transaction.
2255
+ *
2256
+ * @param proof - Intent proof transaction
2257
+ * @returns The fee in satoshis
2258
+ */
2259
+ function fee(proof: Proof): number;
2260
+ type RegisterMessage = {
2261
+ type: "register";
2262
+ onchain_output_indexes: number[];
2263
+ valid_at: number;
2264
+ expire_at: number;
2265
+ cosigners_public_keys: string[];
2266
+ };
2267
+ type DeleteMessage = {
2268
+ type: "delete";
2269
+ expire_at: number;
2270
+ };
2271
+ type GetPendingTxMessage = {
2272
+ type: "get-pending-tx";
2273
+ expire_at: number;
2274
+ };
2275
+ type Message = RegisterMessage | DeleteMessage | GetPendingTxMessage;
2276
+ /**
2277
+ * Serialize an intent message to the canonical JSON string used for signing.
2278
+ *
2279
+ * @param message - Intent message payload
2280
+ * @returns Canonical string form of the message
2281
+ */
2282
+ function encodeMessage(message: Message): string;
2283
+ }
2284
+
2285
+ /**
2286
+ * Delegate identity and fee information returned by `getDelegateInfo`.
2287
+ */
2288
+ interface DelegateInfo {
2289
+ /** Delegate public key. */
2290
+ pubkey: string;
2291
+ /** Delegate fee amount or expression returned by the delegate. */
2292
+ fee: string;
2293
+ /** Address for delegate fee collection. Sourced from `delegatorAddress` in Fulmine response, for now. */
2294
+ delegateAddress: string;
2295
+ /** @deprecated alias for @see DelegateInfo.delegateAddress */
2296
+ delegatorAddress?: string;
2297
+ }
2298
+ /**
2299
+ * Optional delegate behavior flags.
2300
+ */
2301
+ interface DelegateOptions {
2302
+ /**
2303
+ * Instruct the delegate not to replace an existing delegation
2304
+ * (meaning a signed register intent and its forfeit transactions)
2305
+ * that already includes at least one virtual output from this request.
2306
+ *
2307
+ * @defaultValue `false`
2308
+ */
2309
+ rejectReplace?: boolean;
2310
+ }
2311
+ /**
2312
+ * Provider interface for remote delegation service.
2313
+ */
2314
+ interface DelegateProvider {
2315
+ /**
2316
+ * Request delegation for a signed register intent and its forfeit transactions.
2317
+ *
2318
+ * @param intent - Signed register intent to delegate
2319
+ * @param forfeitTxs - Forfeit transactions associated with the delegation request
2320
+ * @param options - Optional delegate behavior flags
2321
+ */
2322
+ delegate(intent: SignedIntent<Intent.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
2323
+ /**
2324
+ * Fetch delegate metadata such as pubkey, fee, and delegate address.
2325
+ *
2326
+ * @returns Delegate identity and fee information
2327
+ */
2328
+ getDelegateInfo(): Promise<DelegateInfo>;
2329
+ }
2330
+ /** @deprecated alias for @see DelegateProvider */
2331
+ type DelegatorProvider = DelegateProvider;
2332
+ /**
2333
+ * REST-based delegate provider implementation.
2334
+ * @example
2335
+ * ```typescript
2336
+ * const provider = new RestDelegateProvider('https://delegate.example.com');
2337
+ * const info = await provider.getDelegateInfo();
2338
+ * await provider.delegate(intent, forfeitTxs);
2339
+ * ```
2340
+ */
2341
+ declare class RestDelegateProvider implements DelegateProvider {
2342
+ url: string;
2343
+ /**
2344
+ * Create a REST delegate provider targeting the given base URL.
2345
+ *
2346
+ * @param url - Base URL of the remote delegation service.
2347
+ */
2348
+ constructor(url: string);
2349
+ /**
2350
+ * Submit a delegation request to the remote delegation service.
2351
+ *
2352
+ * @param intent - Signed register intent to delegate
2353
+ * @param forfeitTxs - Forfeit transactions associated with the delegation request
2354
+ * @param options - Optional delegate behavior flags
2355
+ * @throws Error if the remote service rejects the request
2356
+ */
2357
+ delegate(intent: SignedIntent<Intent.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
2358
+ /**
2359
+ * Fetch delegate metadata exposed by the remote delegation service.
2360
+ *
2361
+ * @returns Delegate identity and fee information
2362
+ * @throws Error if the remote service returns invalid data
2363
+ */
2364
+ getDelegateInfo(): Promise<DelegateInfo>;
2365
+ }
2366
+ /** @deprecated alias for @see RestDelegateProvider */
2367
+ declare const RestDelegatorProvider: typeof RestDelegateProvider;
2368
+ type RestDelegatorProvider = RestDelegateProvider;
2369
+
2370
+ interface IDelegateManager {
2371
+ /**
2372
+ * Delegate virtual outputs to the remote delegation service.
2373
+ *
2374
+ * Vtxos that are not locked to a delegate-type contract (no tap leaf
2375
+ * matches the delegate's pubkey) are filtered out silently, since they
2376
+ * cannot be co-signed by the delegate.
2377
+ *
2378
+ * @param vtxos - Virtual outputs to delegate
2379
+ * @param destination - Arkade address that should receive renewed funds
2380
+ * @param delegateAt - Optional timestamp to force a specific delegation time
2381
+ * @returns Successfully delegated and failed outpoint groups
2382
+ */
2383
+ delegate(vtxos: ContractVtxo[], destination: string, delegateAt?: Date): Promise<{
2384
+ delegated: Outpoint[];
2385
+ failed: {
2386
+ outpoints: Outpoint[];
2387
+ error: unknown;
2388
+ }[];
2389
+ }>;
2390
+ /** Fetch delegate metadata such as pubkey, fee, and delegate address. */
2391
+ getDelegateInfo(): Promise<DelegateInfo>;
2392
+ }
2393
+ /** @deprecated alias for @see IDelegateManager */
2394
+ type IDelegatorManager = IDelegateManager;
2395
+ declare class DelegateManagerImpl implements IDelegateManager {
2396
+ readonly delegateProvider: DelegateProvider;
2397
+ readonly arkInfoProvider: Pick<ArkProvider, "getInfo">;
2398
+ readonly identity: Identity;
2399
+ /** Create a delegate manager from the configured provider, Arkade info source, and wallet identity. */
2400
+ constructor(delegateProvider: DelegateProvider, arkInfoProvider: Pick<ArkProvider, "getInfo">, identity: Identity);
2401
+ getDelegateInfo(): Promise<DelegateInfo>;
2402
+ delegate(vtxos: ContractVtxo[], destination: string, delegateAt?: Date): Promise<{
2403
+ delegated: Outpoint[];
2404
+ failed: {
2405
+ outpoints: Outpoint[];
2406
+ error: unknown;
2407
+ }[];
2408
+ }>;
2409
+ }
2410
+ /** @deprecated alias for @see DelegateManagerImpl */
2411
+ declare const DelegatorManagerImpl: typeof DelegateManagerImpl;
2412
+ type DelegatorManagerImpl = DelegateManagerImpl;
2413
+
2414
+ /**
2415
+ * Wallet receive-address strategy.
2416
+ *
2417
+ * - `'auto'` *(default)*: **short-term** — currently identical to
2418
+ * `'static'`. The `'auto'` name is reserved for a future change that
2419
+ * will re-enable identity-probing once HD rotation has matured in
2420
+ * the field. Until then, opt into HD explicitly via `'hd'` or a
2421
+ * {@link DescriptorProvider}.
2422
+ * *(See `TODO(hd-maturation)` in
2423
+ * `src/wallet/walletReceiveRotator.ts:resolveDescriptorProvider` for
2424
+ * the flip-back criteria.)*
2425
+ * - `'static'`: never rotate. The wallet uses one receive address derived
2426
+ * from `identity.xOnlyPublicKey()`.
2427
+ * - `'hd'`: must rotate, using the built-in HD provider derived from the
2428
+ * identity. Throws at `Wallet.create` if the identity isn't HD-capable
2429
+ * or its descriptor isn't rangeable — no silent fallback.
2430
+ * - A {@link DescriptorProvider} instance: rotate via the supplied
2431
+ * provider on every incoming VTXO. The wallet does not probe the
2432
+ * identity; the caller is responsible for ensuring the identity can
2433
+ * sign for whatever pubkey the provider returns. Errors thrown by the
2434
+ * provider propagate — there is no silent fallback for an explicit
2435
+ * provider.
2436
+ */
2437
+ type WalletMode = "auto" | "static" | "hd" | DescriptorProvider;
2438
+ /**
2439
+ * Base configuration options shared by all wallet types.
2440
+ *
2441
+ * Supports URL-based and provider-based configuration.
2442
+ *
2443
+ * @deprecated URL-based configuration starts from `arkServerUrl` and can optionally override
2444
+ * derived service URLs such as `indexerUrl` and `esploraUrl`.
2445
+ *
2446
+ * Provider-based configuration supplies concrete provider instances directly,
2447
+ * including the ArkProvider, IndexerProvider, OnchainProvider, and DelegateProvider.
2448
+ *
2449
+ * The wallet will use provided URLs to create default providers if custom provider
2450
+ * instances are not supplied. If optional parameters are not provided, the wallet
2451
+ * will fetch configuration from the Arkade server.
2452
+ *
2453
+ * @remarks
2454
+ * URL-based and provider-based configuration can be mixed, but provider instances
2455
+ * always take precedence over URLs for the corresponding service.
2456
+ *
2457
+ * @see WalletConfig
2458
+ * @see ReadonlyWalletConfig
2459
+ * @see StorageConfig
2460
+ */
2461
+ interface BaseWalletConfig {
2462
+ /**
2463
+ * Base URL of the Arkade server.
2464
+ *
2465
+ * @deprecated Pass an explicit `arkProvider` instance instead. URL-based
2466
+ * configuration will be removed in a future major version.
2467
+ */
2468
+ arkServerUrl?: string;
2469
+ /**
2470
+ * Optional override for the indexer URL.
2471
+ *
2472
+ * @deprecated Pass an explicit `indexerProvider` instance instead.
2473
+ */
2474
+ indexerUrl?: string;
2475
+ /**
2476
+ * Optional override for the Esplora API URL.
2477
+ *
2478
+ * @deprecated Pass an explicit `onchainProvider` instance instead.
2479
+ */
2480
+ esploraUrl?: string;
2481
+ /** Optional Arkade server public key used to construct and validate Arkade addresses. */
2482
+ arkServerPublicKey?: string;
2483
+ /** Relative timelock applied to boarding scripts. */
2484
+ boardingTimelock?: RelativeTimelock;
2485
+ /** Relative timelock applied to unilateral exit paths. */
2486
+ exitTimelock?: RelativeTimelock;
2487
+ /**
2488
+ * Repository-backed storage configuration overrides.
2489
+ * Defaults to IndexedDB if unset.
2490
+ */
2491
+ storage?: StorageConfig;
2492
+ /** Optional Arkade provider instance. */
2493
+ arkProvider?: ArkProvider;
2494
+ /** Optional indexer provider instance. */
2495
+ indexerProvider?: IndexerProvider;
2496
+ /** Optional onchain provider instance. */
2497
+ onchainProvider?: OnchainProvider;
2498
+ /** Optional delegation service instance. */
2499
+ delegateProvider?: DelegateProvider;
2500
+ /** @deprecated alias for @see BaseWalletConfig.delegateProvider */
2501
+ delegatorProvider?: DelegateProvider;
2502
+ }
2503
+ /**
2504
+ * Configuration options for readonly wallet initialization.
2505
+ *
2506
+ * Use this config when you only need to query wallet state (balance, addresses, transactions)
2507
+ * without the ability to send transactions. This is useful for:
2508
+ * - Watch-only wallets
2509
+ * - Monitoring addresses
2510
+ * - Safe sharing of wallet state without private key exposure
2511
+ *
2512
+ * @see BaseWalletConfig
2513
+ * @see IReadonlyWallet
2514
+ *
2515
+ * @example
2516
+ * ```typescript
2517
+ * // Provider-based configuration (e.g., for Expo/React Native)
2518
+ * const wallet = await ReadonlyWallet.create({
2519
+ * identity: ReadonlySingleKey.fromPublicKey(pubkey),
2520
+ * arkProvider: new ExpoArkProvider(),
2521
+ * indexerProvider: new ExpoIndexerProvider(),
2522
+ * onchainProvider: new EsploraProvider()
2523
+ * });
2524
+ * ```
2525
+ */
2526
+ interface ReadonlyWalletConfig extends BaseWalletConfig {
2527
+ /** Readonly identity used to derive wallet addresses. */
2528
+ identity: ReadonlyIdentity;
2529
+ /**
2530
+ * Configuration for the ContractManager's watcher.
2531
+ * Controls reconnection behavior and failsafe polling.
2532
+ *
2533
+ * @see ContractWatcherConfig
2534
+ */
2535
+ watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
2536
+ }
2537
+ /**
2538
+ * Configuration options for full wallet initialization.
2539
+ *
2540
+ * This config provides full wallet capabilities including sending transactions,
2541
+ * settling virtual outputs, and all readonly operations.
2542
+ *
2543
+ * @see ReadonlyWalletConfig
2544
+ * @see IWallet
2545
+ *
2546
+ * @example
2547
+ * ```typescript
2548
+ * // Provider-based configuration
2549
+ * const wallet = await Wallet.create({
2550
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
2551
+ * arkProvider: new ExpoArkProvider(),
2552
+ * indexerProvider: new ExpoIndexerProvider(),
2553
+ * onchainProvider: new EsploraProvider()
2554
+ * });
2555
+ *
2556
+ * // With settlement configuration
2557
+ * const wallet = await Wallet.create({
2558
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
2559
+ * arkProvider: new RestArkProvider(),
2560
+ * settlementConfig: {
2561
+ * vtxoThreshold: 60 * 60 * 24, // 24 hours in seconds
2562
+ * boardingUtxoSweep: true,
2563
+ * },
2564
+ * });
2565
+ * ```
2566
+ */
2567
+ interface WalletConfig extends ReadonlyWalletConfig {
2568
+ /** Signing identity used to authorize transactions. */
2569
+ identity: Identity;
2570
+ /**
2571
+ * Legacy renewal configuration.
2572
+ *
2573
+ * @remarks
2574
+ * This field is still accepted for backwards compatibility, but `settlementConfig`
2575
+ * is the source of truth for new code.
2576
+ *
2577
+ * @deprecated Use `settlementConfig` instead.
2578
+ */
2579
+ renewalConfig?: RenewalConfig;
2580
+ /**
2581
+ * Configuration for automatic settlement and renewal.
2582
+ * `false` = explicitly disabled, `undefined` or `{}` = enabled with defaults.
2583
+ *
2584
+ * @defaultValue `undefined` (enabled with defaults)
2585
+ * @see SettlementConfig
2586
+ */
2587
+ settlementConfig?: SettlementConfig | false;
2588
+ /**
2589
+ * Receive-address strategy. Pass `'static'`, `'hd'`, or a
2590
+ * {@link DescriptorProvider} instance to drive rotation; omit (or
2591
+ * pass `'auto'`) for the built-in auto-detect behaviour. See
2592
+ * {@link WalletMode}.
2593
+ *
2594
+ * @defaultValue `'auto'`
2595
+ */
2596
+ walletMode?: WalletMode;
2597
+ }
2598
+ /**
2599
+ * Repository implementations used to store wallet and contract state.
2600
+ *
2601
+ * @see BaseWalletConfig
2602
+ * @see WalletRepository
2603
+ * @see ContractRepository
2604
+ */
2605
+ type StorageConfig = {
2606
+ /** Wallet-state repository implementation. */
2607
+ walletRepository: WalletRepository;
2608
+ /** Contract-state repository implementation. */
2609
+ contractRepository: ContractRepository;
2610
+ };
2611
+ /**
2612
+ * Provider class constructor interface for dependency injection.
2613
+ * Ensures provider classes follow the consistent constructor pattern.
2614
+ */
2615
+ interface ProviderClass<T> {
2616
+ /**
2617
+ * Create a provider instance for the given server URL.
2618
+ *
2619
+ * @param serverUrl - Base server URL used by the provider
2620
+ */
2621
+ new (serverUrl: string): T;
2622
+ }
2623
+ /**
2624
+ * Balance summary returned by `IWallet.getBalance`.
2625
+ *
2626
+ * @see IWallet.getBalance
2627
+ *
2628
+ * @example
2629
+ * ```typescript
2630
+ * const balance = await wallet.getBalance()
2631
+ * console.log(balance.available, balance.boarding.total)
2632
+ * ```
2633
+ */
2634
+ interface WalletBalance {
2635
+ /** Boarding funds */
2636
+ boarding: {
2637
+ /** Confirmed funds ready to swap for virtual outputs. */
2638
+ confirmed: number;
2639
+ /** Pending funds awaiting confirmation on mainnet */
2640
+ unconfirmed: number;
2641
+ /** Combined boarding balance (`confirmed` + `unconfirmed`) */
2642
+ total: number;
2643
+ };
2644
+ /** Spendable settled (finalized) balance. */
2645
+ settled: number;
2646
+ /** Spendable preconfirmed (unfinalized) balance. */
2647
+ preconfirmed: number;
2648
+ /** Spendable offchain balance (`settled + preconfirmed`). */
2649
+ available: number;
2650
+ /** Recoverable balance from subdust or expired (swept) virtual outputs. */
2651
+ recoverable: number;
2652
+ /** Total balance across offchain, recoverable, and boarding funds. */
2653
+ total: number;
2654
+ /** Asset balance entries (`assetId` & `amount`) */
2655
+ assets: Asset[];
2656
+ }
2657
+ /**
2658
+ * Parameters accepted by `OnchainWallet.send`.
2659
+ *
2660
+ * @remarks
2661
+ * This shape was also used by the deprecated `Wallet.sendBitcoin` method.
2662
+ * New wallet sends should use `Recipient` via `IWallet.send`.
2663
+ *
2664
+ * @see Recipient
2665
+ */
2666
+ interface SendBitcoinParams {
2667
+ /** Destination address. */
2668
+ address: string;
2669
+ /** Amount to send in satoshis. */
2670
+ amount: number;
2671
+ /** Optional fee rate override in sats/vB. */
2672
+ feeRate?: number;
2673
+ /**
2674
+ * Optional memo associated with the transaction.
2675
+ * @deprecated Does not appear to have ever been used.
2676
+ */
2677
+ memo?: string;
2678
+ /** Optional explicit virtual output selection used by `Wallet.sendBitcoin`. */
2679
+ selectedVtxos?: ExtendedVirtualCoin[];
2680
+ }
2681
+ /**
2682
+ * Asset amount paired with an asset id.
2683
+ *
2684
+ * @see AssetDetails
2685
+ */
2686
+ interface Asset {
2687
+ /** Asset identifier. */
2688
+ assetId: string;
2689
+ /**
2690
+ * Asset amount in base units. Typed as `bigint` because asset
2691
+ * supplies routinely exceed `Number.MAX_SAFE_INTEGER` (2^53 - 1)
2692
+ * and silently truncating in arithmetic would corrupt balances.
2693
+ */
2694
+ amount: bigint;
2695
+ }
2696
+ /**
2697
+ * Recipient accepted by `IWallet.send`.
2698
+ *
2699
+ * @see IWallet.send
2700
+ */
2701
+ interface Recipient {
2702
+ address: string;
2703
+ /**
2704
+ * BTC amount in satoshis.
2705
+ *
2706
+ * @defaultValue Dust amount (`330`).
2707
+ */
2708
+ amount?: number;
2709
+ /** Assets to send to the same recipient (`assetId` & `amount`) */
2710
+ assets?: Asset[];
2711
+ }
2712
+ /**
2713
+ * Known asset metadata fields.
2714
+ *
2715
+ * @remarks
2716
+ * Additional metadata keys are allowed through `AssetMetadata`.
2717
+ *
2718
+ * @see AssetMetadata
2719
+ */
2720
+ type KnownMetadata = Partial<{
2721
+ /** Asset name, e.g. "Tether USD" */
2722
+ name: string;
2723
+ /** Asset symbol, e.g. "USDT" */
2724
+ ticker: string;
2725
+ /**
2726
+ * Amount of decimal places to adjust the `amount` for
2727
+ * (e.g. `1_000_000` adjusted for `6` decimals = `1`)
2728
+ */
2729
+ decimals: number;
2730
+ /** Image source that can be passed to an `<img src>` attribute. */
2731
+ icon: string;
2732
+ }>;
2733
+ /**
2734
+ * Asset metadata including known fields and arbitrary extension keys.
2735
+ *
2736
+ * @see KnownMetadata
2737
+ */
2738
+ type AssetMetadata = KnownMetadata & Record<string, unknown>;
2739
+ /**
2740
+ * Asset details returned by `IAssetManager.getAssetDetails`.
2741
+ *
2742
+ * @see IAssetManager.getAssetDetails
2743
+ * @see AssetMetadata
2744
+ */
2745
+ type AssetDetails = {
2746
+ /** Asset identifier. */
2747
+ assetId: string;
2748
+ /**
2749
+ * Total issued supply in base units. Typed as `bigint` for the
2750
+ * same reason as {@link Asset.amount} — supplies often exceed
2751
+ * `Number.MAX_SAFE_INTEGER`.
2752
+ */
2753
+ supply: bigint;
2754
+ /** Optional immutable metadata associated with the asset. */
2755
+ metadata?: AssetMetadata;
2756
+ /** Optional control asset id required for future reissuance. */
2757
+ controlAssetId?: string;
2758
+ };
2759
+ /**
2760
+ * Parameters accepted by `IAssetManager.issue`.
2761
+ *
2762
+ * @see IAssetManager.issue
2763
+ * @see IssuanceResult
2764
+ */
2765
+ interface IssuanceParams {
2766
+ /** Initial amount of asset to issue */
2767
+ amount: bigint;
2768
+ /** Optional control asset ID that can be used for future reissuance */
2769
+ controlAssetId?: string;
2770
+ /** Immutable asset metadata including `ticker`, `decimals`, `icon` */
2771
+ metadata?: AssetMetadata;
2772
+ }
2773
+ /**
2774
+ * Result returned by `IAssetManager.issue`.
2775
+ *
2776
+ * @see IAssetManager.issue
2777
+ * @see IssuanceParams
2778
+ */
2779
+ interface IssuanceResult {
2780
+ /** Arkade transaction ID where the asset was issued */
2781
+ arkTxId: string;
2782
+ /** Permanent asset ID, made up of above `arkTxId` and zero-based asset group index */
2783
+ assetId: string;
2784
+ }
2785
+ /**
2786
+ * Parameters accepted by `IAssetManager.reissue`.
2787
+ *
2788
+ * @see IAssetManager.reissue
2789
+ */
2790
+ interface ReissuanceParams {
2791
+ /** Existing asset ID, made up of genesis (Arkade) transaction ID and zero-based asset group index */
2792
+ assetId: string;
2793
+ /** Amount of asset to issue */
2794
+ amount: bigint;
2795
+ }
2796
+ /**
2797
+ * Parameters accepted by `IAssetManager.burn`.
2798
+ *
2799
+ * @see IAssetManager.burn
2800
+ */
2801
+ interface BurnParams {
2802
+ /** Existing asset ID, made up of genesis (Arkade) transaction ID and zero-based asset group index */
2803
+ assetId: string;
2804
+ /** Amount of asset to burn */
2805
+ amount: bigint;
2806
+ }
2807
+ /**
2808
+ * Explicit inputs and outputs accepted by `IWallet.settle`.
2809
+ *
2810
+ * @remarks
2811
+ * Inputs can include both offchain virtual outputs and onchain boarding inputs.
2812
+ *
2813
+ * @see IWallet.settle
2814
+ * @see Output
2815
+ */
2816
+ interface SettleParams {
2817
+ /** Offchain virtual outputs and/or onchain boarding inputs to settle. */
2818
+ inputs: ExtendedCoin[];
2819
+ /** Optional onchain outputs to create (i.e., exit to). */
2820
+ outputs: Output[];
2821
+ }
2822
+ /**
2823
+ * Onchain output status
2824
+ */
2825
+ interface Status {
2826
+ /** Whether the output is confirmed */
2827
+ confirmed: boolean;
2828
+ /**
2829
+ * Whether the output exists as a finalized batch leaf.
2830
+ * In the current mapping this is `true` for settled and swept virtual outputs,
2831
+ * and `false` for preconfirmed virtual outputs.
2832
+ *
2833
+ * @remarks
2834
+ * `isLeaf` is currently derived from `!isPreconfirmed` in the indexer mapping.
2835
+ * It is used primarily by transaction history classification to distinguish
2836
+ * finalized batch outputs from preconfirmed offchain outputs.
2837
+ */
2838
+ isLeaf?: boolean;
2839
+ /** Block height where the output was confirmed, when known. */
2840
+ block_height?: number;
2841
+ /** Block hash where the output was confirmed, when known. */
2842
+ block_hash?: string;
2843
+ /** Block time where the output was confirmed, when known. */
2844
+ block_time?: number;
2845
+ }
2846
+ /**
2847
+ * Virtual output status
2848
+ */
2849
+ interface VirtualStatus {
2850
+ /**
2851
+ * Extended output status.
2852
+ *
2853
+ * - `preconfirmed`: not yet finalized in a batch
2854
+ * - `settled`: finalized in a batch
2855
+ * - `swept`: expired/swept and recoverable in a new batch
2856
+ * - `spent`: destroyed by a later transaction
2857
+ *
2858
+ * @remarks
2859
+ * `state` is the high-level lifecycle summary used throughout wallet balance,
2860
+ * recovery, and transaction history logic.
2861
+ */
2862
+ state: "preconfirmed" | "settled" | "swept" | "spent";
2863
+ /**
2864
+ * Which batch commitment transaction(s) this virtual output depends on.
2865
+ *
2866
+ * @remarks
2867
+ * The history builder uses these ids to group received batch transactions and
2868
+ * relate refreshed or forfeited virtual outputs back to the same batch.
2869
+ */
2870
+ commitmentTxIds?: string[];
2871
+ /**
2872
+ * The earliest point at which this virtual output stops being safely preconfirmed.
2873
+ *
2874
+ * @remarks
2875
+ * The value is stored in milliseconds in the wallet model and is used by expiry
2876
+ * and recovery logic to decide when a virtual output can be swept or renewed.
2877
+ */
2878
+ batchExpiry?: number;
2879
+ }
2880
+ /** Onchain output location data. */
2881
+ interface Outpoint {
2882
+ /** Transaction ID where the output was created */
2883
+ txid: string;
2884
+ /** Transaction output index for this output */
2885
+ vout: number;
2886
+ }
2887
+ /**
2888
+ * Onchain output data.
2889
+ *
2890
+ * @see Outpoint
2891
+ */
2892
+ interface Coin extends Outpoint {
2893
+ /** Value of the output in satoshis */
2894
+ value: number;
2895
+ /** Onchain output status */
2896
+ status: Status;
2897
+ }
2898
+ /**
2899
+ * Virtual output data.
2900
+ *
2901
+ * @see Coin
2902
+ * @see VirtualStatus
2903
+ */
2904
+ interface VirtualCoin extends Coin {
2905
+ /** Creation time of the virtual output. */
2906
+ createdAt: Date;
2907
+ /** The scriptPubKey (hex) locking this virtual output, as returned by the indexer. */
2908
+ script: string;
2909
+ /** Whether this virtual output has been broadcasted onchain via an unroll (unilateral exit). */
2910
+ isUnrolled: boolean;
2911
+ /**
2912
+ * Whether this virtual output is already spent (boolean helper for `spentBy`).
2913
+ * This is not set to true if the virtual output is unrolled or swept, only when it's spent offchain.
2914
+ */
2915
+ isSpent?: boolean;
2916
+ /** ID of the onchain commitment transaction that settled this output, if applicable. */
2917
+ settledBy?: string;
2918
+ /** ID of the offchain checkpoint transaction that spent this output, if applicable. */
2919
+ spentBy?: string;
2920
+ /** ID of the offchain Arkade transaction that spent the above checkpoint output, if applicable. */
2921
+ arkTxId?: string;
2922
+ /** Virtual output status */
2923
+ virtualStatus: VirtualStatus;
2924
+ /** Assets carried by this virtual output, if any. */
2925
+ assets?: Asset[];
2926
+ }
2927
+ /** Wallet transaction direction. */
2928
+ declare enum TxType {
2929
+ TxSent = "SENT",
2930
+ TxReceived = "RECEIVED"
2931
+ }
2932
+ /**
2933
+ * Composite key used to correlate a wallet transaction across layers.
2934
+ *
2935
+ * @see ArkTransaction
2936
+ */
2937
+ interface TxKey {
2938
+ /** Boarding transaction id, when applicable. */
2939
+ boardingTxid: string;
2940
+ /** Batch commitment transaction id, when applicable. */
2941
+ commitmentTxid: string;
2942
+ /** Arkade transaction id, when applicable. */
2943
+ arkTxid: string;
2944
+ }
2945
+ /**
2946
+ * Wallet transaction history entry.
2947
+ *
2948
+ * @see TxKey
2949
+ * @see TxType
2950
+ */
2951
+ interface ArkTransaction {
2952
+ /** Composite key referencing the related transaction ids. */
2953
+ key: TxKey;
2954
+ /** Transaction direction. */
2955
+ type: TxType;
2956
+ /** Net transaction amount in satoshis. */
2957
+ amount: number;
2958
+ /** Whether the transaction is finalized. */
2959
+ settled: boolean;
2960
+ /** Creation timestamp in milliseconds since epoch. */
2961
+ createdAt: number;
2962
+ /** Assets sent or received by this transaction, if any. */
2963
+ assets?: Asset[];
2964
+ }
2965
+ /**
2966
+ * Tapleaves required to spend or settle a wallet output.
2967
+ *
2968
+ * @see ExtendedCoin
2969
+ * @see ExtendedVirtualCoin
2970
+ */
2971
+ type TapLeaves = {
2972
+ /** Tapleaf script used for the forfeit path. */
2973
+ forfeitTapLeafScript: TapLeafScript;
2974
+ /** Tapleaf script used for the intent path. */
2975
+ intentTapLeafScript: TapLeafScript;
2976
+ };
2977
+ /**
2978
+ * Onchain output data enriched with tapscript and witness data.
2979
+ *
2980
+ * @see Coin
2981
+ * @see TapLeaves
2982
+ */
2983
+ type ExtendedCoin = TapLeaves & EncodedVtxoScript & Coin & {
2984
+ extraWitness?: Bytes[];
2985
+ };
2986
+ /**
2987
+ * Virtual output data enriched with tapscript and witness data.
2988
+ *
2989
+ * @see VirtualCoin
2990
+ * @see TapLeaves
2991
+ */
2992
+ type ExtendedVirtualCoin = TapLeaves & EncodedVtxoScript & VirtualCoin & {
2993
+ extraWitness?: Bytes[];
2994
+ };
2995
+ /**
2996
+ * Return whether a virtual output is still spendable.
2997
+ *
2998
+ * @param vtxo - virtual output to inspect
2999
+ * @returns `true` when the virtual output is not marked as spent
3000
+ *
3001
+ * @see isRecoverable
3002
+ * @see isExpired
3003
+ */
3004
+ declare function isSpendable(vtxo: VirtualCoin): boolean;
3005
+ /**
3006
+ * Return whether a virtual output is recoverable.
3007
+ *
3008
+ * @param vtxo - virtual output to inspect
3009
+ * @returns `true` when the virtual output is swept but still spendable
3010
+ *
3011
+ * @remarks
3012
+ * Recoverable virtual outputs are typically re-settled into fresh virtual outputs by the virtual output manager.
3013
+ *
3014
+ * @see isSpendable
3015
+ * @see isExpired
3016
+ */
3017
+ declare function isRecoverable(vtxo: VirtualCoin): boolean;
3018
+ /**
3019
+ * Return whether a virtual output should be treated as expired.
3020
+ *
3021
+ * @param vtxo - virtual output to inspect
3022
+ * @returns `true` when the virtual output is swept or its batch expiry has passed
3023
+ * @remarks
3024
+ * On regtest-like environments the upstream expiry value may be expressed as a block
3025
+ * height instead of a timestamp. This helper intentionally ignores obviously non-time
3026
+ * values to avoid false positives.
3027
+ *
3028
+ * @see VirtualStatus.batchExpiry
3029
+ */
3030
+ declare function isExpired(vtxo: VirtualCoin): boolean;
3031
+ /**
3032
+ * Return whether a virtual output is below the dust threshold.
3033
+ *
3034
+ * @param vtxo - virtual output to inspect
3035
+ * @param dust - dust threshold in satoshis
3036
+ * @returns `true` when the virtual output value is below `dust`
3037
+ *
3038
+ * @see isRecoverable
3039
+ */
3040
+ declare function isSubdust(vtxo: VirtualCoin, dust: bigint): boolean;
3041
+ /**
3042
+ * Filtering options for `IWallet.getVtxos`.
3043
+ *
3044
+ * @see IWallet.getVtxos
3045
+ */
3046
+ type GetVtxosFilter = {
3047
+ /** Include swept but still unspent virtual outputs. */
3048
+ withRecoverable?: boolean;
3049
+ /** Include virtual outputs that have been unrolled onchain. */
3050
+ withUnrolled?: boolean;
3051
+ };
3052
+ /**
3053
+ * Readonly asset manager interface for asset operations that do not require wallet identity.
3054
+ *
3055
+ * @see IAssetManager
3056
+ */
3057
+ interface IReadonlyAssetManager {
3058
+ /**
3059
+ * Fetch metadata and supply data for an asset.
3060
+ *
3061
+ * @param assetId - Asset identifier
3062
+ * @returns Asset details
3063
+ * @see AssetDetails
3064
+ */
3065
+ getAssetDetails(assetId: string): Promise<AssetDetails>;
3066
+ }
3067
+ /**
3068
+ * Asset manager interface for asset operations that require wallet identity.
3069
+ *
3070
+ * @see IReadonlyAssetManager
3071
+ */
3072
+ interface IAssetManager extends IReadonlyAssetManager {
3073
+ /**
3074
+ * Issue a new asset.
3075
+ *
3076
+ * @param params - Asset issuance parameters
3077
+ * @returns Asset issuance result
3078
+ * @see IssuanceParams
3079
+ * @see IssuanceResult
3080
+ */
3081
+ issue(params: IssuanceParams): Promise<IssuanceResult>;
3082
+ /**
3083
+ * Reissue an existing asset.
3084
+ *
3085
+ * @param params - Asset reissuance parameters
3086
+ * @returns Arkade transaction id
3087
+ * @see ReissuanceParams
3088
+ */
3089
+ reissue(params: ReissuanceParams): Promise<string>;
3090
+ /**
3091
+ * Burn an existing asset.
3092
+ *
3093
+ * @param params - Asset burn parameters
3094
+ * @returns Arkade transaction id
3095
+ * @see BurnParams
3096
+ */
3097
+ burn(params: BurnParams): Promise<string>;
3098
+ }
3099
+ /**
3100
+ * Core wallet interface for Bitcoin transactions with Arkade protocol support.
3101
+ *
3102
+ * This interface defines the contract that all wallet implementations must follow.
3103
+ * It provides methods for address management, balance checking, virtual output
3104
+ * operations, and transaction management including sending, settling, and unrolling.
3105
+ *
3106
+ * @see IReadonlyWallet
3107
+ */
3108
+ interface IWallet extends IReadonlyWallet {
3109
+ /** Signing identity associated with the wallet. */
3110
+ identity: Identity;
3111
+ /**
3112
+ * Send bitcoin to a single Arkade address.
3113
+ *
3114
+ * @param params - Destination, amount, fee rate override, etc
3115
+ * @returns Arkade transaction id
3116
+ * @deprecated Use `send`
3117
+ * @see send
3118
+ * @see Recipient
3119
+ */
3120
+ sendBitcoin(params: SendBitcoinParams): Promise<string>;
3121
+ /**
3122
+ * Settle boarding inputs and/or preconfirmed virtual outputs into settled virtual outputs.
3123
+ *
3124
+ * @param params - Optional explicit settlement inputs and outputs
3125
+ * @param eventCallback - Optional callback that receives settlement events
3126
+ * @returns Arkade transaction id
3127
+ * @see SettleParams
3128
+ */
3129
+ settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void): Promise<string>;
3130
+ /**
3131
+ * Send bitcoin and/or assets to one or more Arkade recipients.
3132
+ *
3133
+ * @param recipients - One or more recipients
3134
+ * @returns Arkade transaction id
3135
+ * @example
3136
+ * ```typescript
3137
+ * await wallet.send({ address: 'ark1q...', amount: 1000 })
3138
+ * ```
3139
+ */
3140
+ send(...recipients: [Recipient, ...Recipient[]]): Promise<string>;
3141
+ /** Asset manager bound to this wallet instance. */
3142
+ assetManager: IAssetManager;
3143
+ /** @returns Delegation manager, when configured. */
3144
+ getDelegateManager(): Promise<IDelegateManager | undefined>;
3145
+ /** @deprecated alias for @see IWallet.getDelegateManager */
3146
+ getDelegatorManager(): Promise<IDelegateManager | undefined>;
3147
+ }
3148
+ /**
3149
+ * Readonly wallet interface for Bitcoin transactions with Arkade protocol support.
3150
+ *
3151
+ * This interface defines the contract that all wallet implementations must follow.
3152
+ * It provides methods for address management, balance checking, virtual output
3153
+ * operations, and transaction management including sending, settling, and unrolling.
3154
+ *
3155
+ * @see IWallet
3156
+ */
3157
+ interface IReadonlyWallet {
3158
+ /** Readonly identity associated with the wallet. */
3159
+ identity: ReadonlyIdentity;
3160
+ /** @returns Arkade address used for offchain funds. */
3161
+ getAddress(): Promise<string>;
3162
+ /** @returns Onchain boarding address used to move funds into Arkade. */
3163
+ getBoardingAddress(): Promise<string>;
3164
+ /** @returns The wallet's combined onchain and offchain balance. */
3165
+ getBalance(): Promise<WalletBalance>;
3166
+ /**
3167
+ * Get virtual outputs tracked by the wallet.
3168
+ *
3169
+ * @param filter - Optional filtering flags
3170
+ * @returns virtual outputs with tapscript and witness data
3171
+ * @see GetVtxosFilter
3172
+ */
3173
+ getVtxos(filter?: GetVtxosFilter): Promise<ExtendedVirtualCoin[]>;
3174
+ /** @returns Onchain boarding inputs tracked by the wallet. */
3175
+ getBoardingUtxos(): Promise<ExtendedCoin[]>;
3176
+ /** @returns Wallet transaction history derived from boarding and Arkade activity. */
3177
+ getTransactionHistory(): Promise<ArkTransaction[]>;
3178
+ /**
3179
+ * Get the contract manager associated with this wallet.
3180
+ * This is useful for querying contract state and watching for contract events.
3181
+ *
3182
+ * @returns Contract manager instance
3183
+ */
3184
+ getContractManager(): Promise<IContractManager>;
3185
+ /** Readonly asset manager bound to this wallet instance. */
3186
+ assetManager: IReadonlyAssetManager;
3187
+ }
3188
+
3189
+ type PaginationOptions = {
3190
+ pageIndex?: number;
3191
+ pageSize?: number;
3192
+ };
3193
+ declare enum IndexerTxType {
3194
+ INDEXER_TX_TYPE_UNSPECIFIED = 0,
3195
+ INDEXER_TX_TYPE_RECEIVED = 1,
3196
+ INDEXER_TX_TYPE_SENT = 2
3197
+ }
3198
+ declare enum ChainTxType {
3199
+ UNSPECIFIED = "INDEXER_CHAINED_TX_TYPE_UNSPECIFIED",
3200
+ COMMITMENT = "INDEXER_CHAINED_TX_TYPE_COMMITMENT",
3201
+ ARK = "INDEXER_CHAINED_TX_TYPE_ARK",
3202
+ TREE = "INDEXER_CHAINED_TX_TYPE_TREE",
3203
+ CHECKPOINT = "INDEXER_CHAINED_TX_TYPE_CHECKPOINT"
3204
+ }
3205
+ interface PageResponse {
3206
+ /** Current page index **/
3207
+ current: number;
3208
+ /** Next page index **/
3209
+ next: number;
3210
+ /** Total pages given the page-size used in the query **/
3211
+ total: number;
3212
+ }
3213
+ interface BatchInfo {
3214
+ totalOutputAmount: string;
3215
+ totalOutputVtxos: number;
3216
+ expiresAt: string;
3217
+ swept: boolean;
3218
+ }
3219
+ interface ChainTx {
3220
+ txid: string;
3221
+ expiresAt: string;
3222
+ type: ChainTxType;
3223
+ /** IDs of the transactions in the chain used as input of the current transaction. */
3224
+ spends: string[];
3225
+ }
3226
+ interface CommitmentTx {
3227
+ startedAt: string;
3228
+ endedAt: string;
3229
+ batches: {
3230
+ [key: string]: BatchInfo;
3231
+ };
3232
+ totalInputAmount: string;
3233
+ totalInputVtxos: number;
3234
+ totalOutputAmount: string;
3235
+ totalOutputVtxos: number;
3236
+ }
3237
+ interface Tx {
3238
+ txid: string;
3239
+ children: Record<number, string>;
3240
+ }
3241
+ interface TxHistoryRecord {
3242
+ commitmentTxid?: string;
3243
+ virtualTxid?: string;
3244
+ type: IndexerTxType;
3245
+ amount: string;
3246
+ createdAt: string;
3247
+ isSettled: boolean;
3248
+ settledBy: string;
3249
+ }
3250
+ interface VtxoAsset {
3251
+ assetId: string;
3252
+ amount: string;
3253
+ }
3254
+ interface Vtxo {
3255
+ outpoint: Outpoint;
3256
+ createdAt: string;
3257
+ expiresAt: string | null;
3258
+ amount: string;
3259
+ script: string;
3260
+ isPreconfirmed: boolean;
3261
+ isSwept: boolean;
3262
+ isUnrolled: boolean;
3263
+ isSpent: boolean;
3264
+ spentBy: string | null;
3265
+ commitmentTxids: string[];
3266
+ settledBy?: string;
3267
+ arkTxid?: string;
3268
+ assets?: VtxoAsset[];
3269
+ }
3270
+ interface VtxoChain {
3271
+ chain: ChainTx[];
3272
+ page?: PageResponse;
3273
+ }
3274
+ interface SubscriptionResponse {
3275
+ txid?: string;
3276
+ scripts: string[];
3277
+ newVtxos: VirtualCoin[];
3278
+ spentVtxos: VirtualCoin[];
3279
+ sweptVtxos: VirtualCoin[];
3280
+ tx?: string;
3281
+ checkpointTxs?: Record<string, {
3282
+ txid: string;
3283
+ tx: string;
3284
+ }>;
3285
+ }
3286
+ interface SubscriptionHeartbeat {
3287
+ type: "heartbeat";
3288
+ }
3289
+ interface SubscriptionEvent extends SubscriptionResponse {
3290
+ type: "event";
3291
+ }
3292
+ /**
3293
+ * Filters accepted by `IndexerProvider.getVtxos`.
3294
+ *
3295
+ * @remarks
3296
+ * Exactly one of `scripts` or `outpoints` must be supplied.
3297
+ *
3298
+ * @see IndexerProvider.getVtxos
3299
+ */
3300
+ type GetVtxosOptions = PaginationOptions & {
3301
+ /** Only return spendable virtual outputs. */
3302
+ spendableOnly?: boolean;
3303
+ /** Only return spent virtual outputs. */
3304
+ spentOnly?: boolean;
3305
+ /** Only return recoverable virtual outputs. */
3306
+ recoverableOnly?: boolean;
3307
+ /** Only return pending/preconfirmed virtual outputs. */
3308
+ pendingOnly?: boolean;
3309
+ /** Only return virtual outputs created after this timestamp. */
3310
+ after?: number;
3311
+ /** Only return virtual outputs created before this timestamp. */
3312
+ before?: number;
3313
+ } & ({
3314
+ /** Scripts to search for matching virtual outputs. */
3315
+ scripts: string[];
3316
+ outpoints?: never;
3317
+ } | {
3318
+ /** Explicit outpoints to fetch. */
3319
+ outpoints: Outpoint[];
3320
+ scripts?: never;
3321
+ });
3322
+ interface IndexerProvider {
3323
+ /**
3324
+ * Fetch the virtual output tree for a batch outpoint.
3325
+ *
3326
+ * @param batchOutpoint - Batch outpoint whose tree should be fetched
3327
+ * @param opts - Optional pagination settings
3328
+ * @returns virtual output tree nodes and optional pagination state
3329
+ */
3330
+ getVtxoTree(batchOutpoint: Outpoint, opts?: PaginationOptions): Promise<{
3331
+ vtxoTree: Tx[];
3332
+ page?: PageResponse;
3333
+ }>;
3334
+ /**
3335
+ * Fetch the leaf outpoints for a batch virtual output tree.
3336
+ *
3337
+ * @param batchOutpoint - Batch outpoint whose leaf outpoints should be fetched
3338
+ * @param opts - Optional pagination settings
3339
+ * @returns Leaf outpoints and optional pagination state
3340
+ */
3341
+ getVtxoTreeLeaves(batchOutpoint: Outpoint, opts?: PaginationOptions): Promise<{
3342
+ leaves: Outpoint[];
3343
+ page?: PageResponse;
3344
+ }>;
3345
+ /**
3346
+ * Fetch sweep transactions that spent a batch.
3347
+ *
3348
+ * @param batchOutpoint - Batch outpoint to inspect
3349
+ * @returns Sweep transaction ids
3350
+ */
3351
+ getBatchSweepTransactions(batchOutpoint: Outpoint): Promise<{
3352
+ sweptBy: string[];
3353
+ }>;
3354
+ /**
3355
+ * Fetch a commitment transaction by txid.
3356
+ *
3357
+ * @param txid - Commitment transaction id
3358
+ * @returns Commitment transaction details
3359
+ */
3360
+ getCommitmentTx(txid: string): Promise<CommitmentTx>;
3361
+ /**
3362
+ * Fetch connector transactions for a commitment transaction.
3363
+ *
3364
+ * @param txid - Commitment transaction id
3365
+ * @param opts - Optional pagination settings
3366
+ * @returns Connector transactions and optional pagination state
3367
+ */
3368
+ getCommitmentTxConnectors(txid: string, opts?: PaginationOptions): Promise<{
3369
+ connectors: Tx[];
3370
+ page?: PageResponse;
3371
+ }>;
3372
+ /**
3373
+ * Fetch forfeit transaction ids for a commitment transaction.
3374
+ *
3375
+ * @param txid - Commitment transaction id
3376
+ * @param opts - Optional pagination settings
3377
+ * @returns Forfeit transaction ids and optional pagination state
3378
+ */
3379
+ getCommitmentTxForfeitTxs(txid: string, opts?: PaginationOptions): Promise<{
3380
+ txids: string[];
3381
+ page?: PageResponse;
3382
+ }>;
3383
+ /**
3384
+ * Open a streamed subscription for a previously created subscription id.
3385
+ *
3386
+ * @param subscriptionId - Subscription identifier returned by `subscribeForScripts`
3387
+ * @param abortSignal - Signal used to terminate the stream
3388
+ * @returns Async iterator of subscription responses
3389
+ */
3390
+ getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
3391
+ /**
3392
+ * Fetch raw virtual transactions by txid.
3393
+ *
3394
+ * @param txids - Virtual transaction ids to fetch
3395
+ * @param opts - Optional pagination settings
3396
+ * @returns Raw virtual transactions and optional pagination state
3397
+ */
3398
+ getVirtualTxs(txids: string[], opts?: PaginationOptions): Promise<{
3399
+ txs: string[];
3400
+ page?: PageResponse;
3401
+ }>;
3402
+ /**
3403
+ * Fetch the ancestry chain for a virtual output.
3404
+ *
3405
+ * @param vtxoOutpoint - Virtual output outpoint to inspect
3406
+ * @param opts - Optional pagination settings
3407
+ * @returns Chain data and optional pagination state
3408
+ */
3409
+ getVtxoChain(vtxoOutpoint: Outpoint, opts?: PaginationOptions): Promise<VtxoChain>;
3410
+ /**
3411
+ * Fetch virtual outputs by script set or outpoints.
3412
+ *
3413
+ * @param opts - Virtual output filters and pagination settings
3414
+ * @returns Virtual outputs and optional pagination state
3415
+ */
3416
+ getVtxos(opts?: GetVtxosOptions): Promise<{
3417
+ vtxos: VirtualCoin[];
3418
+ page?: PageResponse;
3419
+ }>;
3420
+ /**
3421
+ * Fetch metadata for a specific asset id.
3422
+ *
3423
+ * @param assetId - Asset identifier
3424
+ * @returns Asset details
3425
+ */
3426
+ getAssetDetails(assetId: string): Promise<AssetDetails>;
3427
+ /**
3428
+ * Create or extend a subscription for a set of scripts.
3429
+ *
3430
+ * @param scripts - Scripts to monitor
3431
+ * @param subscriptionId - Existing subscription id to extend
3432
+ * @returns Subscription id
3433
+ */
3434
+ subscribeForScripts(scripts: string[], subscriptionId?: string): Promise<string>;
3435
+ /**
3436
+ * Remove some or all scripts from an existing subscription.
3437
+ *
3438
+ * @param subscriptionId - Subscription identifier to update
3439
+ * @param scripts - Scripts to remove, or omit to remove all
3440
+ */
3441
+ unsubscribeForScripts(subscriptionId: string, scripts?: string[]): Promise<void>;
3442
+ }
3443
+ /**
3444
+ * REST-based indexer provider implementation.
3445
+ * @see https://buf.build/arkade-os/arkd/docs/main:ark.v1#ark.v1.IndexerService
3446
+ * @example
3447
+ * ```typescript
3448
+ * const provider = new RestIndexerProvider('https://arkade.computer');
3449
+ * const commitmentTx = await provider.getCommitmentTx("6686af8f3be3517880821f62e6c3d749b9d6713736a1d8e229a55daa659446b2");
3450
+ * ```
3451
+ */
3452
+ declare class RestIndexerProvider implements IndexerProvider {
3453
+ serverUrl: string;
3454
+ constructor(serverUrl?: string);
3455
+ getVtxoTree(batchOutpoint: Outpoint, opts?: PaginationOptions): Promise<{
3456
+ vtxoTree: Tx[];
3457
+ page?: PageResponse;
3458
+ }>;
3459
+ getVtxoTreeLeaves(batchOutpoint: Outpoint, opts?: PaginationOptions): Promise<{
3460
+ leaves: Outpoint[];
3461
+ page?: PageResponse;
3462
+ }>;
3463
+ getBatchSweepTransactions(batchOutpoint: Outpoint): Promise<{
3464
+ sweptBy: string[];
3465
+ }>;
3466
+ getCommitmentTx(txid: string): Promise<CommitmentTx>;
3467
+ getCommitmentTxConnectors(txid: string, opts?: PaginationOptions): Promise<{
3468
+ connectors: Tx[];
3469
+ page?: PageResponse;
3470
+ }>;
3471
+ getCommitmentTxForfeitTxs(txid: string, opts?: PaginationOptions): Promise<{
3472
+ txids: string[];
3473
+ page?: PageResponse;
3474
+ }>;
3475
+ getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
3476
+ getVirtualTxs(txids: string[], opts?: PaginationOptions): Promise<{
3477
+ txs: string[];
3478
+ page?: PageResponse;
3479
+ }>;
3480
+ getVtxoChain(vtxoOutpoint: Outpoint, opts?: PaginationOptions): Promise<VtxoChain>;
3481
+ getVtxos(opts?: GetVtxosOptions): Promise<{
3482
+ vtxos: VirtualCoin[];
3483
+ page?: PageResponse;
3484
+ }>;
3485
+ getAssetDetails(assetId: string): Promise<AssetDetails>;
3486
+ subscribeForScripts(scripts: string[], subscriptionId?: string): Promise<string>;
3487
+ unsubscribeForScripts(subscriptionId: string, scripts?: string[]): Promise<void>;
3488
+ }
3489
+
3490
+ /**
3491
+ * FeeAmount is a wrapper around a number that represents a fee amount in satoshis floating point.
3492
+ * @param value - The fee amount in floating point.
3493
+ * @example
3494
+ * const fee = new FeeAmount(1.23456789);
3495
+ * console.log(fee.value); // 1.23456789
3496
+ * console.log(fee.satoshis); // 2
3497
+ */
3498
+ declare class FeeAmount {
3499
+ readonly value: number;
3500
+ static ZERO: FeeAmount;
3501
+ constructor(value: number);
3502
+ /** Returns the fee amount rounded up to whole satoshis. */
3503
+ get satoshis(): number;
3504
+ /** Add two fee amounts together. */
3505
+ add(other: FeeAmount): FeeAmount;
3506
+ }
3507
+ interface IntentFeeConfig {
3508
+ offchainInput?: string;
3509
+ onchainInput?: string;
3510
+ offchainOutput?: string;
3511
+ onchainOutput?: string;
3512
+ }
3513
+ type VtxoType = "recoverable" | "vtxo" | "note";
3514
+ interface OffchainInput {
3515
+ amount: bigint;
3516
+ expiry?: Date;
3517
+ birth?: Date;
3518
+ type: VtxoType;
3519
+ weight: number;
3520
+ }
3521
+ interface OnchainInput {
3522
+ amount: bigint;
3523
+ }
3524
+ interface FeeOutput {
3525
+ amount: bigint;
3526
+ script: string;
3527
+ }
3528
+
3529
+ /** Output requested during settlement or transaction submission. */
3530
+ type Output = {
3531
+ /** Destination address, either onchain or Arkade (offchain). */
3532
+ address: string;
3533
+ /** Amount to send in satoshis. */
3534
+ amount: bigint;
3535
+ };
3536
+ declare enum SettlementEventType {
3537
+ BatchStarted = "batch_started",
3538
+ BatchFinalization = "batch_finalization",
3539
+ BatchFinalized = "batch_finalized",
3540
+ BatchFailed = "batch_failed",
3541
+ TreeSigningStarted = "tree_signing_started",
3542
+ TreeNonces = "tree_nonces",
3543
+ TreeTx = "tree_tx",
3544
+ TreeSignature = "tree_signature",
3545
+ StreamStarted = "stream_started"
3546
+ }
3547
+ type BatchFinalizationEvent = {
3548
+ type: SettlementEventType.BatchFinalization;
3549
+ id: string;
3550
+ commitmentTx: string;
3551
+ };
3552
+ type BatchFinalizedEvent = {
3553
+ type: SettlementEventType.BatchFinalized;
3554
+ id: string;
3555
+ commitmentTxid: string;
3556
+ };
3557
+ type BatchFailedEvent = {
3558
+ type: SettlementEventType.BatchFailed;
3559
+ id: string;
3560
+ reason: string;
3561
+ };
3562
+ type TreeSigningStartedEvent = {
3563
+ type: SettlementEventType.TreeSigningStarted;
3564
+ id: string;
3565
+ cosignersPublicKeys: string[];
3566
+ unsignedCommitmentTx: string;
3567
+ };
3568
+ type TreeNoncesEvent = {
3569
+ type: SettlementEventType.TreeNonces;
3570
+ id: string;
3571
+ topic: string[];
3572
+ txid: string;
3573
+ /** Musig2 public nonces keyed by cosigner public key. */
3574
+ nonces: TreeNonces;
3575
+ };
3576
+ type BatchStartedEvent = {
3577
+ type: SettlementEventType.BatchStarted;
3578
+ id: string;
3579
+ intentIdHashes: string[];
3580
+ batchExpiry: bigint;
3581
+ };
3582
+ type TreeTxEvent = {
3583
+ type: SettlementEventType.TreeTx;
3584
+ id: string;
3585
+ topic: string[];
3586
+ batchIndex: number;
3587
+ chunk: TxTreeNode;
3588
+ };
3589
+ type TreeSignatureEvent = {
3590
+ type: SettlementEventType.TreeSignature;
3591
+ id: string;
3592
+ topic: string[];
3593
+ batchIndex: number;
3594
+ txid: string;
3595
+ signature: string;
3596
+ };
3597
+ type StreamStartedEvent = {
3598
+ type: SettlementEventType.StreamStarted;
3599
+ id: string;
3600
+ };
3601
+ type SettlementEvent = BatchFinalizationEvent | BatchFinalizedEvent | BatchFailedEvent | TreeSigningStartedEvent | TreeNoncesEvent | BatchStartedEvent | TreeTxEvent | TreeSignatureEvent | StreamStartedEvent;
3602
+ interface ScheduledSession {
3603
+ duration: bigint;
3604
+ fees: FeeInfo;
3605
+ nextEndTime: bigint;
3606
+ nextStartTime: bigint;
3607
+ period: bigint;
3608
+ }
3609
+ interface FeeInfo {
3610
+ intentFee: IntentFeeConfig;
3611
+ txFeeRate: string;
3612
+ }
3613
+ interface PendingTx {
3614
+ arkTxid: string;
3615
+ finalArkTx: string;
3616
+ signedCheckpointTxs: string[];
3617
+ }
3618
+ interface DeprecatedSigner {
3619
+ cutoffDate: bigint;
3620
+ pubkey: string;
3621
+ }
3622
+ type ServiceStatus = Record<string, string>;
3623
+ interface ArkInfo {
3624
+ boardingExitDelay: bigint;
3625
+ checkpointTapscript: string;
3626
+ deprecatedSigners: DeprecatedSigner[];
3627
+ digest: string;
3628
+ dust: bigint;
3629
+ fees: FeeInfo;
3630
+ forfeitAddress: string;
3631
+ forfeitPubkey: string;
3632
+ network: string;
3633
+ scheduledSession?: ScheduledSession;
3634
+ serviceStatus: ServiceStatus;
3635
+ sessionDuration: bigint;
3636
+ signerPubkey: string;
3637
+ unilateralExitDelay: bigint;
3638
+ /**
3639
+ * Maximum boarding input amount.
3640
+ *
3641
+ * @remarks
3642
+ * `-1` means unlimited, while `0` disables boarding.
3643
+ */
3644
+ utxoMaxAmount: bigint;
3645
+ utxoMinAmount: bigint;
3646
+ version: string;
3647
+ /**
3648
+ * Maximum virtual output amount.
3649
+ *
3650
+ * @remarks
3651
+ * `-1` means unlimited.
3652
+ */
3653
+ vtxoMaxAmount: bigint;
3654
+ vtxoMinAmount: bigint;
3655
+ }
3656
+ /** Signed intent payload sent to the Arkade server. */
3657
+ interface SignedIntent<T extends Intent.Message> {
3658
+ /** Base64-encoded signed proof transaction. */
3659
+ proof: string;
3660
+ /** Intent message payload associated with the proof. */
3661
+ message: T;
3662
+ }
3663
+ /** Transaction notification emitted by the Arkade server stream. */
3664
+ interface TxNotification {
3665
+ /** Transaction id. */
3666
+ txid: string;
3667
+ /** Raw transaction payload. */
3668
+ tx: string;
3669
+ /** Virtual outputs spent by the transaction. */
3670
+ spentVtxos: Vtxo[];
3671
+ /** Virtual outputs made spendable by the transaction. */
3672
+ spendableVtxos: Vtxo[];
3673
+ /** Optional checkpoint transactions associated with the notification. */
3674
+ checkpointTxs?: Record<string, {
3675
+ txid: string;
3676
+ tx: string;
3677
+ }>;
3678
+ }
3679
+ interface ArkProvider {
3680
+ /** Fetch Arkade server configuration and fee settings. */
3681
+ getInfo(): Promise<ArkInfo>;
3682
+ /** Submit a signed Arkade transaction and its checkpoint transactions. */
3683
+ submitTx(signedArkTx: string, checkpointTxs: string[]): Promise<{
3684
+ arkTxid: string;
3685
+ finalArkTx: string;
3686
+ signedCheckpointTxs: string[];
3687
+ }>;
3688
+ /** Finalize a previously submitted Arkade transaction. */
3689
+ finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
3690
+ /** Register a signed intent with the Arkade server. */
3691
+ registerIntent(intent: SignedIntent<Intent.RegisterMessage>): Promise<string>;
3692
+ /** Delete a previously registered intent. */
3693
+ deleteIntent(intent: SignedIntent<Intent.DeleteMessage>): Promise<void>;
3694
+ /** Confirm an already registered intent id. */
3695
+ confirmRegistration(intentId: string): Promise<void>;
3696
+ /** Submit musig2 tree nonces for a batch signing session. */
3697
+ submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
3698
+ /** Submit musig2 partial signatures for a batch signing session. */
3699
+ submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
3700
+ /** Submit signed forfeit transactions for cooperative settlement. */
3701
+ submitSignedForfeitTxs(signedForfeitTxs: string[], signedCommitmentTx?: string): Promise<void>;
3702
+ /** Open the settlement event stream for the given topics. */
3703
+ getEventStream(signal: AbortSignal, topics: string[]): AsyncIterableIterator<SettlementEvent>;
3704
+ /** Stream transaction notifications emitted by the Arkade server. */
3705
+ getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{
3706
+ commitmentTx?: TxNotification;
3707
+ arkTx?: TxNotification;
3708
+ }>;
3709
+ /** Fetch pending transactions for a signed get-pending-tx intent. */
3710
+ getPendingTxs(intent: SignedIntent<Intent.GetPendingTxMessage>): Promise<PendingTx[]>;
3711
+ }
3712
+ /**
3713
+ * REST-based Arkade provider implementation.
3714
+ *
3715
+ * @see https://buf.build/arkade-os/arkd/docs/main:ark.v1#ark.v1.ArkService
3716
+ * @example
3717
+ * ```typescript
3718
+ * const provider = new RestArkProvider('https://arkade.computer');
3719
+ * const info = await provider.getInfo();
3720
+ * ```
3721
+ */
3722
+ declare class RestArkProvider implements ArkProvider {
3723
+ serverUrl: string;
3724
+ constructor(serverUrl?: string);
3725
+ getInfo(): Promise<ArkInfo>;
3726
+ submitTx(signedArkTx: string, checkpointTxs: string[]): Promise<{
3727
+ arkTxid: string;
3728
+ finalArkTx: string;
3729
+ signedCheckpointTxs: string[];
3730
+ }>;
3731
+ finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
3732
+ registerIntent(intent: SignedIntent<Intent.RegisterMessage>): Promise<string>;
3733
+ deleteIntent(intent: SignedIntent<Intent.DeleteMessage>): Promise<void>;
3734
+ confirmRegistration(intentId: string): Promise<void>;
3735
+ submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
3736
+ submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
3737
+ submitSignedForfeitTxs(signedForfeitTxs: string[], signedCommitmentTx?: string): Promise<void>;
3738
+ getEventStream(signal: AbortSignal, topics: string[]): AsyncIterableIterator<SettlementEvent>;
3739
+ getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{
3740
+ commitmentTx?: TxNotification;
3741
+ arkTx?: TxNotification;
3742
+ }>;
3743
+ getPendingTxs(intent: SignedIntent<Intent.GetPendingTxMessage>): Promise<PendingTx[]>;
3744
+ protected parseSettlementEvent(data: ProtoTypes.GetEventStreamResponse): SettlementEvent | null;
3745
+ protected parseTransactionNotification(data: ProtoTypes.GetTransactionsStreamResponse): {
3746
+ commitmentTx?: TxNotification;
3747
+ arkTx?: TxNotification;
3748
+ } | null;
3749
+ }
3750
+ declare namespace ProtoTypes {
3751
+ interface BatchStartedEvent {
3752
+ id: string;
3753
+ intentIdHashes: string[];
3754
+ batchExpiry: number;
3755
+ }
3756
+ interface BatchFailed {
3757
+ id: string;
3758
+ reason: string;
3759
+ }
3760
+ export interface BatchFinalizationEvent {
3761
+ id: string;
3762
+ commitmentTx: string;
3763
+ }
3764
+ interface BatchFinalizedEvent {
3765
+ id: string;
3766
+ commitmentTxid: string;
3767
+ }
3768
+ interface TreeSigningStartedEvent {
3769
+ id: string;
3770
+ cosignersPubkeys: string[];
3771
+ unsignedCommitmentTx: string;
3772
+ }
3773
+ interface TreeNoncesAggregatedEvent {
3774
+ id: string;
3775
+ treeNonces: Record<string, string>;
3776
+ }
3777
+ interface TreeNoncesEvent {
3778
+ id: string;
3779
+ topic: string[];
3780
+ txid: string;
3781
+ nonces: Record<string, string>;
3782
+ }
3783
+ interface TreeTxEvent {
3784
+ id: string;
3785
+ topic: string[];
3786
+ batchIndex: number;
3787
+ txid: string;
3788
+ tx: string;
3789
+ children: Record<string, string>;
3790
+ }
3791
+ interface TreeSignatureEvent {
3792
+ id: string;
3793
+ topic: string[];
3794
+ batchIndex: number;
3795
+ txid: string;
3796
+ signature: string;
3797
+ }
3798
+ interface StreamStartedEvent {
3799
+ id: string;
3800
+ }
3801
+ interface Heartbeat {
3802
+ }
3803
+ export interface VtxoData {
3804
+ outpoint: {
3805
+ txid: string;
3806
+ vout: number;
3807
+ };
3808
+ amount: string;
3809
+ script: string;
3810
+ createdAt: string;
3811
+ expiresAt: string | null;
3812
+ commitmentTxids: string[];
3813
+ isPreconfirmed: boolean;
3814
+ isSwept: boolean;
3815
+ isUnrolled: boolean;
3816
+ isSpent: boolean;
3817
+ spentBy: string;
3818
+ settledBy?: string;
3819
+ arkTxid?: string;
3820
+ }
3821
+ export interface GetEventStreamResponse {
3822
+ batchStarted?: BatchStartedEvent;
3823
+ batchFailed?: BatchFailed;
3824
+ batchFinalization?: BatchFinalizationEvent;
3825
+ batchFinalized?: BatchFinalizedEvent;
3826
+ treeSigningStarted?: TreeSigningStartedEvent;
3827
+ treeNoncesAggregated?: TreeNoncesAggregatedEvent;
3828
+ treeNonces?: TreeNoncesEvent;
3829
+ treeTx?: TreeTxEvent;
3830
+ treeSignature?: TreeSignatureEvent;
3831
+ streamStarted?: StreamStartedEvent;
3832
+ heartbeat?: Heartbeat;
3833
+ }
3834
+ export interface GetTransactionsStreamResponse {
3835
+ commitmentTx?: {
3836
+ txid: string;
3837
+ tx: string;
3838
+ spentVtxos: VtxoData[];
3839
+ spendableVtxos: VtxoData[];
3840
+ checkpointTxs?: Record<string, {
3841
+ txid: string;
3842
+ tx: string;
3843
+ }>;
3844
+ };
3845
+ arkTx?: {
3846
+ txid: string;
3847
+ tx: string;
3848
+ spentVtxos: VtxoData[];
3849
+ spendableVtxos: VtxoData[];
3850
+ checkpointTxs?: Record<string, {
3851
+ txid: string;
3852
+ tx: string;
3853
+ }>;
3854
+ };
3855
+ heartbeat?: Heartbeat;
3856
+ }
3857
+ export interface EventData {
3858
+ batchStarted?: BatchStartedEvent;
3859
+ batchFailed?: BatchFailed;
3860
+ batchFinalization?: BatchFinalizationEvent;
3861
+ batchFinalized?: BatchFinalizedEvent;
3862
+ treeSigningStarted?: TreeSigningStartedEvent;
3863
+ treeNoncesAggregated?: TreeNoncesAggregatedEvent;
3864
+ treeTx?: TreeTxEvent;
3865
+ treeSignature?: TreeSignatureEvent;
3866
+ }
3867
+ export interface TransactionData {
3868
+ commitmentTx?: {
3869
+ txid: string;
3870
+ tx: string;
3871
+ spentVtxos: VtxoData[];
3872
+ spendableVtxos: VtxoData[];
3873
+ checkpointTxs?: Record<string, {
3874
+ txid: string;
3875
+ tx: string;
3876
+ }>;
3877
+ };
3878
+ arkTx?: {
3879
+ txid: string;
3880
+ tx: string;
3881
+ spentVtxos: VtxoData[];
3882
+ spendableVtxos: VtxoData[];
3883
+ checkpointTxs?: Record<string, {
3884
+ txid: string;
3885
+ tx: string;
3886
+ }>;
3887
+ };
3888
+ }
3889
+ export { };
3890
+ }
3891
+
3892
+ export { CSVMultisigTapscript as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type BatchFailedEvent as D, type ExtendedVirtualCoin as E, type TreeTxEvent as F, type GetVtxosFilter as G, type TreeSignatureEvent as H, type IWallet as I, type DescriptorProvider as J, type IReadonlyWallet as K, type ReadonlyIdentity as L, type DelegateProvider as M, type Network as N, type OnchainProvider as O, type ReadonlyWalletConfig as P, type IReadonlyAssetManager as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type NetworkName as U, VtxoScript as V, type WalletRepository as W, type ArkInfo as X, ArkAddress as Y, type Coin as Z, ContractManager as _, type Identity as a, type IDelegatorManager as a$, type SettlementConfig as a0, VtxoManager as a1, type SignerSession as a2, type SignedIntent as a3, Intent as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type AssetMetadata as aA, type BaseWalletConfig as aB, type BatchInfo as aC, type BatchSignableIdentity as aD, CLTVMultisigTapscript as aE, ChainTxType as aF, type CommitmentTx as aG, ConditionCSVMultisigTapscript as aH, ConditionMultisigTapscript as aI, type ContractBalance as aJ, type ContractEventCallback as aK, type ContractHandler as aL, type ContractManagerConfig as aM, type ContractState as aN, type ContractVtxo as aO, ContractWatcher as aP, DelegateManagerImpl as aQ, type DelegateOptions as aR, DelegatorManagerImpl as aS, type DelegatorProvider as aT, type Discoverable as aU, type DiscoveredContract as aV, type DiscoveryDeps as aW, ESPLORA_URL as aX, EsploraProvider as aY, type ExtendedContractVtxo as aZ, type HandlerError as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type ContractWithVtxos as al, type PathSelection as am, type ContractEvent as an, type AssetDetails as ao, type IssuanceResult as ap, type DelegateInfo as aq, type StorageConfig as ar, type IVtxoManager as as, type ExplorerTransaction as at, type EncodedVtxoScript as au, type Status as av, type Outpoint as aw, type ChainTx as ax, type ArkTapscript as ay, type Asset as az, type WalletConfig as b, IndexerTxType as b0, type KnownMetadata as b1, MultisigTapscript as b2, type Nonces as b3, type Output as b4, type PageResponse as b5, type PaginationOptions as b6, PartialSig as b7, type PathContext as b8, type ProviderClass as b9, isBatchSignable as bA, isDiscoverable as bB, isExpired as bC, isRecoverable as bD, isSpendable as bE, isSubdust as bF, isVtxoExpiringSoon as bG, networks as bH, RestDelegateProvider as ba, RestDelegatorProvider as bb, type ScanContractsOptions as bc, type ScanResult as bd, type ScheduledSession as be, SettlementEventType as bf, type SignRequest as bg, type SubscriptionEvent as bh, type SubscriptionHeartbeat as bi, type TapLeaves as bj, TapTreeCoder as bk, TapscriptType as bl, type TreeNonces as bm, type TreePartialSigs as bn, type Tx as bo, type TxHistoryRecord as bp, type TxKey as bq, type TxTreeNode as br, TxType as bs, type VirtualStatus as bt, type Vtxo as bu, type VtxoChain as bv, type VtxoType as bw, type WalletMode as bx, decodeTapscript as by, getSequence as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type VtxoRepositoryKey as s, type WalletState as t, type ContractFilter as u, type TreeSigningStartedEvent as v, TxTree as w, type TreeNoncesEvent as x, type BatchFinalizationEvent as y, type BatchFinalizedEvent as z };