@arkade-os/sdk 0.4.26 → 0.4.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (522) hide show
  1. package/README.md +36 -125
  2. package/dist/adapters/asyncStorage.cjs +48 -0
  3. package/dist/adapters/asyncStorage.cjs.map +1 -0
  4. package/dist/adapters/asyncStorage.d.cts +16 -0
  5. package/dist/{types/storage → adapters}/asyncStorage.d.ts +5 -2
  6. package/dist/adapters/asyncStorage.js +46 -0
  7. package/dist/adapters/asyncStorage.js.map +1 -0
  8. package/dist/adapters/expo.cjs +19 -0
  9. package/dist/adapters/expo.cjs.map +1 -0
  10. package/dist/adapters/expo.d.cts +48 -0
  11. package/dist/adapters/expo.d.ts +48 -0
  12. package/dist/adapters/expo.js +6 -0
  13. package/dist/adapters/expo.js.map +1 -0
  14. package/dist/adapters/fileSystem.cjs +116 -0
  15. package/dist/adapters/fileSystem.cjs.map +1 -0
  16. package/dist/adapters/fileSystem.d.cts +17 -0
  17. package/dist/{types/storage → adapters}/fileSystem.d.ts +5 -2
  18. package/dist/adapters/fileSystem.js +93 -0
  19. package/dist/adapters/fileSystem.js.map +1 -0
  20. package/dist/adapters/indexedDB.cjs +103 -0
  21. package/dist/adapters/indexedDB.cjs.map +1 -0
  22. package/dist/adapters/indexedDB.d.cts +18 -0
  23. package/dist/{types/storage → adapters}/indexedDB.d.ts +5 -2
  24. package/dist/adapters/indexedDB.js +101 -0
  25. package/dist/adapters/indexedDB.js.map +1 -0
  26. package/dist/adapters/localStorage.cjs +50 -0
  27. package/dist/adapters/localStorage.cjs.map +1 -0
  28. package/dist/{types/storage/inMemory.d.ts → adapters/localStorage.d.cts} +6 -3
  29. package/dist/{types/storage → adapters}/localStorage.d.ts +5 -2
  30. package/dist/adapters/localStorage.js +48 -0
  31. package/dist/adapters/localStorage.js.map +1 -0
  32. package/dist/ark-TZ1gXAXU.d.cts +3880 -0
  33. package/dist/ark-TZ1gXAXU.d.ts +3880 -0
  34. package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-Cb1F_Z9s.d.ts} +6 -3
  35. package/dist/asyncStorageTaskQueue-EFqSmYTg.d.cts +49 -0
  36. package/dist/chunk-5BLDMQED.cjs +18 -0
  37. package/dist/chunk-5BLDMQED.cjs.map +1 -0
  38. package/dist/chunk-5PG7DV7A.cjs +805 -0
  39. package/dist/chunk-5PG7DV7A.cjs.map +1 -0
  40. package/dist/chunk-A3EMF7RN.js +95 -0
  41. package/dist/chunk-A3EMF7RN.js.map +1 -0
  42. package/dist/chunk-ADV27S4N.cjs +2701 -0
  43. package/dist/chunk-ADV27S4N.cjs.map +1 -0
  44. package/dist/chunk-BQLHADL7.js +13805 -0
  45. package/dist/chunk-BQLHADL7.js.map +1 -0
  46. package/dist/chunk-CFZMTDWI.js +209 -0
  47. package/dist/chunk-CFZMTDWI.js.map +1 -0
  48. package/dist/chunk-FG5ACJJW.cjs +212 -0
  49. package/dist/chunk-FG5ACJJW.cjs.map +1 -0
  50. package/dist/chunk-HW3JJ323.js +768 -0
  51. package/dist/chunk-HW3JJ323.js.map +1 -0
  52. package/dist/chunk-I3DGUUCT.cjs +838 -0
  53. package/dist/chunk-I3DGUUCT.cjs.map +1 -0
  54. package/dist/chunk-IPX2R7FR.cjs +100 -0
  55. package/dist/chunk-IPX2R7FR.cjs.map +1 -0
  56. package/dist/chunk-NSBPE2FW.js +15 -0
  57. package/dist/chunk-NSBPE2FW.js.map +1 -0
  58. package/dist/chunk-T64LAI7L.js +829 -0
  59. package/dist/chunk-T64LAI7L.js.map +1 -0
  60. package/dist/chunk-ZBUDLTBO.js +2671 -0
  61. package/dist/chunk-ZBUDLTBO.js.map +1 -0
  62. package/dist/chunk-ZLO6NETT.cjs +13910 -0
  63. package/dist/chunk-ZLO6NETT.cjs.map +1 -0
  64. package/dist/contracts/handlers/index.cjs +26 -0
  65. package/dist/contracts/handlers/index.cjs.map +1 -0
  66. package/dist/contracts/handlers/index.d.cts +7 -0
  67. package/dist/contracts/handlers/index.d.ts +7 -0
  68. package/dist/contracts/handlers/index.js +5 -0
  69. package/dist/contracts/handlers/index.js.map +1 -0
  70. package/dist/delegate-BFZs69hp.d.cts +84 -0
  71. package/dist/delegate-aaVGfWsV.d.ts +84 -0
  72. package/dist/index-B22cA64m.d.cts +199 -0
  73. package/dist/{types/storage/index.d.ts → index-C0IanN1m.d.cts} +3 -1
  74. package/dist/index-C0IanN1m.d.ts +11 -0
  75. package/dist/index-NDla_UoJ.d.ts +199 -0
  76. package/dist/index.cjs +480 -0
  77. package/dist/index.cjs.map +1 -0
  78. package/dist/index.d.cts +3343 -0
  79. package/dist/index.d.ts +3343 -0
  80. package/dist/index.js +7 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/repositories/realm/index.cjs +513 -0
  83. package/dist/repositories/realm/index.cjs.map +1 -0
  84. package/dist/repositories/realm/index.d.cts +217 -0
  85. package/dist/{types/repositories/realm/schemas.d.ts → repositories/realm/index.d.ts} +80 -112
  86. package/dist/repositories/realm/index.js +507 -0
  87. package/dist/repositories/realm/index.js.map +1 -0
  88. package/dist/repositories/sqlite/index.cjs +588 -0
  89. package/dist/repositories/sqlite/index.cjs.map +1 -0
  90. package/dist/repositories/sqlite/index.d.cts +118 -0
  91. package/dist/{types/repositories/sqlite/walletRepository.d.ts → repositories/sqlite/index.d.ts} +58 -5
  92. package/dist/repositories/sqlite/index.js +585 -0
  93. package/dist/repositories/sqlite/index.js.map +1 -0
  94. package/dist/taskRunner-C6Ff4OaU.d.cts +114 -0
  95. package/dist/taskRunner-yvPN8Z0K.d.ts +114 -0
  96. package/dist/wallet/expo/background.cjs +93 -0
  97. package/dist/wallet/expo/background.cjs.map +1 -0
  98. package/dist/wallet/expo/background.d.cts +84 -0
  99. package/dist/wallet/expo/background.d.ts +84 -0
  100. package/dist/wallet/expo/background.js +68 -0
  101. package/dist/wallet/expo/background.js.map +1 -0
  102. package/dist/wallet/expo/index.cjs +171 -0
  103. package/dist/wallet/expo/index.cjs.map +1 -0
  104. package/dist/wallet/expo/index.d.cts +122 -0
  105. package/dist/{types/wallet/expo/wallet.d.ts → wallet/expo/index.d.ts} +45 -22
  106. package/dist/wallet/expo/index.js +169 -0
  107. package/dist/wallet/expo/index.js.map +1 -0
  108. package/dist/wallet-AF-p-OWj.d.cts +774 -0
  109. package/dist/wallet-D9NBRqvC.d.ts +774 -0
  110. package/dist/worker/expo/index.cjs +140 -0
  111. package/dist/worker/expo/index.cjs.map +1 -0
  112. package/dist/worker/expo/index.d.cts +29 -0
  113. package/dist/worker/expo/index.d.ts +29 -0
  114. package/dist/worker/expo/index.js +121 -0
  115. package/dist/worker/expo/index.js.map +1 -0
  116. package/package.json +110 -76
  117. package/dist/cjs/adapters/asyncStorage.js +0 -5
  118. package/dist/cjs/adapters/expo.js +0 -8
  119. package/dist/cjs/adapters/fileSystem.js +0 -5
  120. package/dist/cjs/adapters/indexedDB.js +0 -5
  121. package/dist/cjs/adapters/localStorage.js +0 -5
  122. package/dist/cjs/arkfee/celenv.js +0 -43
  123. package/dist/cjs/arkfee/estimator.js +0 -143
  124. package/dist/cjs/arkfee/index.js +0 -5
  125. package/dist/cjs/arkfee/types.js +0 -26
  126. package/dist/cjs/arknote/index.js +0 -128
  127. package/dist/cjs/bip322/index.js +0 -270
  128. package/dist/cjs/contracts/arkcontract.js +0 -147
  129. package/dist/cjs/contracts/contractManager.js +0 -629
  130. package/dist/cjs/contracts/contractWatcher.js +0 -598
  131. package/dist/cjs/contracts/handlers/default.js +0 -93
  132. package/dist/cjs/contracts/handlers/delegate.js +0 -90
  133. package/dist/cjs/contracts/handlers/helpers.js +0 -115
  134. package/dist/cjs/contracts/handlers/index.js +0 -19
  135. package/dist/cjs/contracts/handlers/registry.js +0 -89
  136. package/dist/cjs/contracts/handlers/vhtlc.js +0 -194
  137. package/dist/cjs/contracts/index.js +0 -41
  138. package/dist/cjs/contracts/types.js +0 -2
  139. package/dist/cjs/contracts/vtxoOwnership.js +0 -78
  140. package/dist/cjs/extension/asset/assetGroup.js +0 -228
  141. package/dist/cjs/extension/asset/assetId.js +0 -152
  142. package/dist/cjs/extension/asset/assetInput.js +0 -222
  143. package/dist/cjs/extension/asset/assetOutput.js +0 -174
  144. package/dist/cjs/extension/asset/assetRef.js +0 -148
  145. package/dist/cjs/extension/asset/index.js +0 -23
  146. package/dist/cjs/extension/asset/metadata.js +0 -187
  147. package/dist/cjs/extension/asset/packet.js +0 -114
  148. package/dist/cjs/extension/asset/types.js +0 -22
  149. package/dist/cjs/extension/asset/utils.js +0 -105
  150. package/dist/cjs/extension/index.js +0 -254
  151. package/dist/cjs/extension/packet.js +0 -20
  152. package/dist/cjs/forfeit.js +0 -45
  153. package/dist/cjs/identity/descriptor.js +0 -169
  154. package/dist/cjs/identity/descriptorProvider.js +0 -2
  155. package/dist/cjs/identity/hdCapableIdentity.js +0 -2
  156. package/dist/cjs/identity/index.js +0 -38
  157. package/dist/cjs/identity/seedIdentity.js +0 -461
  158. package/dist/cjs/identity/serialize.js +0 -171
  159. package/dist/cjs/identity/singleKey.js +0 -126
  160. package/dist/cjs/identity/staticDescriptorProvider.js +0 -65
  161. package/dist/cjs/index.js +0 -200
  162. package/dist/cjs/intent/index.js +0 -259
  163. package/dist/cjs/musig2/index.js +0 -11
  164. package/dist/cjs/musig2/keys.js +0 -57
  165. package/dist/cjs/musig2/nonces.js +0 -48
  166. package/dist/cjs/musig2/sign.js +0 -102
  167. package/dist/cjs/networks.js +0 -26
  168. package/dist/cjs/package.json +0 -3
  169. package/dist/cjs/providers/ark.js +0 -577
  170. package/dist/cjs/providers/delegator.js +0 -85
  171. package/dist/cjs/providers/electrum.js +0 -869
  172. package/dist/cjs/providers/errors.js +0 -59
  173. package/dist/cjs/providers/expoArk.js +0 -82
  174. package/dist/cjs/providers/expoIndexer.js +0 -111
  175. package/dist/cjs/providers/expoUtils.js +0 -124
  176. package/dist/cjs/providers/indexer.js +0 -630
  177. package/dist/cjs/providers/onchain.js +0 -262
  178. package/dist/cjs/providers/utils.js +0 -121
  179. package/dist/cjs/repositories/contractRepository.js +0 -2
  180. package/dist/cjs/repositories/inMemory/contractRepository.js +0 -55
  181. package/dist/cjs/repositories/inMemory/walletRepository.js +0 -115
  182. package/dist/cjs/repositories/index.js +0 -34
  183. package/dist/cjs/repositories/indexedDB/contractRepository.js +0 -187
  184. package/dist/cjs/repositories/indexedDB/db.js +0 -19
  185. package/dist/cjs/repositories/indexedDB/manager.js +0 -100
  186. package/dist/cjs/repositories/indexedDB/schema.js +0 -204
  187. package/dist/cjs/repositories/indexedDB/walletRepository.js +0 -474
  188. package/dist/cjs/repositories/indexedDB/websqlAdapter.js +0 -144
  189. package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +0 -127
  190. package/dist/cjs/repositories/migrations/fromStorageAdapter.js +0 -66
  191. package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +0 -184
  192. package/dist/cjs/repositories/realm/contractRepository.js +0 -116
  193. package/dist/cjs/repositories/realm/index.js +0 -11
  194. package/dist/cjs/repositories/realm/schemas.js +0 -157
  195. package/dist/cjs/repositories/realm/types.js +0 -7
  196. package/dist/cjs/repositories/realm/walletRepository.js +0 -305
  197. package/dist/cjs/repositories/scriptFromAddress.js +0 -16
  198. package/dist/cjs/repositories/serialization.js +0 -82
  199. package/dist/cjs/repositories/sqlite/contractRepository.js +0 -135
  200. package/dist/cjs/repositories/sqlite/index.js +0 -7
  201. package/dist/cjs/repositories/sqlite/types.js +0 -2
  202. package/dist/cjs/repositories/sqlite/walletRepository.js +0 -441
  203. package/dist/cjs/repositories/walletRepository.js +0 -2
  204. package/dist/cjs/script/address.js +0 -108
  205. package/dist/cjs/script/base.js +0 -185
  206. package/dist/cjs/script/default.js +0 -57
  207. package/dist/cjs/script/delegate.js +0 -53
  208. package/dist/cjs/script/tapscript.js +0 -619
  209. package/dist/cjs/script/vhtlc.js +0 -170
  210. package/dist/cjs/storage/asyncStorage.js +0 -50
  211. package/dist/cjs/storage/fileSystem.js +0 -141
  212. package/dist/cjs/storage/inMemory.js +0 -24
  213. package/dist/cjs/storage/index.js +0 -2
  214. package/dist/cjs/storage/indexedDB.js +0 -101
  215. package/dist/cjs/storage/localStorage.js +0 -51
  216. package/dist/cjs/tree/signingSession.js +0 -229
  217. package/dist/cjs/tree/txTree.js +0 -192
  218. package/dist/cjs/tree/validation.js +0 -107
  219. package/dist/cjs/utils/anchor.js +0 -35
  220. package/dist/cjs/utils/arkTransaction.js +0 -271
  221. package/dist/cjs/utils/bip21.js +0 -127
  222. package/dist/cjs/utils/syncCursors.js +0 -128
  223. package/dist/cjs/utils/timelock.js +0 -59
  224. package/dist/cjs/utils/transaction.js +0 -28
  225. package/dist/cjs/utils/transactionHistory.js +0 -183
  226. package/dist/cjs/utils/txSizeEstimator.js +0 -132
  227. package/dist/cjs/utils/unknownFields.js +0 -174
  228. package/dist/cjs/wallet/asset-manager.js +0 -330
  229. package/dist/cjs/wallet/asset.js +0 -119
  230. package/dist/cjs/wallet/batch.js +0 -183
  231. package/dist/cjs/wallet/delegator.js +0 -302
  232. package/dist/cjs/wallet/expo/background.js +0 -116
  233. package/dist/cjs/wallet/expo/index.js +0 -9
  234. package/dist/cjs/wallet/expo/wallet.js +0 -230
  235. package/dist/cjs/wallet/hdDescriptorProvider.js +0 -159
  236. package/dist/cjs/wallet/index.js +0 -82
  237. package/dist/cjs/wallet/onchain.js +0 -290
  238. package/dist/cjs/wallet/ramps.js +0 -216
  239. package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +0 -953
  240. package/dist/cjs/wallet/serviceWorker/wallet.js +0 -1173
  241. package/dist/cjs/wallet/unroll.js +0 -289
  242. package/dist/cjs/wallet/utils.js +0 -111
  243. package/dist/cjs/wallet/validation.js +0 -154
  244. package/dist/cjs/wallet/vtxo-manager.js +0 -1142
  245. package/dist/cjs/wallet/wallet.js +0 -2049
  246. package/dist/cjs/worker/browser/service-worker-manager.js +0 -183
  247. package/dist/cjs/worker/browser/utils.js +0 -67
  248. package/dist/cjs/worker/errors.js +0 -16
  249. package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +0 -78
  250. package/dist/cjs/worker/expo/index.js +0 -13
  251. package/dist/cjs/worker/expo/processors/contractPollProcessor.js +0 -62
  252. package/dist/cjs/worker/expo/processors/index.js +0 -6
  253. package/dist/cjs/worker/expo/taskQueue.js +0 -41
  254. package/dist/cjs/worker/expo/taskRunner.js +0 -73
  255. package/dist/cjs/worker/messageBus.js +0 -473
  256. package/dist/esm/adapters/asyncStorage.js +0 -1
  257. package/dist/esm/adapters/expo.js +0 -3
  258. package/dist/esm/adapters/fileSystem.js +0 -1
  259. package/dist/esm/adapters/indexedDB.js +0 -1
  260. package/dist/esm/adapters/localStorage.js +0 -1
  261. package/dist/esm/arkfee/celenv.js +0 -40
  262. package/dist/esm/arkfee/estimator.js +0 -139
  263. package/dist/esm/arkfee/index.js +0 -1
  264. package/dist/esm/arkfee/types.js +0 -22
  265. package/dist/esm/arknote/index.js +0 -124
  266. package/dist/esm/bip322/index.js +0 -267
  267. package/dist/esm/contracts/arkcontract.js +0 -140
  268. package/dist/esm/contracts/contractManager.js +0 -625
  269. package/dist/esm/contracts/contractWatcher.js +0 -594
  270. package/dist/esm/contracts/handlers/default.js +0 -90
  271. package/dist/esm/contracts/handlers/delegate.js +0 -87
  272. package/dist/esm/contracts/handlers/helpers.js +0 -110
  273. package/dist/esm/contracts/handlers/index.js +0 -12
  274. package/dist/esm/contracts/handlers/registry.js +0 -86
  275. package/dist/esm/contracts/handlers/vhtlc.js +0 -191
  276. package/dist/esm/contracts/index.js +0 -13
  277. package/dist/esm/contracts/types.js +0 -1
  278. package/dist/esm/contracts/vtxoOwnership.js +0 -69
  279. package/dist/esm/extension/asset/assetGroup.js +0 -224
  280. package/dist/esm/extension/asset/assetId.js +0 -148
  281. package/dist/esm/extension/asset/assetInput.js +0 -217
  282. package/dist/esm/extension/asset/assetOutput.js +0 -169
  283. package/dist/esm/extension/asset/assetRef.js +0 -144
  284. package/dist/esm/extension/asset/index.js +0 -8
  285. package/dist/esm/extension/asset/metadata.js +0 -182
  286. package/dist/esm/extension/asset/packet.js +0 -110
  287. package/dist/esm/extension/asset/types.js +0 -19
  288. package/dist/esm/extension/asset/utils.js +0 -99
  289. package/dist/esm/extension/index.js +0 -248
  290. package/dist/esm/extension/packet.js +0 -16
  291. package/dist/esm/forfeit.js +0 -41
  292. package/dist/esm/identity/descriptor.js +0 -161
  293. package/dist/esm/identity/descriptorProvider.js +0 -1
  294. package/dist/esm/identity/hdCapableIdentity.js +0 -1
  295. package/dist/esm/identity/index.js +0 -12
  296. package/dist/esm/identity/seedIdentity.js +0 -453
  297. package/dist/esm/identity/serialize.js +0 -164
  298. package/dist/esm/identity/singleKey.js +0 -121
  299. package/dist/esm/identity/staticDescriptorProvider.js +0 -61
  300. package/dist/esm/index.js +0 -87
  301. package/dist/esm/intent/index.js +0 -255
  302. package/dist/esm/musig2/index.js +0 -3
  303. package/dist/esm/musig2/keys.js +0 -21
  304. package/dist/esm/musig2/nonces.js +0 -11
  305. package/dist/esm/musig2/sign.js +0 -63
  306. package/dist/esm/networks.js +0 -22
  307. package/dist/esm/package.json +0 -3
  308. package/dist/esm/providers/ark.js +0 -572
  309. package/dist/esm/providers/delegator.js +0 -81
  310. package/dist/esm/providers/electrum.js +0 -864
  311. package/dist/esm/providers/errors.js +0 -54
  312. package/dist/esm/providers/expoArk.js +0 -78
  313. package/dist/esm/providers/expoIndexer.js +0 -107
  314. package/dist/esm/providers/expoUtils.js +0 -87
  315. package/dist/esm/providers/indexer.js +0 -626
  316. package/dist/esm/providers/onchain.js +0 -258
  317. package/dist/esm/providers/utils.js +0 -117
  318. package/dist/esm/repositories/contractRepository.js +0 -1
  319. package/dist/esm/repositories/inMemory/contractRepository.js +0 -51
  320. package/dist/esm/repositories/inMemory/walletRepository.js +0 -111
  321. package/dist/esm/repositories/index.js +0 -10
  322. package/dist/esm/repositories/indexedDB/contractRepository.js +0 -183
  323. package/dist/esm/repositories/indexedDB/db.js +0 -4
  324. package/dist/esm/repositories/indexedDB/manager.js +0 -95
  325. package/dist/esm/repositories/indexedDB/schema.js +0 -199
  326. package/dist/esm/repositories/indexedDB/walletRepository.js +0 -470
  327. package/dist/esm/repositories/indexedDB/websqlAdapter.js +0 -138
  328. package/dist/esm/repositories/migrations/contractRepositoryImpl.js +0 -121
  329. package/dist/esm/repositories/migrations/fromStorageAdapter.js +0 -58
  330. package/dist/esm/repositories/migrations/walletRepositoryImpl.js +0 -180
  331. package/dist/esm/repositories/realm/contractRepository.js +0 -112
  332. package/dist/esm/repositories/realm/index.js +0 -3
  333. package/dist/esm/repositories/realm/schemas.js +0 -153
  334. package/dist/esm/repositories/realm/types.js +0 -6
  335. package/dist/esm/repositories/realm/walletRepository.js +0 -301
  336. package/dist/esm/repositories/scriptFromAddress.js +0 -13
  337. package/dist/esm/repositories/serialization.js +0 -67
  338. package/dist/esm/repositories/sqlite/contractRepository.js +0 -131
  339. package/dist/esm/repositories/sqlite/index.js +0 -2
  340. package/dist/esm/repositories/sqlite/types.js +0 -1
  341. package/dist/esm/repositories/sqlite/walletRepository.js +0 -437
  342. package/dist/esm/repositories/walletRepository.js +0 -1
  343. package/dist/esm/script/address.js +0 -104
  344. package/dist/esm/script/base.js +0 -179
  345. package/dist/esm/script/default.js +0 -54
  346. package/dist/esm/script/delegate.js +0 -50
  347. package/dist/esm/script/tapscript.js +0 -615
  348. package/dist/esm/script/vhtlc.js +0 -167
  349. package/dist/esm/storage/asyncStorage.js +0 -46
  350. package/dist/esm/storage/fileSystem.js +0 -104
  351. package/dist/esm/storage/inMemory.js +0 -20
  352. package/dist/esm/storage/index.js +0 -1
  353. package/dist/esm/storage/indexedDB.js +0 -97
  354. package/dist/esm/storage/localStorage.js +0 -47
  355. package/dist/esm/tree/signingSession.js +0 -191
  356. package/dist/esm/tree/txTree.js +0 -188
  357. package/dist/esm/tree/validation.js +0 -101
  358. package/dist/esm/utils/anchor.js +0 -31
  359. package/dist/esm/utils/arkTransaction.js +0 -264
  360. package/dist/esm/utils/bip21.js +0 -123
  361. package/dist/esm/utils/syncCursors.js +0 -119
  362. package/dist/esm/utils/timelock.js +0 -22
  363. package/dist/esm/utils/transaction.js +0 -24
  364. package/dist/esm/utils/transactionHistory.js +0 -180
  365. package/dist/esm/utils/txSizeEstimator.js +0 -128
  366. package/dist/esm/utils/unknownFields.js +0 -169
  367. package/dist/esm/wallet/asset-manager.js +0 -325
  368. package/dist/esm/wallet/asset.js +0 -113
  369. package/dist/esm/wallet/batch.js +0 -180
  370. package/dist/esm/wallet/delegator.js +0 -297
  371. package/dist/esm/wallet/expo/background.js +0 -111
  372. package/dist/esm/wallet/expo/index.js +0 -2
  373. package/dist/esm/wallet/expo/wallet.js +0 -193
  374. package/dist/esm/wallet/hdDescriptorProvider.js +0 -155
  375. package/dist/esm/wallet/index.js +0 -75
  376. package/dist/esm/wallet/onchain.js +0 -285
  377. package/dist/esm/wallet/ramps.js +0 -212
  378. package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +0 -946
  379. package/dist/esm/wallet/serviceWorker/wallet.js +0 -1168
  380. package/dist/esm/wallet/unroll.js +0 -285
  381. package/dist/esm/wallet/utils.js +0 -103
  382. package/dist/esm/wallet/validation.js +0 -142
  383. package/dist/esm/wallet/vtxo-manager.js +0 -1136
  384. package/dist/esm/wallet/wallet.js +0 -2041
  385. package/dist/esm/worker/browser/service-worker-manager.js +0 -177
  386. package/dist/esm/worker/browser/utils.js +0 -63
  387. package/dist/esm/worker/errors.js +0 -11
  388. package/dist/esm/worker/expo/asyncStorageTaskQueue.js +0 -74
  389. package/dist/esm/worker/expo/index.js +0 -4
  390. package/dist/esm/worker/expo/processors/contractPollProcessor.js +0 -59
  391. package/dist/esm/worker/expo/processors/index.js +0 -1
  392. package/dist/esm/worker/expo/taskQueue.js +0 -37
  393. package/dist/esm/worker/expo/taskRunner.js +0 -69
  394. package/dist/esm/worker/messageBus.js +0 -469
  395. package/dist/types/adapters/asyncStorage.d.ts +0 -2
  396. package/dist/types/adapters/expo.d.ts +0 -4
  397. package/dist/types/adapters/fileSystem.d.ts +0 -2
  398. package/dist/types/adapters/indexedDB.d.ts +0 -2
  399. package/dist/types/adapters/localStorage.d.ts +0 -2
  400. package/dist/types/arkfee/celenv.d.ts +0 -25
  401. package/dist/types/arkfee/estimator.d.ts +0 -49
  402. package/dist/types/arkfee/index.d.ts +0 -2
  403. package/dist/types/arkfee/types.d.ts +0 -38
  404. package/dist/types/arknote/index.d.ts +0 -84
  405. package/dist/types/bip322/index.d.ts +0 -55
  406. package/dist/types/contracts/arkcontract.d.ts +0 -99
  407. package/dist/types/contracts/contractManager.d.ts +0 -381
  408. package/dist/types/contracts/contractWatcher.d.ts +0 -217
  409. package/dist/types/contracts/handlers/default.d.ts +0 -19
  410. package/dist/types/contracts/handlers/delegate.d.ts +0 -21
  411. package/dist/types/contracts/handlers/helpers.d.ts +0 -19
  412. package/dist/types/contracts/handlers/index.d.ts +0 -7
  413. package/dist/types/contracts/handlers/registry.d.ts +0 -65
  414. package/dist/types/contracts/handlers/vhtlc.d.ts +0 -32
  415. package/dist/types/contracts/index.d.ts +0 -14
  416. package/dist/types/contracts/types.d.ts +0 -233
  417. package/dist/types/contracts/vtxoOwnership.d.ts +0 -33
  418. package/dist/types/extension/asset/assetGroup.d.ts +0 -119
  419. package/dist/types/extension/asset/assetId.d.ts +0 -83
  420. package/dist/types/extension/asset/assetInput.d.ts +0 -64
  421. package/dist/types/extension/asset/assetOutput.d.ts +0 -54
  422. package/dist/types/extension/asset/assetRef.d.ts +0 -91
  423. package/dist/types/extension/asset/index.d.ts +0 -8
  424. package/dist/types/extension/asset/metadata.d.ts +0 -52
  425. package/dist/types/extension/asset/packet.d.ts +0 -41
  426. package/dist/types/extension/asset/types.d.ts +0 -16
  427. package/dist/types/extension/asset/utils.d.ts +0 -21
  428. package/dist/types/extension/index.d.ts +0 -56
  429. package/dist/types/extension/packet.d.ts +0 -21
  430. package/dist/types/forfeit.d.ts +0 -18
  431. package/dist/types/identity/descriptor.d.ts +0 -61
  432. package/dist/types/identity/descriptorProvider.d.ts +0 -35
  433. package/dist/types/identity/hdCapableIdentity.d.ts +0 -44
  434. package/dist/types/identity/index.d.ts +0 -56
  435. package/dist/types/identity/seedIdentity.d.ts +0 -254
  436. package/dist/types/identity/serialize.d.ts +0 -96
  437. package/dist/types/identity/singleKey.d.ts +0 -62
  438. package/dist/types/identity/staticDescriptorProvider.d.ts +0 -18
  439. package/dist/types/index.d.ts +0 -59
  440. package/dist/types/intent/index.d.ts +0 -86
  441. package/dist/types/musig2/index.d.ts +0 -4
  442. package/dist/types/musig2/keys.d.ts +0 -9
  443. package/dist/types/musig2/nonces.d.ts +0 -14
  444. package/dist/types/musig2/sign.d.ts +0 -27
  445. package/dist/types/networks.d.ts +0 -16
  446. package/dist/types/providers/ark.d.ts +0 -369
  447. package/dist/types/providers/delegator.d.ts +0 -82
  448. package/dist/types/providers/electrum.d.ts +0 -312
  449. package/dist/types/providers/errors.d.ts +0 -13
  450. package/dist/types/providers/expoArk.d.ts +0 -22
  451. package/dist/types/providers/expoIndexer.d.ts +0 -18
  452. package/dist/types/providers/expoUtils.d.ts +0 -18
  453. package/dist/types/providers/indexer.d.ts +0 -301
  454. package/dist/types/providers/onchain.d.ts +0 -148
  455. package/dist/types/providers/utils.d.ts +0 -12
  456. package/dist/types/repositories/contractRepository.d.ts +0 -32
  457. package/dist/types/repositories/inMemory/contractRepository.d.ts +0 -17
  458. package/dist/types/repositories/inMemory/walletRepository.d.ts +0 -29
  459. package/dist/types/repositories/index.d.ts +0 -9
  460. package/dist/types/repositories/indexedDB/contractRepository.d.ts +0 -21
  461. package/dist/types/repositories/indexedDB/db.d.ts +0 -4
  462. package/dist/types/repositories/indexedDB/manager.d.ts +0 -25
  463. package/dist/types/repositories/indexedDB/schema.d.ts +0 -9
  464. package/dist/types/repositories/indexedDB/walletRepository.d.ts +0 -28
  465. package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +0 -49
  466. package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +0 -24
  467. package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +0 -19
  468. package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +0 -27
  469. package/dist/types/repositories/realm/contractRepository.d.ts +0 -24
  470. package/dist/types/repositories/realm/index.d.ts +0 -4
  471. package/dist/types/repositories/realm/types.d.ts +0 -16
  472. package/dist/types/repositories/realm/walletRepository.d.ts +0 -34
  473. package/dist/types/repositories/scriptFromAddress.d.ts +0 -9
  474. package/dist/types/repositories/serialization.d.ts +0 -65
  475. package/dist/types/repositories/sqlite/contractRepository.d.ts +0 -33
  476. package/dist/types/repositories/sqlite/index.d.ts +0 -3
  477. package/dist/types/repositories/sqlite/types.d.ts +0 -18
  478. package/dist/types/repositories/walletRepository.d.ts +0 -72
  479. package/dist/types/script/address.d.ts +0 -67
  480. package/dist/types/script/base.d.ts +0 -105
  481. package/dist/types/script/default.d.ts +0 -44
  482. package/dist/types/script/delegate.d.ts +0 -40
  483. package/dist/types/script/tapscript.d.ts +0 -169
  484. package/dist/types/script/vhtlc.d.ts +0 -66
  485. package/dist/types/tree/signingSession.d.ts +0 -37
  486. package/dist/types/tree/txTree.d.ts +0 -28
  487. package/dist/types/tree/validation.d.ts +0 -15
  488. package/dist/types/utils/anchor.d.ts +0 -19
  489. package/dist/types/utils/arkTransaction.d.ts +0 -49
  490. package/dist/types/utils/bip21.d.ts +0 -38
  491. package/dist/types/utils/syncCursors.d.ts +0 -60
  492. package/dist/types/utils/timelock.d.ts +0 -9
  493. package/dist/types/utils/transaction.d.ts +0 -13
  494. package/dist/types/utils/transactionHistory.d.ts +0 -15
  495. package/dist/types/utils/txSizeEstimator.d.ts +0 -40
  496. package/dist/types/utils/unknownFields.d.ts +0 -83
  497. package/dist/types/wallet/asset-manager.d.ts +0 -69
  498. package/dist/types/wallet/asset.d.ts +0 -21
  499. package/dist/types/wallet/batch.d.ts +0 -107
  500. package/dist/types/wallet/delegator.d.ts +0 -48
  501. package/dist/types/wallet/expo/background.d.ts +0 -66
  502. package/dist/types/wallet/expo/index.d.ts +0 -4
  503. package/dist/types/wallet/hdDescriptorProvider.d.ts +0 -93
  504. package/dist/types/wallet/index.d.ts +0 -755
  505. package/dist/types/wallet/onchain.d.ts +0 -109
  506. package/dist/types/wallet/ramps.d.ts +0 -64
  507. package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
  508. package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -238
  509. package/dist/types/wallet/unroll.d.ts +0 -114
  510. package/dist/types/wallet/utils.d.ts +0 -36
  511. package/dist/types/wallet/validation.d.ts +0 -24
  512. package/dist/types/wallet/vtxo-manager.d.ts +0 -476
  513. package/dist/types/wallet/wallet.d.ts +0 -360
  514. package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
  515. package/dist/types/worker/browser/utils.d.ts +0 -17
  516. package/dist/types/worker/errors.d.ts +0 -7
  517. package/dist/types/worker/expo/index.d.ts +0 -7
  518. package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
  519. package/dist/types/worker/expo/processors/index.d.ts +0 -1
  520. package/dist/types/worker/expo/taskQueue.d.ts +0 -50
  521. package/dist/types/worker/expo/taskRunner.d.ts +0 -66
  522. package/dist/types/worker/messageBus.d.ts +0 -188
