crypto-aio 0.0.3 → 0.1.0

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 (691) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +144 -14
  3. package/dist/adapters/avalanche/address.d.ts +15 -0
  4. package/dist/adapters/avalanche/address.js +74 -0
  5. package/dist/adapters/avalanche/address.js.map +1 -0
  6. package/dist/adapters/avalanche/api.d.ts +100 -0
  7. package/dist/adapters/avalanche/api.js +381 -0
  8. package/dist/adapters/avalanche/api.js.map +1 -0
  9. package/dist/adapters/avalanche/builder.d.ts +13 -0
  10. package/dist/adapters/avalanche/builder.js +336 -0
  11. package/dist/adapters/avalanche/builder.js.map +1 -0
  12. package/dist/adapters/avalanche/cb58.d.ts +7 -0
  13. package/dist/adapters/avalanche/cb58.js +49 -0
  14. package/dist/adapters/avalanche/cb58.js.map +1 -0
  15. package/dist/adapters/avalanche/chains.d.ts +21 -0
  16. package/dist/adapters/avalanche/chains.js +79 -0
  17. package/dist/adapters/avalanche/chains.js.map +1 -0
  18. package/dist/adapters/avalanche/codec.d.ts +94 -0
  19. package/dist/adapters/avalanche/codec.js +371 -0
  20. package/dist/adapters/avalanche/codec.js.map +1 -0
  21. package/dist/adapters/avalanche/context.d.ts +59 -0
  22. package/dist/adapters/avalanche/context.js +114 -0
  23. package/dist/adapters/avalanche/context.js.map +1 -0
  24. package/dist/adapters/avalanche/decode.d.ts +16 -0
  25. package/dist/adapters/avalanche/decode.js +101 -0
  26. package/dist/adapters/avalanche/decode.js.map +1 -0
  27. package/dist/adapters/avalanche/driver.d.ts +22 -0
  28. package/dist/adapters/avalanche/driver.js +81 -0
  29. package/dist/adapters/avalanche/driver.js.map +1 -0
  30. package/dist/adapters/avalanche/errors.d.ts +18 -0
  31. package/dist/adapters/avalanche/errors.js +61 -0
  32. package/dist/adapters/avalanche/errors.js.map +1 -0
  33. package/dist/adapters/avalanche/fees.d.ts +23 -0
  34. package/dist/adapters/avalanche/fees.js +105 -0
  35. package/dist/adapters/avalanche/fees.js.map +1 -0
  36. package/dist/adapters/avalanche/index.d.ts +19 -0
  37. package/dist/adapters/avalanche/index.js +8 -0
  38. package/dist/adapters/avalanche/index.js.map +1 -0
  39. package/dist/adapters/avalanche/network.d.ts +37 -0
  40. package/dist/adapters/avalanche/network.js +135 -0
  41. package/dist/adapters/avalanche/network.js.map +1 -0
  42. package/dist/adapters/avalanche/plugin.d.ts +21 -0
  43. package/dist/adapters/avalanche/plugin.js +46 -0
  44. package/dist/adapters/avalanche/plugin.js.map +1 -0
  45. package/dist/adapters/avalanche/presets.d.ts +6 -0
  46. package/dist/adapters/avalanche/presets.js +86 -0
  47. package/dist/adapters/avalanche/presets.js.map +1 -0
  48. package/dist/adapters/avalanche/proofs.d.ts +41 -0
  49. package/dist/adapters/avalanche/proofs.js +270 -0
  50. package/dist/adapters/avalanche/proofs.js.map +1 -0
  51. package/dist/adapters/avalanche/reader.d.ts +40 -0
  52. package/dist/adapters/avalanche/reader.js +231 -0
  53. package/dist/adapters/avalanche/reader.js.map +1 -0
  54. package/dist/adapters/avalanche/sdk.d.ts +182 -0
  55. package/dist/adapters/avalanche/sdk.js +21 -0
  56. package/dist/adapters/avalanche/sdk.js.map +1 -0
  57. package/dist/adapters/avalanche/types.d.ts +86 -0
  58. package/dist/{type/common.js → adapters/avalanche/types.js} +1 -1
  59. package/dist/adapters/avalanche/types.js.map +1 -0
  60. package/dist/adapters/evm/builder.d.ts +11 -0
  61. package/dist/adapters/evm/builder.js +326 -0
  62. package/dist/adapters/evm/builder.js.map +1 -0
  63. package/dist/adapters/evm/chains.d.ts +6 -0
  64. package/dist/adapters/evm/chains.js +203 -0
  65. package/dist/adapters/evm/chains.js.map +1 -0
  66. package/dist/adapters/evm/client.d.ts +84 -0
  67. package/dist/adapters/evm/client.js +335 -0
  68. package/dist/adapters/evm/client.js.map +1 -0
  69. package/dist/adapters/evm/decode.d.ts +35 -0
  70. package/dist/adapters/evm/decode.js +170 -0
  71. package/dist/adapters/evm/decode.js.map +1 -0
  72. package/dist/adapters/evm/driver.d.ts +8 -0
  73. package/dist/adapters/evm/driver.js +61 -0
  74. package/dist/adapters/evm/driver.js.map +1 -0
  75. package/dist/adapters/evm/errors.d.ts +20 -0
  76. package/dist/adapters/evm/errors.js +110 -0
  77. package/dist/adapters/evm/errors.js.map +1 -0
  78. package/dist/adapters/evm/ethers-client.d.ts +43 -0
  79. package/dist/adapters/evm/ethers-client.js +135 -0
  80. package/dist/adapters/evm/ethers-client.js.map +1 -0
  81. package/dist/adapters/evm/fees.d.ts +79 -0
  82. package/dist/adapters/evm/fees.js +234 -0
  83. package/dist/adapters/evm/fees.js.map +1 -0
  84. package/dist/adapters/evm/index.d.ts +20 -0
  85. package/dist/adapters/evm/index.js +11 -0
  86. package/dist/adapters/evm/index.js.map +1 -0
  87. package/dist/adapters/evm/network.d.ts +60 -0
  88. package/dist/adapters/evm/network.js +131 -0
  89. package/dist/adapters/evm/network.js.map +1 -0
  90. package/dist/adapters/evm/plugin.d.ts +36 -0
  91. package/dist/adapters/evm/plugin.js +102 -0
  92. package/dist/adapters/evm/plugin.js.map +1 -0
  93. package/dist/adapters/evm/presets.d.ts +2 -0
  94. package/dist/adapters/evm/presets.js +105 -0
  95. package/dist/adapters/evm/presets.js.map +1 -0
  96. package/dist/adapters/evm/proofs.d.ts +19 -0
  97. package/dist/adapters/evm/proofs.js +358 -0
  98. package/dist/adapters/evm/proofs.js.map +1 -0
  99. package/dist/adapters/evm/rawtx.d.ts +25 -0
  100. package/dist/adapters/evm/rawtx.js +176 -0
  101. package/dist/adapters/evm/rawtx.js.map +1 -0
  102. package/dist/adapters/evm/reader.d.ts +65 -0
  103. package/dist/adapters/evm/reader.js +292 -0
  104. package/dist/adapters/evm/reader.js.map +1 -0
  105. package/dist/adapters/evm/rpc.d.ts +39 -0
  106. package/dist/adapters/evm/rpc.js +152 -0
  107. package/dist/adapters/evm/rpc.js.map +1 -0
  108. package/dist/adapters/evm/tokens.d.ts +7 -0
  109. package/dist/adapters/evm/tokens.js +23 -0
  110. package/dist/adapters/evm/tokens.js.map +1 -0
  111. package/dist/adapters/evm/types.d.ts +255 -0
  112. package/dist/{type/account.js → adapters/evm/types.js} +1 -1
  113. package/dist/adapters/evm/types.js.map +1 -0
  114. package/dist/adapters/evm/web3-client.d.ts +23 -0
  115. package/dist/adapters/evm/web3-client.js +159 -0
  116. package/dist/adapters/evm/web3-client.js.map +1 -0
  117. package/dist/adapters/solana/builder.d.ts +18 -0
  118. package/dist/adapters/solana/builder.js +545 -0
  119. package/dist/adapters/solana/builder.js.map +1 -0
  120. package/dist/adapters/solana/chains.d.ts +13 -0
  121. package/dist/adapters/solana/chains.js +37 -0
  122. package/dist/adapters/solana/chains.js.map +1 -0
  123. package/dist/adapters/solana/decode.d.ts +111 -0
  124. package/dist/adapters/solana/decode.js +595 -0
  125. package/dist/adapters/solana/decode.js.map +1 -0
  126. package/dist/adapters/solana/driver.d.ts +15 -0
  127. package/dist/adapters/solana/driver.js +72 -0
  128. package/dist/adapters/solana/driver.js.map +1 -0
  129. package/dist/adapters/solana/errors.d.ts +36 -0
  130. package/dist/adapters/solana/errors.js +154 -0
  131. package/dist/adapters/solana/errors.js.map +1 -0
  132. package/dist/adapters/solana/fees.d.ts +68 -0
  133. package/dist/adapters/solana/fees.js +205 -0
  134. package/dist/adapters/solana/fees.js.map +1 -0
  135. package/dist/adapters/solana/heights.d.ts +47 -0
  136. package/dist/adapters/solana/heights.js +185 -0
  137. package/dist/adapters/solana/heights.js.map +1 -0
  138. package/dist/adapters/solana/history.d.ts +10 -0
  139. package/dist/adapters/solana/history.js +71 -0
  140. package/dist/adapters/solana/history.js.map +1 -0
  141. package/dist/adapters/solana/index.d.ts +16 -0
  142. package/dist/adapters/solana/index.js +9 -0
  143. package/dist/adapters/solana/index.js.map +1 -0
  144. package/dist/adapters/solana/keys.d.ts +13 -0
  145. package/dist/adapters/solana/keys.js +69 -0
  146. package/dist/adapters/solana/keys.js.map +1 -0
  147. package/dist/adapters/solana/network.d.ts +24 -0
  148. package/dist/adapters/solana/network.js +95 -0
  149. package/dist/adapters/solana/network.js.map +1 -0
  150. package/dist/adapters/solana/plugin.d.ts +18 -0
  151. package/dist/adapters/solana/plugin.js +41 -0
  152. package/dist/adapters/solana/plugin.js.map +1 -0
  153. package/dist/adapters/solana/presets.d.ts +2 -0
  154. package/dist/adapters/solana/presets.js +77 -0
  155. package/dist/adapters/solana/presets.js.map +1 -0
  156. package/dist/adapters/solana/programs.d.ts +44 -0
  157. package/dist/adapters/solana/programs.js +159 -0
  158. package/dist/adapters/solana/programs.js.map +1 -0
  159. package/dist/adapters/solana/proofs.d.ts +56 -0
  160. package/dist/adapters/solana/proofs.js +540 -0
  161. package/dist/adapters/solana/proofs.js.map +1 -0
  162. package/dist/adapters/solana/reader.d.ts +82 -0
  163. package/dist/adapters/solana/reader.js +326 -0
  164. package/dist/adapters/solana/reader.js.map +1 -0
  165. package/dist/adapters/solana/rpc.d.ts +102 -0
  166. package/dist/adapters/solana/rpc.js +301 -0
  167. package/dist/adapters/solana/rpc.js.map +1 -0
  168. package/dist/adapters/solana/tokens.d.ts +7 -0
  169. package/dist/adapters/solana/tokens.js +19 -0
  170. package/dist/adapters/solana/tokens.js.map +1 -0
  171. package/dist/adapters/solana/types.d.ts +121 -0
  172. package/dist/{type/contract.js → adapters/solana/types.js} +1 -1
  173. package/dist/adapters/solana/types.js.map +1 -0
  174. package/dist/adapters/solana/web3.d.ts +5 -0
  175. package/dist/adapters/solana/web3.js +83 -0
  176. package/dist/adapters/solana/web3.js.map +1 -0
  177. package/dist/adapters/solana/wire.d.ts +62 -0
  178. package/dist/adapters/solana/wire.js +168 -0
  179. package/dist/adapters/solana/wire.js.map +1 -0
  180. package/dist/adapters/ton/address.d.ts +43 -0
  181. package/dist/adapters/ton/address.js +168 -0
  182. package/dist/adapters/ton/address.js.map +1 -0
  183. package/dist/adapters/ton/api.d.ts +344 -0
  184. package/dist/adapters/ton/api.js +942 -0
  185. package/dist/adapters/ton/api.js.map +1 -0
  186. package/dist/adapters/ton/builder.d.ts +18 -0
  187. package/dist/adapters/ton/builder.js +701 -0
  188. package/dist/adapters/ton/builder.js.map +1 -0
  189. package/dist/adapters/ton/chains.d.ts +16 -0
  190. package/dist/adapters/ton/chains.js +39 -0
  191. package/dist/adapters/ton/chains.js.map +1 -0
  192. package/dist/adapters/ton/decode.d.ts +43 -0
  193. package/dist/adapters/ton/decode.js +219 -0
  194. package/dist/adapters/ton/decode.js.map +1 -0
  195. package/dist/adapters/ton/driver.d.ts +10 -0
  196. package/dist/adapters/ton/driver.js +117 -0
  197. package/dist/adapters/ton/driver.js.map +1 -0
  198. package/dist/adapters/ton/errors.d.ts +36 -0
  199. package/dist/adapters/ton/errors.js +89 -0
  200. package/dist/adapters/ton/errors.js.map +1 -0
  201. package/dist/adapters/ton/fees.d.ts +28 -0
  202. package/dist/adapters/ton/fees.js +121 -0
  203. package/dist/adapters/ton/fees.js.map +1 -0
  204. package/dist/adapters/ton/index.d.ts +16 -0
  205. package/dist/adapters/ton/index.js +9 -0
  206. package/dist/adapters/ton/index.js.map +1 -0
  207. package/dist/adapters/ton/messages.d.ts +157 -0
  208. package/dist/adapters/ton/messages.js +397 -0
  209. package/dist/adapters/ton/messages.js.map +1 -0
  210. package/dist/adapters/ton/native-client.d.ts +10 -0
  211. package/dist/adapters/ton/native-client.js +47 -0
  212. package/dist/adapters/ton/native-client.js.map +1 -0
  213. package/dist/adapters/ton/network.d.ts +58 -0
  214. package/dist/adapters/ton/network.js +207 -0
  215. package/dist/adapters/ton/network.js.map +1 -0
  216. package/dist/adapters/ton/plugin.d.ts +24 -0
  217. package/dist/adapters/ton/plugin.js +57 -0
  218. package/dist/adapters/ton/plugin.js.map +1 -0
  219. package/dist/adapters/ton/presets.d.ts +6 -0
  220. package/dist/adapters/ton/presets.js +94 -0
  221. package/dist/adapters/ton/presets.js.map +1 -0
  222. package/dist/adapters/ton/proofs.d.ts +66 -0
  223. package/dist/adapters/ton/proofs.js +813 -0
  224. package/dist/adapters/ton/proofs.js.map +1 -0
  225. package/dist/adapters/ton/reader.d.ts +194 -0
  226. package/dist/adapters/ton/reader.js +781 -0
  227. package/dist/adapters/ton/reader.js.map +1 -0
  228. package/dist/adapters/ton/tokens.d.ts +10 -0
  229. package/dist/adapters/ton/tokens.js +27 -0
  230. package/dist/adapters/ton/tokens.js.map +1 -0
  231. package/dist/adapters/ton/trace.d.ts +48 -0
  232. package/dist/adapters/ton/trace.js +277 -0
  233. package/dist/adapters/ton/trace.js.map +1 -0
  234. package/dist/adapters/ton/types.d.ts +105 -0
  235. package/dist/{type/transact.js → adapters/ton/types.js} +1 -1
  236. package/dist/adapters/ton/types.js.map +1 -0
  237. package/dist/adapters/ton/wallets.d.ts +86 -0
  238. package/dist/adapters/ton/wallets.js +373 -0
  239. package/dist/adapters/ton/wallets.js.map +1 -0
  240. package/dist/adapters/tron/abi.d.ts +39 -0
  241. package/dist/adapters/tron/abi.js +110 -0
  242. package/dist/adapters/tron/abi.js.map +1 -0
  243. package/dist/adapters/tron/address.d.ts +20 -0
  244. package/dist/adapters/tron/address.js +110 -0
  245. package/dist/adapters/tron/address.js.map +1 -0
  246. package/dist/adapters/tron/builder.d.ts +12 -0
  247. package/dist/adapters/tron/builder.js +553 -0
  248. package/dist/adapters/tron/builder.js.map +1 -0
  249. package/dist/adapters/tron/chains.d.ts +12 -0
  250. package/dist/adapters/tron/chains.js +35 -0
  251. package/dist/adapters/tron/chains.js.map +1 -0
  252. package/dist/adapters/tron/codec.d.ts +10 -0
  253. package/dist/adapters/tron/codec.js +322 -0
  254. package/dist/adapters/tron/codec.js.map +1 -0
  255. package/dist/adapters/tron/decode.d.ts +50 -0
  256. package/dist/adapters/tron/decode.js +280 -0
  257. package/dist/adapters/tron/decode.js.map +1 -0
  258. package/dist/adapters/tron/driver.d.ts +12 -0
  259. package/dist/adapters/tron/driver.js +106 -0
  260. package/dist/adapters/tron/driver.js.map +1 -0
  261. package/dist/adapters/tron/errors.d.ts +74 -0
  262. package/dist/adapters/tron/errors.js +261 -0
  263. package/dist/adapters/tron/errors.js.map +1 -0
  264. package/dist/adapters/tron/fees.d.ts +49 -0
  265. package/dist/adapters/tron/fees.js +166 -0
  266. package/dist/adapters/tron/fees.js.map +1 -0
  267. package/dist/adapters/tron/http.d.ts +173 -0
  268. package/dist/adapters/tron/http.js +729 -0
  269. package/dist/adapters/tron/http.js.map +1 -0
  270. package/dist/adapters/tron/index.d.ts +16 -0
  271. package/dist/adapters/tron/index.js +15 -0
  272. package/dist/adapters/tron/index.js.map +1 -0
  273. package/dist/adapters/tron/network.d.ts +44 -0
  274. package/dist/adapters/tron/network.js +163 -0
  275. package/dist/adapters/tron/network.js.map +1 -0
  276. package/dist/adapters/tron/plugin.d.ts +17 -0
  277. package/dist/adapters/tron/plugin.js +39 -0
  278. package/dist/adapters/tron/plugin.js.map +1 -0
  279. package/dist/adapters/tron/presets.d.ts +5 -0
  280. package/dist/adapters/tron/presets.js +68 -0
  281. package/dist/adapters/tron/presets.js.map +1 -0
  282. package/dist/adapters/tron/proofs.d.ts +80 -0
  283. package/dist/adapters/tron/proofs.js +370 -0
  284. package/dist/adapters/tron/proofs.js.map +1 -0
  285. package/dist/adapters/tron/protobuf.d.ts +36 -0
  286. package/dist/adapters/tron/protobuf.js +90 -0
  287. package/dist/adapters/tron/protobuf.js.map +1 -0
  288. package/dist/adapters/tron/reader.d.ts +47 -0
  289. package/dist/adapters/tron/reader.js +203 -0
  290. package/dist/adapters/tron/reader.js.map +1 -0
  291. package/dist/adapters/tron/tokens.d.ts +7 -0
  292. package/dist/adapters/tron/tokens.js +14 -0
  293. package/dist/adapters/tron/tokens.js.map +1 -0
  294. package/dist/adapters/tron/types.d.ts +166 -0
  295. package/dist/adapters/tron/types.js +3 -0
  296. package/dist/adapters/tron/types.js.map +1 -0
  297. package/dist/adapters/utxo/address.d.ts +51 -0
  298. package/dist/adapters/utxo/address.js +341 -0
  299. package/dist/adapters/utxo/address.js.map +1 -0
  300. package/dist/adapters/utxo/builder.d.ts +35 -0
  301. package/dist/adapters/utxo/builder.js +380 -0
  302. package/dist/adapters/utxo/builder.js.map +1 -0
  303. package/dist/adapters/utxo/chains.d.ts +17 -0
  304. package/dist/adapters/utxo/chains.js +99 -0
  305. package/dist/adapters/utxo/chains.js.map +1 -0
  306. package/dist/adapters/utxo/codec.d.ts +120 -0
  307. package/dist/adapters/utxo/codec.js +408 -0
  308. package/dist/adapters/utxo/codec.js.map +1 -0
  309. package/dist/adapters/utxo/coinselect.d.ts +48 -0
  310. package/dist/adapters/utxo/coinselect.js +131 -0
  311. package/dist/adapters/utxo/coinselect.js.map +1 -0
  312. package/dist/adapters/utxo/context.d.ts +57 -0
  313. package/dist/adapters/utxo/context.js +118 -0
  314. package/dist/adapters/utxo/context.js.map +1 -0
  315. package/dist/adapters/utxo/decode.d.ts +14 -0
  316. package/dist/adapters/utxo/decode.js +85 -0
  317. package/dist/adapters/utxo/decode.js.map +1 -0
  318. package/dist/adapters/utxo/driver.d.ts +16 -0
  319. package/dist/adapters/utxo/driver.js +74 -0
  320. package/dist/adapters/utxo/driver.js.map +1 -0
  321. package/dist/adapters/utxo/ecc.d.ts +9 -0
  322. package/dist/adapters/utxo/ecc.js +26 -0
  323. package/dist/adapters/utxo/ecc.js.map +1 -0
  324. package/dist/adapters/utxo/errors.d.ts +52 -0
  325. package/dist/adapters/utxo/errors.js +191 -0
  326. package/dist/adapters/utxo/errors.js.map +1 -0
  327. package/dist/adapters/utxo/esplora.d.ts +79 -0
  328. package/dist/adapters/utxo/esplora.js +451 -0
  329. package/dist/adapters/utxo/esplora.js.map +1 -0
  330. package/dist/adapters/utxo/fees.d.ts +41 -0
  331. package/dist/adapters/utxo/fees.js +125 -0
  332. package/dist/adapters/utxo/fees.js.map +1 -0
  333. package/dist/adapters/utxo/index.d.ts +17 -0
  334. package/dist/adapters/utxo/index.js +8 -0
  335. package/dist/adapters/utxo/index.js.map +1 -0
  336. package/dist/adapters/utxo/network.d.ts +50 -0
  337. package/dist/adapters/utxo/network.js +165 -0
  338. package/dist/adapters/utxo/network.js.map +1 -0
  339. package/dist/adapters/utxo/plugin.d.ts +17 -0
  340. package/dist/adapters/utxo/plugin.js +41 -0
  341. package/dist/adapters/utxo/plugin.js.map +1 -0
  342. package/dist/adapters/utxo/presets.d.ts +12 -0
  343. package/dist/adapters/utxo/presets.js +47 -0
  344. package/dist/adapters/utxo/presets.js.map +1 -0
  345. package/dist/adapters/utxo/preview.d.ts +3 -0
  346. package/dist/adapters/utxo/preview.js +65 -0
  347. package/dist/adapters/utxo/preview.js.map +1 -0
  348. package/dist/adapters/utxo/proofs.d.ts +57 -0
  349. package/dist/adapters/utxo/proofs.js +331 -0
  350. package/dist/adapters/utxo/proofs.js.map +1 -0
  351. package/dist/adapters/utxo/rawtx.d.ts +59 -0
  352. package/dist/adapters/utxo/rawtx.js +234 -0
  353. package/dist/adapters/utxo/rawtx.js.map +1 -0
  354. package/dist/adapters/utxo/reader.d.ts +36 -0
  355. package/dist/adapters/utxo/reader.js +265 -0
  356. package/dist/adapters/utxo/reader.js.map +1 -0
  357. package/dist/adapters/utxo/sdk.d.ts +18 -0
  358. package/dist/adapters/utxo/sdk.js +17 -0
  359. package/dist/adapters/utxo/sdk.js.map +1 -0
  360. package/dist/adapters/utxo/signed-psbt.d.ts +36 -0
  361. package/dist/adapters/utxo/signed-psbt.js +428 -0
  362. package/dist/adapters/utxo/signed-psbt.js.map +1 -0
  363. package/dist/adapters/utxo/spend.d.ts +59 -0
  364. package/dist/adapters/utxo/spend.js +230 -0
  365. package/dist/adapters/utxo/spend.js.map +1 -0
  366. package/dist/adapters/utxo/types.d.ts +167 -0
  367. package/dist/adapters/utxo/types.js +3 -0
  368. package/dist/adapters/utxo/types.js.map +1 -0
  369. package/dist/core/assets/service.d.ts +18 -0
  370. package/dist/core/assets/service.js +69 -0
  371. package/dist/core/assets/service.js.map +1 -0
  372. package/dist/core/blockchain/default-ref.d.ts +4 -0
  373. package/dist/core/blockchain/default-ref.js +16 -0
  374. package/dist/core/blockchain/default-ref.js.map +1 -0
  375. package/dist/core/blockchain/handle.d.ts +200 -0
  376. package/dist/core/blockchain/handle.js +579 -0
  377. package/dist/core/blockchain/handle.js.map +1 -0
  378. package/dist/core/blockchain/internal.d.ts +19 -0
  379. package/dist/core/blockchain/internal.js +16 -0
  380. package/dist/core/blockchain/internal.js.map +1 -0
  381. package/dist/core/blockchain/mapping.d.ts +22 -0
  382. package/dist/core/blockchain/mapping.js +136 -0
  383. package/dist/core/blockchain/mapping.js.map +1 -0
  384. package/dist/core/config/env.d.ts +8 -0
  385. package/dist/core/config/env.js +60 -0
  386. package/dist/core/config/env.js.map +1 -0
  387. package/dist/core/config/merge.d.ts +26 -0
  388. package/dist/core/config/merge.js +144 -0
  389. package/dist/core/config/merge.js.map +1 -0
  390. package/dist/core/config/resolve.d.ts +12 -0
  391. package/dist/core/config/resolve.js +251 -0
  392. package/dist/core/config/resolve.js.map +1 -0
  393. package/dist/core/config/types.d.ts +165 -0
  394. package/dist/core/config/types.js +3 -0
  395. package/dist/core/config/types.js.map +1 -0
  396. package/dist/core/container/builtins.d.ts +4 -0
  397. package/dist/core/container/builtins.js +13 -0
  398. package/dist/core/container/builtins.js.map +1 -0
  399. package/dist/core/container/container.d.ts +69 -0
  400. package/dist/core/container/container.js +466 -0
  401. package/dist/core/container/container.js.map +1 -0
  402. package/dist/core/container/default.d.ts +15 -0
  403. package/dist/core/container/default.js +70 -0
  404. package/dist/core/container/default.js.map +1 -0
  405. package/dist/core/container/internals.d.ts +54 -0
  406. package/dist/core/container/internals.js +21 -0
  407. package/dist/core/container/internals.js.map +1 -0
  408. package/dist/core/container/pool.d.ts +27 -0
  409. package/dist/core/container/pool.js +77 -0
  410. package/dist/core/container/pool.js.map +1 -0
  411. package/dist/core/driver/types.d.ts +346 -0
  412. package/dist/core/driver/types.js +3 -0
  413. package/dist/core/driver/types.js.map +1 -0
  414. package/dist/core/errors/codes.d.ts +153 -0
  415. package/dist/core/errors/codes.js +49 -0
  416. package/dist/core/errors/codes.js.map +1 -0
  417. package/dist/core/errors/error.d.ts +66 -0
  418. package/dist/core/errors/error.js +129 -0
  419. package/dist/core/errors/error.js.map +1 -0
  420. package/dist/core/events/bus.d.ts +12 -0
  421. package/dist/core/events/bus.js +46 -0
  422. package/dist/core/events/bus.js.map +1 -0
  423. package/dist/core/events/logger.d.ts +13 -0
  424. package/dist/core/events/logger.js +42 -0
  425. package/dist/core/events/logger.js.map +1 -0
  426. package/dist/core/events/types.d.ts +131 -0
  427. package/dist/core/events/types.js +3 -0
  428. package/dist/core/events/types.js.map +1 -0
  429. package/dist/core/lifecycle/engine-rules.d.ts +107 -0
  430. package/dist/core/lifecycle/engine-rules.js +257 -0
  431. package/dist/core/lifecycle/engine-rules.js.map +1 -0
  432. package/dist/core/lifecycle/engine.d.ts +500 -0
  433. package/dist/core/lifecycle/engine.js +1732 -0
  434. package/dist/core/lifecycle/engine.js.map +1 -0
  435. package/dist/core/lifecycle/evaluate.d.ts +19 -0
  436. package/dist/core/lifecycle/evaluate.js +72 -0
  437. package/dist/core/lifecycle/evaluate.js.map +1 -0
  438. package/dist/core/lifecycle/intent.d.ts +11 -0
  439. package/dist/core/lifecycle/intent.js +88 -0
  440. package/dist/core/lifecycle/intent.js.map +1 -0
  441. package/dist/core/lifecycle/monitor.d.ts +138 -0
  442. package/dist/core/lifecycle/monitor.js +606 -0
  443. package/dist/core/lifecycle/monitor.js.map +1 -0
  444. package/dist/core/lifecycle/observations.d.ts +17 -0
  445. package/dist/core/lifecycle/observations.js +59 -0
  446. package/dist/core/lifecycle/observations.js.map +1 -0
  447. package/dist/core/lifecycle/reconcile.d.ts +58 -0
  448. package/dist/core/lifecycle/reconcile.js +112 -0
  449. package/dist/core/lifecycle/reconcile.js.map +1 -0
  450. package/dist/core/lifecycle/views.d.ts +49 -0
  451. package/dist/core/lifecycle/views.js +57 -0
  452. package/dist/core/lifecycle/views.js.map +1 -0
  453. package/dist/core/lifecycle/workers.d.ts +82 -0
  454. package/dist/core/lifecycle/workers.js +329 -0
  455. package/dist/core/lifecycle/workers.js.map +1 -0
  456. package/dist/core/model/address.d.ts +32 -0
  457. package/dist/core/model/address.js +43 -0
  458. package/dist/core/model/address.js.map +1 -0
  459. package/dist/core/model/amount.d.ts +25 -0
  460. package/dist/core/model/amount.js +102 -0
  461. package/dist/core/model/amount.js.map +1 -0
  462. package/dist/core/model/asset.d.ts +28 -0
  463. package/dist/core/model/asset.js +47 -0
  464. package/dist/core/model/asset.js.map +1 -0
  465. package/dist/core/model/capability.d.ts +3 -0
  466. package/dist/core/model/capability.js +18 -0
  467. package/dist/core/model/capability.js.map +1 -0
  468. package/dist/core/model/chain.d.ts +63 -0
  469. package/dist/core/model/chain.js +8 -0
  470. package/dist/core/model/chain.js.map +1 -0
  471. package/dist/core/model/fee.d.ts +36 -0
  472. package/dist/core/model/fee.js +17 -0
  473. package/dist/core/model/fee.js.map +1 -0
  474. package/dist/core/model/ids.d.ts +37 -0
  475. package/dist/core/model/ids.js +13 -0
  476. package/dist/core/model/ids.js.map +1 -0
  477. package/dist/core/model/intent.d.ts +63 -0
  478. package/dist/core/model/intent.js +81 -0
  479. package/dist/core/model/intent.js.map +1 -0
  480. package/dist/core/model/ordering.d.ts +20 -0
  481. package/dist/core/model/ordering.js +29 -0
  482. package/dist/core/model/ordering.js.map +1 -0
  483. package/dist/core/model/transaction.d.ts +116 -0
  484. package/dist/{type/lib-types.js → core/model/transaction.js} +1 -1
  485. package/dist/core/model/transaction.js.map +1 -0
  486. package/dist/core/observe/scanner.d.ts +135 -0
  487. package/dist/core/observe/scanner.js +355 -0
  488. package/dist/core/observe/scanner.js.map +1 -0
  489. package/dist/core/ordering/reservations.d.ts +16 -0
  490. package/dist/core/ordering/reservations.js +53 -0
  491. package/dist/core/ordering/reservations.js.map +1 -0
  492. package/dist/core/ordering/sequence.d.ts +61 -0
  493. package/dist/core/ordering/sequence.js +155 -0
  494. package/dist/core/ordering/sequence.js.map +1 -0
  495. package/dist/core/registry/adapters.d.ts +10 -0
  496. package/dist/core/registry/adapters.js +56 -0
  497. package/dist/core/registry/adapters.js.map +1 -0
  498. package/dist/core/registry/assets.d.ts +18 -0
  499. package/dist/core/registry/assets.js +90 -0
  500. package/dist/core/registry/assets.js.map +1 -0
  501. package/dist/core/registry/chains.d.ts +10 -0
  502. package/dist/core/registry/chains.js +80 -0
  503. package/dist/core/registry/chains.js.map +1 -0
  504. package/dist/core/registry/plugin.d.ts +41 -0
  505. package/dist/core/registry/plugin.js +109 -0
  506. package/dist/core/registry/plugin.js.map +1 -0
  507. package/dist/core/registry/providers.d.ts +31 -0
  508. package/dist/core/registry/providers.js +43 -0
  509. package/dist/core/registry/providers.js.map +1 -0
  510. package/dist/core/registry/schemes.d.ts +30 -0
  511. package/dist/core/registry/schemes.js +84 -0
  512. package/dist/core/registry/schemes.js.map +1 -0
  513. package/dist/core/secret/fragments.d.ts +33 -0
  514. package/dist/core/secret/fragments.js +110 -0
  515. package/dist/core/secret/fragments.js.map +1 -0
  516. package/dist/core/secret/redact.d.ts +10 -0
  517. package/dist/core/secret/redact.js +110 -0
  518. package/dist/core/secret/redact.js.map +1 -0
  519. package/dist/core/secret/secret.d.ts +14 -0
  520. package/dist/core/secret/secret.js +42 -0
  521. package/dist/core/secret/secret.js.map +1 -0
  522. package/dist/core/signing/callback.d.ts +10 -0
  523. package/dist/core/signing/callback.js +22 -0
  524. package/dist/core/signing/callback.js.map +1 -0
  525. package/dist/core/signing/guard.d.ts +18 -0
  526. package/dist/core/signing/guard.js +72 -0
  527. package/dist/core/signing/guard.js.map +1 -0
  528. package/dist/core/signing/hd.d.ts +36 -0
  529. package/dist/core/signing/hd.js +167 -0
  530. package/dist/core/signing/hd.js.map +1 -0
  531. package/dist/core/signing/local.d.ts +48 -0
  532. package/dist/core/signing/local.js +190 -0
  533. package/dist/core/signing/local.js.map +1 -0
  534. package/dist/core/signing/orchestrator.d.ts +40 -0
  535. package/dist/core/signing/orchestrator.js +300 -0
  536. package/dist/core/signing/orchestrator.js.map +1 -0
  537. package/dist/core/signing/types.d.ts +64 -0
  538. package/dist/core/signing/types.js +3 -0
  539. package/dist/core/signing/types.js.map +1 -0
  540. package/dist/core/signing/wallet.d.ts +48 -0
  541. package/dist/core/signing/wallet.js +153 -0
  542. package/dist/core/signing/wallet.js.map +1 -0
  543. package/dist/core/store/clone.d.ts +25 -0
  544. package/dist/core/store/clone.js +71 -0
  545. package/dist/core/store/clone.js.map +1 -0
  546. package/dist/core/store/memory.d.ts +38 -0
  547. package/dist/core/store/memory.js +325 -0
  548. package/dist/core/store/memory.js.map +1 -0
  549. package/dist/core/store/types.d.ts +246 -0
  550. package/dist/core/store/types.js +117 -0
  551. package/dist/core/store/types.js.map +1 -0
  552. package/dist/core/transport/backoff.d.ts +8 -0
  553. package/dist/core/transport/backoff.js +27 -0
  554. package/dist/core/transport/backoff.js.map +1 -0
  555. package/dist/core/transport/circuit.d.ts +25 -0
  556. package/dist/core/transport/circuit.js +61 -0
  557. package/dist/core/transport/circuit.js.map +1 -0
  558. package/dist/core/transport/http-transport.d.ts +30 -0
  559. package/dist/core/transport/http-transport.js +1695 -0
  560. package/dist/core/transport/http-transport.js.map +1 -0
  561. package/dist/core/transport/rate-limit.d.ts +27 -0
  562. package/dist/core/transport/rate-limit.js +78 -0
  563. package/dist/core/transport/rate-limit.js.map +1 -0
  564. package/dist/core/transport/stale-view.d.ts +11 -0
  565. package/dist/core/transport/stale-view.js +17 -0
  566. package/dist/core/transport/stale-view.js.map +1 -0
  567. package/dist/core/transport/types.d.ts +144 -0
  568. package/dist/core/transport/types.js +6 -0
  569. package/dist/core/transport/types.js.map +1 -0
  570. package/dist/core/util/bytes.d.ts +9 -0
  571. package/dist/core/util/bytes.js +40 -0
  572. package/dist/core/util/bytes.js.map +1 -0
  573. package/dist/core/util/clock.d.ts +6 -0
  574. package/dist/core/util/clock.js +26 -0
  575. package/dist/core/util/clock.js.map +1 -0
  576. package/dist/core/util/freeze.d.ts +8 -0
  577. package/dist/core/util/freeze.js +31 -0
  578. package/dist/core/util/freeze.js.map +1 -0
  579. package/dist/core/util/json.d.ts +29 -0
  580. package/dist/core/util/json.js +165 -0
  581. package/dist/core/util/json.js.map +1 -0
  582. package/dist/core/util/names.d.ts +21 -0
  583. package/dist/core/util/names.js +46 -0
  584. package/dist/core/util/names.js.map +1 -0
  585. package/dist/index.d.ts +64 -14
  586. package/dist/index.js +105 -49
  587. package/dist/index.js.map +1 -1
  588. package/dist/native.d.ts +21 -0
  589. package/dist/native.js +44 -0
  590. package/dist/native.js.map +1 -0
  591. package/dist/testing/contracts/api.d.ts +12 -0
  592. package/dist/testing/contracts/api.js +58 -0
  593. package/dist/testing/contracts/api.js.map +1 -0
  594. package/dist/testing/contracts/cursors.d.ts +6 -0
  595. package/dist/testing/contracts/cursors.js +43 -0
  596. package/dist/testing/contracts/cursors.js.map +1 -0
  597. package/dist/testing/contracts/locks.d.ts +10 -0
  598. package/dist/testing/contracts/locks.js +63 -0
  599. package/dist/testing/contracts/locks.js.map +1 -0
  600. package/dist/testing/contracts/operations.d.ts +21 -0
  601. package/dist/testing/contracts/operations.js +718 -0
  602. package/dist/testing/contracts/operations.js.map +1 -0
  603. package/dist/testing/contracts/sequences.d.ts +6 -0
  604. package/dist/testing/contracts/sequences.js +68 -0
  605. package/dist/testing/contracts/sequences.js.map +1 -0
  606. package/dist/testing/env.d.ts +63 -0
  607. package/dist/testing/env.js +105 -0
  608. package/dist/testing/env.js.map +1 -0
  609. package/dist/testing/fake-chain.d.ts +118 -0
  610. package/dist/testing/fake-chain.js +536 -0
  611. package/dist/testing/fake-chain.js.map +1 -0
  612. package/dist/testing/fake-clock.d.ts +15 -0
  613. package/dist/testing/fake-clock.js +86 -0
  614. package/dist/testing/fake-clock.js.map +1 -0
  615. package/dist/testing/fake-driver.d.ts +15 -0
  616. package/dist/testing/fake-driver.js +458 -0
  617. package/dist/testing/fake-driver.js.map +1 -0
  618. package/dist/testing/fake-fetch.d.ts +32 -0
  619. package/dist/testing/fake-fetch.js +81 -0
  620. package/dist/testing/fake-fetch.js.map +1 -0
  621. package/dist/testing/fake-plugin.d.ts +30 -0
  622. package/dist/testing/fake-plugin.js +66 -0
  623. package/dist/testing/fake-plugin.js.map +1 -0
  624. package/dist/testing/faulty-store.d.ts +36 -0
  625. package/dist/testing/faulty-store.js +66 -0
  626. package/dist/testing/faulty-store.js.map +1 -0
  627. package/dist/testing/generation.d.ts +60 -0
  628. package/dist/testing/generation.js +252 -0
  629. package/dist/testing/generation.js.map +1 -0
  630. package/dist/testing/index.d.ts +28 -0
  631. package/dist/testing/index.js +51 -0
  632. package/dist/testing/index.js.map +1 -0
  633. package/package.json +188 -45
  634. package/dist/libs/eth/account.d.ts +0 -9
  635. package/dist/libs/eth/account.js +0 -58
  636. package/dist/libs/eth/account.js.map +0 -1
  637. package/dist/libs/eth/contract.d.ts +0 -7
  638. package/dist/libs/eth/contract.js +0 -42
  639. package/dist/libs/eth/contract.js.map +0 -1
  640. package/dist/libs/eth/index.d.ts +0 -24
  641. package/dist/libs/eth/index.js +0 -72
  642. package/dist/libs/eth/index.js.map +0 -1
  643. package/dist/libs/eth/transact.d.ts +0 -7
  644. package/dist/libs/eth/transact.js +0 -26
  645. package/dist/libs/eth/transact.js.map +0 -1
  646. package/dist/libs/index.d.ts +0 -2
  647. package/dist/libs/index.js +0 -19
  648. package/dist/libs/index.js.map +0 -1
  649. package/dist/libs/trx/account.d.ts +0 -9
  650. package/dist/libs/trx/account.js +0 -55
  651. package/dist/libs/trx/account.js.map +0 -1
  652. package/dist/libs/trx/contract.d.ts +0 -7
  653. package/dist/libs/trx/contract.js +0 -27
  654. package/dist/libs/trx/contract.js.map +0 -1
  655. package/dist/libs/trx/index.d.ts +0 -22
  656. package/dist/libs/trx/index.js +0 -64
  657. package/dist/libs/trx/index.js.map +0 -1
  658. package/dist/libs/trx/transact.d.ts +0 -7
  659. package/dist/libs/trx/transact.js +0 -26
  660. package/dist/libs/trx/transact.js.map +0 -1
  661. package/dist/tool/common.d.ts +0 -28
  662. package/dist/tool/common.js +0 -33
  663. package/dist/tool/common.js.map +0 -1
  664. package/dist/tool/eth-tools.d.ts +0 -3
  665. package/dist/tool/eth-tools.js +0 -33
  666. package/dist/tool/eth-tools.js.map +0 -1
  667. package/dist/tool/index.d.ts +0 -5
  668. package/dist/tool/index.js +0 -22
  669. package/dist/tool/index.js.map +0 -1
  670. package/dist/tool/logging.d.ts +0 -3
  671. package/dist/tool/logging.js +0 -11
  672. package/dist/tool/logging.js.map +0 -1
  673. package/dist/tool/options.d.ts +0 -6
  674. package/dist/tool/options.js +0 -41
  675. package/dist/tool/options.js.map +0 -1
  676. package/dist/tool/trx-tools.d.ts +0 -3
  677. package/dist/tool/trx-tools.js +0 -20
  678. package/dist/tool/trx-tools.js.map +0 -1
  679. package/dist/type/account.d.ts +0 -9
  680. package/dist/type/account.js.map +0 -1
  681. package/dist/type/common.d.ts +0 -18
  682. package/dist/type/common.js.map +0 -1
  683. package/dist/type/contract.d.ts +0 -10
  684. package/dist/type/contract.js.map +0 -1
  685. package/dist/type/index.d.ts +0 -5
  686. package/dist/type/index.js +0 -22
  687. package/dist/type/index.js.map +0 -1
  688. package/dist/type/lib-types.d.ts +0 -9
  689. package/dist/type/lib-types.js.map +0 -1
  690. package/dist/type/transact.d.ts +0 -7
  691. package/dist/type/transact.js.map +0 -1
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coinSelectionPreview = coinSelectionPreview;
4
+ /**
5
+ * `ext.utxo.coinSelection`: a dry run of the configured coin selection. Signs nothing. The
6
+ * change output is sized for the sending address (the wallet's `changeAddress` is not known
7
+ * here), so the fee may differ from a build's by a change output's size difference.
8
+ */
9
+ const error_1 = require("../../core/errors/error");
10
+ const coinselect_1 = require("./coinselect");
11
+ const spend_1 = require("./spend");
12
+ /**
13
+ * A caller's request reaches this method unchecked by the core (ext methods are the
14
+ * family's), so its shape is checked here: a malformed one is a fixed-text validation
15
+ * error, never a foreign `TypeError`. Addresses are checked where they are decoded.
16
+ */
17
+ function assertRequest(request) {
18
+ const invalid = (reason) => new error_1.ValidationError('INVALID_INTENT', reason);
19
+ if (request === null || typeof request !== 'object') {
20
+ throw invalid('a coin selection request is { from, outputs, fee?, exclude? }');
21
+ }
22
+ if (!Array.isArray(request.outputs)) {
23
+ throw invalid('outputs must be an array of { to, amount }');
24
+ }
25
+ for (const output of request.outputs) {
26
+ if (output === null || typeof output !== 'object') {
27
+ throw invalid('outputs must be an array of { to, amount }');
28
+ }
29
+ const { amount } = output;
30
+ if (typeof amount !== 'bigint' || amount <= 0n) {
31
+ throw new error_1.ValidationError('INVALID_AMOUNT', 'an output amount must be a positive bigint (satoshis)');
32
+ }
33
+ }
34
+ const exclude = request.exclude;
35
+ if (exclude !== undefined &&
36
+ (!Array.isArray(exclude) || !exclude.every((o) => typeof o === 'string'))) {
37
+ throw invalid('exclude must be an array of outpoints (txid:vout)');
38
+ }
39
+ }
40
+ async function coinSelectionPreview(ctx, request) {
41
+ assertRequest(request);
42
+ const sender = (0, spend_1.senderOf)(ctx, request.from);
43
+ const outputs = (0, spend_1.plannedOutputs)(ctx, request.outputs);
44
+ const rate = await (0, spend_1.rateOf)(ctx, request.fee ?? 'normal');
45
+ const candidates = await (0, spend_1.spendable)(ctx, sender.from.canonical, request.exclude, ctx.config.minInputConfirmations);
46
+ const selection = (0, coinselect_1.selectCoins)({
47
+ candidates,
48
+ outputs,
49
+ changeScript: sender.from.script,
50
+ inputType: sender.type,
51
+ rate,
52
+ dustRelayFee: ctx.config.dustRelayFee,
53
+ strategy: ctx.config.coinSelection,
54
+ });
55
+ const inputs = selection.ok ? selection.inputs : candidates;
56
+ return {
57
+ inputs: inputs.map((i) => ({ outpoint: i.outpoint, value: i.value })),
58
+ fee: selection.fee,
59
+ satPerKvB: rate,
60
+ vsize: selection.vsize,
61
+ change: selection.ok ? selection.change : 0n,
62
+ sufficient: selection.ok,
63
+ };
64
+ }
65
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/adapters/utxo/preview.ts"],"names":[],"mappings":";;AA6CA,oDAgCC;AA7ED;;;;GAIG;AACH,mDAA0D;AAC1D,6CAA2C;AAE3C,mCAAsE;AAGtE;;;;GAIG;AACH,SAAS,aAAa,CAAC,OAA6B;IAClD,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,uBAAe,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAClF,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,OAAO,CAAC,+DAA+D,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,OAAO,CAAC,4CAA4C,CAAC,CAAC;IAC9D,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAA6B,EAAE,CAAC;QAC3D,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAClD,MAAM,OAAO,CAAC,4CAA4C,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAuC,CAAC;QAC3D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;YAC/C,MAAM,IAAI,uBAAe,CACvB,gBAAgB,EAChB,uDAAuD,CACxD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAY,OAAO,CAAC,OAAO,CAAC;IACzC,IACE,OAAO,KAAK,SAAS;QACrB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CA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C,CAAC;QACrE,GAAG,EAAE,SAAS,CAAC,GAAG;QAClB,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QAC5C,UAAU,EAAE,SAAS,CAAC,EAAE;KACzB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * `ext.utxo.coinSelection`: a dry run of the configured coin selection. Signs nothing. The\n * change output is sized for the sending address (the wallet's `changeAddress` is not known\n * here), so the fee may differ from a build's by a change output's size difference.\n */\nimport { ValidationError } from '../../core/errors/error';\nimport { selectCoins } from './coinselect';\nimport type { UtxoContext } from './context';\nimport { plannedOutputs, rateOf, senderOf, spendable } from './spend';\nimport type { UtxoSelectionPreview, UtxoSelectionRequest } from './types';\n\n/**\n * A caller's request reaches this method unchecked by the core (ext methods are the\n * family's), so its shape is checked here: a malformed one is a fixed-text validation\n * error, never a foreign `TypeError`. Addresses are checked where they are decoded.\n */\nfunction assertRequest(request: UtxoSelectionRequest): void {\n const invalid = (reason: string) => new ValidationError('INVALID_INTENT', reason);\n if (request === null || typeof request !== 'object') {\n throw invalid('a coin selection request is { from, outputs, fee?, exclude? }');\n }\n if (!Array.isArray(request.outputs)) {\n throw invalid('outputs must be an array of { to, amount }');\n }\n for (const output of request.outputs as readonly unknown[]) {\n if (output === null || typeof output !== 'object') {\n throw invalid('outputs must be an array of { to, amount }');\n }\n const { amount } = output as { readonly amount?: unknown };\n if (typeof amount !== 'bigint' || amount <= 0n) {\n throw new ValidationError(\n 'INVALID_AMOUNT',\n 'an output amount must be a positive bigint (satoshis)',\n );\n }\n }\n const exclude: unknown = request.exclude;\n if (\n exclude !== undefined &&\n (!Array.isArray(exclude) || !exclude.every((o) => typeof o === 'string'))\n ) {\n throw invalid('exclude must be an array of outpoints (txid:vout)');\n }\n}\n\nexport async function coinSelectionPreview(\n ctx: UtxoContext,\n request: UtxoSelectionRequest,\n): Promise<UtxoSelectionPreview> {\n assertRequest(request);\n const sender = senderOf(ctx, request.from);\n const outputs = plannedOutputs(ctx, request.outputs);\n const rate = await rateOf(ctx, request.fee ?? 'normal');\n const candidates = await spendable(\n ctx,\n sender.from.canonical,\n request.exclude,\n ctx.config.minInputConfirmations,\n );\n const selection = selectCoins({\n candidates,\n outputs,\n changeScript: sender.from.script,\n inputType: sender.type,\n rate,\n dustRelayFee: ctx.config.dustRelayFee,\n strategy: ctx.config.coinSelection,\n });\n const inputs = selection.ok ? selection.inputs : candidates;\n return {\n inputs: inputs.map((i) => ({ outpoint: i.outpoint, value: i.value })),\n fee: selection.fee,\n satPerKvB: rate,\n vsize: selection.vsize,\n change: selection.ok ? selection.change : 0n,\n sufficient: selection.ok,\n };\n}\n"]}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Proofs (finalized-state checks behind `proven` verdicts) and the block source.
3
+ *
4
+ * Finality is N confirmations. Every fact is attested at its own height with a monotone
5
+ * predicate quorum key, and no endpoint proposes a height. "Block h is final" is "every
6
+ * proof endpoint holds a block at h + N − 1": the quorum reads the head with the key
7
+ * `head >= h + N − 1`, so endpoints further ahead agree, and one that trails decides
8
+ * nothing. Only `finalizedHead` (no anchor of its own) takes one endpoint's head, trails
9
+ * it by `PEER_SKEW`, then attests it. One endpoint's head never decides finality.
10
+ *
11
+ * `includedFinal` answers "not included" only when an input of our Attempt has a
12
+ * quorum-attested final spender that is neither our txid nor a malleated copy of it.
13
+ * Every other case decides nothing (a retryable `ProviderError`): our transaction in a
14
+ * mempool or in a block not yet final, an unknown spender, a lagging or load-balanced
15
+ * backend. A stale inclusion (its block is no longer the block at its height) is a
16
+ * retryable `PROVIDER_INCONSISTENT`, and so is a transaction view that puts ours in a
17
+ * block while another transaction's spend of its input is final: both cannot hold. So
18
+ * `includedFinal` never answers "not included" without its own attestation of a different
19
+ * final spend, and an endpoint-set change between the monitor's `slotConsumed` and
20
+ * `includedFinal` calls cannot produce a false proven `replaced`.
21
+ *
22
+ * The block source reads chain data leniently (the Esplora client's parsers) and binds
23
+ * every page to its block: each page has exactly the transactions the block's count
24
+ * leaves for it, no txid twice, each confirmed in that block. A reorg while paging, or a
25
+ * page the endpoint does not have, decides nothing (retryable). Address filters match
26
+ * output and prevout scripts, so a watched address's spend is kept even when no output of
27
+ * it has an address.
28
+ */
29
+ import type { BlockSource, ProofSource } from '../../core/driver/types';
30
+ import { type UtxoContext } from './context';
31
+ import type { EsploraTx } from './types';
32
+ /** Blocks `finalizedHead` trails one endpoint's head by, so peers can attest it. */
33
+ export declare const PEER_SKEW = 2n;
34
+ /**
35
+ * The reads a proof attests under the proof quorum, each fact at its own height. The
36
+ * proof source and the builder share them: the builder's proof-tagged reads are this
37
+ * module's, never a copy.
38
+ */
39
+ export declare function attestedReads(ctx: UtxoContext, signal?: AbortSignal): {
40
+ holds: (height: bigint) => Promise<boolean>;
41
+ hashAt: (height: bigint) => Promise<string | null>;
42
+ assertCanonical: (height: bigint, hash: string) => Promise<void>;
43
+ txView: (txid: string) => Promise<EsploraTx | null>;
44
+ };
45
+ /**
46
+ * Each of `txids` (the previous transactions of the inputs a build adds) is in a
47
+ * block, attested under the proof quorum at its own height: the proof endpoints agree on the
48
+ * transaction and its block, all hold a block `confirmations − 1` above it, and have that
49
+ * block at that height. Its bytes authenticate themselves, but only this proves a
50
+ * chain holds it: an indexer's invented transaction, or one a reorg took out, would stall an
51
+ * Attempt for good, since nothing would ever spend its outpoint. Anything short of that is a
52
+ * retryable `PROVIDER_UNAVAILABLE` (a stale view `PROVIDER_INCONSISTENT`), and every read
53
+ * decides nothing on failure. A parent found final is not read again.
54
+ */
55
+ export declare function assertConfirmed(ctx: UtxoContext, txids: readonly string[], confirmations: number, signal?: AbortSignal): Promise<void>;
56
+ export declare function proofSource(ctx: UtxoContext): ProofSource;
57
+ export declare function blockSource(ctx: UtxoContext): BlockSource;
@@ -0,0 +1,331 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PEER_SKEW = void 0;
4
+ exports.attestedReads = attestedReads;
5
+ exports.assertConfirmed = assertConfirmed;
6
+ exports.proofSource = proofSource;
7
+ exports.blockSource = blockSource;
8
+ const error_1 = require("../../core/errors/error");
9
+ const bytes_1 = require("../../core/util/bytes");
10
+ const address_1 = require("./address");
11
+ const context_1 = require("./context");
12
+ const decode_1 = require("./decode");
13
+ const esplora_1 = require("./esplora");
14
+ const reader_1 = require("./reader");
15
+ /** Blocks `finalizedHead` trails one endpoint's head by, so peers can attest it. */
16
+ exports.PEER_SKEW = 2n;
17
+ /** Esplora's page of block transactions (electrs' `CHAIN_TXS_PER_PAGE`). */
18
+ const PAGE = 25;
19
+ /** Consensus: a block's transaction count × 4 is at most `MAX_BLOCK_WEIGHT` (4,000,000). */
20
+ const MAX_BLOCK_TXS = 1_000_000;
21
+ /** No height is below 0 or beyond what a server parses: such a height is never sent. */
22
+ const MAX_HEIGHT = BigInt(Number.MAX_SAFE_INTEGER);
23
+ const outOfRange = (height) => height < 0n || height > MAX_HEIGHT;
24
+ const undecided = (reason) => new error_1.ProviderError('PROVIDER_UNAVAILABLE', reason);
25
+ /** Two quorum reads that cannot both hold decide nothing (retryable). */
26
+ const contradiction = (reason) => new error_1.ProviderError('PROVIDER_INCONSISTENT', reason, { retryable: true });
27
+ const stale = () => contradiction('the including block is no longer the block at its height');
28
+ /**
29
+ * A block hash read under the proof quorum is compared as `parseHash` reads it, so two
30
+ * honest endpoints that differ only by whitespace agree, and the key is exactly the value
31
+ * the verdict uses. Compared as raw text, one endpoint's trailing newline would split the
32
+ * quorum forever.
33
+ */
34
+ const HASH_PROOF = { ...context_1.PROOF, quorumKey: esplora_1.parseHash };
35
+ /** A transaction view as the proof quorum compares it: its txid, and its block and height. */
36
+ const txViewKey = (answer) => {
37
+ const t = (0, esplora_1.parseTx)(answer);
38
+ return t.status.confirmed
39
+ ? `${t.txid}@${t.status.blockHash}:${t.status.blockHeight}`
40
+ : `${t.txid}:unconfirmed`;
41
+ };
42
+ /**
43
+ * The reads a proof attests under the proof quorum, each fact at its own height. The
44
+ * proof source and the builder share them: the builder's proof-tagged reads are this
45
+ * module's, never a copy.
46
+ */
47
+ function attestedReads(ctx, signal) {
48
+ const { esplora } = ctx;
49
+ /** "I hold a block at `height`" (monotone in the head, so endpoints further ahead agree). */
50
+ const holds = async (height) => {
51
+ const head = await esplora.tipHeight({
52
+ ...(0, context_1.withSignal)(context_1.PROOF, signal),
53
+ quorumKey: (answer) => (0, esplora_1.parseHeight)(answer) >= height,
54
+ });
55
+ return head >= height;
56
+ };
57
+ /** The hash of the block at `height` on the proof endpoints' chain. */
58
+ const hashAt = (height) => esplora.blockHashAt(height, (0, context_1.withSignal)(HASH_PROOF, signal));
59
+ /** The quorum's hash at `height` must be `hash`; otherwise the answer was stale. */
60
+ const assertCanonical = async (height, hash) => {
61
+ if ((await hashAt(height)) !== hash)
62
+ throw stale();
63
+ };
64
+ /** A transaction and the block it is in, as the proof endpoints agree on it. */
65
+ const txView = (txid) => esplora.tx(txid, { ...(0, context_1.withSignal)(context_1.PROOF, signal), quorumKey: txViewKey });
66
+ return { holds, hashAt, assertCanonical, txView };
67
+ }
68
+ /** How many parents `assertConfirmed` reads at once, and keeps once final. */
69
+ const PARENT_READS = 4;
70
+ const FINAL_PARENTS = 10_000;
71
+ const finalParents = new WeakMap();
72
+ const notConfirmed = () => new error_1.ProviderError('PROVIDER_UNAVAILABLE', "an input's previous transaction is not in a block the proof endpoints hold yet");
73
+ /**
74
+ * Each of `txids` (the previous transactions of the inputs a build adds) is in a
75
+ * block, attested under the proof quorum at its own height: the proof endpoints agree on the
76
+ * transaction and its block, all hold a block `confirmations − 1` above it, and have that
77
+ * block at that height. Its bytes authenticate themselves, but only this proves a
78
+ * chain holds it: an indexer's invented transaction, or one a reorg took out, would stall an
79
+ * Attempt for good, since nothing would ever spend its outpoint. Anything short of that is a
80
+ * retryable `PROVIDER_UNAVAILABLE` (a stale view `PROVIDER_INCONSISTENT`), and every read
81
+ * decides nothing on failure. A parent found final is not read again.
82
+ */
83
+ async function assertConfirmed(ctx, txids, confirmations, signal) {
84
+ let final = finalParents.get(ctx.esplora);
85
+ if (!final) {
86
+ final = new Map();
87
+ finalParents.set(ctx.esplora, final);
88
+ }
89
+ const known = final;
90
+ const pending = [...new Set(txids)].filter((txid) => !known.has(txid));
91
+ if (pending.length === 0)
92
+ return;
93
+ await (0, context_1.proofRead)(async () => {
94
+ const reads = attestedReads(ctx, signal);
95
+ const blocks = new Map();
96
+ let top = 0n;
97
+ await (0, context_1.forEachBounded)(pending, PARENT_READS, async (txid) => {
98
+ const tx = await reads.txView(txid);
99
+ if (!tx?.status.confirmed)
100
+ throw notConfirmed();
101
+ const height = tx.status.blockHeight;
102
+ blocks.set(tx.status.blockHash, height);
103
+ if (height > top)
104
+ top = height;
105
+ });
106
+ // Monotone: the proof endpoints hold `top + confirmations − 1` only if they hold every
107
+ // lower height, so one read attests every parent's depth.
108
+ if (!(await reads.holds(top + BigInt(Math.max(1, confirmations)) - 1n))) {
109
+ throw notConfirmed();
110
+ }
111
+ for (const [hash, height] of blocks)
112
+ await reads.assertCanonical(height, hash);
113
+ if (await reads.holds(top + BigInt(ctx.config.confirmations) - 1n)) {
114
+ for (const txid of pending) {
115
+ known.set(txid, true);
116
+ if (known.size > FINAL_PARENTS)
117
+ known.delete(known.keys().next().value);
118
+ }
119
+ }
120
+ });
121
+ }
122
+ function proofSource(ctx) {
123
+ const { esplora, config } = ctx;
124
+ const depth = BigInt(config.confirmations) - 1n;
125
+ const { holds, hashAt, assertCanonical, txView } = attestedReads(ctx);
126
+ /** The transaction that spent `input` in a final, canonical block (quorum-attested). */
127
+ const finalSpender = async (input) => {
128
+ const spend = await esplora.outspend(input.txid, input.vout, {
129
+ ...context_1.PROOF,
130
+ quorumKey: (answer) => {
131
+ const s = (0, esplora_1.parseOutspend)(answer);
132
+ return s.spent && s.status?.confirmed
133
+ ? `${s.txid}@${s.status.blockHash}:${s.status.blockHeight}`
134
+ : 'not-in-a-block';
135
+ },
136
+ });
137
+ const status = spend.status;
138
+ if (!spend.spent || spend.txid === undefined || !status?.confirmed)
139
+ return undefined;
140
+ const height = status.blockHeight;
141
+ const hash = status.blockHash;
142
+ if (!(await holds(height + depth)))
143
+ return undefined;
144
+ await assertCanonical(height, hash);
145
+ return { txid: spend.txid, height, hash };
146
+ };
147
+ const inputsOf = (ordering) => ordering.kind === 'inputs' ? ordering.inputs.map(context_1.parseOutpoint) : [];
148
+ const source = {
149
+ async finalizedHead() {
150
+ const anchor = (await esplora.tipHeight(context_1.MONITOR)) - exports.PEER_SKEW;
151
+ if (anchor < 0n || !(await holds(anchor))) {
152
+ throw undecided('the proof endpoints have not reached the head');
153
+ }
154
+ const final = anchor - depth;
155
+ const height = final < 0n ? 0n : final;
156
+ const hash = await hashAt(height);
157
+ if (hash === null)
158
+ throw undecided('the final block is not visible to the proof endpoints');
159
+ return { height, hash };
160
+ },
161
+ async includedFinal(ref, ordering, from) {
162
+ if (!(0, esplora_1.isHash)(ref.id))
163
+ throw undecided('malformed transaction id');
164
+ const tx = await txView(ref.id);
165
+ if (tx?.status.confirmed) {
166
+ const height = tx.status.blockHeight;
167
+ const hash = tx.status.blockHash;
168
+ if (await holds(height + depth)) {
169
+ await assertCanonical(height, hash);
170
+ // A transaction in a block has executed; its txid commits to its outputs.
171
+ return {
172
+ included: true,
173
+ success: true,
174
+ blockHeight: height,
175
+ blockHash: hash,
176
+ txHash: tx.txid,
177
+ };
178
+ }
179
+ }
180
+ // Unknown, in a mempool, or not yet final: only a final spender of one of our inputs
181
+ // decides. Our own txid there means the views are inconsistent (decide nothing); a
182
+ // malleated copy of ours is our payment; any other transaction proves ours dead,
183
+ // unless the quorum also puts ours in a block (the views contradict each other).
184
+ for (const input of inputsOf(ordering)) {
185
+ const spender = await finalSpender(input);
186
+ if (spender === undefined)
187
+ continue;
188
+ if (spender.txid === ref.id) {
189
+ throw undecided('the spend and the transaction views disagree');
190
+ }
191
+ if (await (0, reader_1.isOwnCopy)(ctx, ref.id, from, spender.txid, context_1.PROOF)) {
192
+ return {
193
+ included: true,
194
+ success: true,
195
+ blockHeight: spender.height,
196
+ blockHash: spender.hash,
197
+ txHash: spender.txid,
198
+ };
199
+ }
200
+ if (tx?.status.confirmed) {
201
+ throw contradiction('the transaction is in a block while another spend of its input is final');
202
+ }
203
+ return { included: false };
204
+ }
205
+ throw undecided(tx
206
+ ? 'the transaction is not final yet'
207
+ : 'the indexer does not know this transaction yet');
208
+ },
209
+ async slotConsumed(ordering, _from, level) {
210
+ for (const input of inputsOf(ordering)) {
211
+ if (level === 'latest') {
212
+ if ((await esplora.outspend(input.txid, input.vout, context_1.MONITOR)).spent)
213
+ return true;
214
+ }
215
+ else if ((await finalSpender(input)) !== undefined) {
216
+ return true;
217
+ }
218
+ }
219
+ return false;
220
+ },
221
+ expired: async () => false,
222
+ async blockHash(height, level) {
223
+ if (outOfRange(height))
224
+ return null;
225
+ if (level === 'finalized' && !(await holds(height + depth)))
226
+ return null;
227
+ return hashAt(height);
228
+ },
229
+ };
230
+ // Every read of every proof decides nothing on "not available here".
231
+ return {
232
+ finalizedHead: () => (0, context_1.proofRead)(() => source.finalizedHead()),
233
+ includedFinal: (ref, ordering, from) => (0, context_1.proofRead)(() => source.includedFinal(ref, ordering, from)),
234
+ slotConsumed: (ordering, from, level) => (0, context_1.proofRead)(() => source.slotConsumed(ordering, from, level)),
235
+ expired: (ordering) => source.expired(ordering),
236
+ blockHash: (height, level) => (0, context_1.proofRead)(() => source.blockHash(height, level)),
237
+ };
238
+ }
239
+ function blockSource(ctx) {
240
+ const { esplora, config } = ctx;
241
+ /** The output scripts of the watched addresses; `undefined` means no filter. */
242
+ const scriptsOf = (addresses) => {
243
+ if (addresses === undefined || addresses.length === 0)
244
+ return undefined;
245
+ const scripts = new Set();
246
+ for (const address of addresses) {
247
+ try {
248
+ scripts.add((0, bytes_1.toHex)((0, address_1.decodeAddress)(address, config.address).script));
249
+ }
250
+ catch {
251
+ // Not an address of this network: it matches nothing.
252
+ }
253
+ }
254
+ return scripts;
255
+ };
256
+ return {
257
+ async header(height) {
258
+ if (outOfRange(height))
259
+ return null;
260
+ const hash = await esplora.blockHashAt(height, context_1.MONITOR);
261
+ if (!hash)
262
+ return null;
263
+ const block = await esplora.block(hash, context_1.MONITOR);
264
+ if (!block)
265
+ return null;
266
+ // The block at `height` must say it is at `height`.
267
+ if (block.height !== height) {
268
+ throw contradiction(`block ${height} changed while reading`);
269
+ }
270
+ return {
271
+ height: block.height,
272
+ hash: block.hash,
273
+ parentHash: block.parentHash,
274
+ timestamp: block.timestamp,
275
+ };
276
+ },
277
+ async transactions(block, filter) {
278
+ const inconsistent = () => contradiction(`block ${block.height} changed while scanning`);
279
+ const meta = await esplora.block(block.hash, context_1.MONITOR);
280
+ if (!meta || meta.height !== block.height)
281
+ throw inconsistent();
282
+ // Every block has a coinbase; none holds more than consensus allows. Bounded work.
283
+ if (meta.txCount < 1 || meta.txCount > MAX_BLOCK_TXS) {
284
+ throw (0, esplora_1.malformed)('block.tx_count');
285
+ }
286
+ // `filter.assets` is a hint: a list without the native asset wants tokens only, and a
287
+ // Bitcoin block has none, so nothing is paged.
288
+ if (filter?.assets?.length && !filter.assets.includes('native'))
289
+ return [];
290
+ const txs = [];
291
+ const seen = new Set();
292
+ for (let start = 0; start < meta.txCount; start += PAGE) {
293
+ let page;
294
+ try {
295
+ page = await esplora.blockTxs(block.hash, start, context_1.MONITOR);
296
+ }
297
+ catch (error) {
298
+ // A backend that does not have the block (lagging, load-balanced) decides nothing.
299
+ if ((0, esplora_1.isNotFound)(error))
300
+ throw inconsistent();
301
+ throw error;
302
+ }
303
+ // Each page holds exactly what the count leaves for it, and no txid twice.
304
+ if (page.length !== Math.min(PAGE, meta.txCount - start)) {
305
+ throw (0, esplora_1.malformed)('block txs page');
306
+ }
307
+ for (const tx of page) {
308
+ if (seen.has(tx.txid))
309
+ throw (0, esplora_1.malformed)('block txs page');
310
+ seen.add(tx.txid);
311
+ const { status } = tx;
312
+ if (!status.confirmed ||
313
+ status.blockHash !== block.hash ||
314
+ status.blockHeight !== block.height) {
315
+ throw inconsistent();
316
+ }
317
+ txs.push(tx);
318
+ }
319
+ }
320
+ // Checked after the pages, so a reorg while paging is caught.
321
+ if ((await esplora.blockHashAt(block.height, context_1.MONITOR)) !== block.hash)
322
+ throw inconsistent();
323
+ const wanted = scriptsOf(filter?.addresses);
324
+ const touches = (tx) => wanted === undefined ||
325
+ tx.vout.some((output) => wanted.has(output.script)) ||
326
+ tx.vin.some((input) => input.prevout && wanted.has(input.prevout.script));
327
+ return txs.filter(touches).map((tx) => (0, decode_1.decodeTransaction)(tx, config.address));
328
+ },
329
+ };
330
+ }
331
+ //# sourceMappingURL=proofs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofs.js","sourceRoot":"","sources":["../../../src/adapters/utxo/proofs.ts"],"names":[],"mappings":";;;AAwGA,sCAqBC;AAuBD,0CAsCC;AAED,kCA+HC;AAED,kCAwFC;AAnXD,mDAAwD;AAGxD,iDAA8C;AAC9C,uCAA0C;AAC1C,uCAQmB;AACnB,qCAA6C;AAC7C,uCASmB;AACnB,qCAAqC;AAGrC,oFAAoF;AACvE,QAAA,SAAS,GAAG,EAAE,CAAC;AAE5B,4EAA4E;AAC5E,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,4FAA4F;AAC5F,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,wFAAwF;AACxF,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,UAAU,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,GAAG,EAAE,IAAI,MAAM,GAAG,UAAU,CAAC;AAEnF,MAAM,SAAS,GAAG,CAAC,MAAc,EAAiB,EAAE,CAClD,IAAI,qBAAa,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAEpD,yEAAyE;AACzE,MAAM,aAAa,GAAG,CAAC,M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,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAChF,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Proofs (finalized-state checks behind `proven` verdicts) and the block source.\n *\n * Finality is N confirmations. Every fact is attested at its own height with a monotone\n * predicate quorum key, and no endpoint proposes a height. \"Block h is final\" is \"every\n * proof endpoint holds a block at h + N − 1\": the quorum reads the head with the key\n * `head >= h + N − 1`, so endpoints further ahead agree, and one that trails decides\n * nothing. Only `finalizedHead` (no anchor of its own) takes one endpoint's head, trails\n * it by `PEER_SKEW`, then attests it. One endpoint's head never decides finality.\n *\n * `includedFinal` answers \"not included\" only when an input of our Attempt has a\n * quorum-attested final spender that is neither our txid nor a malleated copy of it.\n * Every other case decides nothing (a retryable `ProviderError`): our transaction in a\n * mempool or in a block not yet final, an unknown spender, a lagging or load-balanced\n * backend. A stale inclusion (its block is no longer the block at its height) is a\n * retryable `PROVIDER_INCONSISTENT`, and so is a transaction view that puts ours in a\n * block while another transaction's spend of its input is final: both cannot hold. So\n * `includedFinal` never answers \"not included\" without its own attestation of a different\n * final spend, and an endpoint-set change between the monitor's `slotConsumed` and\n * `includedFinal` calls cannot produce a false proven `replaced`.\n *\n * The block source reads chain data leniently (the Esplora client's parsers) and binds\n * every page to its block: each page has exactly the transactions the block's count\n * leaves for it, no txid twice, each confirmed in that block. A reorg while paging, or a\n * page the endpoint does not have, decides nothing (retryable). Address filters match\n * output and prevout scripts, so a watched address's spend is kept even when no output of\n * it has an address.\n */\nimport type {\n BlockSource,\n DriverBlock,\n FinalityLevel,\n ProofSource,\n} from '../../core/driver/types';\nimport { ProviderError } from '../../core/errors/error';\nimport type { OrderingData } from '../../core/model/ordering';\nimport type { AttemptRef } from '../../core/model/transaction';\nimport { toHex } from '../../core/util/bytes';\nimport { decodeAddress } from './address';\nimport {\n MONITOR,\n PROOF,\n forEachBounded,\n parseOutpoint,\n proofRead,\n withSignal,\n type UtxoContext,\n} from './context';\nimport { decodeTransaction } from './decode';\nimport {\n isHash,\n isNotFound,\n type EsploraClient,\n malformed,\n parseHash,\n parseHeight,\n parseOutspend,\n parseTx,\n} from './esplora';\nimport { isOwnCopy } from './reader';\nimport type { EsploraTx } from './types';\n\n/** Blocks `finalizedHead` trails one endpoint's head by, so peers can attest it. */\nexport const PEER_SKEW = 2n;\n\n/** Esplora's page of block transactions (electrs' `CHAIN_TXS_PER_PAGE`). */\nconst PAGE = 25;\n/** Consensus: a block's transaction count × 4 is at most `MAX_BLOCK_WEIGHT` (4,000,000). */\nconst MAX_BLOCK_TXS = 1_000_000;\n/** No height is below 0 or beyond what a server parses: such a height is never sent. */\nconst MAX_HEIGHT = BigInt(Number.MAX_SAFE_INTEGER);\nconst outOfRange = (height: bigint): boolean => height < 0n || height > MAX_HEIGHT;\n\nconst undecided = (reason: string): ProviderError =>\n new ProviderError('PROVIDER_UNAVAILABLE', reason);\n\n/** Two quorum reads that cannot both hold decide nothing (retryable). */\nconst contradiction = (reason: string): ProviderError =>\n new ProviderError('PROVIDER_INCONSISTENT', reason, { retryable: true });\n\nconst stale = (): ProviderError =>\n contradiction('the including block is no longer the block at its height');\n\n/**\n * A block hash read under the proof quorum is compared as `parseHash` reads it, so two\n * honest endpoints that differ only by whitespace agree, and the key is exactly the value\n * the verdict uses. Compared as raw text, one endpoint's trailing newline would split the\n * quorum forever.\n */\nconst HASH_PROOF = { ...PROOF, quorumKey: parseHash };\n\n/** A transaction view as the proof quorum compares it: its txid, and its block and height. */\nconst txViewKey = (answer: unknown): string => {\n const t = parseTx(answer);\n return t.status.confirmed\n ? `${t.txid}@${t.status.blockHash}:${t.status.blockHeight}`\n : `${t.txid}:unconfirmed`;\n};\n\n/**\n * The reads a proof attests under the proof quorum, each fact at its own height. The\n * proof source and the builder share them: the builder's proof-tagged reads are this\n * module's, never a copy.\n */\nexport function attestedReads(ctx: UtxoContext, signal?: AbortSignal) {\n const { esplora } = ctx;\n /** \"I hold a block at `height`\" (monotone in the head, so endpoints further ahead agree). */\n const holds = async (height: bigint): Promise<boolean> => {\n const head = await esplora.tipHeight({\n ...withSignal(PROOF, signal),\n quorumKey: (answer) => parseHeight(answer) >= height,\n });\n return head >= height;\n };\n /** The hash of the block at `height` on the proof endpoints' chain. */\n const hashAt = (height: bigint): Promise<string | null> =>\n esplora.blockHashAt(height, withSignal(HASH_PROOF, signal));\n /** The quorum's hash at `height` must be `hash`; otherwise the answer was stale. */\n const assertCanonical = async (height: bigint, hash: string): Promise<void> => {\n if ((await hashAt(height)) !== hash) throw stale();\n };\n /** A transaction and the block it is in, as the proof endpoints agree on it. */\n const txView = (txid: string): Promise<EsploraTx | null> =>\n esplora.tx(txid, { ...withSignal(PROOF, signal), quorumKey: txViewKey });\n return { holds, hashAt, assertCanonical, txView };\n}\n\n/** How many parents `assertConfirmed` reads at once, and keeps once final. */\nconst PARENT_READS = 4;\nconst FINAL_PARENTS = 10_000;\nconst finalParents = new WeakMap<EsploraClient, Map<string, true>>();\n\nconst notConfirmed = (): ProviderError =>\n new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n \"an input's previous transaction is not in a block the proof endpoints hold yet\",\n );\n\n/**\n * Each of `txids` (the previous transactions of the inputs a build adds) is in a\n * block, attested under the proof quorum at its own height: the proof endpoints agree on the\n * transaction and its block, all hold a block `confirmations − 1` above it, and have that\n * block at that height. Its bytes authenticate themselves, but only this proves a\n * chain holds it: an indexer's invented transaction, or one a reorg took out, would stall an\n * Attempt for good, since nothing would ever spend its outpoint. Anything short of that is a\n * retryable `PROVIDER_UNAVAILABLE` (a stale view `PROVIDER_INCONSISTENT`), and every read\n * decides nothing on failure. A parent found final is not read again.\n */\nexport async function assertConfirmed(\n ctx: UtxoContext,\n txids: readonly string[],\n confirmations: number,\n signal?: AbortSignal,\n): Promise<void> {\n let final = finalParents.get(ctx.esplora);\n if (!final) {\n final = new Map();\n finalParents.set(ctx.esplora, final);\n }\n const known = final;\n const pending = [...new Set(txids)].filter((txid) => !known.has(txid));\n if (pending.length === 0) return;\n await proofRead(async () => {\n const reads = attestedReads(ctx, signal);\n const blocks = new Map<string, bigint>();\n let top = 0n;\n await forEachBounded(pending, PARENT_READS, async (txid) => {\n const tx = await reads.txView(txid);\n if (!tx?.status.confirmed) throw notConfirmed();\n const height = tx.status.blockHeight as bigint;\n blocks.set(tx.status.blockHash as string, height);\n if (height > top) top = height;\n });\n // Monotone: the proof endpoints hold `top + confirmations − 1` only if they hold every\n // lower height, so one read attests every parent's depth.\n if (!(await reads.holds(top + BigInt(Math.max(1, confirmations)) - 1n))) {\n throw notConfirmed();\n }\n for (const [hash, height] of blocks) await reads.assertCanonical(height, hash);\n if (await reads.holds(top + BigInt(ctx.config.confirmations) - 1n)) {\n for (const txid of pending) {\n known.set(txid, true);\n if (known.size > FINAL_PARENTS) known.delete(known.keys().next().value as string);\n }\n }\n });\n}\n\nexport function proofSource(ctx: UtxoContext): ProofSource {\n const { esplora, config } = ctx;\n const depth = BigInt(config.confirmations) - 1n;\n const { holds, hashAt, assertCanonical, txView } = attestedReads(ctx);\n\n /** The transaction that spent `input` in a final, canonical block (quorum-attested). */\n const finalSpender = async (input: {\n txid: string;\n vout: number;\n }): Promise<{ txid: string; height: bigint; hash: string } | undefined> => {\n const spend = await esplora.outspend(input.txid, input.vout, {\n ...PROOF,\n quorumKey: (answer) => {\n const s = parseOutspend(answer);\n return s.spent && s.status?.confirmed\n ? `${s.txid}@${s.status.blockHash}:${s.status.blockHeight}`\n : 'not-in-a-block';\n },\n });\n const status = spend.status;\n if (!spend.spent || spend.txid === undefined || !status?.confirmed) return undefined;\n const height = status.blockHeight as bigint;\n const hash = status.blockHash as string;\n if (!(await holds(height + depth))) return undefined;\n await assertCanonical(height, hash);\n return { txid: spend.txid, height, hash };\n };\n\n const inputsOf = (ordering: OrderingData): { txid: string; vout: number }[] =>\n ordering.kind === 'inputs' ? ordering.inputs.map(parseOutpoint) : [];\n\n const source: ProofSource = {\n async finalizedHead() {\n const anchor = (await esplora.tipHeight(MONITOR)) - PEER_SKEW;\n if (anchor < 0n || !(await holds(anchor))) {\n throw undecided('the proof endpoints have not reached the head');\n }\n const final = anchor - depth;\n const height = final < 0n ? 0n : final;\n const hash = await hashAt(height);\n if (hash === null)\n throw undecided('the final block is not visible to the proof endpoints');\n return { height, hash };\n },\n\n async includedFinal(ref: AttemptRef, ordering: OrderingData, from: string) {\n if (!isHash(ref.id)) throw undecided('malformed transaction id');\n const tx = await txView(ref.id);\n if (tx?.status.confirmed) {\n const height = tx.status.blockHeight as bigint;\n const hash = tx.status.blockHash as string;\n if (await holds(height + depth)) {\n await assertCanonical(height, hash);\n // A transaction in a block has executed; its txid commits to its outputs.\n return {\n included: true,\n success: true,\n blockHeight: height,\n blockHash: hash,\n txHash: tx.txid,\n };\n }\n }\n // Unknown, in a mempool, or not yet final: only a final spender of one of our inputs\n // decides. Our own txid there means the views are inconsistent (decide nothing); a\n // malleated copy of ours is our payment; any other transaction proves ours dead,\n // unless the quorum also puts ours in a block (the views contradict each other).\n for (const input of inputsOf(ordering)) {\n const spender = await finalSpender(input);\n if (spender === undefined) continue;\n if (spender.txid === ref.id) {\n throw undecided('the spend and the transaction views disagree');\n }\n if (await isOwnCopy(ctx, ref.id, from, spender.txid, PROOF)) {\n return {\n included: true,\n success: true,\n blockHeight: spender.height,\n blockHash: spender.hash,\n txHash: spender.txid,\n };\n }\n if (tx?.status.confirmed) {\n throw contradiction(\n 'the transaction is in a block while another spend of its input is final',\n );\n }\n return { included: false };\n }\n throw undecided(\n tx\n ? 'the transaction is not final yet'\n : 'the indexer does not know this transaction yet',\n );\n },\n\n async slotConsumed(ordering, _from, level: FinalityLevel) {\n for (const input of inputsOf(ordering)) {\n if (level === 'latest') {\n if ((await esplora.outspend(input.txid, input.vout, MONITOR)).spent)\n return true;\n } else if ((await finalSpender(input)) !== undefined) {\n return true;\n }\n }\n return false;\n },\n\n expired: async () => false,\n\n async blockHash(height, level) {\n if (outOfRange(height)) return null;\n if (level === 'finalized' && !(await holds(height + depth))) return null;\n return hashAt(height);\n },\n };\n\n // Every read of every proof decides nothing on \"not available here\".\n return {\n finalizedHead: () => proofRead(() => source.finalizedHead()),\n includedFinal: (ref, ordering, from) =>\n proofRead(() => source.includedFinal(ref, ordering, from)),\n slotConsumed: (ordering, from, level) =>\n proofRead(() => source.slotConsumed(ordering, from, level)),\n expired: (ordering) => source.expired(ordering),\n blockHash: (height, level) => proofRead(() => source.blockHash(height, level)),\n };\n}\n\nexport function blockSource(ctx: UtxoContext): BlockSource {\n const { esplora, config } = ctx;\n\n /** The output scripts of the watched addresses; `undefined` means no filter. */\n const scriptsOf = (addresses: readonly string[] | undefined) => {\n if (addresses === undefined || addresses.length === 0) return undefined;\n const scripts = new Set<string>();\n for (const address of addresses) {\n try {\n scripts.add(toHex(decodeAddress(address, config.address).script));\n } catch {\n // Not an address of this network: it matches nothing.\n }\n }\n return scripts;\n };\n\n return {\n async header(height): Promise<DriverBlock | null> {\n if (outOfRange(height)) return null;\n const hash = await esplora.blockHashAt(height, MONITOR);\n if (!hash) return null;\n const block = await esplora.block(hash, MONITOR);\n if (!block) return null;\n // The block at `height` must say it is at `height`.\n if (block.height !== height) {\n throw contradiction(`block ${height} changed while reading`);\n }\n return {\n height: block.height,\n hash: block.hash,\n parentHash: block.parentHash,\n timestamp: block.timestamp,\n };\n },\n\n async transactions(block, filter) {\n const inconsistent = () =>\n contradiction(`block ${block.height} changed while scanning`);\n const meta = await esplora.block(block.hash, MONITOR);\n if (!meta || meta.height !== block.height) throw inconsistent();\n // Every block has a coinbase; none holds more than consensus allows. Bounded work.\n if (meta.txCount < 1 || meta.txCount > MAX_BLOCK_TXS) {\n throw malformed('block.tx_count');\n }\n // `filter.assets` is a hint: a list without the native asset wants tokens only, and a\n // Bitcoin block has none, so nothing is paged.\n if (filter?.assets?.length && !filter.assets.includes('native')) return [];\n const txs: EsploraTx[] = [];\n const seen = new Set<string>();\n for (let start = 0; start < meta.txCount; start += PAGE) {\n let page: EsploraTx[];\n try {\n page = await esplora.blockTxs(block.hash, start, MONITOR);\n } catch (error) {\n // A backend that does not have the block (lagging, load-balanced) decides nothing.\n if (isNotFound(error)) throw inconsistent();\n throw error;\n }\n // Each page holds exactly what the count leaves for it, and no txid twice.\n if (page.length !== Math.min(PAGE, meta.txCount - start)) {\n throw malformed('block txs page');\n }\n for (const tx of page) {\n if (seen.has(tx.txid)) throw malformed('block txs page');\n seen.add(tx.txid);\n const { status } = tx;\n if (\n !status.confirmed ||\n status.blockHash !== block.hash ||\n status.blockHeight !== block.height\n ) {\n throw inconsistent();\n }\n txs.push(tx);\n }\n }\n // Checked after the pages, so a reorg while paging is caught.\n if ((await esplora.blockHashAt(block.height, MONITOR)) !== block.hash)\n throw inconsistent();\n const wanted = scriptsOf(filter?.addresses);\n const touches = (tx: EsploraTx) =>\n wanted === undefined ||\n tx.vout.some((output) => wanted.has(output.script)) ||\n tx.vin.some((input) => input.prevout && wanted.has(input.prevout.script));\n return txs.filter(touches).map((tx) => decodeTransaction(tx, config.address));\n },\n };\n}\n"]}
@@ -0,0 +1,59 @@
1
+ /** Bitcoin Core's `MAX_BLOCK_SERIALIZED_SIZE`: no transaction's bytes are more. */
2
+ export declare const MAX_TX_BYTES = 4000000;
3
+ /**
4
+ * Consensus: a transaction's weight (4 × its size without witness data, at least) is at most
5
+ * `MAX_BLOCK_WEIGHT` (4,000,000), so a transaction a chain holds has at most 1,000,000 bytes
6
+ * without its witness.
7
+ */
8
+ export declare const MAX_STRIPPED_BYTES = 1000000;
9
+ export interface ParsedInput {
10
+ /** The previous txid, in display order (the reverse of the serialized hash). */
11
+ readonly txid: string;
12
+ /** The previous transaction's hash as serialized (internal byte order): a view. */
13
+ readonly hash: Uint8Array;
14
+ readonly vout: number;
15
+ readonly script: Uint8Array;
16
+ readonly sequence: number;
17
+ readonly witness: readonly Uint8Array[];
18
+ }
19
+ export interface ParsedOutput {
20
+ /** As bitcoind reads it: a signed 64-bit integer. */
21
+ readonly value: bigint;
22
+ readonly script: Uint8Array;
23
+ }
24
+ export interface ParsedTx {
25
+ readonly txid: string;
26
+ readonly version: number;
27
+ readonly locktime: number;
28
+ readonly inputs: readonly ParsedInput[];
29
+ readonly outputs: readonly ParsedOutput[];
30
+ readonly hasWitness: boolean;
31
+ /** The size without witness data (bitcoind's `TX_NO_WITNESS` serialization). */
32
+ readonly strippedSize: number;
33
+ /** The output list as serialized (its count, then each output): a view. */
34
+ readonly outputBytes: Uint8Array;
35
+ /** The serialization without witness data (BIP174 `non_witness_utxo`). */
36
+ stripped(): Uint8Array;
37
+ }
38
+ export interface ReadOptions {
39
+ /**
40
+ * The most bytes without witness data: `MAX_STRIPPED_BYTES` (the default) for data a chain
41
+ * holds; the broadcaster reads what it sent with `MAX_TX_BYTES`, so every size bitcoind
42
+ * decodes is read (bitcoind refuses a larger one later, as `bad-txns-oversize`).
43
+ */
44
+ readonly maxStripped?: number;
45
+ }
46
+ /** The txid of a serialization without witness data, given as consecutive stretches. */
47
+ export declare const txidOfParts: (parts: readonly Uint8Array[]) => string;
48
+ /** A little-endian 32-bit field, as bitcoind writes it. */
49
+ export declare function writeU32(n: number): Uint8Array;
50
+ /** A CompactSize, as bitcoind writes it (at most `MAX_SIZE` here). */
51
+ export declare function writeSize(n: number): Uint8Array;
52
+ /** Transaction bytes, read in one pass; `undefined` when bitcoind would not decode them. */
53
+ export declare function readTx(bytes: Uint8Array, options?: ReadOptions): ParsedTx | undefined;
54
+ /**
55
+ * Transaction hex (either case, no prefix), capped at `MAX_TX_BYTES` before it is
56
+ * decoded, then read by `readTx`. Node's hex decoder is native and linear, and stops at
57
+ * the first pair that is not hex, so a short result means the text was not plain hex.
58
+ */
59
+ export declare function readTxHex(hex: string, options?: ReadOptions): ParsedTx | undefined;