@laceio/sdk 0.1.1-canary.3 → 0.1.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 (386) hide show
  1. package/dist/{TransactionBuilder-CCjOn7NA.cjs → TransactionBuilder-DrB3NVTi.cjs} +0 -42
  2. package/dist/{TransactionBuilder-CIzdw18M.js → TransactionBuilder-V6aLx4SV.js} +1 -1
  3. package/dist/{_polyfill-buffer-patch-CM8X7JiY.cjs → _polyfill-buffer-patch-BnPVerlG.cjs} +2 -21
  4. package/dist/account-guards.stable-B1DSSh9D.cjs +10 -0
  5. package/dist/account-guards.stable-JRQ5qx2V.js +5 -0
  6. package/dist/{activity-type-Ch6ljxBy.cjs → activity-type.stable-BJEfeLxL.cjs} +1 -2
  7. package/dist/{activity-type-GsJGWs-3.js → activity-type.stable-C76_hWd7.js} +1 -2
  8. package/dist/{address-book-address-validator-0J9XAADH.js → address-book-address-validator-DIUolI-s.js} +2 -2
  9. package/dist/{address-book-address-validator-Dte_YQ2L.cjs → address-book-address-validator-DNwQGlOB.cjs} +2 -2
  10. package/dist/bitcoin.cjs +0 -45
  11. package/dist/bitcoin.d.ts +1 -29906
  12. package/dist/bitcoin.js +0 -20
  13. package/dist/{blockfrost-tx-submit-provider-CLNQ5ycR.cjs → blockfrost-tx-submit-provider-BAIzV5o3.cjs} +167 -3
  14. package/dist/{blockfrost-tx-submit-provider-CBWQ0wK9.js → blockfrost-tx-submit-provider-DPTrapz-.js} +157 -5
  15. package/dist/{secret-box-DrjLZuS1.cjs → bytes.vo-Ck5u40RA.cjs} +35 -1
  16. package/dist/{secret-box-DUR0ACYz.js → bytes.vo-TgiwogWF.js} +25 -3
  17. package/dist/{cardano-network-id.vo-Cfpvbod9.js → cardano-network-id.vo-CK1tNQDg.js} +1 -1
  18. package/dist/{cardano-network-id.vo-BEDPn6Li.cjs → cardano-network-id.vo-DSxrFk9S.cjs} +1 -1
  19. package/dist/cardano.cjs +18 -22
  20. package/dist/cardano.d.ts +3774 -18959
  21. package/dist/cardano.js +11 -16
  22. package/dist/codecs-B7X9pAsK.cjs +1945 -0
  23. package/dist/codecs-CC1Xjntz.js +1882 -0
  24. package/dist/{const-D-eZIS4n.cjs → const-BDEg2Trq.cjs} +4 -4
  25. package/dist/{const-iwzZEE_w.cjs → const-BY8B3_0_.cjs} +1 -1
  26. package/dist/{const-BJfIK_G-.js → const-C84qHkjp.js} +4 -4
  27. package/dist/{const-CjmfjBP3.js → const-DXk2tFyv.js} +1 -1
  28. package/dist/{delegation-tx-builder-DZFjHDS8.js → delegation-tx-builder-CGVqlaFE.js} +5 -5
  29. package/dist/{delegation-tx-builder-CCjiakoy.cjs → delegation-tx-builder-CRpLP6jH.cjs} +6 -6
  30. package/dist/{deregistration-tx-builder-Bf6xAYp4.js → deregistration-tx-builder-B-CrUyX6.js} +5 -5
  31. package/dist/{deregistration-tx-builder-CQP35yex.cjs → deregistration-tx-builder-DZGwB4cz.cjs} +6 -6
  32. package/dist/{earn-rewards-tx-builder-Bsga3yFb.js → earn-rewards-tx-builder-BDbTDZmD.js} +5 -5
  33. package/dist/{earn-rewards-tx-builder-GuxofYns.cjs → earn-rewards-tx-builder-D5sUT5v8.cjs} +6 -6
  34. package/dist/{group-cardano-addresses-by-account-Bp0g4wEY.cjs → group-cardano-addresses-by-account-B533oVXR.cjs} +39 -3
  35. package/dist/{group-cardano-addresses-by-account-SR8MMrZf.js → group-cardano-addresses-by-account-RHKoEskR.js} +35 -5
  36. package/dist/{guarded-transaction-signer-MFpPg98D.cjs → guarded-transaction-signer-Bxl6_XNd.cjs} +18 -17
  37. package/dist/{guarded-transaction-signer-P6Rp1faj.js → guarded-transaction-signer-CpKLj8Kp.js} +15 -8
  38. package/dist/{in-memory-wallet-integration-t9I00R_V.cjs → in-memory-wallet-integration-CnLYeX4-.cjs} +108 -17
  39. package/dist/{in-memory-wallet-integration-CljprQQV.js → in-memory-wallet-integration-Croiuopx.js} +104 -7
  40. package/dist/{in-memory-wallet-integration-ChIOirMW.js → in-memory-wallet-integration-D-qn65Kx.js} +2 -5
  41. package/dist/{in-memory-wallet-integration-Cm6P8sk6.cjs → in-memory-wallet-integration-DVh9sRXa.cjs} +2 -3
  42. package/dist/index.cjs +47 -84
  43. package/dist/index.d.ts +13480 -40888
  44. package/dist/index.js +24 -52
  45. package/dist/{init-DUF4ar8P.cjs → init-B64zCLxG.cjs} +4 -4
  46. package/dist/{init-Y3mkB4XS.js → init-BAJJzBza.js} +2 -2
  47. package/dist/{init-EhzD7a8i.cjs → init-BJVU54pI.cjs} +1 -1
  48. package/dist/{init-D6BxBs7e.cjs → init-BKhH6mVR.cjs} +1 -1
  49. package/dist/{init-EP0CUWNK.cjs → init-BsCBAGWf.cjs} +2 -2
  50. package/dist/{init-Dy-05ktr.cjs → init-BtzMZ7Pk.cjs} +1 -1
  51. package/dist/init-Bv53hpLM.js +19 -0
  52. package/dist/{init-BopV9ed4.cjs → init-C-jErzp5.cjs} +2 -2
  53. package/dist/{init-Bp9GsPS_.cjs → init-C4Bkib9u.cjs} +56 -46
  54. package/dist/{init-lzHt4Cli.cjs → init-C7IeJwQR.cjs} +59 -256
  55. package/dist/{init-C-G32J12.cjs → init-CB__aLD7.cjs} +2 -2
  56. package/dist/{init-CyAY4Lzl.js → init-CFYsq82V.js} +1 -1
  57. package/dist/{init-0zzs9aqU.js → init-CLHuAMB-.js} +4 -4
  58. package/dist/{init-DA7zmptx.js → init-CNLGJJRx.js} +1 -1
  59. package/dist/{init-DS5qN63m.js → init-CR6tpw1B.js} +32 -24
  60. package/dist/init-CRbjI7p1.js +3494 -0
  61. package/dist/{init-CSDpdu0Q.cjs → init-CSHwHnfg.cjs} +2 -2
  62. package/dist/{init-CNM5m7M2.js → init-Cg9XdAru.js} +4 -4
  63. package/dist/{init-B3-1ghyx.js → init-CigestoM.js} +2 -2
  64. package/dist/{init-Dv3zKj0r.cjs → init-D6DBUsD3.cjs} +4 -4
  65. package/dist/init-DAna1KCg.cjs +3495 -0
  66. package/dist/{init-D74mn8nH2.js → init-DDdhguVC.js} +2 -2
  67. package/dist/init-DGe47B22.cjs +364 -0
  68. package/dist/init-DMtyvYfC.cjs +21 -0
  69. package/dist/{init-BrdVzxei.cjs → init-DX4WyB0R.cjs} +3 -3
  70. package/dist/{init-C8URA2OX.js → init-DcYY6zMD.js} +1 -1
  71. package/dist/{init-DFMiP2ZH.cjs → init-DkIc5nqF.cjs} +1 -1
  72. package/dist/{init-kEfUTuG2.js → init-Dku4b2lG.js} +1 -1
  73. package/dist/{init-NdhG_VrF.cjs → init-DxUHsN53.cjs} +6 -6
  74. package/dist/{init-CfTbSEKy.js → init-FMGDET-9.js} +60 -259
  75. package/dist/{init-DrkOb-wd.cjs → init-LfyMo-sS.cjs} +2 -2
  76. package/dist/{init-NCjgwCZy.js → init-Rxohwpmu.js} +2 -2
  77. package/dist/init-TkPDD750.js +363 -0
  78. package/dist/{init-C2RgrfZe.js → init-TkPq_Ny_.js} +1 -1
  79. package/dist/{init-5KcGcBb5.cjs → init-U8c9yHYx.cjs} +1 -1
  80. package/dist/{init-CX0AMQUn.js → init-aJHl-7AO.js} +2 -2
  81. package/dist/{init-rmt7-fQE.cjs → init-anYu6XB7.cjs} +2 -2
  82. package/dist/{init-Fw89ZmrR.js → init-w9GEs73W.js} +2 -2
  83. package/dist/{init-Dnsv155v.js → init-y2Ra0vZP.js} +3 -3
  84. package/dist/{init-DFjT8YvT.js → init-zSzCjoor.js} +4 -4
  85. package/dist/{is-retriable-error-BUiVJDwH.js → is-retriable-error-BU0e3hVI.js} +1 -1
  86. package/dist/{is-retriable-error-Dpt860if.cjs → is-retriable-error-CeeuHqDa.cjs} +1 -1
  87. package/dist/{lace-context-BZciB9c7.js → lace-context-CZcNHr4M.js} +4 -4
  88. package/dist/{lace-context-DgR6vLli.cjs → lace-context-fJTDghdp.cjs} +4 -4
  89. package/dist/{libsodium-wrappers-BhbOA8dQ.js → libsodium-wrappers-UH0LaOUE.js} +1647 -3
  90. package/dist/modules-cardano-BDvuL4Xx.js +5248 -0
  91. package/dist/modules-cardano-D2G3De2P.cjs +5432 -0
  92. package/dist/{retry-config-Dmgt28wM.js → retry-config-BcUmMS--.js} +1 -1
  93. package/dist/{retry-config-BaCfVC1H.cjs → retry-config-DC5IMaH7.cjs} +1 -1
  94. package/dist/{seam-cardano-B_etH4F4.js → seam-cardano-CATqBEyK.js} +1 -1
  95. package/dist/{signer-factory-DObB55D4.js → signer-factory-9URFliA5.js} +3 -6
  96. package/dist/{signer-factory-Ds6G2AZk.cjs → signer-factory-BWGUmnvm.cjs} +3 -4
  97. package/dist/{slice-qt0uBExh.js → slice-B2PhoWAg.js} +37 -325
  98. package/dist/{slice-DyNs7oWp.js → slice-BNu73oBa.js} +2 -2
  99. package/dist/{slice-GwiiJRoq.js → slice-CB4SnzMm.js} +3 -3
  100. package/dist/slice-CGVHXHDt.cjs +125 -0
  101. package/dist/{slice-CU80pbiu.js → slice-CnyWevM9.js} +3 -3
  102. package/dist/{slice-CwyYrh1H.js → slice-CobanYgn.js} +2 -2
  103. package/dist/{slice-7G2xxYKJ.cjs → slice-CuHUaPZx.cjs} +3 -3
  104. package/dist/{slice-DayJvMRD.cjs → slice-D11m2EKl.cjs} +1 -1
  105. package/dist/{slice-Bg6HEr3K.cjs → slice-DGcNrbPR.cjs} +4 -4
  106. package/dist/{slice-B4CdYoPu.cjs → slice-DZmQJNV8.cjs} +2 -2
  107. package/dist/slice-DhvF7L6X.js +107 -0
  108. package/dist/{slice-C9TT5KhY.cjs → slice-Do2R2CYW.cjs} +6 -6
  109. package/dist/{slice-Bs2aMERu.cjs → slice-DtaO72qY.cjs} +3 -3
  110. package/dist/{slice-C34iOOUH.cjs → slice-HeHCv3bl.cjs} +7 -7
  111. package/dist/{slice-D-9aPKG-.js → slice-d0p6-xj5.js} +6 -6
  112. package/dist/{slice-CK07EBCo.js → slice-eIwcwKHI.js} +4 -4
  113. package/dist/{slice-DBpJ2QGf.js → slice-maaskdUn.js} +6 -6
  114. package/dist/{slice-DTZTiJle.cjs → slice-mxLQ_FeY.cjs} +39 -352
  115. package/dist/{slice-DnG-yvpI.cjs → slice-oqm_r1cS.cjs} +2 -2
  116. package/dist/{slice-Da426sf9.js → slice-zJ9XVYjZ.js} +1 -1
  117. package/dist/{sync-operation-utils-31iFLExW.js → sync-operation-utils-BYXLO80m.js} +38 -2
  118. package/dist/{sync-operation-utils-COIZ66-I.cjs → sync-operation-utils-SdPbwFoD.cjs} +67 -1
  119. package/dist/{token-id-mapper-D29Ggv8h.js → token-id-mapper-B2ivlLv3.js} +2 -2
  120. package/dist/{token-id-mapper-CVyQJUKY.cjs → token-id-mapper-DsPAL6Nh.cjs} +2 -2
  121. package/dist/{util-Cp5cZkfK.js → util-BaLzwa32.js} +1 -1
  122. package/dist/{util-Bu4W5lF4.cjs → util-CGzqQ8IV.cjs} +1 -1
  123. package/dist/{utils-DsElZgCI.cjs → utils-5JvjbqH3.cjs} +1 -7
  124. package/dist/{utils-BfBEUvWA.js → utils-o8aMjfln.js} +2 -2
  125. package/dist/{vote-delegation-tx-builder-BUg1S2Ep.cjs → vote-delegation-tx-builder-BpEMSti4.cjs} +6 -6
  126. package/dist/{vote-delegation-tx-builder-C6FiS7zI.js → vote-delegation-tx-builder-CmKv6GoG.js} +5 -5
  127. package/package.json +4 -96
  128. package/dist/_polyfill-buffer-patch-yNxN4d5E.js +0 -1467
  129. package/dist/_web-crypto-random-bytes-Bo-GTcRS.js +0 -197
  130. package/dist/acc-module-4iIUv6My.cjs +0 -27654
  131. package/dist/acc-module-Cmj8EsIb.js +0 -27624
  132. package/dist/account-BOQruszJ.js +0 -6
  133. package/dist/account-BUOj4pYJ.cjs +0 -11
  134. package/dist/account-call-D68oF6bh.js +0 -267
  135. package/dist/account-call-DIIa2rK_.cjs +0 -314
  136. package/dist/account-call-NgLhYein.cjs +0 -4
  137. package/dist/account-call-n-Nkp35e.js +0 -3
  138. package/dist/account-guards-BtjTGxDZ.cjs +0 -42
  139. package/dist/account-guards-D9Lu5T3W.js +0 -36
  140. package/dist/account-tokens-DvkOFVON.js +0 -16
  141. package/dist/account-tokens-nwcvwLu4.cjs +0 -21
  142. package/dist/address-B9ntKL8K.js +0 -13761
  143. package/dist/address-BXp-mY8H.cjs +0 -11270
  144. package/dist/address-book-address-validator-DK0dnsRS.cjs +0 -41
  145. package/dist/address-book-address-validator-Di_ywo8M.js +0 -39
  146. package/dist/artefact-loader-54uK5RAa.js +0 -160
  147. package/dist/artefact-loader-DZPYrq-6.cjs +0 -183
  148. package/dist/auto-dismiss-failure-on-success-C-qoJuid.cjs +0 -37
  149. package/dist/auto-dismiss-failure-on-success-s8MGDEIu.js +0 -31
  150. package/dist/bip32-D6wd_QMn.cjs +0 -3851
  151. package/dist/bitcoin-data-provider-BYPSmuZS.js +0 -21
  152. package/dist/bitcoin-data-provider-w1oEDSU3.cjs +0 -26
  153. package/dist/bn-d3nSOIf7.cjs +0 -2553
  154. package/dist/browser-B1eMbDwh.js +0 -7468
  155. package/dist/bytes.vo-BB7_4JK6.js +0 -23
  156. package/dist/bytes.vo-BNRquqaO.cjs +0 -34
  157. package/dist/cardano-DfPwhwm-.js +0 -3
  158. package/dist/client-DXBLHk7K.cjs +0 -808
  159. package/dist/codecs-Cswkg7Tm.cjs +0 -4051
  160. package/dist/codecs-Dc1Krpbt.js +0 -3903
  161. package/dist/const-BhYOdznB.cjs +0 -42
  162. package/dist/const-BsnjG2_Q.cjs +0 -32071
  163. package/dist/const-CUnCl5U0.js +0 -13
  164. package/dist/const-D0CbQlo4.js +0 -154
  165. package/dist/contract-BD_312b0.js +0 -171
  166. package/dist/contract-DevBp9u8.cjs +0 -189
  167. package/dist/create-add-accounts-Brqk84vF.js +0 -102
  168. package/dist/create-add-accounts-DzXIh7Ot.cjs +0 -114
  169. package/dist/device-commitment-hex.vo-5wFtQvDS.js +0 -26
  170. package/dist/device-commitment-hex.vo-CT3RmAug.cjs +0 -31
  171. package/dist/device-readers-70i7tQqU.cjs +0 -8
  172. package/dist/device-readers-B7--ezKM.js +0 -4
  173. package/dist/device-readers-BWOmz9eD.js +0 -145
  174. package/dist/device-readers-CIgYZN7f.cjs +0 -168
  175. package/dist/dist-BMi5ZjEq.cjs +0 -43175
  176. package/dist/dist-BtIq4XFn.cjs +0 -535
  177. package/dist/dist-C3SHC_Ho.cjs +0 -1394
  178. package/dist/dist-CykEjYEX.cjs +0 -3814
  179. package/dist/dist-Dcsxh3be.cjs +0 -3452
  180. package/dist/dist-DqJfSlTd.cjs +0 -4413
  181. package/dist/dist-nTZ70qj7.cjs +0 -1306
  182. package/dist/enc-key-circuits-C8fGAMEF.cjs +0 -24
  183. package/dist/enc-key-circuits-DA2Xs3vZ.js +0 -13
  184. package/dist/english-Byb9M0E_.cjs +0 -2057
  185. package/dist/envelopes-BkH1Qdxk.js +0 -1620
  186. package/dist/envelopes-ETZEJS_O.cjs +0 -1721
  187. package/dist/errors-BZ8hnhCM.cjs +0 -584
  188. package/dist/errors-DIJTAsLa.js +0 -392
  189. package/dist/esm-HBSUQw3w.js +0 -384
  190. package/dist/esm-LZuaZjMf.cjs +0 -389
  191. package/dist/experimental.cjs +0 -7075
  192. package/dist/experimental.d.ts +0 -85525
  193. package/dist/experimental.js +0 -6917
  194. package/dist/gated-call-Boy6rXdC.js +0 -3
  195. package/dist/gated-call-DJWY299W.cjs +0 -736
  196. package/dist/gated-call-DjoRPqn1.js +0 -695
  197. package/dist/gated-call-SomdJ5nj.cjs +0 -4
  198. package/dist/grant-circuits-_1x--moV.cjs +0 -49
  199. package/dist/grant-circuits-swuzEdUl.js +0 -26
  200. package/dist/grant-rules-7Zqi_3BN.cjs +0 -7114
  201. package/dist/grant-rules-_xJHAT2M.js +0 -6833
  202. package/dist/grant-status-B2y49iIu.js +0 -2688
  203. package/dist/grant-status-DOr3t_u8.cjs +0 -2820
  204. package/dist/grants--b0LQQzZ.cjs +0 -266
  205. package/dist/grants-BIs6qm3b.js +0 -213
  206. package/dist/grants-CSgfYlOO.js +0 -5
  207. package/dist/grants-D61131nK.cjs +0 -17
  208. package/dist/hex-D9ITYbwt.cjs +0 -263
  209. package/dist/hex-mkXcV3pN.js +0 -191
  210. package/dist/http-client-B3N-TMxu.cjs +0 -167
  211. package/dist/http-client-TRlhDZGh.js +0 -155
  212. package/dist/identity-BMLuufva.cjs +0 -263
  213. package/dist/identity-DII6f-h7.js +0 -233
  214. package/dist/in-memory-wallet-integration-B2xzxORj.cjs +0 -20741
  215. package/dist/in-memory-wallet-integration-CBRiPjLO.js +0 -130
  216. package/dist/in-memory-wallet-integration-CULUB5Tf.cjs +0 -240
  217. package/dist/in-memory-wallet-integration-TM9bBphA.js +0 -20738
  218. package/dist/init-8v_n8boO.js +0 -1177
  219. package/dist/init-B5X_sGj9.cjs +0 -6
  220. package/dist/init-B8U3ABhS.cjs +0 -107
  221. package/dist/init-BJn-8_hf.js +0 -141
  222. package/dist/init-BmzfDaKL.js +0 -1142
  223. package/dist/init-BpHTq2R5.js +0 -105
  224. package/dist/init-BpSITBfF.js +0 -39
  225. package/dist/init-C00gw1zi.js +0 -422
  226. package/dist/init-CR7BfztQ.cjs +0 -18
  227. package/dist/init-Cp8EJGbm.js +0 -5
  228. package/dist/init-CuW7rHNA.js +0 -3584
  229. package/dist/init-Cz0rz5fU.cjs +0 -3585
  230. package/dist/init-D8OeObDF.cjs +0 -1141
  231. package/dist/init-D9g1HXYf.cjs +0 -40
  232. package/dist/init-DGjXwWs2.cjs +0 -143
  233. package/dist/init-DHrCbpkW.cjs +0 -121
  234. package/dist/init-DU5yYX5u.js +0 -2374
  235. package/dist/init-DlqJuHhl.js +0 -119
  236. package/dist/init-DrRdf5sZ.cjs +0 -1176
  237. package/dist/init-DuYENxci.js +0 -17
  238. package/dist/init-GsT2AEa4.cjs +0 -424
  239. package/dist/init-ZjNDDC-T.cjs +0 -2375
  240. package/dist/jubjub-authoriser-BxE3oN2y.js +0 -86
  241. package/dist/jubjub-authoriser-C6SDEP9I.cjs +0 -87
  242. package/dist/key-source-5oUBFiC7.cjs +0 -583
  243. package/dist/key-source-B08HukZg.js +0 -2550
  244. package/dist/keyDerivation-D3k9XyHg.js +0 -4077
  245. package/dist/keyDerivation-u0nBA93T.cjs +0 -274
  246. package/dist/lib--iqvW4O_.js +0 -2354
  247. package/dist/lib-Yk6Upl5D.cjs +0 -2359
  248. package/dist/midnight-account-id.vo-0x9X-r3l.cjs +0 -10
  249. package/dist/midnight-account-id.vo-DjCAGcqc.js +0 -5
  250. package/dist/midnight-engine-DpemplKO.js +0 -5
  251. package/dist/midnight-engine-xU1wotne.cjs +0 -6
  252. package/dist/midnight-wallet-DIsAlSn6.js +0 -18
  253. package/dist/midnight-wallet-XTZc2li7.cjs +0 -24
  254. package/dist/midnight.cjs +0 -1408
  255. package/dist/midnight.d.ts +0 -28934
  256. package/dist/midnight.js +0 -1352
  257. package/dist/modules-cardano-BrS68BbA.js +0 -995
  258. package/dist/modules-cardano-D843LvB0.cjs +0 -1108
  259. package/dist/node-relay-Cv0cNknM.js +0 -48
  260. package/dist/node-relay-DblH5fKv.cjs +0 -49
  261. package/dist/outputs-Bd2yZVjx.js +0 -720
  262. package/dist/outputs-CJoQBIA2.cjs +0 -990
  263. package/dist/pbkdf2-CIW-oWrm.cjs +0 -1337
  264. package/dist/pending-operation-B0_P78Jo.cjs +0 -26
  265. package/dist/pending-operation-BIS6mpjB.js +0 -21
  266. package/dist/providers-BLgJ0uQs.cjs +0 -366
  267. package/dist/providers-CwnT4vEE.js +0 -343
  268. package/dist/redacted-BmE2aXqr.js +0 -81
  269. package/dist/redacted-CRZJLS3w.cjs +0 -86
  270. package/dist/safe-buffer-B_vMqJWU.js +0 -43
  271. package/dist/safe-buffer-DYOwEfHB.cjs +0 -48
  272. package/dist/sdk-Dd0MKXFz.cjs +0 -1439
  273. package/dist/sdk-_yO75IHD.js +0 -1241
  274. package/dist/sdk-init-CYViTJY_.cjs +0 -3841
  275. package/dist/sdk-init-OMHyOGOK.js +0 -4138
  276. package/dist/send-proof-progress-C-ljq1x5.js +0 -30
  277. package/dist/send-proof-progress-vmsaSfbz.cjs +0 -47
  278. package/dist/side-effects-BnqYz7Nl.js +0 -768
  279. package/dist/side-effects-CngaeXi0.cjs +0 -804
  280. package/dist/sign-bitcoin-transaction-with-seed-D4z62-jV.js +0 -147
  281. package/dist/sign-bitcoin-transaction-with-seed-DsLYXnCY.cjs +0 -158
  282. package/dist/signer-3fk8lZtE.cjs +0 -7
  283. package/dist/signer-CsL28DrK.cjs +0 -121
  284. package/dist/signer-DGluibtn.js +0 -92
  285. package/dist/signer-RqB5pu3K.js +0 -2
  286. package/dist/signer-factory-BA7WFJVZ.js +0 -282
  287. package/dist/signer-factory-Cwd6o-lG.cjs +0 -281
  288. package/dist/signer-factory-DhZiE03y.cjs +0 -149
  289. package/dist/signer-factory-hzSRaIw2.js +0 -148
  290. package/dist/slice-BPNuHKfw.js +0 -9091
  291. package/dist/slice-CxKWDuBP.js +0 -87
  292. package/dist/slice-Czfp6t84.cjs +0 -436
  293. package/dist/slice-DnBWfA-k.cjs +0 -9109
  294. package/dist/slice-HjLXJyQG2.cjs +0 -105
  295. package/dist/slice-oWnc7YVD.js +0 -412
  296. package/dist/src-BDzYIksE.cjs +0 -20637
  297. package/dist/src-BFoefPv_.js +0 -20755
  298. package/dist/store-B1Lq3cEf.cjs +0 -66
  299. package/dist/store-DuBG8qh5.js +0 -37
  300. package/dist/submit-BBYjnZu8.cjs +0 -87
  301. package/dist/submit-D_yxYM_T.js +0 -70
  302. package/dist/submit-bitcoin-tx-BG3Gemov.js +0 -983
  303. package/dist/submit-bitcoin-tx-Y0CtvFN7.cjs +0 -1049
  304. package/dist/token-id-mapper-Bnds3xKH.cjs +0 -18
  305. package/dist/token-id-mapper-CnKHQ8DV.js +0 -16
  306. package/dist/tokens-Cevp7rdU.cjs +0 -62
  307. package/dist/tokens-Diw4MLRM.js +0 -44
  308. package/dist/types-B8uiJn-X.js +0 -12
  309. package/dist/types-CJT6XF2c.js +0 -10
  310. package/dist/types-CLRUYpfe.cjs +0 -23
  311. package/dist/types-DWbVZpnF.cjs +0 -15
  312. package/dist/types-T0cjaR75.js +0 -33
  313. package/dist/types-Zj78LtYu.cjs +0 -50
  314. package/dist/unwrap-provider-result-BZSiwabU.js +0 -32
  315. package/dist/unwrap-provider-result-ZqfBsTkk.cjs +0 -39
  316. package/dist/utils-DFwzEvbv.js +0 -65
  317. package/dist/utils-IXxR-Djh.cjs +0 -112
  318. package/dist/v8Signatures-CO_Uloy7.cjs +0 -71
  319. package/dist/watch-D-RoItM5.js +0 -21997
  320. package/dist/watch-DMF2s-II.cjs +0 -52281
  321. /package/dist/{account-id.vo-DwqFjK5u.cjs → account-id.vo-LvCBVn5r.cjs} +0 -0
  322. /package/dist/{account-id.vo-OPz2v-JZ.js → account-id.vo-MYSI7YFm.js} +0 -0
  323. /package/dist/{actions-iLXdgL5Y.js → actions-9QSQR-GB.js} +0 -0
  324. /package/dist/{actions-B2BJ4RTy.cjs → actions-DdGbj7c7.cjs} +0 -0
  325. /package/dist/{apply-vkey-witnesses-ZnFS0jnJ.cjs → apply-vkey-witnesses-CLzVSWxl.cjs} +0 -0
  326. /package/dist/{apply-vkey-witnesses-BKx3lcs0.js → apply-vkey-witnesses-ClZbpk5w.js} +0 -0
  327. /package/dist/{asyncoption-CruEYOBI.js → asyncoption-Cw07zPH7.js} +0 -0
  328. /package/dist/{asyncoption-i0VbqVTq.cjs → asyncoption-DYoGuQfP.cjs} +0 -0
  329. /package/dist/{bignum.vo-CEXOIew0.js → bignum.vo-B0rK_PQ1.js} +0 -0
  330. /package/dist/{bignum.vo-hx2kuqlA.cjs → bignum.vo-DsG3kNiZ.cjs} +0 -0
  331. /package/dist/{bip32ed25519-B7Yat217.cjs → bip32ed25519-1ApqeAZk.cjs} +0 -0
  332. /package/dist/{bip32ed25519-FQ8qvdcq.js → bip32ed25519-DetAdGwD.js} +0 -0
  333. /package/dist/{blake2b-DEeVUdKR.cjs → blake2b-B9tftbvG.cjs} +0 -0
  334. /package/dist/{blake2b-BiQTw3GC.js → blake2b-DOEVc57D.js} +0 -0
  335. /package/dist/{blockchain-network-id.vo-BAKEwGjG.cjs → blockchain-network-id.vo-BXpZhvvQ.cjs} +0 -0
  336. /package/dist/{blockchain-network-id.vo-CiVykuqG.js → blockchain-network-id.vo-DNRkuT5B.js} +0 -0
  337. /package/dist/{blockingWithLatestFrom-Cd8c8EPG.js → blockingWithLatestFrom-C5wp_uA-.js} +0 -0
  338. /package/dist/{blockingWithLatestFrom-D8kBPBMX.cjs → blockingWithLatestFrom-DY8OPg0w.cjs} +0 -0
  339. /package/dist/{cardano-network-id-to-network-type-C0ufJOyE.cjs → cardano-network-id-to-network-type-BDTF-HmK.cjs} +0 -0
  340. /package/dist/{cardano-network-id-to-network-type-BWwzeEtM.js → cardano-network-id-to-network-type-CrZfUcyP.js} +0 -0
  341. /package/dist/{cardano-tx-id.vo-TLjJZHCI.cjs → cardano-tx-id.vo-BPhV-AmZ.cjs} +0 -0
  342. /package/dist/{cardano-tx-id.vo-eVnKuzlm.js → cardano-tx-id.vo-DF9NzZXk.js} +0 -0
  343. /package/dist/{composite-signer-factory-m5cVs9h_.cjs → composite-signer-factory-BpF1mIYA.cjs} +0 -0
  344. /package/dist/{composite-signer-factory-CR8YHA1y.js → composite-signer-factory-_46QsNBz.js} +0 -0
  345. /package/dist/{error-DIZOY2Lw.js → error-BCp9NkPi.js} +0 -0
  346. /package/dist/{error-Cb3EnD0u.cjs → error-CNIquqT5.cjs} +0 -0
  347. /package/dist/{esm-browser-MG97cre9.js → esm-browser-C93Q-EOI.js} +0 -0
  348. /package/dist/{esm-browser-bweqfBlL.cjs → esm-browser-DTc9IK3D.cjs} +0 -0
  349. /package/dist/{feature-flag-key.vo-RlfHL3hq.cjs → feature-flag-key.vo-BPz-ZAp6.cjs} +0 -0
  350. /package/dist/{feature-flag-key.vo-DN_-4-sG.js → feature-flag-key.vo-ofrB6ZVQ.js} +0 -0
  351. /package/dist/{first-state-of-status-unPynOuM.js → first-state-of-status-DQnMT3ya.js} +0 -0
  352. /package/dist/{first-state-of-status-CbT7hPa4.cjs → first-state-of-status-OROkXcRv.cjs} +0 -0
  353. /package/dist/{init-zUoRG_EC2.cjs → init-C5CEZ1m0.cjs} +0 -0
  354. /package/dist/{init-DHaMxHM1.js → init-CKipPE_c.js} +0 -0
  355. /package/dist/{init-Atisw4x2.cjs → init-DFQQ9dTW.cjs} +0 -0
  356. /package/dist/{init-829HRYcz.js → init-Es3wHW7D.js} +0 -0
  357. /package/dist/{init-BgNobbNq.cjs → init-IAk_CkGa.cjs} +0 -0
  358. /package/dist/{init-atCFur0v.js → init-cqN3uX2j.js} +0 -0
  359. /package/dist/{is-redux-persist-state-BCFnSm36.cjs → is-redux-persist-state-CTn3WZVh.cjs} +0 -0
  360. /package/dist/{is-redux-persist-state-yBfq0h_E.js → is-redux-persist-state-Cxcd0_bM.js} +0 -0
  361. /package/dist/{key-value-store--W3SrMaw.js → key-value-store-8cMzeNyG.js} +0 -0
  362. /package/dist/{key-value-store-C2Xt5Emp.cjs → key-value-store-DUAepXQf.cjs} +0 -0
  363. /package/dist/{repo-slice-RxFm0zDZ.js → repo-slice-DwyMhCR1.js} +0 -0
  364. /package/dist/{repo-slice-7X4AYYVm.cjs → repo-slice-WxetRhMY.cjs} +0 -0
  365. /package/dist/{reselect-CGoLzEPv.js → reselect-C06X06oX.js} +0 -0
  366. /package/dist/{reselect-Bd94u0K-.cjs → reselect-CRDqmQY9.cjs} +0 -0
  367. /package/dist/{serializable-BHdKIgk3.js → serializable-B8GahgE1.js} +0 -0
  368. /package/dist/{serializable-BxHkoPdk.cjs → serializable-CRdnFaLZ.cjs} +0 -0
  369. /package/dist/{slice-obCSLm1x.js → slice-B87b52iM.js} +0 -0
  370. /package/dist/{slice-Bk0Sv05J.js → slice-Be7hj4Iy.js} +0 -0
  371. /package/dist/{slice-BiRsDKOK.cjs → slice-D11FHQuQ.cjs} +0 -0
  372. /package/dist/{slice-Dqw1ecum.cjs → slice-FioKeHtA.cjs} +0 -0
  373. /package/dist/{src-Cqp0B2M_.cjs → src-BTPIvlDI.cjs} +0 -0
  374. /package/dist/{src-BlxEp6Mm.js → src-vq1wS9sZ.js} +0 -0
  375. /package/dist/{time.vo-D3wWRw9L.cjs → time.vo-CQ8pSXz2.cjs} +0 -0
  376. /package/dist/{time.vo-tNheinXm.js → time.vo-DkYYGYp6.js} +0 -0
  377. /package/dist/{toEmpty-8Zax1MPd.js → toEmpty-CgAl3097.js} +0 -0
  378. /package/dist/{toEmpty-CYAbupM4.cjs → toEmpty-DAMmNB5r.cjs} +0 -0
  379. /package/dist/{token-id.vo-DXv5uS9n.cjs → token-id.vo-BxG9TG0O.cjs} +0 -0
  380. /package/dist/{token-id.vo-Bvwhr3ZE.js → token-id.vo-ClsroxHO.js} +0 -0
  381. /package/dist/{util-CzeB3hfa.cjs → util-CmdAhheh.cjs} +0 -0
  382. /package/dist/{util-C8a4fA9p.js → util-DxzlYNS5.js} +0 -0
  383. /package/dist/{util-selector-BWPH68_l.cjs → util-selector-BcAncU4L.cjs} +0 -0
  384. /package/dist/{util-selector-BSTsxgne.js → util-selector-CcK-GAdE.js} +0 -0
  385. /package/dist/{while-active-B0lWy_6l.js → while-active-BpppWuCs.js} +0 -0
  386. /package/dist/{while-active-Dsowp0Fi.cjs → while-active-Dhc2LwOm.cjs} +0 -0