@@ -1,869 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ElectrumOnchainProvider = exports.WsElectrumChainSource = exports.ELECTRUM_TCP_HOST = exports.ELECTRUM_WS_URL = void 0;
4
- const btc_signer_1 = require("@scure/btc-signer");
5
- const utils_js_1 = require("@scure/btc-signer/utils.js");
6
- const base_1 = require("@scure/base");
7
- /**
8
- * Default WebSocket Electrum endpoints. Mainnet, mutinynet, and signet
9
- * point at Ark Labs–operated Fulcrum 2.1 deployments (which support
10
- * `blockchain.transaction.broadcast_package` for atomic 1P1C TRUC
11
- * relay; see `ElectrumOnchainProvider.broadcastTransaction`). Testnet
12
- * defaults to Blockstream's public Fulcrum because Ark doesn't host
13
- * it. Regtest assumes the `electrum-ws` websocat bridge from
14
- * `vulpemventures/nigiri`.
15
- *
16
- * @example
17
- * ```typescript
18
- * import { ElectrumWS } from "ws-electrumx-client";
19
- * import { ELECTRUM_WS_URL, ElectrumOnchainProvider, networks } from "@arkade-os/sdk";
20
- *
21
- * const ws = new ElectrumWS(ELECTRUM_WS_URL.bitcoin);
22
- * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
23
- * ```
24
- */
25
- exports.ELECTRUM_WS_URL = {
26
- bitcoin: "wss://electrum.arkade.sh",
27
- testnet: "wss://electrum.blockstream.info:60004",
28
- signet: "wss://electrum.signet.arkade.sh",
29
- mutinynet: "wss://electrum.mutinynet.arkade.sh",
30
- regtest: "ws://localhost:50003",
31
- };
32
- /**
33
- * Hostnames for Electrum endpoints reachable over raw TCP. Provided as
34
- * a reference for Node-side consumers — the SDK's
35
- * {@link ElectrumOnchainProvider} only speaks WebSocket because it has
36
- * to run in browsers, so this map is informational only and not
37
- * consumed by any built-in provider.
38
- *
39
- * Public Ark Labs Fulcrum instances expose:
40
- * - port 50001 — plain TCP (Electrum protocol)
41
- * - port 50002 — TCP + TLS (Electrum protocol)
42
- * - port 50003 — WebSocket (Electrum-over-WS, see {@link ELECTRUM_WS_URL})
43
- */
44
- exports.ELECTRUM_TCP_HOST = {
45
- bitcoin: "electrum.arkade.sh",
46
- testnet: null,
47
- signet: "electrum.signet.arkade.sh",
48
- mutinynet: "electrum.mutinynet.arkade.sh",
49
- regtest: "localhost",
50
- };
51
- // Electrum protocol method names
52
- const BroadcastTransaction = "blockchain.transaction.broadcast";
53
- const BroadcastPackageMethod = "blockchain.transaction.broadcast_package";
54
- const EstimateFee = "blockchain.estimatefee";
55
- const GetBlockHeader = "blockchain.block.header";
56
- const GetHistoryMethod = "blockchain.scripthash.get_history";
57
- const GetTransactionMethod = "blockchain.transaction.get";
58
- const GetTransactionMerkleMethod = "blockchain.transaction.get_merkle";
59
- const SubscribeStatusMethod = "blockchain.scripthash";
60
- const SubscribeHeadersMethod = "blockchain.headers";
61
- const GetRelayFeeMethod = "blockchain.relayfee";
62
- const ListUnspentMethod = "blockchain.scripthash.listunspent";
63
- const MISSING_TRANSACTION = "missingtransaction";
64
- const MAX_FETCH_TRANSACTIONS_ATTEMPTS = 5;
65
- // Bitcoin block header is 80 bytes
66
- const BLOCK_HEADER_SIZE = 80;
67
- /**
68
- * Parse a raw block header (80 bytes hex = 160 chars) to extract fields.
69
- * Bitcoin block header layout:
70
- * - version: 4 bytes (LE)
71
- * - prevHash: 32 bytes
72
- * - merkleRoot: 32 bytes
73
- * - timestamp: 4 bytes (LE)
74
- * - bits: 4 bytes
75
- * - nonce: 4 bytes
76
- */
77
- function parseBlockHeader(headerHex) {
78
- const headerBytes = base_1.hex.decode(headerHex);
79
- if (headerBytes.length !== BLOCK_HEADER_SIZE) {
80
- throw new Error(`Invalid block header size: ${headerBytes.length}, expected ${BLOCK_HEADER_SIZE}`);
81
- }
82
- // timestamp is at offset 68 (4+32+32), 4 bytes little-endian
83
- const view = new DataView(headerBytes.buffer, headerBytes.byteOffset);
84
- const timestamp = view.getUint32(68, true);
85
- // block hash = double SHA256 of header, reversed
86
- const hash1 = (0, utils_js_1.sha256)(headerBytes);
87
- const hash2 = (0, utils_js_1.sha256)(hash1);
88
- const hashStr = base_1.hex.encode(new Uint8Array(hash2).reverse());
89
- return { hash: hashStr, timestamp };
90
- }
91
- /**
92
- * WebSocket-based Electrum chain source using ws-electrumx-client.
93
- * Provides low-level methods for the Electrum protocol.
94
- *
95
- * @example
96
- * ```typescript
97
- * import { ElectrumWS } from "ws-electrumx-client";
98
- * import { WsElectrumChainSource } from "./providers/electrum";
99
- * import { networks } from "./networks";
100
- *
101
- * const ws = new ElectrumWS("wss://electrum.blockstream.info:50004");
102
- * const chain = new WsElectrumChainSource(ws, networks.bitcoin);
103
- *
104
- * const history = await chain.fetchHistories([script]);
105
- * await chain.close();
106
- * ```
107
- */
108
- class WsElectrumChainSource {
109
- constructor(ws, network) {
110
- this.ws = ws;
111
- this.network = network;
112
- // Cached chain tip kept fresh by the headers subscription. Initialized
113
- // lazily on first call to subscribeHeaders().
114
- this.cachedTip = null;
115
- this.headersSubscribePromise = null;
116
- }
117
- /**
118
- * Send N requests in parallel and aggregate the results, replacement
119
- * for `ws.batchRequest`. The library's batchRequest is implemented as
120
- * `Promise.all` over individual request promises — when one element
121
- * rejects, the others remain pending. When their (often error)
122
- * responses arrive later, the library rejects them too, and nobody is
123
- * awaiting them: the rejections become unhandled and crash the test
124
- * runner / pollute production logs.
125
- *
126
- * `safeBatchRequest` issues each request through `ws.request` (so each
127
- * has its own request-promise lifecycle), waits for all of them via
128
- * `Promise.allSettled` (every promise gets an explicit handler), and
129
- * then surfaces the first error if any failed. Same wall-clock cost
130
- * as the library's batch (parallel send), no orphan rejections.
131
- *
132
- * Use this in place of `ws.batchRequest` for any call where one or
133
- * more elements may legitimately error (e.g. electrs index lag
134
- * surfacing as `missingheight` for a subset of heights/txids).
135
- */
136
- async safeBatchRequest(requests) {
137
- if (requests.length === 0)
138
- return [];
139
- const settled = await Promise.allSettled(requests.map((req) => this.ws.request(req.method, ...req.params)));
140
- for (const r of settled) {
141
- if (r.status === "rejected")
142
- throw r.reason;
143
- }
144
- return settled.map((r) => r.value);
145
- }
146
- async fetchTransactions(txids) {
147
- const requests = txids.map((txid) => ({
148
- method: GetTransactionMethod,
149
- params: [txid],
150
- }));
151
- for (let i = 0; i < MAX_FETCH_TRANSACTIONS_ATTEMPTS; i++) {
152
- try {
153
- const responses = await this.safeBatchRequest(requests);
154
- return responses.map((hexStr, i) => ({
155
- txID: txids[i],
156
- hex: hexStr,
157
- }));
158
- }
159
- catch (e) {
160
- const msg = e instanceof Error ? e.message : String(e);
161
- if (msg.toLowerCase().includes(MISSING_TRANSACTION)) {
162
- console.warn("missing transaction error, retrying");
163
- await new Promise((resolve) => setTimeout(resolve, 1000));
164
- continue;
165
- }
166
- throw e;
167
- }
168
- }
169
- throw new Error("Unable to fetch transactions: " + txids);
170
- }
171
- async fetchVerboseTransaction(txid) {
172
- return this.ws.request(GetTransactionMethod, txid, true);
173
- }
174
- async fetchVerboseTransactions(txids) {
175
- if (txids.length === 0)
176
- return [];
177
- const requests = txids.map((txid) => ({
178
- method: GetTransactionMethod,
179
- params: [txid, true],
180
- }));
181
- return this.safeBatchRequest(requests);
182
- }
183
- /**
184
- * Look up the block height of a confirmed transaction without relying
185
- * on the verbose-tx endpoint. `blockchain.transaction.get_merkle` is
186
- * part of the standard SPV protocol and is supported by both Fulcrum
187
- * and electrs (whereas `blockchain.transaction.get` with verbose=true
188
- * is Fulcrum-only). Returns `null` when the tx is in the mempool —
189
- * electrs in that case rejects with a "not yet in a block" error.
190
- */
191
- async fetchTxMerkle(txid) {
192
- let result;
193
- try {
194
- result = await this.ws.request(GetTransactionMerkleMethod, txid);
195
- }
196
- catch (err) {
197
- // electrs/Fulcrum raise specific errors when the tx isn't yet in
198
- // a block — either "not in a block" wording, or "missingheight"
199
- // when get_merkle hits the same index-lag race that block.header
200
- // hits (the tx is reportedly confirmed but the height isn't
201
- // queryable yet). Map both to mempool/unknown; everything else
202
- // (auth failure, network outage, malformed response) must surface
203
- // so callers can fail rather than silently treat the tx as
204
- // unconfirmed forever.
205
- if (isTxNotInBlockError(err) || isMissingHeightError(err))
206
- return null;
207
- throw err;
208
- }
209
- if (!result ||
210
- typeof result.block_height !== "number" ||
211
- result.block_height <= 0) {
212
- return null;
213
- }
214
- return { blockHeight: result.block_height };
215
- }
216
- async unsubscribeScriptStatus(script) {
217
- await this.ws
218
- .unsubscribe(SubscribeStatusMethod, toScriptHash(script))
219
- .catch(() => { });
220
- }
221
- async subscribeScriptStatus(script, callback) {
222
- const scriptHash = toScriptHash(script);
223
- await this.ws.subscribe(SubscribeStatusMethod, (scripthash, status) => {
224
- if (scripthash === scriptHash) {
225
- callback(scripthash, status);
226
- }
227
- }, scriptHash);
228
- }
229
- async fetchHistories(scripts) {
230
- const scriptsHashes = scripts.map((s) => toScriptHash(s));
231
- return this.safeBatchRequest(scriptsHashes.map((s) => ({
232
- method: GetHistoryMethod,
233
- params: [s],
234
- })));
235
- }
236
- async fetchHistory(script) {
237
- const scriptHash = toScriptHash(script);
238
- return this.ws.request(GetHistoryMethod, scriptHash);
239
- }
240
- async fetchBlockHeaders(heights) {
241
- const responses = await this.safeBatchRequest(heights.map((h) => ({ method: GetBlockHeader, params: [h] })));
242
- return responses.map((hexStr, i) => ({
243
- height: heights[i],
244
- hex: hexStr,
245
- }));
246
- }
247
- async fetchBlockHeader(height) {
248
- const headerHex = await this.ws.request(GetBlockHeader, height);
249
- return { height, hex: headerHex };
250
- }
251
- /**
252
- * Returns the current chain tip and keeps it fresh via a single
253
- * server-side subscription. Subsequent calls return the cached tip
254
- * (updated by background notifications) without round-tripping to the
255
- * server. Previously each call issued `blockchain.headers.subscribe` as
256
- * a regular request, leaving a stale subscription on the server every
257
- * time — under polling that adds up. ws-electrumx-client deduplicates
258
- * `subscribe()` by method+params, so registering once is enough.
259
- */
260
- async subscribeHeaders() {
261
- if (this.cachedTip)
262
- return this.cachedTip;
263
- if (this.headersSubscribePromise)
264
- return this.headersSubscribePromise;
265
- this.headersSubscribePromise = new Promise((resolve, reject) => {
266
- let resolved = false;
267
- this.ws
268
- .subscribe(SubscribeHeadersMethod, (header) => {
269
- if (!isHeaderSubscribeResult(header))
270
- return;
271
- this.cachedTip = header;
272
- if (!resolved) {
273
- resolved = true;
274
- resolve(header);
275
- }
276
- })
277
- .catch((err) => {
278
- if (!resolved) {
279
- resolved = true;
280
- reject(err);
281
- }
282
- });
283
- });
284
- try {
285
- return await this.headersSubscribePromise;
286
- }
287
- catch (err) {
288
- // Allow the next call to retry from scratch.
289
- this.headersSubscribePromise = null;
290
- throw err;
291
- }
292
- }
293
- async estimateFees(targetNumberBlocks) {
294
- const feeRate = await this.ws.request(EstimateFee, targetNumberBlocks);
295
- return feeRate;
296
- }
297
- async broadcastTransaction(txHex) {
298
- return this.ws.request(BroadcastTransaction, txHex);
299
- }
300
- /**
301
- * Submit a package of raw transactions atomically via Fulcrum's
302
- * `blockchain.transaction.broadcast_package` method, the on-the-wire
303
- * equivalent of bitcoind's `submitpackage` RPC.
304
- *
305
- * Required for TRUC (BIP 431) 1P1C relay where the parent has zero
306
- * (or below-minfee) fee and depends on the child to pay for both via
307
- * CPFP — sequential broadcast cannot work in that case because the
308
- * parent would be rejected from the mempool on its own.
309
- *
310
- * @param txHexes - Topologically sorted raw transactions; child must
311
- * be the last element. Currently must be a 1P1C pair
312
- * (length 2). Parents may not depend on each other.
313
- * @returns The child transaction id (the last entry in the array),
314
- * computed locally — `broadcast_package` itself returns
315
- * `{success, errors}` rather than a txid.
316
- * @throws If the server does not implement `broadcast_package` (e.g.
317
- * ElectrumX, or older Fulcrum, or Fulcrum backed by bitcoind
318
- * < v28.0.0). Callers must surface this clearly to users —
319
- * this method does NOT silently fall back to sequential
320
- * broadcasts because doing so would let TRUC packages fail
321
- * in subtle ways.
322
- * @throws If the server returns `success=false`, surfacing the
323
- * underlying mempool rejection in the error message.
324
- */
325
- async broadcastPackage(txHexes) {
326
- const result = await this.ws.request(BroadcastPackageMethod, txHexes, false);
327
- if (!result.success) {
328
- const detail = result.errors
329
- ? JSON.stringify(result.errors)
330
- : "unknown error";
331
- throw new Error(`Package broadcast rejected: ${detail}`);
332
- }
333
- // The child txid is not in the response — derive it from the raw
334
- // bytes (double-SHA256 of the serialized tx, reversed).
335
- return childTxidFromHex(txHexes[txHexes.length - 1]);
336
- }
337
- async getRelayFee() {
338
- return this.ws.request(GetRelayFeeMethod);
339
- }
340
- async close() {
341
- try {
342
- await this.ws.close("close");
343
- }
344
- catch (e) {
345
- console.debug("error closing ws:", e);
346
- }
347
- }
348
- waitForAddressReceivesTx(addr) {
349
- return new Promise((resolve, reject) => {
350
- const script = btc_signer_1.OutScript.encode((0, btc_signer_1.Address)(this.network).decode(addr));
351
- this.subscribeScriptStatus(script, (_, status) => {
352
- if (status !== null) {
353
- resolve();
354
- }
355
- }).catch(reject);
356
- });
357
- }
358
- async listUnspents(addr) {
359
- const script = btc_signer_1.OutScript.encode((0, btc_signer_1.Address)(this.network).decode(addr));
360
- const scriptHash = toScriptHash(script);
361
- const unspentsFromElectrum = await this.ws.request(ListUnspentMethod, scriptHash);
362
- const txs = await this.fetchTransactions(unspentsFromElectrum.map((u) => u.tx_hash));
363
- return unspentsFromElectrum.map((u, index) => {
364
- const tx = btc_signer_1.Transaction.fromRaw(base_1.hex.decode(txs[index].hex), {
365
- allowUnknownOutputs: true,
366
- });
367
- const output = tx.getOutput(u.tx_pos);
368
- if (!output.script || output.amount === undefined) {
369
- throw new Error(`Missing output data for ${u.tx_hash}:${u.tx_pos}`);
370
- }
371
- return {
372
- txid: u.tx_hash,
373
- vout: u.tx_pos,
374
- witnessUtxo: {
375
- script: output.script,
376
- value: output.amount,
377
- },
378
- };
379
- });
380
- }
381
- /**
382
- * Get the address string for a script output, if decodable.
383
- */
384
- addressForScript(scriptHex) {
385
- try {
386
- const script = base_1.hex.decode(scriptHex);
387
- return (0, btc_signer_1.Address)(this.network).encode(btc_signer_1.OutScript.decode(script));
388
- }
389
- catch {
390
- return undefined;
391
- }
392
- }
393
- }
394
- exports.WsElectrumChainSource = WsElectrumChainSource;
395
- /**
396
- * Electrum-based implementation of the {@link OnchainProvider} interface.
397
- *
398
- * Built around the subset of the Electrum protocol that both **Fulcrum**
399
- * and **electrs** support — listunspent, get_history, transaction.get
400
- * (non-verbose), transaction.get_merkle, block.header,
401
- * headers.subscribe, scripthash.subscribe, estimatefee, relayfee, and
402
- * broadcast. The verbose form of `transaction.get` is **not** used (it's
403
- * Fulcrum-only and rejected by electrs); confirmation status is derived
404
- * from `transaction.get_merkle` plus parsed block headers.
405
- *
406
- * Output amounts are derived from parsed raw transaction bytes (exact
407
- * bigints), never the floating-point `value` fields some servers return.
408
- *
409
- * Atomic 1P1C package broadcast (TRUC / BIP 431) is supported via
410
- * Fulcrum's `blockchain.transaction.broadcast_package`. There is **no
411
- * fallback** to sequential parent-then-child broadcasts — TRUC packages
412
- * with a zero-fee parent would silently fail, so the call surfaces an
413
- * error against servers that don't support the method.
414
- *
415
- * @example Default URL via {@link ELECTRUM_WS_URL}
416
- * ```typescript
417
- * import { ElectrumWS } from "ws-electrumx-client";
418
- * import {
419
- * ElectrumOnchainProvider,
420
- * ELECTRUM_WS_URL,
421
- * networks,
422
- * } from "@arkade-os/sdk";
423
- *
424
- * const ws = new ElectrumWS(ELECTRUM_WS_URL.bitcoin);
425
- * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
426
- *
427
- * const coins = await provider.getCoins("bc1q...");
428
- * await provider.close();
429
- * ```
430
- *
431
- * @example Custom server
432
- * ```typescript
433
- * const ws = new ElectrumWS("wss://my-fulcrum.example:50004");
434
- * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
435
- * ```
436
- */
437
- class ElectrumOnchainProvider {
438
- constructor(ws, network) {
439
- this.ws = ws;
440
- this.network = network;
441
- this.chain = new WsElectrumChainSource(ws, network);
442
- }
443
- async getCoins(address) {
444
- const script = this.encodeAddress(address);
445
- const scriptHash = toScriptHash(script);
446
- const unspents = await this.ws.request(ListUnspentMethod, scriptHash);
447
- return unspents.map((u) => ({
448
- txid: u.tx_hash,
449
- vout: u.tx_pos,
450
- value: u.value,
451
- status: {
452
- confirmed: u.height > 0,
453
- block_height: u.height > 0 ? u.height : undefined,
454
- },
455
- }));
456
- }
457
- async getFeeRate() {
458
- // electrum returns BTC/kB, we need sat/vB
459
- // 1 BTC = 100_000_000 sat, 1 kB = 1000 bytes
460
- // sat/vB = (BTC/kB) * 100_000_000 / 1000 = (BTC/kB) * 100_000
461
- const feePerKb = await this.chain.estimateFees(1);
462
- if (feePerKb < 0) {
463
- // -1 means the daemon cannot estimate
464
- return undefined;
465
- }
466
- return Math.max(1, Math.ceil(feePerKb * 100000));
467
- }
468
- /**
469
- * Broadcast a single transaction or a TRUC (BIP 431) 1P1C package
470
- * atomically.
471
- *
472
- * **Server requirements for 1P1C packages:** the backing Electrum
473
- * server must implement `blockchain.transaction.broadcast_package`
474
- * (Fulcrum ≥ 1.10) and be backed by bitcoind ≥ v28.0.0. ElectrumX
475
- * does not implement this method. There is **no fallback** to
476
- * sequential parent-then-child broadcast: TRUC packages typically
477
- * have a zero-fee parent and would be rejected from the mempool on
478
- * their own, so a fallback would silently fail in subtle ways.
479
- * Callers receiving a "method not found" error here should route
480
- * through a different provider for that submission.
481
- *
482
- * @param txs - One transaction (single broadcast) or two
483
- * topologically-sorted transactions (parent first,
484
- * child last) for 1P1C package relay.
485
- * @returns The broadcast txid (or the child txid for 1P1C packages).
486
- */
487
- async broadcastTransaction(...txs) {
488
- if (txs.length === 1) {
489
- return this.chain.broadcastTransaction(txs[0]);
490
- }
491
- if (txs.length === 2) {
492
- return this.chain.broadcastPackage(txs);
493
- }
494
- throw new Error("Only 1 or 1P1C package can be broadcast");
495
- }
496
- async getTxOutspends(txid) {
497
- // Step 1: fetch the creating tx to get its output scripts (1 round trip)
498
- const [txResult] = await this.chain.fetchTransactions([txid]);
499
- const tx = btc_signer_1.Transaction.fromRaw(base_1.hex.decode(txResult.hex), {
500
- allowUnknownOutputs: true,
501
- });
502
- const outputCount = tx.outputsLength;
503
- const outputScriptHashes = [];
504
- for (let i = 0; i < outputCount; i++) {
505
- const output = tx.getOutput(i);
506
- outputScriptHashes.push(output.script ? toScriptHash(output.script) : undefined);
507
- }
508
- const validScriptHashes = outputScriptHashes.filter((h) => h !== undefined);
509
- const results = Array.from({ length: outputCount }, () => ({ spent: false, txid: "" }));
510
- if (validScriptHashes.length === 0)
511
- return results;
512
- // Step 2: batch listunspent for all output scripthashes (1 round trip)
513
- // This tells us exactly which txid:vout pairs are still unspent.
514
- const unspentBatch = await this.chain.safeBatchRequest(validScriptHashes.map((sh) => ({
515
- method: ListUnspentMethod,
516
- params: [sh],
517
- })));
518
- const unspentSet = new Set();
519
- let validIdx = 0;
520
- for (let i = 0; i < outputCount; i++) {
521
- if (outputScriptHashes[i] !== undefined) {
522
- for (const u of unspentBatch[validIdx]) {
523
- unspentSet.add(`${u.tx_hash}:${u.tx_pos}`);
524
- }
525
- validIdx++;
526
- }
527
- }
528
- // Step 3: batch get_history only for spent outputs (1 round trip)
529
- const spentIndices = [];
530
- const spentScriptHashes = [];
531
- for (let i = 0; i < outputCount; i++) {
532
- const sh = outputScriptHashes[i];
533
- if (sh && !unspentSet.has(`${txid}:${i}`)) {
534
- spentIndices.push(i);
535
- spentScriptHashes.push(sh);
536
- }
537
- }
538
- if (spentIndices.length === 0)
539
- return results;
540
- const histories = await this.chain.safeBatchRequest(spentScriptHashes.map((sh) => ({
541
- method: GetHistoryMethod,
542
- params: [sh],
543
- })));
544
- // For each spent output find the spender in its history.
545
- // Common case: history has exactly 2 entries (creating + spending tx).
546
- // Ambiguous case (same script reused): batch-fetch all candidates at once.
547
- const ambiguousIndices = [];
548
- const ambiguousCandidates = [];
549
- for (let j = 0; j < spentIndices.length; j++) {
550
- const i = spentIndices[j];
551
- const candidates = histories[j]
552
- .map((h) => h.tx_hash)
553
- .filter((hash) => hash !== txid);
554
- if (candidates.length === 1) {
555
- // Fast path: one candidate = the spender
556
- results[i] = { spent: true, txid: candidates[0] };
557
- }
558
- else if (candidates.length > 1) {
559
- ambiguousIndices.push(i);
560
- ambiguousCandidates.push(candidates);
561
- }
562
- // candidates.length === 0 → mempool eviction, treat as unspent
563
- }
564
- // Step 4 (rare): batch-fetch all ambiguous candidate txs at once
565
- if (ambiguousIndices.length > 0) {
566
- const allCandidateTxids = [...new Set(ambiguousCandidates.flat())];
567
- const fetched = await this.chain.fetchTransactions(allCandidateTxids);
568
- const txMap = new Map(fetched.map((t) => [t.txID, t.hex]));
569
- for (let j = 0; j < ambiguousIndices.length; j++) {
570
- const i = ambiguousIndices[j];
571
- for (const candidateTxid of ambiguousCandidates[j]) {
572
- const rawHex = txMap.get(candidateTxid);
573
- if (!rawHex)
574
- continue;
575
- const candidateTx = btc_signer_1.Transaction.fromRaw(base_1.hex.decode(rawHex), { allowUnknownOutputs: true, allowUnknownInputs: true });
576
- let found = false;
577
- for (let k = 0; k < candidateTx.inputsLength; k++) {
578
- const input = candidateTx.getInput(k);
579
- if (input.txid &&
580
- base_1.hex.encode(input.txid) === txid &&
581
- input.index === i) {
582
- results[i] = { spent: true, txid: candidateTxid };
583
- found = true;
584
- break;
585
- }
586
- }
587
- if (found)
588
- break;
589
- }
590
- }
591
- }
592
- return results;
593
- }
594
- async getTransactions(address) {
595
- const script = this.encodeAddress(address);
596
- const history = await this.chain.fetchHistory(script);
597
- if (history.length === 0)
598
- return [];
599
- return this.historyToExplorerTxs(history);
600
- }
601
- /**
602
- * Resolve a list of `{tx_hash, height}` entries (as returned by the
603
- * scripthash history endpoint) into ExplorerTransaction shape **without
604
- * using the verbose-tx endpoint**, which only Fulcrum implements. We
605
- * reconstruct everything the verbose response would have given us:
606
- * - vouts ← parse the raw tx (exact sat amounts, no float precision risk)
607
- * - block_time ← batch-fetch the block headers for the heights present
608
- * - addresses ← decode each output's scriptPubKey via @scure/btc-signer
609
- */
610
- async historyToExplorerTxs(history) {
611
- const txids = history.map((h) => h.tx_hash);
612
- const rawTxs = await this.chain.fetchTransactions(txids);
613
- const rawHexByTxid = new Map(rawTxs.map((t) => [t.txID, t.hex]));
614
- // De-duplicated batch lookup of block headers (now safe — see
615
- // safeBatchRequest above). Heights whose headers fail to resolve
616
- // surface via the wrapper's first-error throw; we tolerate that
617
- // here by falling back to per-height calls under Promise.allSettled
618
- // so one missing header doesn't poison the whole history mapping.
619
- // The old verbose-tx code had the same tolerance via
620
- // `vtx.blocktime || vtx.time || 0`.
621
- const confirmedHeights = [
622
- ...new Set(history.map((h) => h.height).filter((h) => h > 0)),
623
- ];
624
- const blockTimeByHeight = new Map();
625
- if (confirmedHeights.length > 0) {
626
- try {
627
- const headers = await this.chain.fetchBlockHeaders(confirmedHeights);
628
- for (const header of headers) {
629
- blockTimeByHeight.set(header.height, parseBlockHeader(header.hex).timestamp);
630
- }
631
- }
632
- catch {
633
- const settled = await Promise.allSettled(confirmedHeights.map((h) => this.chain.fetchBlockHeader(h)));
634
- settled.forEach((res) => {
635
- if (res.status === "fulfilled") {
636
- blockTimeByHeight.set(res.value.height, parseBlockHeader(res.value.hex).timestamp);
637
- }
638
- // Rejections leave the height absent → block_time = 0.
639
- });
640
- }
641
- }
642
- return history.map((entry) => this.buildExplorerTx(entry, rawHexByTxid.get(entry.tx_hash), blockTimeByHeight));
643
- }
644
- /**
645
- * Build an ExplorerTransaction from a history entry plus the raw tx hex
646
- * (when known) and a height→block_time map. Parse errors propagate —
647
- * silently returning an empty vout would hide real outputs (e.g. a
648
- * deposit) and is far worse for protocol-level money handling than
649
- * failing the whole batch.
650
- */
651
- buildExplorerTx(entry, rawHex, blockTimeByHeight) {
652
- const vout = [];
653
- if (rawHex) {
654
- let tx;
655
- try {
656
- tx = btc_signer_1.Transaction.fromRaw(base_1.hex.decode(rawHex), {
657
- allowUnknownOutputs: true,
658
- allowUnknownInputs: true,
659
- });
660
- }
661
- catch (err) {
662
- throw new Error(`Failed to parse raw tx for ${entry.tx_hash}: ${err instanceof Error ? err.message : String(err)}`);
663
- }
664
- for (let i = 0; i < tx.outputsLength; i++) {
665
- const output = tx.getOutput(i);
666
- const scriptHex = output.script
667
- ? base_1.hex.encode(output.script)
668
- : "";
669
- vout.push({
670
- scriptpubkey_address: scriptHex
671
- ? (this.chain.addressForScript(scriptHex) ?? "")
672
- : "",
673
- value: (output.amount ?? 0n).toString(),
674
- });
675
- }
676
- }
677
- return {
678
- txid: entry.tx_hash,
679
- vout,
680
- status: {
681
- confirmed: entry.height > 0,
682
- block_time: blockTimeByHeight.get(entry.height) ?? 0,
683
- },
684
- };
685
- }
686
- /**
687
- * Decode `address` into its scriptPubKey, throwing a clear error if the
688
- * input is malformed. @scure/btc-signer raises a generic decode error
689
- * which is hard to map back to user input — this wraps it.
690
- */
691
- encodeAddress(address) {
692
- try {
693
- return btc_signer_1.OutScript.encode((0, btc_signer_1.Address)(this.network).decode(address));
694
- }
695
- catch (err) {
696
- const reason = err instanceof Error ? err.message : String(err);
697
- throw new Error(`Invalid address ${address}: ${reason}`);
698
- }
699
- }
700
- async getTxStatus(txid) {
701
- // Use `transaction.get_merkle` rather than the verbose `transaction.get`
702
- // because electrs (used by mempool.space, blockstream.info, and the
703
- // nigiri regtest) doesn't implement verbose. get_merkle is part of the
704
- // standard SPV protocol and supported by every Electrum server.
705
- const merkle = await this.chain.fetchTxMerkle(txid);
706
- if (!merkle)
707
- return { confirmed: false };
708
- // Header lookup can transiently race with electrs's index right
709
- // after a fresh block — listunspent/get_merkle expose the new
710
- // height before block.header(N) is queryable. Tolerate that the
711
- // same way historyToExplorerTxs does: confirmation status and
712
- // height are still authoritative; only block_time degrades.
713
- let blockTime = 0;
714
- try {
715
- const header = await this.chain.fetchBlockHeader(merkle.blockHeight);
716
- blockTime = parseBlockHeader(header.hex).timestamp;
717
- }
718
- catch (err) {
719
- if (!isMissingHeightError(err))
720
- throw err;
721
- }
722
- return {
723
- confirmed: true,
724
- blockHeight: merkle.blockHeight,
725
- blockTime,
726
- };
727
- }
728
- async getChainTip() {
729
- const tip = await this.chain.subscribeHeaders();
730
- const { hash, timestamp } = parseBlockHeader(tip.hex);
731
- return {
732
- height: tip.height,
733
- time: timestamp,
734
- hash,
735
- };
736
- }
737
- async watchAddresses(addresses, eventCallback) {
738
- const scripts = addresses.map((addr) => this.encodeAddress(addr));
739
- const scriptHashes = scripts.map(toScriptHash);
740
- // O(1) scripthash → script lookup, kept in sync with the
741
- // scripts/scriptHashes arrays. Server notifications hit this on
742
- // every push, so the previous indexOf was O(n) per event.
743
- const scriptByHash = new Map(scriptHashes.map((h, i) => [h, scripts[i]]));
744
- // Track known history per script to detect new txs.
745
- const knownTxids = new Map();
746
- // Initialize known-set in parallel — for a wallet watching many
747
- // addresses this avoids n sequential round trips on first call.
748
- const initialHistories = await Promise.all(scripts.map((s) => this.chain.fetchHistory(s)));
749
- initialHistories.forEach((history, i) => {
750
- knownTxids.set(scriptHashes[i], new Set(history.map((h) => h.tx_hash)));
751
- });
752
- // Per-scripthash mutex serializing concurrent notifications so
753
- // two pushes for the same address can't fetch history in parallel
754
- // and emit duplicate events. Each call chains onto the previous
755
- // one's tail; failures are swallowed to keep the chain alive.
756
- const inFlight = new Map();
757
- const processStatusChange = async (scripthash) => {
758
- const script = scriptByHash.get(scripthash);
759
- if (!script)
760
- return;
761
- const history = await this.chain.fetchHistory(script);
762
- const known = knownTxids.get(scripthash) ?? new Set();
763
- const newEntries = history.filter((entry) => !known.has(entry.tx_hash));
764
- if (newEntries.length === 0)
765
- return;
766
- // Map the new history entries through the same non-verbose
767
- // pipeline getTransactions uses, so subscribe-driven and
768
- // poll-driven callers see ExplorerTransactions of identical shape.
769
- // The dedupe set is updated ONLY after delivery succeeds —
770
- // otherwise a failed fetch or callback would permanently mark
771
- // these txids as seen and the next notification wouldn't
772
- // re-deliver them.
773
- const explorerTxs = await this.historyToExplorerTxs(newEntries);
774
- eventCallback(explorerTxs);
775
- for (const entry of newEntries)
776
- known.add(entry.tx_hash);
777
- knownTxids.set(scripthash, known);
778
- };
779
- const handleStatusChange = (scripthash) => {
780
- const previous = inFlight.get(scripthash) ?? Promise.resolve();
781
- const next = previous.then(() => processStatusChange(scripthash));
782
- // Keep the chain alive even when one link rejects.
783
- inFlight.set(scripthash, next.catch(() => undefined));
784
- return next;
785
- };
786
- // Register all subscriptions in parallel; if any one fails, tear
787
- // down the others so we don't leak server-side subscriptions on
788
- // a connection the caller never gets a stop() handle for.
789
- const subscribed = [];
790
- try {
791
- await Promise.all(scripts.map(async (script) => {
792
- await this.chain.subscribeScriptStatus(script, (scripthash, status) => {
793
- if (status !== null) {
794
- handleStatusChange(scripthash).catch(console.error);
795
- }
796
- });
797
- subscribed.push(script);
798
- }));
799
- }
800
- catch (err) {
801
- await Promise.allSettled(subscribed.map((s) => this.chain.unsubscribeScriptStatus(s)));
802
- throw err;
803
- }
804
- return () => {
805
- for (const script of scripts) {
806
- this.chain.unsubscribeScriptStatus(script).catch(() => { });
807
- }
808
- };
809
- }
810
- /** Close the underlying WebSocket connection. */
811
- async close() {
812
- await this.chain.close();
813
- }
814
- }
815
- exports.ElectrumOnchainProvider = ElectrumOnchainProvider;
816
- function toScriptHash(script) {
817
- return base_1.hex.encode((0, utils_js_1.sha256)(script).reverse());
818
- }
819
- function isHeaderSubscribeResult(v) {
820
- if (typeof v !== "object" || v === null)
821
- return false;
822
- const obj = v;
823
- return typeof obj.height === "number" && typeof obj.hex === "string";
824
- }
825
- /**
826
- * Recognise the "block header not yet indexable" failure shape returned by
827
- * electrum servers (electrs in particular) when `block.header(N)` runs
828
- * against a height that's already in `listunspent`/`get_merkle` but hasn't
829
- * been indexed yet. Surfaced as `missingheight`. Tolerated by callers so
830
- * the index-lag race doesn't poison confirmed-status reads; genuine
831
- * failures (auth/network) propagate.
832
- */
833
- function isMissingHeightError(err) {
834
- const msg = err instanceof Error ? err.message : typeof err === "string" ? err : "";
835
- return msg.toLowerCase().includes("missingheight");
836
- }
837
- /**
838
- * Recognise the "transaction not in a block yet" failure shape returned by
839
- * electrum servers when `blockchain.transaction.get_merkle` is asked about a
840
- * mempool tx. electrs surfaces this as the strings below; Fulcrum mirrors
841
- * the wording. We match conservatively so genuine errors (auth, network,
842
- * malformed response) still propagate.
843
- */
844
- function isTxNotInBlockError(err) {
845
- const msg = err instanceof Error ? err.message : typeof err === "string" ? err : "";
846
- const normalized = msg.toLowerCase();
847
- return (normalized.includes("not yet in a block") ||
848
- normalized.includes("not in a block") ||
849
- normalized.includes("not in block") ||
850
- normalized.includes("no confirmed transaction"));
851
- }
852
- /**
853
- * Compute the txid of a serialized transaction. For segwit transactions
854
- * (every Ark transaction), the broadcast hex includes witness data, but
855
- * the txid is the double-SHA256 of the legacy (witness-stripped)
856
- * serialization. Hashing the raw broadcast bytes directly would yield
857
- * the wtxid instead — silently breaking any caller that tracks the tx
858
- * by id (round settlement, forfeit monitoring, exit paths).
859
- *
860
- * Delegating to `Transaction.fromRaw(...).id` lets @scure/btc-signer
861
- * handle the witness-stripping correctly.
862
- */
863
- function childTxidFromHex(txHex) {
864
- const tx = btc_signer_1.Transaction.fromRaw(base_1.hex.decode(txHex), {
865
- allowUnknownOutputs: true,
866
- allowUnknownInputs: true,
867
- });
868
- return tx.id;
869
- }