@bigmi/core 0.8.1 → 0.9.1

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 (393) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/_virtual/_rolldown/runtime.js +1 -1
  4. package/dist/cjs/actions/getBalance.d.ts +5 -6
  5. package/dist/cjs/actions/getBlock.d.ts +3 -8
  6. package/dist/cjs/actions/getBlockCount.d.ts +2 -4
  7. package/dist/cjs/actions/getBlockStats.d.ts +3 -9
  8. package/dist/cjs/actions/getTransactionFee.d.ts +3 -7
  9. package/dist/cjs/actions/getTransactions.d.ts +3 -10
  10. package/dist/cjs/actions/getUTXOTransaction.d.ts +6 -9
  11. package/dist/cjs/actions/getUTXOs.d.ts +3 -8
  12. package/dist/cjs/actions/getXPubAddresses.d.ts +25 -26
  13. package/dist/cjs/actions/sendUTXOTransaction.d.ts +6 -9
  14. package/dist/cjs/actions/signPsbt.d.ts +1 -3
  15. package/dist/cjs/actions/waitForTransaction.d.ts +48 -55
  16. package/dist/cjs/actions/waitForTransaction.js.map +1 -1
  17. package/dist/cjs/actions/watchBlockNumber.d.ts +18 -21
  18. package/dist/cjs/actions/watchBlockNumber.js +3 -2
  19. package/dist/cjs/actions/watchBlockNumber.js.map +1 -1
  20. package/dist/cjs/chains/bitcoin.d.ts +1 -3
  21. package/dist/cjs/chains/bitcoin.js.map +1 -1
  22. package/dist/cjs/chains/defineChain.d.ts +1 -3
  23. package/dist/cjs/chains/signet.d.ts +1 -3
  24. package/dist/cjs/chains/signet.js.map +1 -1
  25. package/dist/cjs/clients/decorators/public.d.ts +2 -4
  26. package/dist/cjs/clients/decorators/wallet.d.ts +4 -6
  27. package/dist/cjs/errors/address.d.ts +3 -7
  28. package/dist/cjs/errors/base.d.ts +3 -4
  29. package/dist/cjs/errors/base.js.map +1 -1
  30. package/dist/cjs/errors/block.d.ts +3 -8
  31. package/dist/cjs/errors/provider.d.ts +1 -3
  32. package/dist/cjs/errors/request.d.ts +15 -39
  33. package/dist/cjs/errors/request.js.map +1 -1
  34. package/dist/cjs/errors/rpc.d.ts +28 -30
  35. package/dist/cjs/errors/transaction.d.ts +9 -21
  36. package/dist/cjs/errors/transport.d.ts +8 -17
  37. package/dist/cjs/errors/transport.js.map +1 -1
  38. package/dist/cjs/errors/utils.d.ts +3 -5
  39. package/dist/cjs/errors/utxo.d.ts +3 -9
  40. package/dist/cjs/factories/createClient.d.ts +55 -37
  41. package/dist/cjs/factories/createClient.js.map +1 -1
  42. package/dist/cjs/factories/createTransport.d.ts +3 -14
  43. package/dist/cjs/test/utils.d.ts +1 -2
  44. package/dist/cjs/transports/ankr/ankr.d.ts +1 -3
  45. package/dist/cjs/transports/ankr/ankr.types.d.ts +7 -8
  46. package/dist/cjs/transports/ankr/getBalance.d.ts +1 -3
  47. package/dist/cjs/transports/ankr/getTransactionFee.d.ts +1 -3
  48. package/dist/cjs/transports/ankr/getTransactions.d.ts +1 -3
  49. package/dist/cjs/transports/ankr/methods.d.ts +1 -3
  50. package/dist/cjs/transports/ankr/utils.d.ts +1 -3
  51. package/dist/cjs/transports/blockchair/blockchair.d.ts +1 -3
  52. package/dist/cjs/transports/blockchair/blockchair.types.d.ts +13 -14
  53. package/dist/cjs/transports/blockchair/getBalance.d.ts +1 -3
  54. package/dist/cjs/transports/blockchair/getTransactionFee.d.ts +1 -3
  55. package/dist/cjs/transports/blockchair/getTransactionFee.js.map +1 -1
  56. package/dist/cjs/transports/blockchair/getUTXOs.d.ts +1 -3
  57. package/dist/cjs/transports/blockchair/getUTXOs.js.map +1 -1
  58. package/dist/cjs/transports/blockchair/getXPubAddresses.d.ts +1 -3
  59. package/dist/cjs/transports/blockchair/getXPubAddresses.js.map +1 -1
  60. package/dist/cjs/transports/blockchair/methods.d.ts +1 -3
  61. package/dist/cjs/transports/blockcypher/blockcypher.d.ts +1 -3
  62. package/dist/cjs/transports/blockcypher/blockcypher.types.d.ts +8 -9
  63. package/dist/cjs/transports/blockcypher/getBalance.d.ts +1 -3
  64. package/dist/cjs/transports/blockcypher/getTransactionFee.d.ts +1 -3
  65. package/dist/cjs/transports/blockcypher/getUTXOs.d.ts +1 -3
  66. package/dist/cjs/transports/blockcypher/getUTXOs.js.map +1 -1
  67. package/dist/cjs/transports/blockcypher/methods.d.ts +1 -3
  68. package/dist/cjs/transports/blockcypher/utils.d.ts +1 -3
  69. package/dist/cjs/transports/blockcypher/utils.js.map +1 -1
  70. package/dist/cjs/transports/custom.d.ts +15 -12
  71. package/dist/cjs/transports/fallback.d.ts +38 -43
  72. package/dist/cjs/transports/fallback.js.map +1 -1
  73. package/dist/cjs/transports/getHttpRpcClient.d.ts +23 -16
  74. package/dist/cjs/transports/getHttpRpcClient.js.map +1 -1
  75. package/dist/cjs/transports/getRpcProviderMethods.d.ts +1 -3
  76. package/dist/cjs/transports/http.d.ts +35 -25
  77. package/dist/cjs/transports/mempool/getBalance.d.ts +1 -3
  78. package/dist/cjs/transports/mempool/getTransactionFee.d.ts +1 -3
  79. package/dist/cjs/transports/mempool/getTransactions.d.ts +1 -3
  80. package/dist/cjs/transports/mempool/getTransactions.js.map +1 -1
  81. package/dist/cjs/transports/mempool/mempool.d.ts +1 -3
  82. package/dist/cjs/transports/mempool/mempool.types.d.ts +7 -8
  83. package/dist/cjs/transports/mempool/methods.d.ts +1 -3
  84. package/dist/cjs/transports/mempool/utils.d.ts +1 -3
  85. package/dist/cjs/transports/types.d.ts +28 -27
  86. package/dist/cjs/transports/utxo.d.ts +1 -3
  87. package/dist/cjs/transports/utxo.js.map +1 -1
  88. package/dist/cjs/types/account.d.ts +1 -3
  89. package/dist/cjs/types/address.d.ts +4 -6
  90. package/dist/cjs/types/block.d.ts +18 -19
  91. package/dist/cjs/types/blockStats.d.ts +2 -3
  92. package/dist/cjs/types/chain.d.ts +26 -16
  93. package/dist/cjs/types/client.d.ts +43 -29
  94. package/dist/cjs/types/hash.d.ts +1 -2
  95. package/dist/cjs/types/request.d.ts +16 -13
  96. package/dist/cjs/types/rpc.d.ts +4 -5
  97. package/dist/cjs/types/transaction.d.ts +2 -3
  98. package/dist/cjs/types/transport.d.ts +18 -14
  99. package/dist/cjs/types/utils.d.ts +43 -44
  100. package/dist/cjs/types/xpub.d.ts +1 -3
  101. package/dist/cjs/utils/buildRequest.d.ts +3 -5
  102. package/dist/cjs/utils/buildRequest.js +2 -1
  103. package/dist/cjs/utils/buildRequest.js.map +1 -1
  104. package/dist/cjs/utils/cancelTransaction.d.ts +1 -3
  105. package/dist/cjs/utils/converter.d.ts +5 -6
  106. package/dist/cjs/utils/converter.js.map +1 -1
  107. package/dist/cjs/utils/createBatchScheduler.d.ts +2 -10
  108. package/dist/cjs/utils/createBatchScheduler.js.map +1 -1
  109. package/dist/cjs/utils/deepEqual.d.ts +1 -2
  110. package/dist/cjs/utils/deepEqual.js.map +1 -1
  111. package/dist/cjs/utils/getAction.d.ts +7 -9
  112. package/dist/cjs/utils/getAddressInfo.d.ts +2 -4
  113. package/dist/cjs/utils/getAddressInfo.js +2 -1
  114. package/dist/cjs/utils/getAddressInfo.js.map +1 -1
  115. package/dist/cjs/utils/idCache.d.ts +1 -2
  116. package/dist/cjs/utils/isAddress.d.ts +1 -3
  117. package/dist/cjs/utils/lru.d.ts +5 -6
  118. package/dist/cjs/utils/lru.js.map +1 -1
  119. package/dist/cjs/utils/modifyFee.d.ts +1 -3
  120. package/dist/cjs/utils/modifyFee.js.map +1 -1
  121. package/dist/cjs/utils/observe.d.ts +7 -9
  122. package/dist/cjs/utils/observe.js.map +1 -1
  123. package/dist/cjs/utils/parseAccount.d.ts +2 -4
  124. package/dist/cjs/utils/poll.d.ts +4 -11
  125. package/dist/cjs/utils/poll.js +2 -1
  126. package/dist/cjs/utils/poll.js.map +1 -1
  127. package/dist/cjs/utils/retryUntil.d.ts +18 -17
  128. package/dist/cjs/utils/retryUntil.js.map +1 -1
  129. package/dist/cjs/utils/sleep.d.ts +1 -2
  130. package/dist/cjs/utils/stringify.d.ts +2 -4
  131. package/dist/cjs/utils/uid.d.ts +1 -2
  132. package/dist/cjs/utils/uid.js.map +1 -1
  133. package/dist/cjs/utils/url.d.ts +1 -2
  134. package/dist/cjs/utils/url.js.map +1 -1
  135. package/dist/cjs/utils/wait.d.ts +1 -2
  136. package/dist/cjs/utils/withDedupe.d.ts +2 -7
  137. package/dist/cjs/utils/withDedupe.js.map +1 -1
  138. package/dist/cjs/utils/withResolvers.d.ts +2 -3
  139. package/dist/cjs/utils/withRetry.d.ts +4 -13
  140. package/dist/cjs/utils/withTimeout.d.ts +3 -11
  141. package/dist/cjs/utils/withTimeout.js.map +1 -1
  142. package/dist/cjs/version.d.ts +2 -3
  143. package/dist/cjs/version.js +1 -1
  144. package/dist/cjs/version.js.map +1 -1
  145. package/dist/cjs/vite-env.d.ts +1 -1
  146. package/dist/esm/actions/getBalance.d.ts +5 -6
  147. package/dist/esm/actions/getBalance.d.ts.map +1 -1
  148. package/dist/esm/actions/getBlock.d.ts +3 -8
  149. package/dist/esm/actions/getBlock.d.ts.map +1 -1
  150. package/dist/esm/actions/getBlockCount.d.ts +2 -4
  151. package/dist/esm/actions/getBlockCount.d.ts.map +1 -1
  152. package/dist/esm/actions/getBlockStats.d.ts +3 -9
  153. package/dist/esm/actions/getBlockStats.d.ts.map +1 -1
  154. package/dist/esm/actions/getTransactionFee.d.ts +3 -7
  155. package/dist/esm/actions/getTransactionFee.d.ts.map +1 -1
  156. package/dist/esm/actions/getTransactions.d.ts +3 -10
  157. package/dist/esm/actions/getTransactions.d.ts.map +1 -1
  158. package/dist/esm/actions/getUTXOTransaction.d.ts +6 -9
  159. package/dist/esm/actions/getUTXOTransaction.d.ts.map +1 -1
  160. package/dist/esm/actions/getUTXOs.d.ts +3 -8
  161. package/dist/esm/actions/getUTXOs.d.ts.map +1 -1
  162. package/dist/esm/actions/getXPubAddresses.d.ts +25 -26
  163. package/dist/esm/actions/getXPubAddresses.d.ts.map +1 -1
  164. package/dist/esm/actions/sendUTXOTransaction.d.ts +6 -9
  165. package/dist/esm/actions/sendUTXOTransaction.d.ts.map +1 -1
  166. package/dist/esm/actions/signPsbt.d.ts +1 -3
  167. package/dist/esm/actions/signPsbt.d.ts.map +1 -1
  168. package/dist/esm/actions/waitForTransaction.d.ts +48 -55
  169. package/dist/esm/actions/waitForTransaction.d.ts.map +1 -1
  170. package/dist/esm/actions/waitForTransaction.js.map +1 -1
  171. package/dist/esm/actions/watchBlockNumber.d.ts +18 -21
  172. package/dist/esm/actions/watchBlockNumber.d.ts.map +1 -1
  173. package/dist/esm/actions/watchBlockNumber.js +3 -2
  174. package/dist/esm/actions/watchBlockNumber.js.map +1 -1
  175. package/dist/esm/chains/bitcoin.d.ts +1 -3
  176. package/dist/esm/chains/bitcoin.d.ts.map +1 -1
  177. package/dist/esm/chains/defineChain.d.ts +1 -3
  178. package/dist/esm/chains/defineChain.d.ts.map +1 -1
  179. package/dist/esm/chains/signet.d.ts +1 -3
  180. package/dist/esm/chains/signet.d.ts.map +1 -1
  181. package/dist/esm/clients/decorators/public.d.ts +2 -4
  182. package/dist/esm/clients/decorators/public.d.ts.map +1 -1
  183. package/dist/esm/clients/decorators/wallet.d.ts +4 -6
  184. package/dist/esm/clients/decorators/wallet.d.ts.map +1 -1
  185. package/dist/esm/errors/address.d.ts +3 -7
  186. package/dist/esm/errors/address.d.ts.map +1 -1
  187. package/dist/esm/errors/base.d.ts +3 -4
  188. package/dist/esm/errors/base.d.ts.map +1 -1
  189. package/dist/esm/errors/base.js.map +1 -1
  190. package/dist/esm/errors/block.d.ts +3 -8
  191. package/dist/esm/errors/block.d.ts.map +1 -1
  192. package/dist/esm/errors/provider.d.ts +1 -3
  193. package/dist/esm/errors/provider.d.ts.map +1 -1
  194. package/dist/esm/errors/request.d.ts +15 -39
  195. package/dist/esm/errors/request.d.ts.map +1 -1
  196. package/dist/esm/errors/request.js.map +1 -1
  197. package/dist/esm/errors/rpc.d.ts +28 -30
  198. package/dist/esm/errors/rpc.d.ts.map +1 -1
  199. package/dist/esm/errors/transaction.d.ts +9 -21
  200. package/dist/esm/errors/transaction.d.ts.map +1 -1
  201. package/dist/esm/errors/transport.d.ts +8 -17
  202. package/dist/esm/errors/transport.d.ts.map +1 -1
  203. package/dist/esm/errors/transport.js.map +1 -1
  204. package/dist/esm/errors/utils.d.ts +3 -5
  205. package/dist/esm/errors/utils.d.ts.map +1 -1
  206. package/dist/esm/errors/utxo.d.ts +3 -9
  207. package/dist/esm/errors/utxo.d.ts.map +1 -1
  208. package/dist/esm/factories/createClient.d.ts +55 -37
  209. package/dist/esm/factories/createClient.d.ts.map +1 -1
  210. package/dist/esm/factories/createClient.js.map +1 -1
  211. package/dist/esm/factories/createTransport.d.ts +3 -14
  212. package/dist/esm/factories/createTransport.d.ts.map +1 -1
  213. package/dist/esm/test/utils.d.ts +1 -2
  214. package/dist/esm/test/utils.d.ts.map +1 -1
  215. package/dist/esm/transports/ankr/ankr.d.ts +1 -3
  216. package/dist/esm/transports/ankr/ankr.d.ts.map +1 -1
  217. package/dist/esm/transports/ankr/ankr.types.d.ts +7 -8
  218. package/dist/esm/transports/ankr/ankr.types.d.ts.map +1 -1
  219. package/dist/esm/transports/ankr/getBalance.d.ts +1 -3
  220. package/dist/esm/transports/ankr/getBalance.d.ts.map +1 -1
  221. package/dist/esm/transports/ankr/getTransactionFee.d.ts +1 -3
  222. package/dist/esm/transports/ankr/getTransactionFee.d.ts.map +1 -1
  223. package/dist/esm/transports/ankr/getTransactions.d.ts +1 -3
  224. package/dist/esm/transports/ankr/getTransactions.d.ts.map +1 -1
  225. package/dist/esm/transports/ankr/methods.d.ts +1 -3
  226. package/dist/esm/transports/ankr/methods.d.ts.map +1 -1
  227. package/dist/esm/transports/ankr/utils.d.ts +1 -3
  228. package/dist/esm/transports/ankr/utils.d.ts.map +1 -1
  229. package/dist/esm/transports/blockchair/blockchair.d.ts +1 -3
  230. package/dist/esm/transports/blockchair/blockchair.d.ts.map +1 -1
  231. package/dist/esm/transports/blockchair/blockchair.types.d.ts +13 -14
  232. package/dist/esm/transports/blockchair/blockchair.types.d.ts.map +1 -1
  233. package/dist/esm/transports/blockchair/getBalance.d.ts +1 -3
  234. package/dist/esm/transports/blockchair/getBalance.d.ts.map +1 -1
  235. package/dist/esm/transports/blockchair/getTransactionFee.d.ts +1 -3
  236. package/dist/esm/transports/blockchair/getTransactionFee.d.ts.map +1 -1
  237. package/dist/esm/transports/blockchair/getTransactionFee.js.map +1 -1
  238. package/dist/esm/transports/blockchair/getUTXOs.d.ts +1 -3
  239. package/dist/esm/transports/blockchair/getUTXOs.d.ts.map +1 -1
  240. package/dist/esm/transports/blockchair/getUTXOs.js.map +1 -1
  241. package/dist/esm/transports/blockchair/getXPubAddresses.d.ts +1 -3
  242. package/dist/esm/transports/blockchair/getXPubAddresses.d.ts.map +1 -1
  243. package/dist/esm/transports/blockchair/getXPubAddresses.js.map +1 -1
  244. package/dist/esm/transports/blockchair/methods.d.ts +1 -3
  245. package/dist/esm/transports/blockchair/methods.d.ts.map +1 -1
  246. package/dist/esm/transports/blockcypher/blockcypher.d.ts +1 -3
  247. package/dist/esm/transports/blockcypher/blockcypher.d.ts.map +1 -1
  248. package/dist/esm/transports/blockcypher/blockcypher.types.d.ts +8 -9
  249. package/dist/esm/transports/blockcypher/blockcypher.types.d.ts.map +1 -1
  250. package/dist/esm/transports/blockcypher/getBalance.d.ts +1 -3
  251. package/dist/esm/transports/blockcypher/getBalance.d.ts.map +1 -1
  252. package/dist/esm/transports/blockcypher/getTransactionFee.d.ts +1 -3
  253. package/dist/esm/transports/blockcypher/getTransactionFee.d.ts.map +1 -1
  254. package/dist/esm/transports/blockcypher/getUTXOs.d.ts +1 -3
  255. package/dist/esm/transports/blockcypher/getUTXOs.d.ts.map +1 -1
  256. package/dist/esm/transports/blockcypher/getUTXOs.js.map +1 -1
  257. package/dist/esm/transports/blockcypher/methods.d.ts +1 -3
  258. package/dist/esm/transports/blockcypher/methods.d.ts.map +1 -1
  259. package/dist/esm/transports/blockcypher/utils.d.ts +1 -3
  260. package/dist/esm/transports/blockcypher/utils.d.ts.map +1 -1
  261. package/dist/esm/transports/blockcypher/utils.js.map +1 -1
  262. package/dist/esm/transports/custom.d.ts +15 -12
  263. package/dist/esm/transports/custom.d.ts.map +1 -1
  264. package/dist/esm/transports/fallback.d.ts +38 -43
  265. package/dist/esm/transports/fallback.d.ts.map +1 -1
  266. package/dist/esm/transports/fallback.js.map +1 -1
  267. package/dist/esm/transports/getHttpRpcClient.d.ts +23 -16
  268. package/dist/esm/transports/getHttpRpcClient.d.ts.map +1 -1
  269. package/dist/esm/transports/getHttpRpcClient.js.map +1 -1
  270. package/dist/esm/transports/getRpcProviderMethods.d.ts +1 -3
  271. package/dist/esm/transports/getRpcProviderMethods.d.ts.map +1 -1
  272. package/dist/esm/transports/http.d.ts +35 -25
  273. package/dist/esm/transports/http.d.ts.map +1 -1
  274. package/dist/esm/transports/mempool/getBalance.d.ts +1 -3
  275. package/dist/esm/transports/mempool/getBalance.d.ts.map +1 -1
  276. package/dist/esm/transports/mempool/getTransactionFee.d.ts +1 -3
  277. package/dist/esm/transports/mempool/getTransactionFee.d.ts.map +1 -1
  278. package/dist/esm/transports/mempool/getTransactions.d.ts +1 -3
  279. package/dist/esm/transports/mempool/getTransactions.d.ts.map +1 -1
  280. package/dist/esm/transports/mempool/getTransactions.js.map +1 -1
  281. package/dist/esm/transports/mempool/mempool.d.ts +1 -3
  282. package/dist/esm/transports/mempool/mempool.d.ts.map +1 -1
  283. package/dist/esm/transports/mempool/mempool.types.d.ts +7 -8
  284. package/dist/esm/transports/mempool/mempool.types.d.ts.map +1 -1
  285. package/dist/esm/transports/mempool/methods.d.ts +1 -3
  286. package/dist/esm/transports/mempool/methods.d.ts.map +1 -1
  287. package/dist/esm/transports/mempool/utils.d.ts +1 -3
  288. package/dist/esm/transports/mempool/utils.d.ts.map +1 -1
  289. package/dist/esm/transports/types.d.ts +28 -27
  290. package/dist/esm/transports/types.d.ts.map +1 -1
  291. package/dist/esm/transports/utxo.d.ts +1 -3
  292. package/dist/esm/transports/utxo.d.ts.map +1 -1
  293. package/dist/esm/transports/utxo.js.map +1 -1
  294. package/dist/esm/types/account.d.ts +1 -3
  295. package/dist/esm/types/account.d.ts.map +1 -1
  296. package/dist/esm/types/address.d.ts +4 -6
  297. package/dist/esm/types/address.d.ts.map +1 -1
  298. package/dist/esm/types/block.d.ts +18 -19
  299. package/dist/esm/types/block.d.ts.map +1 -1
  300. package/dist/esm/types/blockStats.d.ts +2 -3
  301. package/dist/esm/types/blockStats.d.ts.map +1 -1
  302. package/dist/esm/types/chain.d.ts +26 -16
  303. package/dist/esm/types/chain.d.ts.map +1 -1
  304. package/dist/esm/types/client.d.ts +43 -29
  305. package/dist/esm/types/client.d.ts.map +1 -1
  306. package/dist/esm/types/hash.d.ts +1 -2
  307. package/dist/esm/types/hash.d.ts.map +1 -1
  308. package/dist/esm/types/request.d.ts +16 -13
  309. package/dist/esm/types/request.d.ts.map +1 -1
  310. package/dist/esm/types/rpc.d.ts +4 -5
  311. package/dist/esm/types/rpc.d.ts.map +1 -1
  312. package/dist/esm/types/transaction.d.ts +2 -3
  313. package/dist/esm/types/transaction.d.ts.map +1 -1
  314. package/dist/esm/types/transport.d.ts +18 -14
  315. package/dist/esm/types/transport.d.ts.map +1 -1
  316. package/dist/esm/types/utils.d.ts +43 -44
  317. package/dist/esm/types/utils.d.ts.map +1 -1
  318. package/dist/esm/types/xpub.d.ts +1 -3
  319. package/dist/esm/types/xpub.d.ts.map +1 -1
  320. package/dist/esm/utils/buildRequest.d.ts +3 -5
  321. package/dist/esm/utils/buildRequest.d.ts.map +1 -1
  322. package/dist/esm/utils/buildRequest.js +2 -1
  323. package/dist/esm/utils/buildRequest.js.map +1 -1
  324. package/dist/esm/utils/cancelTransaction.d.ts +1 -3
  325. package/dist/esm/utils/cancelTransaction.d.ts.map +1 -1
  326. package/dist/esm/utils/converter.d.ts +5 -6
  327. package/dist/esm/utils/converter.d.ts.map +1 -1
  328. package/dist/esm/utils/converter.js.map +1 -1
  329. package/dist/esm/utils/createBatchScheduler.d.ts +2 -10
  330. package/dist/esm/utils/createBatchScheduler.d.ts.map +1 -1
  331. package/dist/esm/utils/createBatchScheduler.js.map +1 -1
  332. package/dist/esm/utils/deepEqual.d.ts +1 -2
  333. package/dist/esm/utils/deepEqual.d.ts.map +1 -1
  334. package/dist/esm/utils/deepEqual.js.map +1 -1
  335. package/dist/esm/utils/getAction.d.ts +7 -9
  336. package/dist/esm/utils/getAction.d.ts.map +1 -1
  337. package/dist/esm/utils/getAddressInfo.d.ts +2 -4
  338. package/dist/esm/utils/getAddressInfo.d.ts.map +1 -1
  339. package/dist/esm/utils/getAddressInfo.js +2 -1
  340. package/dist/esm/utils/getAddressInfo.js.map +1 -1
  341. package/dist/esm/utils/idCache.d.ts +1 -2
  342. package/dist/esm/utils/idCache.d.ts.map +1 -1
  343. package/dist/esm/utils/isAddress.d.ts +1 -3
  344. package/dist/esm/utils/isAddress.d.ts.map +1 -1
  345. package/dist/esm/utils/lru.d.ts +5 -6
  346. package/dist/esm/utils/lru.d.ts.map +1 -1
  347. package/dist/esm/utils/lru.js.map +1 -1
  348. package/dist/esm/utils/modifyFee.d.ts +1 -3
  349. package/dist/esm/utils/modifyFee.d.ts.map +1 -1
  350. package/dist/esm/utils/modifyFee.js.map +1 -1
  351. package/dist/esm/utils/observe.d.ts +7 -9
  352. package/dist/esm/utils/observe.d.ts.map +1 -1
  353. package/dist/esm/utils/observe.js.map +1 -1
  354. package/dist/esm/utils/parseAccount.d.ts +2 -4
  355. package/dist/esm/utils/parseAccount.d.ts.map +1 -1
  356. package/dist/esm/utils/poll.d.ts +4 -11
  357. package/dist/esm/utils/poll.d.ts.map +1 -1
  358. package/dist/esm/utils/poll.js +2 -1
  359. package/dist/esm/utils/poll.js.map +1 -1
  360. package/dist/esm/utils/retryUntil.d.ts +18 -17
  361. package/dist/esm/utils/retryUntil.d.ts.map +1 -1
  362. package/dist/esm/utils/retryUntil.js.map +1 -1
  363. package/dist/esm/utils/sleep.d.ts +1 -2
  364. package/dist/esm/utils/sleep.d.ts.map +1 -1
  365. package/dist/esm/utils/stringify.d.ts +2 -4
  366. package/dist/esm/utils/stringify.d.ts.map +1 -1
  367. package/dist/esm/utils/uid.d.ts +1 -2
  368. package/dist/esm/utils/uid.d.ts.map +1 -1
  369. package/dist/esm/utils/uid.js.map +1 -1
  370. package/dist/esm/utils/url.d.ts +1 -2
  371. package/dist/esm/utils/url.d.ts.map +1 -1
  372. package/dist/esm/utils/url.js.map +1 -1
  373. package/dist/esm/utils/wait.d.ts +1 -2
  374. package/dist/esm/utils/wait.d.ts.map +1 -1
  375. package/dist/esm/utils/withDedupe.d.ts +2 -7
  376. package/dist/esm/utils/withDedupe.d.ts.map +1 -1
  377. package/dist/esm/utils/withDedupe.js.map +1 -1
  378. package/dist/esm/utils/withResolvers.d.ts +2 -3
  379. package/dist/esm/utils/withResolvers.d.ts.map +1 -1
  380. package/dist/esm/utils/withRetry.d.ts +4 -13
  381. package/dist/esm/utils/withRetry.d.ts.map +1 -1
  382. package/dist/esm/utils/withTimeout.d.ts +3 -11
  383. package/dist/esm/utils/withTimeout.d.ts.map +1 -1
  384. package/dist/esm/utils/withTimeout.js.map +1 -1
  385. package/dist/esm/version.d.ts +2 -3
  386. package/dist/esm/version.d.ts.map +1 -1
  387. package/dist/esm/version.js +1 -1
  388. package/dist/esm/version.js.map +1 -1
  389. package/dist/esm/vite-env.d.ts +1 -1
  390. package/package.json +3 -3
  391. package/src/factories/createClient.ts +1 -2
  392. package/src/types/client.ts +1 -2
  393. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @bigmi/core
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#75](https://github.com/lifinance/bigmi/pull/75) [`c9f3cd2`](https://github.com/lifinance/bigmi/commit/c9f3cd28fb5010277744c09857a4f4e1eaac6551) Thanks [@chybisov](https://github.com/chybisov)! - Bump runtime dependencies: `bitcoinjs-lib` 7.0.1 → 7.0.2 and `zustand` 5.0.14 → 5.0.15.
8
+
9
+ `@noble/hashes` stays on `^1.8.0` on purpose. `bitcoinjs-lib@7.0.2` and `bs58check@4.0.0`
10
+ both declare `@noble/hashes: ^1.2.0`, so moving `@bigmi/core` to v2 would put two copies of
11
+ the library in every consumer's tree. v2 is also ESM-only and drops the `./sha256`,
12
+ `./sha1` and `./ripemd160` subpaths that `bitcoinjs-lib` imports, so an `overrides` pin to
13
+ v2 would break it at runtime. Revisit once `bitcoinjs-lib` widens its range.
14
+
15
+ ## 0.9.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#62](https://github.com/lifinance/bigmi/pull/62) [`3569fc2`](https://github.com/lifinance/bigmi/commit/3569fc295a7877daf5b47989edecde85b2c38ea8) Thanks [@chybisov](https://github.com/chybisov)! - chore: migrate the toolchain to TypeScript 7
20
+
21
+ Bump the `typescript` devDependency from `6.x` to `7.x` (the native compiler) across the workspace, and bump `tsdown` `0.22.3` → `0.22.7` so its peer range accepts `typescript@^7`.
22
+
23
+ This is a build-time-only change with **no integration impact**: `typescript` is a devDependency (never a peer/runtime dependency), so consumers' own TypeScript version is untouched, and `.d.ts`/`.js` emit is handled by tsdown (Rolldown + OXC isolated declarations), not `tsc`. `tsc --noEmit` type-checks cleanly on TS 7 with zero source changes, and the public type surface is semantically identical (a rebuild only reformats declaration whitespace/comments via the newer `rolldown-plugin-dts` printer). Safe to ship as a minor.
24
+
3
25
  ## 0.8.1
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -110,12 +110,12 @@ Simple bigmi setup with a react app:
110
110
 