@@ -1,1049 +0,0 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-Br2OG8yv.cjs");
2
- const require__polyfill_buffer_patch = require("./_polyfill-buffer-patch-CM8X7JiY.cjs");
3
- const require_address = require("./address-BXp-mY8H.cjs");
4
- const require_src$2 = require("./src-BDzYIksE.cjs");
5
- const require_bytes_vo = require("./bytes.vo-BNRquqaO.cjs");
6
- const require_sdk = require("./sdk-Dd0MKXFz.cjs");
7
- const require_asyncoption = require("./asyncoption-i0VbqVTq.cjs");
8
- const require_store = require("./store-B1Lq3cEf.cjs");
9
- const require_activity_type = require("./activity-type-Ch6ljxBy.cjs");
10
- const require_composite_signer_factory = require("./composite-signer-factory-m5cVs9h_.cjs");
11
- const require_types = require("./types-DWbVZpnF.cjs");
12
- const require_contract = require("./contract-DevBp9u8.cjs");
13
- const require_types$1 = require("./types-CLRUYpfe.cjs");
14
- const require_const = require("./const-BhYOdznB.cjs");
15
- const require_keyDerivation = require("./keyDerivation-u0nBA93T.cjs");
16
- const require_side_effects = require("./side-effects-CngaeXi0.cjs");
17
- const require_sign_bitcoin_transaction_with_seed = require("./sign-bitcoin-transaction-with-seed-DsLYXnCY.cjs");
18
- let rxjs = require("rxjs");
19
- let lodash_isEqual = require("lodash/isEqual.js");
20
- lodash_isEqual = require_rolldown_runtime.__toESM(lodash_isEqual);
21
- //#region ../../packages/contract/bitcoin-context/src/contract.ts
22
- const bitcoinProviderContract = require_store.inferContractContext({
23
- name: require_sdk.ContractName("bitcoin-provider"),
24
- instance: "exactly-one",
25
- contractType: "sideEffectDependency"
26
- });
27
- const bitcoinFeeMarketProvider = require_store.inferContractContext({
28
- name: require_sdk.ContractName("bitcoin-fee-market-provider"),
29
- instance: "exactly-one",
30
- contractType: "sideEffectDependency"
31
- });
32
- //#endregion
33
- //#region ../../packages/contract/bitcoin-context/src/fee-rate.ts
34
- const SATOSHIS_PER_BITCOIN = 1e8;
35
- const BYTES_PER_KILOBYTE = 1e3;
36
- /**
37
- * Upper bound for a caller-supplied fee rate, in sat/vB. Far above any real
38
- * mempool spike, so it catches a unit mix-up (a BTC/kB figure arriving where
39
- * sat/vB is expected, or a stray exponent) without refusing an urgent send.
40
- */
41
- const MAX_FEE_RATE_SATS_PER_VBYTE = 1e4;
42
- /**
43
- * Converts a fee rate given in sat/vB — the unit dApp APIs and the fee input
44
- * speak — into the BTC-per-kilobyte rate that
45
- * `BitcoinBlockchainSpecificTxData.feeRate.customFeeRate` carries.
46
- *
47
- * Returns `undefined` for a rate that must not be built against: not a finite
48
- * number, not positive, or above {@link MAX_FEE_RATE_SATS_PER_VBYTE}. Callers
49
- * are expected to refuse the request rather than substitute a default — a
50
- * zero rate yields a transaction no node relays, and an unconverted sat/vB
51
- * figure overpays by five orders of magnitude.
52
- */
53
- const feeRateFromSatsPerVByte = (satsPerVByte) => Number.isFinite(satsPerVByte) && satsPerVByte > 0 && satsPerVByte <= MAX_FEE_RATE_SATS_PER_VBYTE ? satsPerVByte * BYTES_PER_KILOBYTE / SATOSHIS_PER_BITCOIN : void 0;
54
- //#endregion
55
- //#region ../../packages/module/blockchain-bitcoin/src/store/index.ts
56
- var store_default$2 = require_store.inferStoreContext({
57
- load: async () => Promise.resolve().then(() => require("./init-CR7BfztQ.cjs")),
58
- context: {
59
- actions: require_side_effects.bitcoinContextActions,
60
- selectors: require_side_effects.bitcoinContextSelectors
61
- }
62
- });
63
- //#endregion
64
- //#region ../../packages/module/blockchain-bitcoin/src/input-selection/GreedyInputSelector.ts
65
- /**
66
- * A concrete implementation of InputSelector that uses a simple greedy algorithm.
67
- */
68
- var GreedyInputSelector = class {
69
- selectInputs(props) {
70
- const { changeAddress, utxos, outputs, feeRate, hasOpReturn } = props;
71
- const selected = [];
72
- const totalOutput = outputs.reduce((accumulator, output) => accumulator + output.value, 0);
73
- let inputSum = 0;
74
- let fee = 0;
75
- for (const utxo of utxos) {
76
- selected.push(utxo);
77
- inputSum += utxo.satoshis;
78
- fee = this.computeFee({
79
- inputCount: selected.length,
80
- outputCount: outputs.length,
81
- feeRate,
82
- hasOpReturn
83
- });
84
- if (inputSum >= totalOutput + fee) break;
85
- }
86
- if (inputSum < totalOutput + fee) return null;
87
- let change = inputSum - totalOutput - fee;
88
- if (change > 0 && change < 546) {
89
- const { change: newChange, fee: feeDelta } = this.attemptDustRescue({
90
- change,
91
- feeRate,
92
- selected,
93
- remaining: utxos.slice(selected.length),
94
- inputSum,
95
- totalOutput,
96
- outputsCount: outputs.length,
97
- hasOpReturn
98
- });
99
- change = newChange;
100
- fee += feeDelta;
101
- if (change < 546) {
102
- fee += change;
103
- change = 0;
104
- }
105
- }
106
- const finalOutputs = outputs.map(({ address, value }) => ({
107
- address,
108
- value
109
- }));
110
- if (change >= 546) finalOutputs.push({
111
- address: changeAddress,
112
- value: change
113
- });
114
- return {
115
- selectedUTxOs: selected,
116
- outputs: finalOutputs,
117
- fee
118
- };
119
- }
120
- /** Estimate the fee for a given input / output count */
121
- computeFee(params) {
122
- const { inputCount, outputCount, feeRate, hasOpReturn } = params;
123
- const size = inputCount * 68 + (outputCount + (hasOpReturn ? 1 : 0)) * 31 + 10;
124
- return Math.ceil(size * feeRate);
125
- }
126
- /**
127
- * Try to pull one more UTxO so that change exceeds the dust threshold if
128
- * the value rescued is worth more than the added fee.
129
- */
130
- attemptDustRescue({ change, feeRate, selected, remaining, inputSum, totalOutput, outputsCount, hasOpReturn }) {
131
- if (change === 0 || change >= 546) return {
132
- change,
133
- fee: 0
134
- };
135
- const originalChange = change;
136
- let feeDelta = 0;
137
- for (const utxo of remaining) {
138
- const newInputSum = inputSum + utxo.satoshis;
139
- const newFee = this.computeFee({
140
- inputCount: selected.length + 1,
141
- outputCount: outputsCount + 1,
142
- feeRate,
143
- hasOpReturn
144
- });
145
- const newChange = newInputSum - totalOutput - newFee;
146
- if (newChange - originalChange >= Math.ceil(68 * feeRate) && newChange >= 546) {
147
- selected.push(utxo);
148
- feeDelta = newFee - this.computeFee({
149
- inputCount: selected.length - 1,
150
- outputCount: outputsCount + 1,
151
- feeRate,
152
- hasOpReturn
153
- });
154
- return {
155
- change: newChange,
156
- fee: feeDelta
157
- };
158
- }
159
- }
160
- return {
161
- change,
162
- fee: 0
163
- };
164
- }
165
- };
166
- //#endregion
167
- //#region ../../packages/module/blockchain-bitcoin/src/tx-builder/errors.ts
168
- /**
169
- * The reason a Bitcoin payment cannot be built.
170
- */
171
- let BitcoinTxBuildErrorCode = /* @__PURE__ */ function(BitcoinTxBuildErrorCode) {
172
- /** The funding UTxO set is empty (e.g. the only UTxO is spent by a pending tx). */
173
- BitcoinTxBuildErrorCode["NoUtxos"] = "NoUtxos";
174
- /** UTxOs exist but cannot cover the requested amount plus the network fee. */
175
- BitcoinTxBuildErrorCode["InsufficientFunds"] = "InsufficientFunds";
176
- /** No transaction outputs were provided. */
177
- BitcoinTxBuildErrorCode["NoOutputs"] = "NoOutputs";
178
- /** Change address was never set (internal invariant). */
179
- BitcoinTxBuildErrorCode["ChangeAddressNotSet"] = "ChangeAddressNotSet";
180
- /** The change address failed validation. */
181
- BitcoinTxBuildErrorCode["InvalidChangeAddress"] = "InvalidChangeAddress";
182
- /** A recipient address failed validation. */
183
- BitcoinTxBuildErrorCode["InvalidRecipientAddress"] = "InvalidRecipientAddress";
184
- /** A selected UTxO's address could not be matched to a known signing address. */
185
- BitcoinTxBuildErrorCode["UnresolvedUtxoAddress"] = "UnresolvedUtxoAddress";
186
- /** The OP_RETURN message exceeds the 80-byte limit. */
187
- BitcoinTxBuildErrorCode["MessageTooLong"] = "MessageTooLong";
188
- /** The resolved fee rate is not a positive number, so the tx would pay no fee. */
189
- BitcoinTxBuildErrorCode["InvalidFeeRate"] = "InvalidFeeRate";
190
- return BitcoinTxBuildErrorCode;
191
- }({});
192
- /**
193
- * The error a Bitcoin payment build fails with, identified by its `code`.
194
- */
195
- var BitcoinTxBuildError = class extends Error {
196
- /** The reason the payment cannot be built. */
197
- code;
198
- constructor(code, message) {
199
- super(message);
200
- this.name = "BitcoinTxBuildError";
201
- this.code = code;
202
- }
203
- };
204
- BitcoinTxBuildErrorCode.NoUtxos, BitcoinTxBuildErrorCode.InsufficientFunds, BitcoinTxBuildErrorCode.NoOutputs, BitcoinTxBuildErrorCode.ChangeAddressNotSet, BitcoinTxBuildErrorCode.InvalidChangeAddress, BitcoinTxBuildErrorCode.InvalidRecipientAddress, BitcoinTxBuildErrorCode.UnresolvedUtxoAddress, BitcoinTxBuildErrorCode.MessageTooLong, BitcoinTxBuildErrorCode.InvalidFeeRate;
205
- //#endregion
206
- //#region ../../packages/module/blockchain-bitcoin/src/tx-builder/TransactionBuilder.ts
207
- require__polyfill_buffer_patch.init__polyfill_buffer_patch();
208
- var import_src$1 = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_address.require_src());
209
- /**
210
- * A class to build Bitcoin transactions using a flexible input and output management system.
211
- */
212
- var TransactionBuilder = class {
213
- psbt;
214
- network;
215
- feeRate;
216
- knownAddresses;
217
- outputs = [];
218
- utxos = [];
219
- changeAddress;
220
- changeDerivation;
221
- changeMasterFingerprint;
222
- signers = [];
223
- inputSelector = new GreedyInputSelector();
224
- opReturnData;
225
- /**
226
- * Initializes the transaction builder.
227
- *
228
- * @param network - The Bitcoin network (Mainnet or Testnet).
229
- * @param feeRate - The fee rate in BTC per kilobyte.
230
- * @param knownAddresses - The list of known addresses with their public keys.
231
- */
232
- constructor(network, feeRate, knownAddresses) {
233
- this.feeRate = feeRate;
234
- this.knownAddresses = knownAddresses;
235
- this.network = network;
236
- this.psbt = new import_src$1.Psbt({ network: network === require_types$1.BitcoinNetwork.Mainnet ? import_src$1.networks.bitcoin : import_src$1.networks.testnet });
237
- }
238
- /**
239
- * Sets the UTXO set that will be used to fund the transaction.
240
- *
241
- * @param utxos - Array of available UTXOs.
242
- * @returns The builder instance for chaining.
243
- */
244
- setUtxoSet(utxos) {
245
- this.utxos = utxos;
246
- return this;
247
- }
248
- /**
249
- * Sets the change address where any remaining funds will be sent.
250
- *
251
- * @param changeAddress - The change address.
252
- * @returns The builder instance for chaining.
253
- */
254
- setChangeAddress(changeAddress) {
255
- if (require_address.validateBitcoinAddress(changeAddress, this.network) !== require_address.AddressValidationResult.Valid) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.InvalidChangeAddress, "Invalid change address");
256
- this.changeAddress = changeAddress;
257
- return this;
258
- }
259
- /**
260
- * Sets the change address together with its derivation and the account master
261
- * fingerprint, so the change output can be stamped with a BIP-32 key-origin an
262
- * air-gapped device uses to recognize change. When the master fingerprint is
263
- * absent (in-memory accounts) no key-origin is stamped.
264
- *
265
- * @param changeDerivation - The change address and its derivation path/pubkey.
266
- * @param masterFingerprint - Device xfp as 8-char hex, or undefined.
267
- * @returns The builder instance for chaining.
268
- */
269
- setChange(changeDerivation, masterFingerprint) {
270
- this.setChangeAddress(changeDerivation.address);
271
- this.changeDerivation = changeDerivation;
272
- this.changeMasterFingerprint = masterFingerprint;
273
- return this;
274
- }
275
- /**
276
- * Sets the input selection strategy.
277
- *
278
- * @param inputSelector - An implementation of the InputSelector interface.
279
- * @returns The builder instance for chaining.
280
- */
281
- setInputSelection(inputSelector) {
282
- this.inputSelector = inputSelector;
283
- return this;
284
- }
285
- /**
286
- * Adds an output to the transaction.
287
- *
288
- * @param address - The destination address.
289
- * @param value - The amount to send (in satoshis as bigint).
290
- * @returns The builder instance for chaining.
291
- */
292
- addOutput(address, value) {
293
- if (require_address.validateBitcoinAddress(address, this.network) !== require_address.AddressValidationResult.Valid) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.InvalidRecipientAddress, "Invalid recipient address");
294
- this.outputs.push({
295
- address,
296
- value
297
- });
298
- return this;
299
- }
300
- /**
301
- * Adds an OP_RETURN message to the transaction.
302
- *
303
- * @param message - The message to embed (string, UTF-8). Max 80 bytes after encoding.
304
- * If null, removes any existing OP_RETURN data.
305
- * @returns The builder instance for chaining.
306
- */
307
- addOpReturnOutput(message) {
308
- if (!message?.trim()) {
309
- this.opReturnData = void 0;
310
- return this;
311
- }
312
- const data = require__polyfill_buffer_patch.import_buffer.Buffer.from(message, "utf8");
313
- if (data.length > 80) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.MessageTooLong, `OP_RETURN message exceeds 80 bytes (actual: ${data.length}).`);
314
- this.opReturnData = data;
315
- return this;
316
- }
317
- /**
318
- * Builds the transaction by selecting UTXOs (using either the provided input selector or a fallback),
319
- * adding inputs and outputs (including a change output if needed), and calculating fees.
320
- * If the change amount is below the dust threshold, it is added to the fee instead.
321
- *
322
- * @returns An UnsignedTransaction containing the PSBT context, fee, estimated virtual bytes, signers, and outputs.
323
- * @throws Error if funds are insufficient, no UTXOs are set, or if the change address is not provided.
324
- */
325
- build() {
326
- if (!this.utxos || this.utxos.length === 0) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.NoUtxos, "No UTXOs available to fund the transaction.");
327
- if (!this.changeAddress) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.ChangeAddressNotSet, "Change address not set.");
328
- if (this.outputs.length === 0) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.NoOutputs, "No outputs have been added.");
329
- const feeRateSatoshis = this.feeRate * 1e8 / 1e3;
330
- let selectedUTxOs = [];
331
- let fee = 0;
332
- let coinselectOutputs = [];
333
- const result = this.inputSelector.selectInputs({
334
- changeAddress: this.changeAddress,
335
- utxos: this.utxos,
336
- outputs: this.outputs,
337
- feeRate: feeRateSatoshis,
338
- hasOpReturn: !!this.opReturnData
339
- });
340
- if (!result) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.InsufficientFunds, "Insufficient funds or coin selection failed.");
341
- selectedUTxOs = result.selectedUTxOs;
342
- fee = result.fee;
343
- coinselectOutputs = result.outputs;
344
- for (const utxo of selectedUTxOs) {
345
- const knownAddr = this.knownAddresses.find((addr) => addr.address === utxo.address);
346
- if (!knownAddr) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.UnresolvedUtxoAddress, "Unknown address in UTXO set.");
347
- this.signers.push(knownAddr);
348
- const net = this.network === require_types$1.BitcoinNetwork.Mainnet ? import_src$1.networks.bitcoin : import_src$1.networks.testnet;
349
- this.psbt.addInput({
350
- hash: utxo.txId,
351
- index: utxo.index,
352
- witnessUtxo: {
353
- script: import_src$1.payments.p2wpkh({
354
- pubkey: require__polyfill_buffer_patch.import_buffer.Buffer.from(knownAddr.publicKeyHex, "hex"),
355
- network: net
356
- }).output,
357
- value: utxo.satoshis
358
- }
359
- });
360
- }
361
- coinselectOutputs.forEach(({ address, value }) => {
362
- if (require_address.isP2trAddress(address)) {
363
- const taprootPubKey = require__polyfill_buffer_patch.import_buffer.Buffer.from(import_src$1.address.fromBech32(address).data);
364
- this.psbt.addOutput({
365
- script: import_src$1.script.compile([import_src$1.opcodes.OP_1, taprootPubKey]),
366
- value
367
- });
368
- } else this.psbt.addOutput({
369
- address,
370
- value
371
- });
372
- });
373
- if (this.opReturnData) {
374
- const embed = import_src$1.payments.embed({ data: [this.opReturnData] });
375
- this.psbt.addOutput({
376
- script: embed.output,
377
- value: 0
378
- });
379
- }
380
- this.stampChangeOutput(coinselectOutputs);
381
- const opReturnOutput = this.opReturnData ? 1 : 0;
382
- const vBytes = selectedUTxOs.length * 68 + (coinselectOutputs.length + opReturnOutput) * 31 + 10;
383
- return {
384
- context: this.psbt,
385
- toAddress: this.outputs[0].address,
386
- fee,
387
- amount: this.outputs[0].value,
388
- vBytes,
389
- signers: this.signers
390
- };
391
- }
392
- /**
393
- * Stamps the change output with a BIP-32 key-origin (master fingerprint +
394
- * change pubkey + full derivation path) so an air-gapped device recognizes it
395
- * as the wallet's own change instead of a third-party spend. No-ops unless a
396
- * change output is present, its derivation was provided via setChange, and a
397
- * master fingerprint is known (in-memory accounts skip stamping, leaving the
398
- * PSBT byte-identical for that path).
399
- *
400
- * @param finalOutputs - The outputs selected by coin selection, in PSBT order.
401
- */
402
- stampChangeOutput(finalOutputs) {
403
- const { changeDerivation, changeMasterFingerprint } = this;
404
- if (!changeDerivation || !changeMasterFingerprint) return;
405
- const changeOutputIndex = finalOutputs.findLastIndex((output) => output.address === changeDerivation.address);
406
- if (changeOutputIndex === -1) return;
407
- this.psbt.updateOutput(changeOutputIndex, { bip32Derivation: [{
408
- masterFingerprint: require__polyfill_buffer_patch.import_buffer.Buffer.from(changeMasterFingerprint, "hex"),
409
- pubkey: require__polyfill_buffer_patch.import_buffer.Buffer.from(changeDerivation.publicKeyHex, "hex"),
410
- path: require_keyDerivation.bitcoinFullDerivationPath({
411
- addressType: changeDerivation.addressType,
412
- network: this.network,
413
- account: changeDerivation.account,
414
- chain: changeDerivation.chain,
415
- index: changeDerivation.index
416
- })
417
- }] });
418
- }
419
- };
420
- //#endregion
421
- //#region ../../packages/module/blockchain-bitcoin/src/tx-builder/build-bitcoin-payment.ts
422
- require__polyfill_buffer_patch.init__polyfill_buffer_patch();
423
- const getBitcoinInFlight = (activity) => {
424
- if (activity.type !== require_activity_type.ActivityType.Pending) return void 0;
425
- return activity.blockchainSpecific?.Bitcoin;
426
- };
427
- const outpointKey = (ref) => `${ref.txId}#${ref.index}`;
428
- /**
429
- * Drops the outpoints consumed by pending transactions from the spendable set.
430
- * Unconfirmed outputs produced by those transactions are not added: spending
431
- * unconfirmed Bitcoin outputs is unsafe under RBF and bounded by mempool
432
- * ancestor limits.
433
- *
434
- * @param utxos - The confirmed UTxOs of the account.
435
- * @param _accountAddresses - The addresses of the account.
436
- * @param pendingActivities - The pending activities of the account.
437
- */
438
- const applyInFlightUtxoAdjustments = (utxos, _accountAddresses, pendingActivities) => {
439
- const spent = /* @__PURE__ */ new Set();
440
- for (const activity of pendingActivities) {
441
- const inFlight = getBitcoinInFlight(activity);
442
- if (!inFlight) continue;
443
- for (const input of inFlight.consumedInputs) spent.add(outpointKey(input));
444
- }
445
- if (spent.size === 0) return [...utxos];
446
- return utxos.filter((utxo) => !spent.has(outpointKey(utxo)));
447
- };
448
- /**
449
- * Resolves the rate to build against, in BTC per kilobyte.
450
- *
451
- * The market is read ONLY for the three quoted tiers. `Custom` is a rate the
452
- * user typed and must stay buildable while mempool.space is unreachable, so
453
- * the fetch must not be hoisted above that branch, or an unreachable market
454
- * fails every Bitcoin build. A tier build still fails when the market cannot
455
- * be read.
456
- *
457
- * @param feeRate - The chosen option, plus the typed rate when it is `Custom`.
458
- * @param getCurrentFeeMarket - Fetches the market; called only for a tier.
459
- */
460
- const resolveFeeRate = async (feeRate, getCurrentFeeMarket) => {
461
- if (feeRate.feeOption === "Custom") return feeRate.customFeeRate ?? 0;
462
- const market = (await (0, rxjs.firstValueFrom)(getCurrentFeeMarket())).unwrap();
463
- switch (feeRate.feeOption) {
464
- case "Fast": return market.fast.feeRate;
465
- case "Average": return market.standard.feeRate;
466
- case "Low": return market.slow.feeRate;
467
- }
468
- };
469
- /**
470
- * Embeds each input's full previous transaction (nonWitnessUtxo) into the
471
- * PSBT so it is self-contained for hardware signers: Ledger requires the
472
- * previous transaction for segwit-v0 inputs and Trezor consumes it as refTxs.
473
- * Duplicate previous transactions are fetched only once and all fetches run
474
- * concurrently. Each fetched transaction is verified to hash to the requested
475
- * txid so a wrong provider response fails the build locally instead of as an
476
- * opaque device-side rejection. Throws if any fetch fails, failing the build
477
- * instead of producing a PSBT a device would reject.
478
- *
479
- * @param psbt - The freshly built PSBT whose inputs carry only witnessUtxo.
480
- * @param getRawTransaction - Fetches the raw transaction hex for a tx id.
481
- */
482
- const embedPreviousTransactions = async (psbt, getRawTransaction) => {
483
- const inputTxIds = psbt.txInputs.map((input) => require__polyfill_buffer_patch.import_buffer.Buffer.from(input.hash).reverse().toString("hex"));
484
- const uniqueTxIds = [...new Set(inputTxIds)];
485
- if (uniqueTxIds.length === 0) return;
486
- const rawTxResults = await (0, rxjs.firstValueFrom)((0, rxjs.forkJoin)(uniqueTxIds.map((txId) => getRawTransaction(txId))));
487
- const rawTxByTxId = /* @__PURE__ */ new Map();
488
- uniqueTxIds.forEach((txId, index) => {
489
- const rawTx = require__polyfill_buffer_patch.import_buffer.Buffer.from(rawTxResults[index].unwrap(), "hex");
490
- if (import_src$1.Transaction.fromBuffer(rawTx).getId() !== txId) throw new Error(`Fetched previous transaction does not match requested txid ${txId}`);
491
- rawTxByTxId.set(txId, rawTx);
492
- });
493
- inputTxIds.forEach((txId, index) => {
494
- psbt.updateInput(index, { nonWitnessUtxo: rawTxByTxId.get(txId) });
495
- });
496
- };
497
- /**
498
- * Builds an unsigned Bitcoin payment from the account wallet's current UTxOs
499
- * and addresses. Outpoints consumed by pending activities are not spent
500
- * again, change goes to the wallet address, and hardware accounts (those with
501
- * a master fingerprint) get each input's previous transaction embedded.
502
- *
503
- * @param params - The wallet, pending activities, recipients, fee option and memo.
504
- * @returns The serialized unsigned transaction and the fee it pays.
505
- * @throws {@link BitcoinTxBuildError} when the payment cannot be built, for example
506
- * when the fee rate is not positive or the funds do not cover it.
507
- */
508
- const buildBitcoinPayment = async ({ wallet, pendingActivities, outputs, feeRate, memo, logger }) => {
509
- const network = wallet.network;
510
- const utxos = await (0, rxjs.firstValueFrom)(wallet.utxos$);
511
- const addresses = await (0, rxjs.firstValueFrom)(wallet.addresses$);
512
- const rateToUse = await resolveFeeRate(feeRate, () => wallet.getCurrentFeeMarket());
513
- if (!Number.isFinite(rateToUse) || rateToUse <= 0) throw new BitcoinTxBuildError(BitcoinTxBuildErrorCode.InvalidFeeRate, `Invalid fee rate: ${rateToUse}`);
514
- logger?.debug(`Bitcoin buildTx: Using fee rate of ${rateToUse} BTC/kB`);
515
- const txBuilder = new TransactionBuilder(network, rateToUse, addresses);
516
- const adjustedUtxos = applyInFlightUtxoAdjustments(utxos, new Set(addresses.map((a) => a.address)), pendingActivities);
517
- txBuilder.setChange(wallet.address, wallet.masterFingerprint).setUtxoSet(adjustedUtxos);
518
- for (const output of outputs) {
519
- txBuilder.addOutput(output.address, output.amount);
520
- logger?.debug(`Bitcoin buildTx: Adding output to address: ${output.address} with amount from txParams: ${output.amount}`);
521
- }
522
- if (memo) {
523
- logger?.debug(`Bitcoin buildTx: Adding OP_RETURN memo: ${memo}`);
524
- txBuilder.addOpReturnOutput(memo);
525
- }
526
- const tx = txBuilder.build();
527
- tx.network = network;
528
- if (wallet.masterFingerprint) await embedPreviousTransactions(tx.context, (txId) => wallet.getRawTransaction(txId));
529
- return {
530
- serializedTx: require_sign_bitcoin_transaction_with_seed.encodeUnsignedTxToString(tx),
531
- fee: BigInt(tx.fee)
532
- };
533
- };
534
- //#endregion
535
- //#region ../../packages/module/blockchain-bitcoin/src/sdk.ts
536
- const implementsContracts = require_store.combineContracts([
537
- require_sdk.inMemoryIntegrationAddonContract,
538
- require_sdk.tokensStoreContract,
539
- require_sdk.addressesStoreContract,
540
- require_sdk.syncStoreContract,
541
- require_contract.addressBookAddressValidatorAddonContract,
542
- require_contract.tokenIdMapperAddonContract,
543
- require_sdk.signerFactoryAddonContract
544
- ]);
545
- const dependsOnContracts = require_store.combineContracts([
546
- bitcoinProviderContract,
547
- bitcoinFeeMarketProvider,
548
- require_sdk.networkStoreContract,
549
- require_sdk.walletRepoStoreContract,
550
- require_sdk.walletActiveStateDependencyContract,
551
- require_sdk.activitiesStoreContract,
552
- require_sdk.tokensStoreContract
553
- ]);
554
- /**
555
- * Bitcoin accounts: their addresses, tokens and sync, in-memory wallet
556
- * creation and signing, without any user interface or send flow. Loads when
557
- * `BITCOIN_FEATURE_FLAG` is enabled, and needs a Bitcoin provider module such
558
- * as `m.bitcoinProviderMaestro` and a fee market module such as
559
- * `m.bitcoinMempoolFeeMarket`.
560
- */
561
- var sdk_default$2 = require_store.inferModuleContext({
562
- moduleName: require_sdk.ModuleName("blockchain-bitcoin"),
563
- implements: implementsContracts,
564
- dependsOn: dependsOnContracts,
565
- feature: {
566
- willLoad: (featureFlags) => featureFlags.some((flag) => flag.key === require_const.BITCOIN_FEATURE_FLAG),
567
- metadata: {
568
- name: "Bitcoin",
569
- description: "Bitcoin blockchain support"
570
- }
571
- },
572
- store: store_default$2,
573
- addons: {
574
- loadInMemoryWalletIntegration: async () => Promise.resolve().then(() => require("./in-memory-wallet-integration-B2xzxORj.cjs")),
575
- loadAddressBookAddressValidators: async () => Promise.resolve().then(() => require("./address-book-address-validator-DK0dnsRS.cjs")),
576
- loadTokenIdMapper: async () => Promise.resolve().then(() => require("./token-id-mapper-Bnds3xKH.cjs")),
577
- loadSignerFactory: async () => Promise.resolve().then(() => require("./signer-factory-Cwd6o-lG.cjs"))
578
- }
579
- });
580
- //#endregion
581
- //#region ../../packages/module/bitcoin-mempool-fee-market/src/store/index.ts
582
- var store_default$1 = require_store.inferStoreContext({
583
- load: async () => Promise.resolve().then(() => require("./init-DHrCbpkW.cjs")),
584
- context: {
585
- actions: {},
586
- selectors: {}
587
- }
588
- });
589
- //#endregion
590
- //#region ../../packages/module/bitcoin-mempool-fee-market/src/sdk.ts
591
- /**
592
- * Bitcoin fee rate estimates from mempool.space. Loads when
593
- * `BITCOIN_MEMPOOL_FEE_MARKET_FEATURE_FLAG` is enabled.
594
- */
595
- var sdk_default$1 = require_store.inferModuleContext({
596
- moduleName: require_sdk.ModuleName("bitcoin-mempool-fee-market"),
597
- dependsOn: require_store.combineContracts([]),
598
- implements: require_store.combineContracts([bitcoinFeeMarketProvider]),
599
- store: store_default$1,
600
- feature: {
601
- willLoad: (featureFlags) => featureFlags.some((flag) => flag.key === require_const.BITCOIN_MEMPOOL_FEE_MARKET_FEATURE_FLAG),
602
- metadata: {
603
- name: "Mempool.space fee market provider",
604
- description: "Mempool.space fee market provider for Bitcoin"
605
- }
606
- },
607
- addons: {}
608
- });
609
- //#endregion
610
- //#region ../../packages/module/bitcoin-provider-maestro/src/store/index.ts
611
- var store_default = require_store.inferStoreContext({
612
- load: async () => Promise.resolve().then(() => require("./init-GsT2AEa4.cjs")),
613
- context: {
614
- actions: {},
615
- selectors: {}
616
- }
617
- });
618
- //#endregion
619
- //#region ../../packages/module/bitcoin-provider-maestro/src/sdk.ts
620
- /**
621
- * Bitcoin chain data through Maestro: UTxOs, transactions and fee estimates.
622
- * Loads when `BITCOIN_FEATURE_FLAG` is enabled.
623
- */
624
- var sdk_default = require_store.inferModuleContext({
625
- moduleName: require_sdk.ModuleName("bitcoin-provider-maestro"),
626
- dependsOn: require_store.combineContracts([]),
627
- implements: require_store.combineContracts([bitcoinProviderContract]),
628
- store: store_default,
629
- feature: {
630
- willLoad: (featureFlags) => featureFlags.some((flag) => flag.key === require_const.BITCOIN_FEATURE_FLAG),
631
- metadata: {
632
- name: "Maestro",
633
- description: "Maestro provider for Bitcoin"
634
- }
635
- },
636
- addons: {}
637
- });
638
- //#endregion
639
- //#region src/bitcoin/modules.ts
640
- var modules_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
641
- bitcoinMempoolFeeMarket: () => sdk_default$1,
642
- bitcoinProviderMaestro: () => sdk_default,
643
- blockchainBitcoin: () => sdk_default$2,
644
- featureDev: () => require_sdk.sdk_default$2,
645
- storageInMemory: () => require_sdk.sdk_default$1,
646
- storageWebIndexeddb: () => require_sdk.sdk_default
647
- });
648
- //#endregion
649
- //#region src/bitcoin/bitcoin-lazy-in-memory-signer-factory.ts
650
- var import_src = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_src$2.require_src(), 1);
651
- /**
652
- * Signer factory for {@link WalletType.LazyInMemory} Bitcoin accounts.
653
- *
654
- * The seed is never persisted by Lace: each signature asks for the recovery
655
- * words, derives the seed, and wipes it once signing settles. The words must
656
- * derive the account's stored extended public keys, regardless of their
657
- * source, or nothing is signed.
658
- *
659
- * Like the Cardano lazy signer, each signature first asks the user to confirm
660
- * through `auth.authenticate()`. The auth secret is never read, because there
661
- * is no encrypted seed to open.
662
- */
663
- var BitcoinLazyInMemorySignerFactory = class {
664
- #withMnemonicWords;
665
- constructor(props) {
666
- this.#withMnemonicWords = props.withMnemonicWords;
667
- }
668
- canSign(account) {
669
- return account.accountType === "LazyInMemory" && account.blockchainName === "Bitcoin";
670
- }
671
- createTransactionSigner(context) {
672
- const accountProps = this.#extractAccountProps(context);
673
- const { auth } = context;
674
- return { sign: (request) => this.#sign(request, accountProps, auth) };
675
- }
676
- /**
677
- * Message signing is not offered for lazy Bitcoin accounts.
678
- *
679
- * @throws Always.
680
- */
681
- createDataSigner(_context) {
682
- throw new Error("Data signing is not supported for lazy Bitcoin accounts.");
683
- }
684
- #sign(request, accountProps, auth) {
685
- return auth.authenticate().pipe((0, rxjs.switchMap)((confirmed) => {
686
- if (!confirmed) return (0, rxjs.throwError)(() => new require_types.AuthenticationCancelledError());
687
- return this.#signWithWords(request, accountProps);
688
- }));
689
- }
690
- #signWithWords(request, accountProps) {
691
- return new rxjs.Observable((subscriber) => {
692
- const assertActive = () => {
693
- if (subscriber.closed) throw new Error("Signing request cancelled.");
694
- };
695
- this.#withMnemonicWords(async (words) => {
696
- assertActive();
697
- const seed = await import_src.mnemonicToSeed(words.join(" "));
698
- try {
699
- assertActive();
700
- const derivedKeys = require_keyDerivation.getExtendedPubKeys(seed, accountProps.accountIndex);
701
- if (!(0, lodash_isEqual.default)(accountProps.network === require_types$1.BitcoinNetwork.Mainnet ? derivedKeys.mainnet : derivedKeys.testnet4, accountProps.extendedAccountPublicKeys)) throw new require_contract.LazyWalletMismatchError();
702
- return require_sign_bitcoin_transaction_with_seed.signBitcoinTransactionWithSeed(request.serializedTx, seed);
703
- } finally {
704
- seed.fill(0);
705
- }
706
- }).then((result) => {
707
- if (!subscriber.closed) {
708
- subscriber.next(result);
709
- subscriber.complete();
710
- }
711
- }, (error) => {
712
- if (!subscriber.closed) subscriber.error(error);
713
- });
714
- });
715
- }
716
- #extractAccountProps(context) {
717
- const account = context.wallet.accounts.find((a) => a.accountId === context.accountId);
718
- if (!account || !this.canSign(account)) throw new Error(`BitcoinLazyInMemorySignerFactory does not support account type: ${account?.accountType ?? "unknown"}`);
719
- const { accountIndex, extendedAccountPublicKeys, networkId } = account.blockchainSpecific;
720
- const network = require_address.BitcoinNetworkId.getBitcoinNetwork(networkId ?? account.blockchainNetworkId);
721
- if (!network) throw new Error(`Cannot resolve Bitcoin network from networkId: ${String(networkId ?? account.blockchainNetworkId)}`);
722
- return {
723
- accountIndex,
724
- network,
725
- extendedAccountPublicKeys
726
- };
727
- }
728
- };
729
- //#endregion
730
- //#region src/bitcoin/create-bitcoin-lazy-in-memory-vault-module.ts
731
- /**
732
- * Builds a vault module that signs for {@link WalletType.LazyInMemory}
733
- * Bitcoin accounts by asking `withMnemonicWords` for the recovery words at
734
- * each signature. The words must derive the account's stored extended public
735
- * keys, or signing fails with `LazyWalletMismatchError`. The seed derived
736
- * from the words is wiped once each signature settles. Only transactions are
737
- * signed: lazy Bitcoin accounts do not sign messages.
738
- *
739
- * Pass the returned module to `createLaceWallet({ modules: [...] })`. Only the
740
- * `signer-factory-addon` contract is implemented, because the SDK has no
741
- * encrypted vault to expose to features such as account management or
742
- * password verification.
743
- *
744
- * @param props - The source of the recovery words.
745
- * @returns A module for the `modules` array of `createLaceWallet`.
746
- */
747
- const createBitcoinLazyInMemoryVaultModule = (props) => {
748
- const signerFactory = new BitcoinLazyInMemorySignerFactory(props);
749
- const implementsContracts = require_store.combineContracts([require_sdk.signerFactoryAddonContract]);
750
- return require_store.inferModuleContext({
751
- moduleName: require_sdk.ModuleName("bitcoin-lazy-in-memory-vault"),
752
- implements: implementsContracts,
753
- addons: { loadSignerFactory: async () => ({ default: () => signerFactory }) }
754
- });
755
- };
756
- //#endregion
757
- //#region src/bitcoin/resolve-bitcoin-account.ts
758
- /**
759
- * Picks the Bitcoin account a transaction is for, among the accounts of
760
- * `wallets` on the active networks: the requested one, or the only one when
761
- * none is requested.
762
- *
763
- * @param wallets - The wallet entities whose accounts may be picked.
764
- * @param activeNetworkIds - The networks the wallet is on.
765
- * @param requestedAccountId - The account asked for, if any.
766
- * @returns `Ok` with the account and its wallet entity, or `Err` when the
767
- * requested account is not found, or no account or several accounts match.
768
- */
769
- const resolveBitcoinAccount = (wallets, activeNetworkIds, requestedAccountId) => {
770
- const bitcoinAccounts = wallets.flatMap((walletEntity) => walletEntity.accounts.filter((account) => account.blockchainName === "Bitcoin" && activeNetworkIds.includes(account.blockchainNetworkId)).map((account) => ({
771
- account,
772
- walletEntity
773
- })));
774
- if (requestedAccountId) {
775
- const found = bitcoinAccounts.find(({ account }) => account.accountId === requestedAccountId);
776
- return found ? require_asyncoption.Ok(found) : require_asyncoption.Err(/* @__PURE__ */ new Error(`Bitcoin account "${requestedAccountId}" not found on the active network`));
777
- }
778
- if (bitcoinAccounts.length === 0) return require_asyncoption.Err(/* @__PURE__ */ new Error("No Bitcoin accounts found on the active network"));
779
- if (bitcoinAccounts.length > 1) return require_asyncoption.Err(/* @__PURE__ */ new Error(`Multiple Bitcoin accounts found (${bitcoinAccounts.length}): specify accountId to disambiguate`));
780
- return require_asyncoption.Ok(bitcoinAccounts[0]);
781
- };
782
- /**
783
- * Picks the Bitcoin account a transaction is for from the wallet's current
784
- * state, by the rules of {@link resolveBitcoinAccount}.
785
- *
786
- * @param stateObservables - The wallet's wallets and networks.
787
- * @param requestedAccountId - The account asked for, if any.
788
- * @returns `Ok` with the account id, or `Err` when no single account matches.
789
- */
790
- const resolveBitcoinAccountId = async (stateObservables, requestedAccountId) => {
791
- const resolved = resolveBitcoinAccount(await (0, rxjs.firstValueFrom)(stateObservables.wallets.selectAll$), await (0, rxjs.firstValueFrom)(stateObservables.network.selectAllActiveNetworkIds$), requestedAccountId);
792
- return resolved.isErr() ? require_asyncoption.Err(resolved.error) : require_asyncoption.Ok(resolved.value.account.accountId);
793
- };
794
- /**
795
- * Finds the Bitcoin wallet that syncs an account. Every wallet in a
796
- * JavaScript realm registers its accounts in one shared registry, so an
797
- * account must be loaded by at most one wallet per realm.
798
- *
799
- * @param accountId - The account to find.
800
- * @returns `Ok` with the account's Bitcoin wallet, or `Err` when the account
801
- * has not started syncing yet.
802
- */
803
- const findBitcoinAccountWallet = (accountId) => {
804
- const accountWallet = require_side_effects.bitcoinAccountWallets$.value[accountId];
805
- return accountWallet ? require_asyncoption.Ok(accountWallet) : require_asyncoption.Err(/* @__PURE__ */ new Error(`Bitcoin account "${accountId}" has not started syncing yet`));
806
- };
807
- //#endregion
808
- //#region src/bitcoin/build-bitcoin-tx.ts
809
- const isPositiveSatoshiAmount = (amount) => Number.isSafeInteger(amount) && amount > 0;
810
- const validateRecipients = (recipients) => {
811
- if (recipients.length === 0) return require_asyncoption.Err(/* @__PURE__ */ new Error("At least one recipient is required"));
812
- const invalid = recipients.find(({ amount }) => !isPositiveSatoshiAmount(amount));
813
- if (invalid) return require_asyncoption.Err(/* @__PURE__ */ new Error(`Invalid amount ${invalid.amount} for ${invalid.address}: amounts are positive whole numbers of satoshis`));
814
- const dust = recipients.find(({ amount }) => amount < 546);
815
- return dust ? require_asyncoption.Err(/* @__PURE__ */ new Error(`Amount ${dust.amount} for ${dust.address} is below the dust limit of 546 satoshis`)) : require_asyncoption.Ok(void 0);
816
- };
817
- const toPaymentFeeRate = (feeRate) => {
818
- if (feeRate.feeOption !== "Custom") return require_asyncoption.Ok(feeRate);
819
- const customFeeRate = feeRateFromSatsPerVByte(feeRate.satsPerVByte);
820
- return customFeeRate === void 0 ? require_asyncoption.Err(/* @__PURE__ */ new Error(`Invalid fee rate ${feeRate.satsPerVByte}: custom rates are positive numbers of satoshis per virtual byte, at most 10,000`)) : require_asyncoption.Ok({
821
- feeOption: "Custom",
822
- customFeeRate
823
- });
824
- };
825
- /**
826
- * Builds an unsigned Bitcoin payment from the account's synced UTxOs. Outputs
827
- * spent by the account's pending transactions are not spent again, and the
828
- * change goes back to the account. The account is `props.accountId`, or the
829
- * only Bitcoin account on the active network.
830
- *
831
- * The account must have synced first: await
832
- * {@link waitForBitcoinAccountSync} after adding the wallet. A Bitcoin
833
- * account must be loaded by at most one wallet per JavaScript realm, since
834
- * the account's synced state is shared across the realm by account id.
835
- *
836
- * @param wallet - A wallet holding the paying account (see
837
- * {@link WalletWithBitcoinTxBuilding}).
838
- * @param props - The recipients, with amounts in satoshis, the fee rate, and
839
- * the account and memo when needed.
840
- * @returns `Ok` with the unsigned transaction and its fee, or `Err` when an
841
- * amount is not a positive whole number of satoshis or is below the dust
842
- * limit of 546 satoshis, a custom fee rate is out of range, no account
843
- * matches, the account has not started syncing, or the payment cannot be
844
- * built, for example when the funds do not cover it. It never rejects.
845
- */
846
- const buildBitcoinTx = async (wallet, props) => {
847
- const { accountId: requestedAccountId, recipients, feeRate, memo } = props;
848
- try {
849
- const validRecipients = validateRecipients(recipients);
850
- if (validRecipients.isErr()) return require_asyncoption.Err(validRecipients.error);
851
- const paymentFeeRate = toPaymentFeeRate(feeRate);
852
- if (paymentFeeRate.isErr()) return require_asyncoption.Err(paymentFeeRate.error);
853
- const accountId = await resolveBitcoinAccountId(wallet.stateObservables, requestedAccountId);
854
- if (accountId.isErr()) return require_asyncoption.Err(accountId.error);
855
- const accountWallet = findBitcoinAccountWallet(accountId.value);
856
- if (accountWallet.isErr()) return require_asyncoption.Err(accountWallet.error);
857
- const pendingActivities = await (0, rxjs.firstValueFrom)(wallet.stateObservables.activities.selectPendingActivitiesByAccount$);
858
- const { serializedTx, fee } = await buildBitcoinPayment({
859
- wallet: accountWallet.value,
860
- pendingActivities: pendingActivities[accountId.value] ?? [],
861
- outputs: recipients,
862
- feeRate: paymentFeeRate.value,
863
- memo
864
- });
865
- return require_asyncoption.Ok({
866
- serializedTx,
867
- fee
868
- });
869
- } catch (error) {
870
- return require_asyncoption.Err(error instanceof Error ? error : new Error(String(error)));
871
- }
872
- };
873
- /**
874
- * Returns a promise that resolves once a Bitcoin account is on the active
875
- * network and has synced its UTxOs with the provider. Await it after adding
876
- * a wallet, before {@link buildBitcoinTx}, so the build sees the account's
877
- * funds. A Bitcoin account must be loaded by at most one wallet per
878
- * JavaScript realm: with two, the promise may resolve on the other wallet's
879
- * sync.
880
- *
881
- * @param wallet - A wallet holding the account (see
882
- * {@link WalletWithBitcoinTxBuilding}).
883
- * @param options - Optional configuration.
884
- * @returns A promise that resolves once the account has synced.
885
- * @throws A `TimeoutError` when the account has not synced within
886
- * `options.timeout`.
887
- */
888
- const waitForBitcoinAccountSync = async (wallet, options) => {
889
- const { wallets, network } = wallet.stateObservables;
890
- await (0, rxjs.firstValueFrom)((0, rxjs.combineLatest)([wallets.selectAll$, network.selectAllActiveNetworkIds$]).pipe((0, rxjs.map)(([allWallets, activeNetworkIds]) => resolveBitcoinAccount(allWallets, activeNetworkIds, options?.accountId)), (0, rxjs.filter)((resolved) => resolved.isOk()), (0, rxjs.map)((resolved) => resolved.unwrap().account.accountId), (0, rxjs.take)(1), (0, rxjs.switchMap)((accountId) => require_side_effects.bitcoinAccountWallets$.pipe((0, rxjs.map)((accountWallets) => accountWallets[accountId]))), (0, rxjs.filter)((accountWallet) => !!accountWallet), (0, rxjs.switchMap)((accountWallet) => accountWallet.syncStatus$), (0, rxjs.filter)(({ status }) => status === require_side_effects.SyncStatus.Synced), options?.timeout != null ? (0, rxjs.timeout)({ first: options.timeout }) : passthrough()));
891
- };
892
- const passthrough = () => (source$) => source$;
893
- //#endregion
894
- //#region src/bitcoin/sign-bitcoin-tx.ts
895
- const isSignableBitcoinWallet = (wallet) => wallet.type === require_sdk.WalletType.InMemory || wallet.type === require_sdk.WalletType.LazyInMemory;
896
- /**
897
- * Signs a Bitcoin transaction with the wallet's keys, through the signer of
898
- * its wallet kind, with no confirmation prompt of the SDK's own: confirm with
899
- * the user before calling it. The account is `props.accountId`, or the only
900
- * signable Bitcoin account on the active network. A `LazyInMemory` account
901
- * signs through the vault module of `createBitcoinLazyInMemoryVaultModule`.
902
- *
903
- * @param wallet - A wallet holding the signing account (see
904
- * {@link WalletWithBitcoinSigning}).
905
- * @param props - The unsigned transaction from `buildBitcoinTx`, and the
906
- * password and account when needed.
907
- * @returns `Ok` with the signed transaction, ready for `submitBitcoinTx`, or
908
- * `Err` when no account matches, the password is missing or signing fails.
909
- * It never rejects.
910
- */
911
- const signBitcoinTx = async (wallet, props) => {
912
- const { serializedTx, password, accountId: requestedAccountId } = props;
913
- try {
914
- const { stateObservables: obs } = wallet;
915
- const allWallets = await (0, rxjs.firstValueFrom)(obs.wallets.selectAll$);
916
- const activeNetworkIds = await (0, rxjs.firstValueFrom)(obs.network.selectAllActiveNetworkIds$);
917
- const resolved = resolveBitcoinAccount(allWallets.filter(isSignableBitcoinWallet), activeNetworkIds, requestedAccountId);
918
- if (resolved.isErr()) return require_asyncoption.Err(resolved.error);
919
- const { account, walletEntity } = resolved.value;
920
- if (walletEntity.type === require_sdk.WalletType.InMemory && !password) return require_asyncoption.Err(/* @__PURE__ */ new Error("password is required for InMemory wallets: supply props.password or use a LazyInMemory wallet"));
921
- const auth = {
922
- authenticate: () => (0, rxjs.of)(true),
923
- accessAuthSecret: (callback) => password ? callback(require_sdk.AuthSecret(require_bytes_vo.ByteArray(password))) : (0, rxjs.throwError)(() => /* @__PURE__ */ new Error("accessAuthSecret called on a wallet that has no password: this is a LazyInMemory wallet; signer factories must not access the auth secret"))
924
- };
925
- const signerFactory = new require_composite_signer_factory.CompositeSignerFactory(await wallet._loadModules("addons.loadSignerFactory"));
926
- const context = {
927
- wallet: walletEntity,
928
- accountId: account.accountId,
929
- auth
930
- };
931
- return require_asyncoption.Ok(await (0, rxjs.firstValueFrom)(signerFactory.createTransactionSigner(context).sign({ serializedTx: require_bytes_vo.HexBytes(serializedTx) })));
932
- } catch (error) {
933
- return require_asyncoption.Err(error instanceof Error ? error : new Error(String(error)));
934
- }
935
- };
936
- //#endregion
937
- //#region src/bitcoin/submit-bitcoin-tx.ts
938
- const SUBMIT_TX_TIMEOUT_MS = 6e4;
939
- const isBitcoinNetwork = (network) => Object.values(require_types$1.BitcoinNetwork).includes(network);
940
- const decodeSignedTx = (serializedTx) => {
941
- const payload = JSON.parse(require_bytes_vo.HexBytes.toUTF8(require_bytes_vo.HexBytes(serializedTx)));
942
- if (typeof payload?.hex !== "string" || !isBitcoinNetwork(payload.network)) throw new Error("Not a signed Bitcoin transaction");
943
- return {
944
- network: payload.network,
945
- hex: payload.hex
946
- };
947
- };
948
- /**
949
- * Submits a signed transaction through the account's Bitcoin wallet, which
950
- * adds it to the account's pending transactions once the provider accepts it,
951
- * and waits up to 60 seconds for the provider's answer. The account is
952
- * `props.accountId`, or the only Bitcoin account on the active network. A
953
- * Bitcoin account must be loaded by at most one wallet per JavaScript realm,
954
- * since the account's pending transactions are shared across the realm by
955
- * account id.
956
- *
957
- * @param wallet - A wallet with the Bitcoin modules loaded (see
958
- * {@link WalletWithBitcoinSubmit}).
959
- * @param props - The signed transaction, and the account when needed.
960
- * @returns `Ok` with the transaction ID once the provider accepts it, or
961
- * `Err` when no account matches, the account has not started syncing, the
962
- * transaction is for another network, the provider refuses it or the wait
963
- * times out. It never rejects.
964
- */
965
- const submitBitcoinTx = async (wallet, props) => {
966
- const { serializedTx, accountId: requestedAccountId } = props;
967
- try {
968
- const { network, hex } = decodeSignedTx(serializedTx);
969
- const resolved = await resolveBitcoinAccountId(wallet.stateObservables, requestedAccountId);
970
- if (resolved.isErr()) return require_asyncoption.Err(resolved.error);
971
- const accountId = resolved.value;
972
- const foundWallet = findBitcoinAccountWallet(accountId);
973
- if (foundWallet.isErr()) return require_asyncoption.Err(foundWallet.error);
974
- const accountWallet = foundWallet.value;
975
- if (accountWallet.network !== network) return require_asyncoption.Err(/* @__PURE__ */ new Error(`The transaction is for the Bitcoin ${network} network, but account "${accountId}" is on ${accountWallet.network}`));
976
- const result = await (0, rxjs.firstValueFrom)(accountWallet.submitTransaction(hex).pipe((0, rxjs.timeout)(SUBMIT_TX_TIMEOUT_MS)));
977
- if (result.isErr()) return require_asyncoption.Err(new Error(`Transaction submission failed: ${result.error.reason}`, { cause: result.error }));
978
- return require_asyncoption.Ok({ txId: result.value });
979
- } catch (error) {
980
- return require_asyncoption.Err(error instanceof Error ? error : new Error(String(error)));
981
- }
982
- };
983
- //#endregion
984
- Object.defineProperty(exports, "BitcoinTxBuildError", {
985
- enumerable: true,
986
- get: function() {
987
- return BitcoinTxBuildError;
988
- }
989
- });
990
- Object.defineProperty(exports, "BitcoinTxBuildErrorCode", {
991
- enumerable: true,
992
- get: function() {
993
- return BitcoinTxBuildErrorCode;
994
- }
995
- });
996
- Object.defineProperty(exports, "buildBitcoinTx", {
997
- enumerable: true,
998
- get: function() {
999
- return buildBitcoinTx;
1000
- }
1001
- });
1002
- Object.defineProperty(exports, "createBitcoinLazyInMemoryVaultModule", {
1003
- enumerable: true,
1004
- get: function() {
1005
- return createBitcoinLazyInMemoryVaultModule;
1006
- }
1007
- });
1008
- Object.defineProperty(exports, "modules_exports", {
1009
- enumerable: true,
1010
- get: function() {
1011
- return modules_exports;
1012
- }
1013
- });
1014
- Object.defineProperty(exports, "sdk_default", {
1015
- enumerable: true,
1016
- get: function() {
1017
- return sdk_default;
1018
- }
1019
- });
1020
- Object.defineProperty(exports, "sdk_default$1", {
1021
- enumerable: true,
1022
- get: function() {
1023
- return sdk_default$1;
1024
- }
1025
- });
1026
- Object.defineProperty(exports, "sdk_default$2", {
1027
- enumerable: true,
1028
- get: function() {
1029
- return sdk_default$2;
1030
- }
1031
- });
1032
- Object.defineProperty(exports, "signBitcoinTx", {
1033
- enumerable: true,
1034
- get: function() {
1035
- return signBitcoinTx;
1036
- }
1037
- });
1038
- Object.defineProperty(exports, "submitBitcoinTx", {
1039
- enumerable: true,
1040
- get: function() {
1041
- return submitBitcoinTx;
1042
- }
1043
- });
1044
- Object.defineProperty(exports, "waitForBitcoinAccountSync", {
1045
- enumerable: true,
1046
- get: function() {
1047
- return waitForBitcoinAccountSync;
1048
- }
1049
- });