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