111
111
  import { bitcoin, http, createClient } from '@bigmi/core'
112
112
  import { BigmiProvider, createConfig } from '@bigmi/react'
113
- import { binance, xverse, phantom } from '@bigmi/client'
113
+ import { binance, xverse } from '@bigmi/client'
114
114
 
115
115
  // Create bigmi config object
116
116
  const config = createConfig({
117
117
  chains: [bitcoin],
118
- connectors: [binance(), xverse(), phantom()],
118
+ connectors: [binance(), xverse()],
119
119
  client: ({ chain }) => createClient({ chain, transport: http() }),
120
120
  ssr: true // If using Next.js or SSR
121
121
  })
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
19
  value: mod,
20
20
  enumerable: true
21
21
  }) : target, mod));
@@ -3,13 +3,12 @@ import { UTXOSchema } from "../transports/types.js";
3
3
  import { Account } from "../types/account.js";
4
4
  import { Transport } from "../types/transport.js";
5
5
  import { Client } from "../types/client.js";
6
-
7
6
  //#region src/actions/getBalance.d.ts
8
- type GetBalanceParameters = {
9
- /** The address of the account. */address: string;
7
+ export type GetBalanceParameters = {
8
+ /** The address of the account. */
9
+ address: string;
10
10
  };
11
- type GetBalanceReturnType = bigint;
12
- declare function getBalance<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, params: GetBalanceParameters): Promise<GetBalanceReturnType>;
11
+ export type GetBalanceReturnType = bigint;
12
+ export declare function getBalance<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, params: GetBalanceParameters): Promise<GetBalanceReturnType>;
13
13
  //#endregion
14
- export { GetBalanceParameters, GetBalanceReturnType, getBalance };
15
14
  //# sourceMappingURL=getBalance.d.ts.map
@@ -4,20 +4,15 @@ import { Account } from "../types/account.js";
4
4
  import { Transport } from "../types/transport.js";
5
5
  import { Client } from "../types/client.js";
6
6
  import { Block } from "bitcoinjs-lib";
7
-
8
7
  //#region src/actions/getBlock.d.ts
9
- type GetBlockParameters = {
8
+ export type GetBlockParameters = {
10
9
  blockHash: string;
11
10
  blockNumber?: never;
12
11
  } | {
13
12
  blockHash?: never;
14
13
  blockNumber: number;
15
14
  };
16
- type GetBlockReturnType = Block;
17
- declare function getBlock<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, {
18
- blockHash,
19
- blockNumber
20
- }: GetBlockParameters): Promise<GetBlockReturnType>;
15
+ export type GetBlockReturnType = Block;
16
+ export declare function getBlock<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, { blockHash, blockNumber }: GetBlockParameters): Promise<GetBlockReturnType>;
21
17
  //#endregion
22
- export { GetBlockParameters, GetBlockReturnType, getBlock };
23
18
  //# sourceMappingURL=getBlock.d.ts.map
@@ -3,10 +3,8 @@ import { UTXOSchema } from "../transports/types.js";
3
3
  import { Account } from "../types/account.js";
4
4
  import { Transport } from "../types/transport.js";
5
5
  import { Client } from "../types/client.js";
6
-
7
6
  //#region src/actions/getBlockCount.d.ts
8
- type GetBlockCountReturnType = number;
9
- declare function getBlockCount<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>): Promise<GetBlockCountReturnType>;
7
+ export type GetBlockCountReturnType = number;
8
+ export declare function getBlockCount<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>): Promise<GetBlockCountReturnType>;
10
9
  //#endregion
11
- export { GetBlockCountReturnType, getBlockCount };
12
10
  //# sourceMappingURL=getBlockCount.d.ts.map
@@ -4,9 +4,8 @@ import { UTXOSchema } from "../transports/types.js";
4
4
  import { Account } from "../types/account.js";
5
5
  import { Transport } from "../types/transport.js";
6
6
  import { Client } from "../types/client.js";
7
-
8
7
  //#region src/actions/getBlockStats.d.ts
9
- type GetBlockStatsParameters = ({
8
+ export type GetBlockStatsParameters = ({
10
9
  blockHash: string;
11
10
  blockNumber?: never;
12
11
  } | {
@@ -15,12 +14,7 @@ type GetBlockStatsParameters = ({
15
14
  }) & {
16
15
  stats?: Array<BlockStatsKeys>;
17
16
  };
18
- type GetBlockStatsReturnType = BlockStats;
19
- declare function getBlockStats<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, {
20
- blockHash,
21
- blockNumber,
22
- stats
23
- }: GetBlockStatsParameters): Promise<GetBlockStatsReturnType>;
17
+ export type GetBlockStatsReturnType = BlockStats;
18
+ export declare function getBlockStats<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, { blockHash, blockNumber, stats }: GetBlockStatsParameters): Promise<GetBlockStatsReturnType>;
24
19
  //#endregion
25
- export { GetBlockStatsParameters, GetBlockStatsReturnType, getBlockStats };
26
20
  //# sourceMappingURL=getBlockStats.d.ts.map
@@ -3,15 +3,11 @@ import { UTXOSchema } from "../transports/types.js";
3
3
  import { Account } from "../types/account.js";
4
4
  import { Transport } from "../types/transport.js";
5
5
  import { Client } from "../types/client.js";
6
-
7
6
  //#region src/actions/getTransactionFee.d.ts
8
- type GetTransactionFeeParameters = {
7
+ export type GetTransactionFeeParameters = {
9
8
  txId: string;
10
9
  };
11
- type GetTransactionFeeReturnType = bigint;
12
- declare function getTransactionFee<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, {
13
- txId
14
- }: GetTransactionFeeParameters): Promise<GetTransactionFeeReturnType>;
10
+ export type GetTransactionFeeReturnType = bigint;
11
+ export declare function getTransactionFee<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, { txId }: GetTransactionFeeParameters): Promise<GetTransactionFeeReturnType>;
15
12
  //#endregion
16
- export { GetTransactionFeeParameters, GetTransactionFeeReturnType, getTransactionFee };
17
13
  //# sourceMappingURL=getTransactionFee.d.ts.map
@@ -4,26 +4,19 @@ import { UTXOSchema } from "../transports/types.js";
4
4
  import { Account } from "../types/account.js";
5
5
  import { Transport } from "../types/transport.js";
6
6
  import { Client } from "../types/client.js";
7
-
8
7
  //#region src/actions/getTransactions.d.ts
9
- type GetTransactionsParameters = {
8
+ export type GetTransactionsParameters = {
10
9
  address: string;
11
10
  offset?: number;
12
11
  limit?: number;
13
12
  lastBlock?: string;
14
13
  afterTxId?: string;
15
14
  };
16
- type GetTransactionsReturnType = {
15
+ export type GetTransactionsReturnType = {
17
16
  transactions: Array<Partial<UTXOTransaction>>;
18
17
  total: number;
19
18
  hasMore?: boolean;
20
19
  };
21
- declare function getTransactions<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, {
22
- address,
23
- offset,
24
- limit,
25
- lastBlock
26
- }: GetTransactionsParameters): Promise<GetTransactionsReturnType>;
20
+ export declare function getTransactions<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, { address, offset, limit, lastBlock }: GetTransactionsParameters): Promise<GetTransactionsReturnType>;
27
21
  //#endregion
28
- export { GetTransactionsParameters, GetTransactionsReturnType, getTransactions };
29
22
  //# sourceMappingURL=getTransactions.d.ts.map
@@ -4,17 +4,14 @@ import { UTXOSchema } from "../transports/types.js";
4
4
  import { Account } from "../types/account.js";
5
5
  import { Transport } from "../types/transport.js";
6
6
  import { Client } from "../types/client.js";
7
-
8
7
  //#region src/actions/getUTXOTransaction.d.ts
9
- type GetUTXOTransactionParameters = {
10
- /** The Id of the transaction */txId: string; /** The block in which to look for the transaction */
8
+ export type GetUTXOTransactionParameters = {
9
+ /** The Id of the transaction */
10
+ txId: string;
11
+ /** The block in which to look for the transaction */
11
12
  blockHash?: string;
12
13
  };
13
- type GetUTXOTransactionReturnType = UTXOTransaction;
14
- declare function getUTXOTransaction<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, {
15
- txId,
16
- blockHash
17
- }: GetUTXOTransactionParameters): Promise<GetUTXOTransactionReturnType>;
14
+ export type GetUTXOTransactionReturnType = UTXOTransaction;
15
+ export declare function getUTXOTransaction<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, { txId, blockHash }: GetUTXOTransactionParameters): Promise<GetUTXOTransactionReturnType>;
18
16
  //#endregion
19
- export { GetUTXOTransactionParameters, GetUTXOTransactionReturnType, getUTXOTransaction };
20
17
  //# sourceMappingURL=getUTXOTransaction.d.ts.map
@@ -4,17 +4,12 @@ import { UTXOSchema } from "../transports/types.js";
4
4
  import { Account } from "../types/account.js";
5
5
  import { Transport } from "../types/transport.js";
6
6
  import { Client } from "../types/client.js";
7
-
8
7
  //#region src/actions/getUTXOs.d.ts
9
- type GetUTXOsParameters = {
8
+ export type GetUTXOsParameters = {
10
9
  address: string;
11
10
  minValue?: number;
12
11
  };
13
- type GetUTXOsReturnType = Array<UTXO>;
14
- declare function getUTXOs<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, {
15
- address,
16
- minValue
17
- }: GetUTXOsParameters): Promise<GetUTXOsReturnType>;
12
+ export type GetUTXOsReturnType = Array<UTXO>;
13
+ export declare function getUTXOs<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, { address, minValue }: GetUTXOsParameters): Promise<GetUTXOsReturnType>;
18
14
  //#endregion
19
- export { GetUTXOsParameters, GetUTXOsReturnType, getUTXOs };
20
15
  //# sourceMappingURL=getUTXOs.d.ts.map
@@ -4,34 +4,33 @@ import { UTXOSchema } from "../transports/types.js";
4
4
  import { Account } from "../types/account.js";
5
5
  import { Transport } from "../types/transport.js";
6
6
  import { Client } from "../types/client.js";
7
-
8
7
  //#region src/actions/getXPubAddresses.d.ts
9
- type GetXPubAddressesParameters = {
10
- /** The public key you're trying to get addresses of. */xPubKey: string;
8
+ export type GetXPubAddressesParameters = {
9
+ /** The public key you're trying to get addresses of. */
10
+ xPubKey: string;
11
11
  };
12
- type GetXPubAddressesReturnType = xPubAccount;
12
+ export type GetXPubAddressesReturnType = xPubAccount;
13
13
  /**
14
- * Retrieves all addresses and their balances associated with an extended public key (xPub).
15
- *
16
- * An extended public key (xPub) is a Bitcoin public key that can be used to derive multiple
17
- * child addresses. This action fetches all derived addresses along with their individual balances
18
- * and the total balance across all addresses.
19
- *
20
- * @param client - Client instance configured with UTXO transport
21
- * @param params - {@link GetXPubAddressesParameters}
22
- * @returns The xPub account data including total balance and all derived addresses. {@link GetXPubAddressesReturnType}
23
- *
24
- * @example
25
- * ```typescript
26
- * const result = await getXPubAddresses(client, {
27
- * xPubKey: 'xpub6CcGTthbwnbxsMRuEF3sb...'
28
- * })
29
- *
30
- * console.log(result.balance) // Total balance across all addresses
31
- * console.log(result.addresses) // Array of derived addresses with individual balances
32
- * ```
33
- */
34
- declare function getXPubAddresses<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, params: GetXPubAddressesParameters): Promise<GetXPubAddressesReturnType>;
14
+ * Retrieves all addresses and their balances associated with an extended public key (xPub).
15
+ *
16
+ * An extended public key (xPub) is a Bitcoin public key that can be used to derive multiple
17
+ * child addresses. This action fetches all derived addresses along with their individual balances
18
+ * and the total balance across all addresses.
19
+ *
20
+ * @param client - Client instance configured with UTXO transport
21
+ * @param params - {@link GetXPubAddressesParameters}
22
+ * @returns The xPub account data including total balance and all derived addresses. {@link GetXPubAddressesReturnType}
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const result = await getXPubAddresses(client, {
27
+ * xPubKey: 'xpub6CcGTthbwnbxsMRuEF3sb...'
28
+ * })
29
+ *
30
+ * console.log(result.balance) // Total balance across all addresses
31
+ * console.log(result.addresses) // Array of derived addresses with individual balances
32
+ * ```
33
+ */
34
+ export declare function getXPubAddresses<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, params: GetXPubAddressesParameters): Promise<GetXPubAddressesReturnType>;
35
35
  //#endregion
36
- export { GetXPubAddressesParameters, GetXPubAddressesReturnType, getXPubAddresses };
37
36
  //# sourceMappingURL=getXPubAddresses.d.ts.map
@@ -3,17 +3,14 @@ import { UTXOSchema } from "../transports/types.js";
3
3
  import { Account } from "../types/account.js";
4
4
  import { Transport } from "../types/transport.js";
5
5
  import { Client } from "../types/client.js";
6
-
7
6
  //#region src/actions/sendUTXOTransaction.d.ts
8
- type SendUTXOTransactionParameters = {
9
- /** The hex string of the raw transaction. */hex: string; /** Rejects transactions whose fee rate is higher than the specified value, expressed in BTC/kB. Set to 0 to accept any fee rate. Default = 0.10 */
7
+ export type SendUTXOTransactionParameters = {
8
+ /** The hex string of the raw transaction. */
9
+ hex: string;
10
+ /** Rejects transactions whose fee rate is higher than the specified value, expressed in BTC/kB. Set to 0 to accept any fee rate. Default = 0.10 */
10
11
  maxFeeRate?: number;
11
12
  };
12
- type SendUTXOTransactionReturnType = string;
13
- declare function sendUTXOTransaction<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, {
14
- hex,
15
- maxFeeRate
16
- }: SendUTXOTransactionParameters): Promise<SendUTXOTransactionReturnType>;
13
+ export type SendUTXOTransactionReturnType = string;
14
+ export declare function sendUTXOTransaction<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOSchema>, { hex, maxFeeRate }: SendUTXOTransactionParameters): Promise<SendUTXOTransactionReturnType>;
17
15
  //#endregion
18
- export { SendUTXOTransactionParameters, SendUTXOTransactionReturnType, sendUTXOTransaction };
19
16
  //# sourceMappingURL=sendUTXOTransaction.d.ts.map
@@ -3,9 +3,7 @@ import { SignPsbtParameters, SignPsbtReturnType, UTXOWalletSchema } from "../tra
3
3
  import { Account } from "../types/account.js";
4
4
  import { Transport } from "../types/transport.js";
5
5
  import { Client } from "../types/client.js";
6
-
7
6
  //#region src/actions/signPsbt.d.ts
8
- declare function signPsbt<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOWalletSchema>, params: SignPsbtParameters): Promise<SignPsbtReturnType>;
7
+ export declare function signPsbt<C extends Chain | undefined, A extends Account | undefined = Account | undefined>(client: Client<Transport, C, A, UTXOWalletSchema>, params: SignPsbtParameters): Promise<SignPsbtReturnType>;
9
8
  //#endregion
10
- export { signPsbt };
11
9
  //# sourceMappingURL=signPsbt.d.ts.map
@@ -3,85 +3,78 @@ import { Chain } from "../types/chain.js";
3
3
  import { Transport } from "../types/transport.js";
4
4
  import { Client } from "../types/client.js";
5
5
  import { Transaction } from "bitcoinjs-lib";
6
-
7
6
  //#region src/actions/waitForTransaction.d.ts
8
- type ReplacementReason = "cancelled" | "replaced" | "repriced";
9
- type ReplacementReturnType = {
7
+ export type ReplacementReason = "cancelled" | "replaced" | "repriced";
8
+ export type ReplacementReturnType = {
10
9
  reason: ReplacementReason;
11
10
  replacedTransaction: Transaction;
12
11
  transaction: UTXOTransaction;
13
12
  };
14
- type WaitForTransactionReceiptReturnType = UTXOTransaction;
15
- type WithRetryParameters = {
13
+ export type WaitForTransactionReceiptReturnType = UTXOTransaction;
14
+ export type WithRetryParameters = {
16
15
  delay?: ((config: {
17
16
  count: number;
18
17
  error: Error;
19
18
  }) => number) | number | undefined;
20
19
  retryCount?: number | undefined;
21
20
  };
22
- type WaitForTransactionReceiptParameters = {
23
- /** The Id of the transaction. */txId: string; /** The hex string of the raw transaction. */
24
- txHex: string; /** The sender address of the transaction. */
21
+ export type WaitForTransactionReceiptParameters = {
22
+ /** The Id of the transaction. */
23
+ txId: string;
24
+ /** The hex string of the raw transaction. */
25
+ txHex: string;
26
+ /** The sender address of the transaction. */
25
27
  senderAddress?: string;
26
28
  /**
27
- * The number of confirmations (blocks that have passed) to wait before resolving.
28
- * @default 1
29
- */
30
- confirmations?: number | undefined; /** Optional callback to emit if the transaction has been replaced. */
29
+ * The number of confirmations (blocks that have passed) to wait before resolving.
30
+ * @default 1
31
+ */
32
+ confirmations?: number | undefined;
33
+ /** Optional callback to emit if the transaction has been replaced. */
31
34
  onReplaced?: ((response: ReplacementReturnType) => void) | undefined;
32
35
  /**
33
- * Polling frequency (in ms). Defaults to the client's pollingInterval config.
34
- * @default client.pollingInterval
35
- */
36
+ * Polling frequency (in ms). Defaults to the client's pollingInterval config.
37
+ * @default client.pollingInterval
38
+ */
36
39
  pollingInterval?: number | undefined;
37
40
  /**
38
- * Number of times to retry if the transaction or block is not found.
39
- * @default 6 (exponential backoff)
40
- */
41
+ * Number of times to retry if the transaction or block is not found.
42
+ * @default 6 (exponential backoff)
43
+ */
41
44
  retryCount?: number;
42
45
  /**
43
- * Time to wait (in ms) between retries.
44
- */
46
+ * Time to wait (in ms) between retries.
47
+ */
45
48
  retryDelay?: ((config: {
46
49
  count: number;
47
50
  error: Error;
48
- }) => number) | number; /** Optional timeout (in milliseconds) to wait before stopping polling. */
51
+ }) => number) | number;
52
+ /** Optional timeout (in milliseconds) to wait before stopping polling. */
49
53
  timeout?: number | undefined;
50
54
  };
51
55
  /**
52
- * Waits for the transaction to be included on a block (one confirmation), and then returns the transaction.
53
- * - JSON-RPC Methods:
54
- * - Polls getrawtransaction on each block until it has been processed.
55
- * - If a transaction has been replaced:
56
- * - Calls getblock and extracts the transactions
57
- * - Checks if one of the transactions is a replacement
58
- * - If so, calls getrawtransaction.
59
- *
60
- * The `waitForTransaction` action additionally supports replacement detection (e.g. RBF - transactions replaced-by-fee ).
61
- *
62
- * Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel).
63
- * https://bitcoinops.org/en/topics/replace-by-fee/
64
- *
65
- * There are 3 types of Transaction Replacement reasons:
66
- *
67
- * - `repriced`: The fee has been modified (e.g. same outputs, different amounts)
68
- * - `cancelled`: The Transaction has been cancelled (e.g. output is sender address)
69
- * - `replaced`: The Transaction has been replaced (e.g. different outputs)
70
- * @param client - Client to use
71
- * @param parameters - {@link WaitForTransactionReceiptParameters}
72
- * @returns The UTXO transaction. {@link WaitForTransactionReceiptReturnType}
73
- */
74
- declare function waitForTransaction<chain extends Chain | undefined>(client: Client<Transport, chain>, {
75
- confirmations,
76
- txId,
77
- txHex,
78
- senderAddress,
79
- onReplaced,
80
- pollingInterval,
81
- retryCount,
82
- retryDelay,
83
- timeout
84
- }: WaitForTransactionReceiptParameters): Promise<WaitForTransactionReceiptReturnType>;
56
+ * Waits for the transaction to be included on a block (one confirmation), and then returns the transaction.
57
+ * - JSON-RPC Methods:
58
+ * - Polls getrawtransaction on each block until it has been processed.
59
+ * - If a transaction has been replaced:
60
+ * - Calls getblock and extracts the transactions
61
+ * - Checks if one of the transactions is a replacement
62
+ * - If so, calls getrawtransaction.
63
+ *
64
+ * The `waitForTransaction` action additionally supports replacement detection (e.g. RBF - transactions replaced-by-fee ).
65
+ *
66
+ * Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel).
67
+ * https://bitcoinops.org/en/topics/replace-by-fee/
68
+ *
69
+ * There are 3 types of Transaction Replacement reasons:
70
+ *
71
+ * - `repriced`: The fee has been modified (e.g. same outputs, different amounts)
72
+ * - `cancelled`: The Transaction has been cancelled (e.g. output is sender address)
73
+ * - `replaced`: The Transaction has been replaced (e.g. different outputs)
74
+ * @param client - Client to use
75
+ * @param parameters - {@link WaitForTransactionReceiptParameters}
76
+ * @returns The UTXO transaction. {@link WaitForTransactionReceiptReturnType}
77
+ */
78
+ export declare function waitForTransaction<chain extends Chain | undefined>(client: Client<Transport, chain>, { confirmations, txId, txHex, senderAddress, onReplaced, pollingInterval, retryCount, retryDelay, timeout }: WaitForTransactionReceiptParameters): Promise<WaitForTransactionReceiptReturnType>;
85
79
  //#endregion
86
- export { ReplacementReason, ReplacementReturnType, WaitForTransactionReceiptParameters, WaitForTransactionReceiptReturnType, WithRetryParameters, waitForTransaction };
87
80
  //# sourceMappingURL=waitForTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"waitForTransaction.js","names":["stringify","WaitForTransactionReceiptTimeoutError","observe","getAction","watchBlockNumber","getBlockStats","withRetry","getUTXOTransaction","TransactionReceiptNotFoundError","TransactionNotFoundError","Transaction","getBlock","address"],"sources":["../../../src/actions/waitForTransaction.ts"],"sourcesContent":["import { address, Transaction } from 'bitcoinjs-lib'\nimport {\n TransactionNotFoundError,\n TransactionReceiptNotFoundError,\n WaitForTransactionReceiptTimeoutError,\n} from '../errors/transaction.js'\nimport type { Chain } from '../types/chain.js'\nimport type { Client } from '../types/client.js'\nimport type { UTXOTransaction } from '../types/transaction.js'\nimport type { Transport } from '../types/transport.js'\nimport { getAction } from '../utils/getAction.js'\nimport { observe } from '../utils/observe.js'\nimport { stringify } from '../utils/stringify.js'\nimport { withRetry } from '../utils/withRetry.js'\nimport { getBlock } from './getBlock.js'\nimport { getBlockStats } from './getBlockStats.js'\nimport { getUTXOTransaction } from './getUTXOTransaction.js'\nimport { watchBlockNumber } from './watchBlockNumber.js'\n\nexport type ReplacementReason = 'cancelled' | 'replaced' | 'repriced'\nexport type ReplacementReturnType = {\n reason: ReplacementReason\n replacedTransaction: Transaction\n transaction: UTXOTransaction\n}\n\nexport type WaitForTransactionReceiptReturnType = UTXOTransaction\n\nexport type WithRetryParameters = {\n // The delay (in ms) between retries.\n delay?:\n | ((config: { count: number; error: Error }) => number)\n | number\n | undefined\n // The max number of times to retry.\n retryCount?: number | undefined\n}\n\nexport type WaitForTransactionReceiptParameters = {\n /** The Id of the transaction. */\n txId: string\n /** The hex string of the raw transaction. */\n txHex: string\n /** The sender address of the transaction. */\n senderAddress?: string\n /**\n * The number of confirmations (blocks that have passed) to wait before resolving.\n * @default 1\n */\n confirmations?: number | undefined\n /** Optional callback to emit if the transaction has been replaced. */\n onReplaced?: ((response: ReplacementReturnType) => void) | undefined\n /**\n * Polling frequency (in ms). Defaults to the client's pollingInterval config.\n * @default client.pollingInterval\n */\n pollingInterval?: number | undefined\n /**\n * Number of times to retry if the transaction or block is not found.\n * @default 6 (exponential backoff)\n */\n retryCount?: number\n /**\n * Time to wait (in ms) between retries.\n */\n retryDelay?: ((config: { count: number; error: Error }) => number) | number\n /** Optional timeout (in milliseconds) to wait before stopping polling. */\n timeout?: number | undefined\n}\n\n/**\n * Waits for the transaction to be included on a block (one confirmation), and then returns the transaction.\n * - JSON-RPC Methods:\n * - Polls getrawtransaction on each block until it has been processed.\n * - If a transaction has been replaced:\n * - Calls getblock and extracts the transactions\n * - Checks if one of the transactions is a replacement\n * - If so, calls getrawtransaction.\n *\n * The `waitForTransaction` action additionally supports replacement detection (e.g. RBF - transactions replaced-by-fee ).\n *\n * Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel).\n * https://bitcoinops.org/en/topics/replace-by-fee/\n *\n * There are 3 types of Transaction Replacement reasons:\n *\n * - `repriced`: The fee has been modified (e.g. same outputs, different amounts)\n * - `cancelled`: The Transaction has been cancelled (e.g. output is sender address)\n * - `replaced`: The Transaction has been replaced (e.g. different outputs)\n * @param client - Client to use\n * @param parameters - {@link WaitForTransactionReceiptParameters}\n * @returns The UTXO transaction. {@link WaitForTransactionReceiptReturnType}\n */\nexport async function waitForTransaction<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n confirmations = 1,\n txId,\n txHex,\n senderAddress,\n onReplaced,\n pollingInterval = client.pollingInterval,\n retryCount = 10,\n retryDelay = 3_000,\n timeout,\n }: WaitForTransactionReceiptParameters\n): Promise<WaitForTransactionReceiptReturnType> {\n const observerId = stringify(['waitForTransaction', client.uid, txId])\n\n let count = 0\n let transaction: UTXOTransaction | undefined\n let replacedTransaction: Transaction | undefined\n let retrying = false\n\n return new Promise((resolve, reject) => {\n if (timeout) {\n setTimeout(\n () =>\n reject(\n new WaitForTransactionReceiptTimeoutError({ hash: txId as never })\n ),\n timeout\n )\n }\n\n const _unobserve = observe(\n observerId,\n { onReplaced, resolve, reject },\n (emit) => {\n const _unwatch = getAction(\n client,\n watchBlockNumber,\n 'watchBlockNumber'\n )({\n emitMissed: true,\n emitOnBegin: true,\n pollingInterval,\n async onBlockNumber(blockNumber_) {\n const done = (fn: () => void) => {\n _unwatch()\n fn()\n _unobserve()\n }\n\n let blockNumber = blockNumber_\n\n if (retrying) {\n return\n }\n if (count > retryCount) {\n done(() =>\n emit.reject(\n new WaitForTransactionReceiptTimeoutError({\n hash: txId as never,\n })\n )\n )\n }\n\n try {\n // If we already have a valid receipt, let's check if we have enough\n // confirmations. If we do, then we can resolve.\n if (transaction?.blockhash) {\n const blockStats = await getAction(\n client,\n getBlockStats,\n 'getBlockStats'\n )({\n blockHash: transaction.blockhash,\n stats: ['height'],\n })\n if (\n confirmations > 1 &&\n (!blockStats.height ||\n blockNumber - blockStats.height + 1 < confirmations)\n ) {\n return\n }\n done(() => emit.resolve(transaction!))\n return\n }\n\n // Get the transaction to check if it's been replaced.\n // We need to retry as some RPC Providers may be slow to sync\n // up mined transactions.\n retrying = true\n transaction = await withRetry(\n () =>\n getAction(\n client,\n getUTXOTransaction,\n 'getUTXOTransaction'\n // If transaction exists it might be the replaced one with different txId\n )({ txId: transaction?.txid || txId }),\n {\n delay: retryDelay,\n retryCount,\n }\n )\n if (transaction.blockhash) {\n const blockStats = await getAction(\n client,\n getBlockStats,\n 'getBlockStats'\n )({\n blockHash: transaction.blockhash,\n stats: ['height'],\n })\n if (blockStats.height) {\n blockNumber = blockStats.height\n }\n }\n retrying = false\n\n // Check if transaction has been processed.\n if (!transaction?.confirmations) {\n throw new TransactionReceiptNotFoundError({\n hash: txId as never,\n })\n }\n\n // Check if we have enough confirmations. If not, continue polling.\n if (transaction.confirmations < confirmations) {\n return\n }\n\n done(() => emit.resolve(transaction!))\n } catch (err) {\n // If the receipt is not found, the transaction will be pending.\n // We need to check if it has potentially been replaced.\n if (\n err instanceof TransactionNotFoundError ||\n err instanceof TransactionReceiptNotFoundError\n ) {\n try {\n replacedTransaction = Transaction.fromHex(\n transaction?.hex || txHex\n )\n\n // Let's retrieve the transactions from the current block.\n // We need to retry as some RPC Providers may be slow to sync\n // up mined blocks.\n retrying = true\n const block = await withRetry(\n () =>\n getAction(\n client,\n getBlock,\n 'getBlock'\n )({\n blockNumber,\n }),\n {\n delay: retryDelay,\n retryCount,\n // shouldRetry: ({ error }) =>\n // error instanceof BlockNotFoundError,\n }\n )\n retrying = false\n\n // Create a set of input identifiers for mempool transaction\n const replacedTransactionInputs = new Set<string>()\n\n for (const input of replacedTransaction.ins) {\n const txid = Array.from(input.hash)\n .reverse()\n .map((byte) => `00${byte.toString(16)}`.slice(-2))\n .join('')\n const vout = input.index\n const inputId = `${txid}:${vout}`\n replacedTransactionInputs.add(inputId)\n }\n\n let replacementTransaction: Transaction | undefined\n\n for (const tx of block.transactions!) {\n if (tx.isCoinbase()) {\n continue\n }\n\n // Check if any input of this transaction matches an input of mempool transaction\n for (const input of tx.ins) {\n const txid = Array.from(input.hash)\n .reverse()\n .map((byte) => `00${byte.toString(16)}`.slice(-2))\n .join('')\n const vout = input.index\n const inputId = `${txid}:${vout}`\n if (replacedTransactionInputs.has(inputId)) {\n replacementTransaction = tx\n break\n }\n }\n if (replacementTransaction) {\n break\n }\n }\n\n // If we couldn't find a replacement transaction, continue polling.\n if (!replacementTransaction) {\n return\n }\n\n // If we found a replacement transaction, return it's receipt.\n transaction = await getAction(\n client,\n getUTXOTransaction,\n 'getUTXOTransaction'\n )({\n txId: replacementTransaction.getId(),\n })\n\n // Check if we have enough confirmations. If not, continue polling.\n if (\n transaction.confirmations &&\n transaction.confirmations < confirmations\n ) {\n return\n }\n\n let reason: ReplacementReason = 'replaced'\n\n // Function to get output addresses\n function getOutputAddresses(tx: Transaction): string[] {\n const addresses: string[] = []\n for (const output of tx.outs) {\n try {\n const outputAddress = address.fromOutputScript(\n output.script\n )\n addresses.push(outputAddress)\n } catch (_e) {\n // Handle non-standard scripts (e.g., OP_RETURN)\n }\n }\n return addresses\n }\n\n // Get the recipient addresses from the original transaction\n const originalOutputAddresses =\n getOutputAddresses(replacedTransaction)\n\n // Get the recipient addresses from the replacement transaction\n const replacementOutputAddresses = getOutputAddresses(\n replacementTransaction\n )\n\n if (\n originalOutputAddresses.length ===\n replacementOutputAddresses.length &&\n originalOutputAddresses.every((address) =>\n replacementOutputAddresses.includes(address)\n )\n ) {\n reason = 'repriced'\n } else if (\n senderAddress &&\n replacementOutputAddresses.length === 1 &&\n replacementOutputAddresses.includes(senderAddress)\n ) {\n reason = 'cancelled'\n }\n\n done(() => {\n emit.onReplaced?.({\n reason,\n replacedTransaction: replacedTransaction!,\n transaction: transaction!,\n })\n emit.resolve(transaction!)\n })\n } catch (err_) {\n done(() => emit.reject(err_))\n }\n } else {\n done(() => emit.reject(err))\n }\n } finally {\n count++\n }\n },\n })\n }\n )\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,eAAsB,mBACpB,QACA,EACE,gBAAgB,GAChB,MACA,OACA,eACA,YACA,kBAAkB,OAAO,iBACzB,aAAa,IACb,aAAa,KACb,WAE4C;CAC9C,MAAM,aAAaA,wBAAAA,UAAU;EAAC;EAAsB,OAAO;EAAK;CAAI,CAAC;CAErE,IAAI,QAAQ;CACZ,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CAEf,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI,SACF,iBAEI,OACE,IAAIC,2BAAAA,sCAAsC,EAAE,MAAM,KAAc,CAAC,CACnE,GACF,OACF;EAGF,MAAM,aAAaC,sBAAAA,QACjB,YACA;GAAE;GAAY;GAAS;EAAO,IAC7B,SAAS;GACR,MAAM,WAAWC,wBAAAA,UACf,QACAC,iCAAAA,kBACA,kBACF,EAAE;IACA,YAAY;IACZ,aAAa;IACb;IACA,MAAM,cAAc,cAAc;KAChC,MAAM,QAAQ,OAAmB;MAC/B,SAAS;MACT,GAAG;MACH,WAAW;KACb;KAEA,IAAI,cAAc;KAElB,IAAI,UACF;KAEF,IAAI,QAAQ,YACV,WACE,KAAK,OACH,IAAIH,2BAAAA,sCAAsC,EACxC,MAAM,KACR,CAAC,CACH,CACF;KAGF,IAAI;MAGF,IAAI,aAAa,WAAW;OAC1B,MAAM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O,IAAI,CAAC;MAC9B;WAEA,WAAW,KAAK,OAAO,GAAG,CAAC;KAE/B,UAAU;MACR;KACF;IACF;GACF,CAAC;EACH,CACF;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"waitForTransaction.js","names":["stringify","WaitForTransactionReceiptTimeoutError","observe","getAction","watchBlockNumber","getBlockStats","withRetry","getUTXOTransaction","TransactionReceiptNotFoundError","TransactionNotFoundError","Transaction","getBlock","address"],"sources":["../../../src/actions/waitForTransaction.ts"],"sourcesContent":["import { address, Transaction } from 'bitcoinjs-lib'\nimport {\n TransactionNotFoundError,\n TransactionReceiptNotFoundError,\n WaitForTransactionReceiptTimeoutError,\n} from '../errors/transaction.js'\nimport type { Chain } from '../types/chain.js'\nimport type { Client } from '../types/client.js'\nimport type { UTXOTransaction } from '../types/transaction.js'\nimport type { Transport } from '../types/transport.js'\nimport { getAction } from '../utils/getAction.js'\nimport { observe } from '../utils/observe.js'\nimport { stringify } from '../utils/stringify.js'\nimport { withRetry } from '../utils/withRetry.js'\nimport { getBlock } from './getBlock.js'\nimport { getBlockStats } from './getBlockStats.js'\nimport { getUTXOTransaction } from './getUTXOTransaction.js'\nimport { watchBlockNumber } from './watchBlockNumber.js'\n\nexport type ReplacementReason = 'cancelled' | 'replaced' | 'repriced'\nexport type ReplacementReturnType = {\n reason: ReplacementReason\n replacedTransaction: Transaction\n transaction: UTXOTransaction\n}\n\nexport type WaitForTransactionReceiptReturnType = UTXOTransaction\n\nexport type WithRetryParameters = {\n // The delay (in ms) between retries.\n delay?:\n | ((config: { count: number; error: Error }) => number)\n | number\n | undefined\n // The max number of times to retry.\n retryCount?: number | undefined\n}\n\nexport type WaitForTransactionReceiptParameters = {\n /** The Id of the transaction. */\n txId: string\n /** The hex string of the raw transaction. */\n txHex: string\n /** The sender address of the transaction. */\n senderAddress?: string\n /**\n * The number of confirmations (blocks that have passed) to wait before resolving.\n * @default 1\n */\n confirmations?: number | undefined\n /** Optional callback to emit if the transaction has been replaced. */\n onReplaced?: ((response: ReplacementReturnType) => void) | undefined\n /**\n * Polling frequency (in ms). Defaults to the client's pollingInterval config.\n * @default client.pollingInterval\n */\n pollingInterval?: number | undefined\n /**\n * Number of times to retry if the transaction or block is not found.\n * @default 6 (exponential backoff)\n */\n retryCount?: number\n /**\n * Time to wait (in ms) between retries.\n */\n retryDelay?: ((config: { count: number; error: Error }) => number) | number\n /** Optional timeout (in milliseconds) to wait before stopping polling. */\n timeout?: number | undefined\n}\n\n/**\n * Waits for the transaction to be included on a block (one confirmation), and then returns the transaction.\n * - JSON-RPC Methods:\n * - Polls getrawtransaction on each block until it has been processed.\n * - If a transaction has been replaced:\n * - Calls getblock and extracts the transactions\n * - Checks if one of the transactions is a replacement\n * - If so, calls getrawtransaction.\n *\n * The `waitForTransaction` action additionally supports replacement detection (e.g. RBF - transactions replaced-by-fee ).\n *\n * Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel).\n * https://bitcoinops.org/en/topics/replace-by-fee/\n *\n * There are 3 types of Transaction Replacement reasons:\n *\n * - `repriced`: The fee has been modified (e.g. same outputs, different amounts)\n * - `cancelled`: The Transaction has been cancelled (e.g. output is sender address)\n * - `replaced`: The Transaction has been replaced (e.g. different outputs)\n * @param client - Client to use\n * @param parameters - {@link WaitForTransactionReceiptParameters}\n * @returns The UTXO transaction. {@link WaitForTransactionReceiptReturnType}\n */\nexport async function waitForTransaction<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n confirmations = 1,\n txId,\n txHex,\n senderAddress,\n onReplaced,\n pollingInterval = client.pollingInterval,\n retryCount = 10,\n retryDelay = 3_000,\n timeout,\n }: WaitForTransactionReceiptParameters\n): Promise<WaitForTransactionReceiptReturnType> {\n const observerId = stringify(['waitForTransaction', client.uid, txId])\n\n let count = 0\n let transaction: UTXOTransaction | undefined\n let replacedTransaction: Transaction | undefined\n let retrying = false\n\n return new Promise((resolve, reject) => {\n if (timeout) {\n setTimeout(\n () =>\n reject(\n new WaitForTransactionReceiptTimeoutError({ hash: txId as never })\n ),\n timeout\n )\n }\n\n const _unobserve = observe(\n observerId,\n { onReplaced, resolve, reject },\n (emit) => {\n const _unwatch = getAction(\n client,\n watchBlockNumber,\n 'watchBlockNumber'\n )({\n emitMissed: true,\n emitOnBegin: true,\n pollingInterval,\n async onBlockNumber(blockNumber_) {\n const done = (fn: () => void) => {\n _unwatch()\n fn()\n _unobserve()\n }\n\n let blockNumber = blockNumber_\n\n if (retrying) {\n return\n }\n if (count > retryCount) {\n done(() =>\n emit.reject(\n new WaitForTransactionReceiptTimeoutError({\n hash: txId as never,\n })\n )\n )\n }\n\n try {\n // If we already have a valid receipt, let's check if we have enough\n // confirmations. If we do, then we can resolve.\n if (transaction?.blockhash) {\n const blockStats = await getAction(\n client,\n getBlockStats,\n 'getBlockStats'\n )({\n blockHash: transaction.blockhash,\n stats: ['height'],\n })\n if (\n confirmations > 1 &&\n (!blockStats.height ||\n blockNumber - blockStats.height + 1 < confirmations)\n ) {\n return\n }\n done(() => emit.resolve(transaction!))\n return\n }\n\n // Get the transaction to check if it's been replaced.\n // We need to retry as some RPC Providers may be slow to sync\n // up mined transactions.\n retrying = true\n transaction = await withRetry(\n () =>\n getAction(\n client,\n getUTXOTransaction,\n 'getUTXOTransaction'\n // If transaction exists it might be the replaced one with different txId\n )({ txId: transaction?.txid || txId }),\n {\n delay: retryDelay,\n retryCount,\n }\n )\n if (transaction.blockhash) {\n const blockStats = await getAction(\n client,\n getBlockStats,\n 'getBlockStats'\n )({\n blockHash: transaction.blockhash,\n stats: ['height'],\n })\n if (blockStats.height) {\n blockNumber = blockStats.height\n }\n }\n retrying = false\n\n // Check if transaction has been processed.\n if (!transaction?.confirmations) {\n throw new TransactionReceiptNotFoundError({\n hash: txId as never,\n })\n }\n\n // Check if we have enough confirmations. If not, continue polling.\n if (transaction.confirmations < confirmations) {\n return\n }\n\n done(() => emit.resolve(transaction!))\n } catch (err) {\n // If the receipt is not found, the transaction will be pending.\n // We need to check if it has potentially been replaced.\n if (\n err instanceof TransactionNotFoundError ||\n err instanceof TransactionReceiptNotFoundError\n ) {\n try {\n replacedTransaction = Transaction.fromHex(\n transaction?.hex || txHex\n )\n\n // Let's retrieve the transactions from the current block.\n // We need to retry as some RPC Providers may be slow to sync\n // up mined blocks.\n retrying = true\n const block = await withRetry(\n () =>\n getAction(\n client,\n getBlock,\n 'getBlock'\n )({\n blockNumber,\n }),\n {\n delay: retryDelay,\n retryCount,\n // shouldRetry: ({ error }) =>\n // error instanceof BlockNotFoundError,\n }\n )\n retrying = false\n\n // Create a set of input identifiers for mempool transaction\n const replacedTransactionInputs = new Set<string>()\n\n for (const input of replacedTransaction.ins) {\n const txid = Array.from(input.hash)\n .reverse()\n .map((byte) => `00${byte.toString(16)}`.slice(-2))\n .join('')\n const vout = input.index\n const inputId = `${txid}:${vout}`\n replacedTransactionInputs.add(inputId)\n }\n\n let replacementTransaction: Transaction | undefined\n\n for (const tx of block.transactions!) {\n if (tx.isCoinbase()) {\n continue\n }\n\n // Check if any input of this transaction matches an input of mempool transaction\n for (const input of tx.ins) {\n const txid = Array.from(input.hash)\n .reverse()\n .map((byte) => `00${byte.toString(16)}`.slice(-2))\n .join('')\n const vout = input.index\n const inputId = `${txid}:${vout}`\n if (replacedTransactionInputs.has(inputId)) {\n replacementTransaction = tx\n break\n }\n }\n if (replacementTransaction) {\n break\n }\n }\n\n // If we couldn't find a replacement transaction, continue polling.\n if (!replacementTransaction) {\n return\n }\n\n // If we found a replacement transaction, return it's receipt.\n transaction = await getAction(\n client,\n getUTXOTransaction,\n 'getUTXOTransaction'\n )({\n txId: replacementTransaction.getId(),\n })\n\n // Check if we have enough confirmations. If not, continue polling.\n if (\n transaction.confirmations &&\n transaction.confirmations < confirmations\n ) {\n return\n }\n\n let reason: ReplacementReason = 'replaced'\n\n // Function to get output addresses\n function getOutputAddresses(tx: Transaction): string[] {\n const addresses: string[] = []\n for (const output of tx.outs) {\n try {\n const outputAddress = address.fromOutputScript(\n output.script\n )\n addresses.push(outputAddress)\n } catch (_e) {\n // Handle non-standard scripts (e.g., OP_RETURN)\n }\n }\n return addresses\n }\n\n // Get the recipient addresses from the original transaction\n const originalOutputAddresses =\n getOutputAddresses(replacedTransaction)\n\n // Get the recipient addresses from the replacement transaction\n const replacementOutputAddresses = getOutputAddresses(\n replacementTransaction\n )\n\n if (\n originalOutputAddresses.length ===\n replacementOutputAddresses.length &&\n originalOutputAddresses.every((address) =>\n replacementOutputAddresses.includes(address)\n )\n ) {\n reason = 'repriced'\n } else if (\n senderAddress &&\n replacementOutputAddresses.length === 1 &&\n replacementOutputAddresses.includes(senderAddress)\n ) {\n reason = 'cancelled'\n }\n\n done(() => {\n emit.onReplaced?.({\n reason,\n replacedTransaction: replacedTransaction!,\n transaction: transaction!,\n })\n emit.resolve(transaction!)\n })\n } catch (err_) {\n done(() => emit.reject(err_))\n }\n } else {\n done(() => emit.reject(err))\n }\n } finally {\n count++\n }\n },\n })\n }\n )\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,eAAsB,mBACpB,QACA,EACE,gBAAgB,GAChB,MACA,OACA,eACA,YACA,kBAAkB,OAAO,iBACzB,aAAa,IACb,aAAa,KACb,WAE4C;CAC9C,MAAM,aAAaA,wBAAAA,UAAU;EAAC;EAAsB,OAAO;EAAK;CAAI,CAAC;CAErE,IAAI,QAAQ;CACZ,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CAEf,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI,SACF,iBAEI,OACE,IAAIC,2BAAAA,sCAAsC,EAAE,MAAM,KAAc,CAAC,CACnE,GACF,OACF;EAGF,MAAM,aAAaC,sBAAAA,QACjB,YACA;GAAE;GAAY;GAAS;EAAO,IAC7B,SAAS;GACR,MAAM,WAAWC,wBAAAA,UACf,QACAC,iCAAAA,kBACA,kBACF,CAAC,CAAC;IACA,YAAY;IACZ,aAAa;IACb;IACA,MAAM,cAAc,cAAc;KAChC,MAAM,QA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,wBAAwB,WACtB,2BAA2B,UAC7B,wBAAwB,OAAO,YAC7B,2BAA2B,SAAS,OAAO,CAC7C,GAEA,SAAS;YACJ,IACL,iBACA,2BAA2B,WAAW,KACtC,2BAA2B,SAAS,aAAa,GAEjD,SAAS;OAGX,WAAW;QACT,KAAK,aAAa;SAChB;SACqB;SACR;QACf,CAAC;QACD,KAAK,QAAQ,WAAY;OAC3B,CAAC;MACH,SAAS,MAAM;OACb,WAAW,KAAK,OAAO,IAAI,CAAC;MAC9B;WAEA,WAAW,KAAK,OAAO,GAAG,CAAC;KAE/B,UAAU;MACR;KACF;IACF;GACF,CAAC;EACH,CACF;CACF,CAAC;AACH"}
@@ -2,32 +2,29 @@ import { Chain } from "../types/chain.js";
2
2
  import { Transport } from "../types/transport.js";
3
3
  import { Client } from "../types/client.js";
4
4
  import { GetBlockCountReturnType } from "./getBlockCount.js";
5
-
6
5
  //#region src/actions/watchBlockNumber.d.ts
7
- type OnBlockNumberParameter = GetBlockCountReturnType;
8
- type OnBlockNumberFn = (blockNumber: OnBlockNumberParameter, prevBlockNumber: OnBlockNumberParameter | undefined) => Promise<void>;
9
- type WatchBlockNumberParameters = {
10
- /** The callback to call when a new block number is received. */onBlockNumber: OnBlockNumberFn; /** The callback to call when an error occurred when trying to get for a new block. */
6
+ export type OnBlockNumberParameter = GetBlockCountReturnType;
7
+ export type OnBlockNumberFn = (blockNumber: OnBlockNumberParameter, prevBlockNumber: OnBlockNumberParameter | undefined) => Promise<void>;
8
+ export type WatchBlockNumberParameters = {
9
+ /** The callback to call when a new block number is received. */
10
+ onBlockNumber: OnBlockNumberFn;
11
+ /** The callback to call when an error occurred when trying to get for a new block. */
11
12
  onError?: ((error: Error) => void) | undefined;
12
13
  } & {
13
- /** Whether or not to emit the missed block numbers to the callback. */emitMissed?: boolean | undefined; /** Whether or not to emit the latest block number to the callback when the subscription opens. */
14
- emitOnBegin?: boolean | undefined; /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
14
+ /** Whether or not to emit the missed block numbers to the callback. */
15
+ emitMissed?: boolean | undefined;
16
+ /** Whether or not to emit the latest block number to the callback when the subscription opens. */
17
+ emitOnBegin?: boolean | undefined;
18
+ /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
15
19
  pollingInterval?: number | undefined;
16
20
  };
17
- type WatchBlockNumberReturnType = () => void;
21
+ export type WatchBlockNumberReturnType = () => void;
18
22
  /**
19
- * Watches and returns incoming block numbers.
20
- * @param client - Client to use
21
- * @param parameters - {@link WatchBlockNumberParameters}
22
- * @returns A function that can be invoked to stop watching for new block numbers. {@link WatchBlockNumberReturnType}
23
- */
24
- declare function watchBlockNumber<chain extends Chain | undefined, transport extends Transport>(client: Client<transport, chain>, {
25
- emitOnBegin,
26
- emitMissed,
27
- onBlockNumber,
28
- onError,
29
- pollingInterval
30
- }: WatchBlockNumberParameters): WatchBlockNumberReturnType;
23
+ * Watches and returns incoming block numbers.
24
+ * @param client - Client to use
25
+ * @param parameters - {@link WatchBlockNumberParameters}
26
+ * @returns A function that can be invoked to stop watching for new block numbers. {@link WatchBlockNumberReturnType}
27
+ */
28
+ export declare function watchBlockNumber<chain extends Chain | undefined, transport extends Transport>(client: Client<transport, chain>, { emitOnBegin, emitMissed, onBlockNumber, onError, pollingInterval }: WatchBlockNumberParameters): WatchBlockNumberReturnType;
31
29
  //#endregion
32
- export { OnBlockNumberFn, OnBlockNumberParameter, WatchBlockNumberParameters, WatchBlockNumberReturnType, watchBlockNumber };
33
30
  //# sourceMappingURL=watchBlockNumber.d.ts.map