@miradexio/client 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.
- package/LICENSE +21 -0
- package/README.md +405 -0
- package/dist/address/base58.d.ts +9 -0
- package/dist/address/base58.d.ts.map +1 -0
- package/dist/address/base58.js +33 -0
- package/dist/address/base58.js.map +1 -0
- package/dist/address/bech32.d.ts +13 -0
- package/dist/address/bech32.d.ts.map +1 -0
- package/dist/address/bech32.js +41 -0
- package/dist/address/bech32.js.map +1 -0
- package/dist/address/evm.d.ts +5 -0
- package/dist/address/evm.d.ts.map +1 -0
- package/dist/address/evm.js +27 -0
- package/dist/address/evm.js.map +1 -0
- package/dist/address/index.d.ts +15 -0
- package/dist/address/index.d.ts.map +1 -0
- package/dist/address/index.js +134 -0
- package/dist/address/index.js.map +1 -0
- package/dist/address/monero.d.ts +15 -0
- package/dist/address/monero.d.ts.map +1 -0
- package/dist/address/monero.js +30 -0
- package/dist/address/monero.js.map +1 -0
- package/dist/address/polkadot.d.ts +10 -0
- package/dist/address/polkadot.d.ts.map +1 -0
- package/dist/address/polkadot.js +36 -0
- package/dist/address/polkadot.js.map +1 -0
- package/dist/address/solana.d.ts +5 -0
- package/dist/address/solana.d.ts.map +1 -0
- package/dist/address/solana.js +17 -0
- package/dist/address/solana.js.map +1 -0
- package/dist/address/ton.d.ts +11 -0
- package/dist/address/ton.d.ts.map +1 -0
- package/dist/address/ton.js +28 -0
- package/dist/address/ton.js.map +1 -0
- package/dist/api/index.d.ts +80 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +213 -0
- package/dist/api/index.js.map +1 -0
- package/dist/atomic-swap/drive.d.ts +22 -0
- package/dist/atomic-swap/drive.d.ts.map +1 -0
- package/dist/atomic-swap/drive.js +713 -0
- package/dist/atomic-swap/drive.js.map +1 -0
- package/dist/atomic-swap/extract.d.ts +46 -0
- package/dist/atomic-swap/extract.d.ts.map +1 -0
- package/dist/atomic-swap/extract.js +55 -0
- package/dist/atomic-swap/extract.js.map +1 -0
- package/dist/atomic-swap/index.d.ts +15 -0
- package/dist/atomic-swap/index.d.ts.map +1 -0
- package/dist/atomic-swap/index.js +13 -0
- package/dist/atomic-swap/index.js.map +1 -0
- package/dist/atomic-swap/monero-sweep/errors.d.ts +2 -0
- package/dist/atomic-swap/monero-sweep/errors.d.ts.map +1 -0
- package/dist/atomic-swap/monero-sweep/errors.js +43 -0
- package/dist/atomic-swap/monero-sweep/errors.js.map +1 -0
- package/dist/atomic-swap/monero-sweep/index.d.ts +33 -0
- package/dist/atomic-swap/monero-sweep/index.d.ts.map +1 -0
- package/dist/atomic-swap/monero-sweep/index.js +415 -0
- package/dist/atomic-swap/monero-sweep/index.js.map +1 -0
- package/dist/atomic-swap/monero-sweep/ring-select.d.ts +12 -0
- package/dist/atomic-swap/monero-sweep/ring-select.d.ts.map +1 -0
- package/dist/atomic-swap/monero-sweep/ring-select.js +61 -0
- package/dist/atomic-swap/monero-sweep/ring-select.js.map +1 -0
- package/dist/atomic-swap/presign.d.ts +101 -0
- package/dist/atomic-swap/presign.d.ts.map +1 -0
- package/dist/atomic-swap/presign.js +460 -0
- package/dist/atomic-swap/presign.js.map +1 -0
- package/dist/atomic-swap/refund.d.ts +72 -0
- package/dist/atomic-swap/refund.d.ts.map +1 -0
- package/dist/atomic-swap/refund.js +224 -0
- package/dist/atomic-swap/refund.js.map +1 -0
- package/dist/atomic-swap/run.d.ts +27 -0
- package/dist/atomic-swap/run.d.ts.map +1 -0
- package/dist/atomic-swap/run.js +282 -0
- package/dist/atomic-swap/run.js.map +1 -0
- package/dist/atomic-swap/snapshot.d.ts +111 -0
- package/dist/atomic-swap/snapshot.d.ts.map +1 -0
- package/dist/atomic-swap/snapshot.js +69 -0
- package/dist/atomic-swap/snapshot.js.map +1 -0
- package/dist/atomic-swap/submit-encsig.d.ts +10 -0
- package/dist/atomic-swap/submit-encsig.d.ts.map +1 -0
- package/dist/atomic-swap/submit-encsig.js +56 -0
- package/dist/atomic-swap/submit-encsig.js.map +1 -0
- package/dist/atomic-swap/types.d.ts +168 -0
- package/dist/atomic-swap/types.d.ts.map +1 -0
- package/dist/atomic-swap/types.js +5 -0
- package/dist/atomic-swap/types.js.map +1 -0
- package/dist/blockchain/quorum-provider.d.ts +25 -0
- package/dist/blockchain/quorum-provider.d.ts.map +1 -0
- package/dist/blockchain/quorum-provider.js +144 -0
- package/dist/blockchain/quorum-provider.js.map +1 -0
- package/dist/cooperative-redeem.d.ts +23 -0
- package/dist/cooperative-redeem.d.ts.map +1 -0
- package/dist/cooperative-redeem.js +40 -0
- package/dist/cooperative-redeem.js.map +1 -0
- package/dist/engine/blockchain-querier.d.ts +34 -0
- package/dist/engine/blockchain-querier.d.ts.map +1 -0
- package/dist/engine/blockchain-querier.js +2 -0
- package/dist/engine/blockchain-querier.js.map +1 -0
- package/dist/engine/engine-state.d.ts +20 -0
- package/dist/engine/engine-state.d.ts.map +1 -0
- package/dist/engine/engine-state.js +9 -0
- package/dist/engine/engine-state.js.map +1 -0
- package/dist/engine/flow-context.d.ts +494 -0
- package/dist/engine/flow-context.d.ts.map +1 -0
- package/dist/engine/flow-context.js +147 -0
- package/dist/engine/flow-context.js.map +1 -0
- package/dist/engine/flows/atomic-flow-state.d.ts +124 -0
- package/dist/engine/flows/atomic-flow-state.d.ts.map +1 -0
- package/dist/engine/flows/atomic-flow-state.js +2 -0
- package/dist/engine/flows/atomic-flow-state.js.map +1 -0
- package/dist/engine/flows/atomic-flow.d.ts +88 -0
- package/dist/engine/flows/atomic-flow.d.ts.map +1 -0
- package/dist/engine/flows/atomic-flow.js +1192 -0
- package/dist/engine/flows/atomic-flow.js.map +1 -0
- package/dist/engine/flows/history-flow-state.d.ts +19 -0
- package/dist/engine/flows/history-flow-state.d.ts.map +1 -0
- package/dist/engine/flows/history-flow-state.js +2 -0
- package/dist/engine/flows/history-flow-state.js.map +1 -0
- package/dist/engine/flows/providers-flow-state.d.ts +14 -0
- package/dist/engine/flows/providers-flow-state.d.ts.map +1 -0
- package/dist/engine/flows/providers-flow-state.js +2 -0
- package/dist/engine/flows/providers-flow-state.js.map +1 -0
- package/dist/engine/flows/quote-flow-state.d.ts +20 -0
- package/dist/engine/flows/quote-flow-state.d.ts.map +1 -0
- package/dist/engine/flows/quote-flow-state.js +2 -0
- package/dist/engine/flows/quote-flow-state.js.map +1 -0
- package/dist/engine/flows/swap-flow-state.d.ts +155 -0
- package/dist/engine/flows/swap-flow-state.d.ts.map +1 -0
- package/dist/engine/flows/swap-flow-state.js +2 -0
- package/dist/engine/flows/swap-flow-state.js.map +1 -0
- package/dist/engine/flows/swap-flow.d.ts +81 -0
- package/dist/engine/flows/swap-flow.d.ts.map +1 -0
- package/dist/engine/flows/swap-flow.js +720 -0
- package/dist/engine/flows/swap-flow.js.map +1 -0
- package/dist/engine/flows/tokens-flow-state.d.ts +16 -0
- package/dist/engine/flows/tokens-flow-state.d.ts.map +1 -0
- package/dist/engine/flows/tokens-flow-state.js +2 -0
- package/dist/engine/flows/tokens-flow-state.js.map +1 -0
- package/dist/engine/miradex-engine.d.ts +152 -0
- package/dist/engine/miradex-engine.d.ts.map +1 -0
- package/dist/engine/miradex-engine.js +278 -0
- package/dist/engine/miradex-engine.js.map +1 -0
- package/dist/engine/pipeline.d.ts +27 -0
- package/dist/engine/pipeline.d.ts.map +1 -0
- package/dist/engine/pipeline.js +166 -0
- package/dist/engine/pipeline.js.map +1 -0
- package/dist/engine/platform.d.ts +220 -0
- package/dist/engine/platform.d.ts.map +1 -0
- package/dist/engine/platform.js +2 -0
- package/dist/engine/platform.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/blockchain.d.ts +33 -0
- package/dist/interfaces/blockchain.d.ts.map +1 -0
- package/dist/interfaces/blockchain.js +2 -0
- package/dist/interfaces/blockchain.js.map +1 -0
- package/dist/interfaces/logger.d.ts +14 -0
- package/dist/interfaces/logger.d.ts.map +1 -0
- package/dist/interfaces/logger.js +7 -0
- package/dist/interfaces/logger.js.map +1 -0
- package/dist/lib/bitcoin/deposit-watcher.d.ts +66 -0
- package/dist/lib/bitcoin/deposit-watcher.d.ts.map +1 -0
- package/dist/lib/bitcoin/deposit-watcher.js +218 -0
- package/dist/lib/bitcoin/deposit-watcher.js.map +1 -0
- package/dist/lib/bitcoin/script-hash.d.ts +8 -0
- package/dist/lib/bitcoin/script-hash.d.ts.map +1 -0
- package/dist/lib/bitcoin/script-hash.js +29 -0
- package/dist/lib/bitcoin/script-hash.js.map +1 -0
- package/dist/lib/bitcoin/sweep.d.ts +56 -0
- package/dist/lib/bitcoin/sweep.d.ts.map +1 -0
- package/dist/lib/bitcoin/sweep.js +185 -0
- package/dist/lib/bitcoin/sweep.js.map +1 -0
- package/dist/lib/bitcoin/tx-verify.d.ts +43 -0
- package/dist/lib/bitcoin/tx-verify.d.ts.map +1 -0
- package/dist/lib/bitcoin/tx-verify.js +202 -0
- package/dist/lib/bitcoin/tx-verify.js.map +1 -0
- package/dist/lib/bitcoin/wallet.d.ts +71 -0
- package/dist/lib/bitcoin/wallet.d.ts.map +1 -0
- package/dist/lib/bitcoin/wallet.js +141 -0
- package/dist/lib/bitcoin/wallet.js.map +1 -0
- package/dist/lib/crypto/bytes.d.ts +21 -0
- package/dist/lib/crypto/bytes.d.ts.map +1 -0
- package/dist/lib/crypto/bytes.js +39 -0
- package/dist/lib/crypto/bytes.js.map +1 -0
- package/dist/lib/crypto/errors.d.ts +12 -0
- package/dist/lib/crypto/errors.d.ts.map +1 -0
- package/dist/lib/crypto/errors.js +16 -0
- package/dist/lib/crypto/errors.js.map +1 -0
- package/dist/lib/crypto/keygen.d.ts +19 -0
- package/dist/lib/crypto/keygen.d.ts.map +1 -0
- package/dist/lib/crypto/keygen.js +24 -0
- package/dist/lib/crypto/keygen.js.map +1 -0
- package/dist/lib/crypto/libp2p-identity.d.ts +25 -0
- package/dist/lib/crypto/libp2p-identity.d.ts.map +1 -0
- package/dist/lib/crypto/libp2p-identity.js +80 -0
- package/dist/lib/crypto/libp2p-identity.js.map +1 -0
- package/dist/lib/crypto/mnemonic.d.ts +28 -0
- package/dist/lib/crypto/mnemonic.d.ts.map +1 -0
- package/dist/lib/crypto/mnemonic.js +97 -0
- package/dist/lib/crypto/mnemonic.js.map +1 -0
- package/dist/lib/crypto/platform.d.ts +10 -0
- package/dist/lib/crypto/platform.d.ts.map +1 -0
- package/dist/lib/crypto/platform.js +38 -0
- package/dist/lib/crypto/platform.js.map +1 -0
- package/dist/lib/crypto/scalars.d.ts +33 -0
- package/dist/lib/crypto/scalars.d.ts.map +1 -0
- package/dist/lib/crypto/scalars.js +81 -0
- package/dist/lib/crypto/scalars.js.map +1 -0
- package/dist/lib/crypto/types.d.ts +24 -0
- package/dist/lib/crypto/types.d.ts.map +1 -0
- package/dist/lib/crypto/types.js +2 -0
- package/dist/lib/crypto/types.js.map +1 -0
- package/dist/lib/crypto/wasm.d.ts +51 -0
- package/dist/lib/crypto/wasm.d.ts.map +1 -0
- package/dist/lib/crypto/wasm.js +192 -0
- package/dist/lib/crypto/wasm.js.map +1 -0
- package/dist/lib/default-config.d.ts +140 -0
- package/dist/lib/default-config.d.ts.map +1 -0
- package/dist/lib/default-config.js +239 -0
- package/dist/lib/default-config.js.map +1 -0
- package/dist/lib/delay.d.ts +6 -0
- package/dist/lib/delay.d.ts.map +1 -0
- package/dist/lib/delay.js +20 -0
- package/dist/lib/delay.js.map +1 -0
- package/dist/lib/errors.d.ts +90 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +129 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/format.d.ts +7 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +43 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/keystore.d.ts +85 -0
- package/dist/lib/keystore.d.ts.map +1 -0
- package/dist/lib/keystore.js +105 -0
- package/dist/lib/keystore.js.map +1 -0
- package/dist/lib/monero/output-scanner.d.ts +53 -0
- package/dist/lib/monero/output-scanner.d.ts.map +1 -0
- package/dist/lib/monero/output-scanner.js +180 -0
- package/dist/lib/monero/output-scanner.js.map +1 -0
- package/dist/lib/monero/rpc.d.ts +131 -0
- package/dist/lib/monero/rpc.d.ts.map +1 -0
- package/dist/lib/monero/rpc.js +267 -0
- package/dist/lib/monero/rpc.js.map +1 -0
- package/dist/lib/monero/verify-lock.d.ts +50 -0
- package/dist/lib/monero/verify-lock.d.ts.map +1 -0
- package/dist/lib/monero/verify-lock.js +161 -0
- package/dist/lib/monero/verify-lock.js.map +1 -0
- package/dist/lib/monero/verify-sweep.d.ts +59 -0
- package/dist/lib/monero/verify-sweep.d.ts.map +1 -0
- package/dist/lib/monero/verify-sweep.js +82 -0
- package/dist/lib/monero/verify-sweep.js.map +1 -0
- package/dist/lib/monero/wasm.d.ts +19 -0
- package/dist/lib/monero/wasm.d.ts.map +1 -0
- package/dist/lib/monero/wasm.js +24 -0
- package/dist/lib/monero/wasm.js.map +1 -0
- package/dist/lib/pow-solver.d.ts +4 -0
- package/dist/lib/pow-solver.d.ts.map +1 -0
- package/dist/lib/pow-solver.js +37 -0
- package/dist/lib/pow-solver.js.map +1 -0
- package/dist/lib/retry.d.ts +86 -0
- package/dist/lib/retry.d.ts.map +1 -0
- package/dist/lib/retry.js +104 -0
- package/dist/lib/retry.js.map +1 -0
- package/dist/portable.d.ts +23 -0
- package/dist/portable.d.ts.map +1 -0
- package/dist/portable.js +13 -0
- package/dist/portable.js.map +1 -0
- package/dist/quote-binding.d.ts +31 -0
- package/dist/quote-binding.d.ts.map +1 -0
- package/dist/quote-binding.js +40 -0
- package/dist/quote-binding.js.map +1 -0
- package/dist/swap-executor.d.ts +51 -0
- package/dist/swap-executor.d.ts.map +1 -0
- package/dist/swap-executor.js +138 -0
- package/dist/swap-executor.js.map +1 -0
- package/dist/types/api.d.ts +34 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +18 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/errors.d.ts +94 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +93 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/keys.d.ts +33 -0
- package/dist/types/keys.d.ts.map +1 -0
- package/dist/types/keys.js +2 -0
- package/dist/types/keys.js.map +1 -0
- package/dist/types/protocol.d.ts +93 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/protocol.js +18 -0
- package/dist/types/protocol.js.map +1 -0
- package/dist/types/status.d.ts +3 -0
- package/dist/types/status.d.ts.map +1 -0
- package/dist/types/status.js +23 -0
- package/dist/types/status.js.map +1 -0
- package/dist/types/verification.d.ts +49 -0
- package/dist/types/verification.d.ts.map +1 -0
- package/dist/types/verification.js +34 -0
- package/dist/types/verification.js.map +1 -0
- package/dist/verification/atomic-swap.d.ts +9 -0
- package/dist/verification/atomic-swap.d.ts.map +1 -0
- package/dist/verification/atomic-swap.js +22 -0
- package/dist/verification/atomic-swap.js.map +1 -0
- package/dist/verification/chainflip-networks.d.ts +46 -0
- package/dist/verification/chainflip-networks.d.ts.map +1 -0
- package/dist/verification/chainflip-networks.js +24 -0
- package/dist/verification/chainflip-networks.js.map +1 -0
- package/dist/verification/chainflip.d.ts +61 -0
- package/dist/verification/chainflip.d.ts.map +1 -0
- package/dist/verification/chainflip.js +377 -0
- package/dist/verification/chainflip.js.map +1 -0
- package/dist/verification/constants.d.ts +52 -0
- package/dist/verification/constants.d.ts.map +1 -0
- package/dist/verification/constants.js +54 -0
- package/dist/verification/constants.js.map +1 -0
- package/dist/verification/index.d.ts +71 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +91 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/memo.d.ts +27 -0
- package/dist/verification/memo.d.ts.map +1 -0
- package/dist/verification/memo.js +52 -0
- package/dist/verification/memo.js.map +1 -0
- package/dist/verification/near-intents.d.ts +91 -0
- package/dist/verification/near-intents.d.ts.map +1 -0
- package/dist/verification/near-intents.js +213 -0
- package/dist/verification/near-intents.js.map +1 -0
- package/dist/verification/rate-oracle.d.ts +32 -0
- package/dist/verification/rate-oracle.d.ts.map +1 -0
- package/dist/verification/rate-oracle.js +43 -0
- package/dist/verification/rate-oracle.js.map +1 -0
- package/dist/verification/shared.d.ts +20 -0
- package/dist/verification/shared.d.ts.map +1 -0
- package/dist/verification/shared.js +25 -0
- package/dist/verification/shared.js.map +1 -0
- package/dist/verification/thorchain-networks.d.ts +35 -0
- package/dist/verification/thorchain-networks.d.ts.map +1 -0
- package/dist/verification/thorchain-networks.js +35 -0
- package/dist/verification/thorchain-networks.js.map +1 -0
- package/dist/verification/thorchain.d.ts +55 -0
- package/dist/verification/thorchain.d.ts.map +1 -0
- package/dist/verification/thorchain.js +232 -0
- package/dist/verification/thorchain.js.map +1 -0
- package/dist/wasm-pins.d.ts +4 -0
- package/dist/wasm-pins.d.ts.map +1 -0
- package/dist/wasm-pins.js +6 -0
- package/dist/wasm-pins.js.map +1 -0
- package/dist/wire/chainflip.zod.d.ts +144 -0
- package/dist/wire/chainflip.zod.d.ts.map +1 -0
- package/dist/wire/chainflip.zod.js +33 -0
- package/dist/wire/chainflip.zod.js.map +1 -0
- package/dist/wire/near-intents.zod.d.ts +376 -0
- package/dist/wire/near-intents.zod.d.ts.map +1 -0
- package/dist/wire/near-intents.zod.js +101 -0
- package/dist/wire/near-intents.zod.js.map +1 -0
- package/dist/wire/server/action.zod.d.ts +1119 -0
- package/dist/wire/server/action.zod.d.ts.map +1 -0
- package/dist/wire/server/action.zod.js +173 -0
- package/dist/wire/server/action.zod.js.map +1 -0
- package/dist/wire/server/common.zod.d.ts +62 -0
- package/dist/wire/server/common.zod.d.ts.map +1 -0
- package/dist/wire/server/common.zod.js +43 -0
- package/dist/wire/server/common.zod.js.map +1 -0
- package/dist/wire/server/index.d.ts +8 -0
- package/dist/wire/server/index.d.ts.map +1 -0
- package/dist/wire/server/index.js +8 -0
- package/dist/wire/server/index.js.map +1 -0
- package/dist/wire/server/pow.zod.d.ts +45 -0
- package/dist/wire/server/pow.zod.d.ts.map +1 -0
- package/dist/wire/server/pow.zod.js +18 -0
- package/dist/wire/server/pow.zod.js.map +1 -0
- package/dist/wire/server/quotes.zod.d.ts +694 -0
- package/dist/wire/server/quotes.zod.d.ts.map +1 -0
- package/dist/wire/server/quotes.zod.js +103 -0
- package/dist/wire/server/quotes.zod.js.map +1 -0
- package/dist/wire/server/swap.zod.d.ts +1981 -0
- package/dist/wire/server/swap.zod.d.ts.map +1 -0
- package/dist/wire/server/swap.zod.js +270 -0
- package/dist/wire/server/swap.zod.js.map +1 -0
- package/dist/wire/server/tokens.zod.d.ts +93 -0
- package/dist/wire/server/tokens.zod.d.ts.map +1 -0
- package/dist/wire/server/tokens.zod.js +28 -0
- package/dist/wire/server/tokens.zod.js.map +1 -0
- package/dist/wire/server/verify.zod.d.ts +30 -0
- package/dist/wire/server/verify.zod.d.ts.map +1 -0
- package/dist/wire/server/verify.zod.js +12 -0
- package/dist/wire/server/verify.zod.js.map +1 -0
- package/dist/wire/thorchain.zod.d.ts +224 -0
- package/dist/wire/thorchain.zod.d.ts.map +1 -0
- package/dist/wire/thorchain.zod.js +51 -0
- package/dist/wire/thorchain.zod.js.map +1 -0
- package/package.json +128 -0
- package/wasm/miradex-rust/README.md +74 -0
- package/wasm/miradex-rust/miradex_rust.d.ts +149 -0
- package/wasm/miradex-rust/miradex_rust.js +943 -0
- package/wasm/miradex-rust/miradex_rust_bg.wasm +0 -0
- package/wasm/miradex-rust/miradex_rust_bg.wasm.d.ts +31 -0
- package/wasm/miradex-rust/package.json +24 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified WASM loader + synchronous crypto wrappers.
|
|
3
|
+
*
|
|
4
|
+
* Callers invoke `await ensureWasm()` once (typically at the entry of an
|
|
5
|
+
* atomic-swap flow) and then call the synchronous wrappers afterwards.
|
|
6
|
+
* Thorchain, Chainflip, and NEAR-Intents verification paths never call this
|
|
7
|
+
* file, so the WASM binary is never loaded when those providers are used.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { detectPlatform } from './platform.js';
|
|
11
|
+
import { WasmError } from './errors.js';
|
|
12
|
+
import { SWAP_WASM_SHA256 } from '../../wasm-pins.js';
|
|
13
|
+
let cached = null;
|
|
14
|
+
let initInFlight = null;
|
|
15
|
+
export async function ensureWasm(options) {
|
|
16
|
+
if (cached)
|
|
17
|
+
return;
|
|
18
|
+
if (initInFlight) {
|
|
19
|
+
await initInFlight;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
initInFlight = (async () => {
|
|
23
|
+
const platform = detectPlatform();
|
|
24
|
+
let bytes;
|
|
25
|
+
if (options?.overrideBytes) {
|
|
26
|
+
bytes = options.overrideBytes;
|
|
27
|
+
}
|
|
28
|
+
else if (options?.loadBytes) {
|
|
29
|
+
bytes = await options.loadBytes();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
bytes = await readBytes(platform);
|
|
33
|
+
}
|
|
34
|
+
if (shouldVerifyIntegrity(options)) {
|
|
35
|
+
await verifyIntegrity(bytes);
|
|
36
|
+
}
|
|
37
|
+
const mod = await instantiate(bytes);
|
|
38
|
+
cached = mod;
|
|
39
|
+
return mod;
|
|
40
|
+
})();
|
|
41
|
+
try {
|
|
42
|
+
await initInFlight;
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
initInFlight = null;
|
|
46
|
+
if (err instanceof WasmError)
|
|
47
|
+
throw err;
|
|
48
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
49
|
+
throw new WasmError('E_WASM_INIT', `ensureWasm failed: ${message}`, err);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
initInFlight = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function getModule() {
|
|
56
|
+
if (!cached) {
|
|
57
|
+
throw new WasmError('E_WASM_NOT_LOADED', 'ensureWasm() must be called before this operation');
|
|
58
|
+
}
|
|
59
|
+
return cached;
|
|
60
|
+
}
|
|
61
|
+
function shouldVerifyIntegrity(opts) {
|
|
62
|
+
if (opts?.verifyIntegrity !== undefined)
|
|
63
|
+
return opts.verifyIntegrity;
|
|
64
|
+
return typeof process !== 'undefined' && process.env['MIRADEX_VERIFY_WASM'] === '1';
|
|
65
|
+
}
|
|
66
|
+
async function readBytes(platform) {
|
|
67
|
+
switch (platform) {
|
|
68
|
+
case 'node':
|
|
69
|
+
case 'electron-main':
|
|
70
|
+
return readBytesNode();
|
|
71
|
+
case 'browser':
|
|
72
|
+
case 'electron-renderer':
|
|
73
|
+
case 'worker':
|
|
74
|
+
return readBytesBrowser();
|
|
75
|
+
case 'react-native':
|
|
76
|
+
throw new WasmError('E_WASM_RN_REQUIRES_BYTES', 'React Native requires explicit bytes via ensureWasm({ overrideBytes })');
|
|
77
|
+
case 'unknown':
|
|
78
|
+
default:
|
|
79
|
+
throw new WasmError('E_WASM_PLATFORM_UNKNOWN', `cannot detect platform for WASM loading (got ${platform})`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function readBytesNode() {
|
|
83
|
+
const [{ readFile }, { fileURLToPath }] = await Promise.all([
|
|
84
|
+
import('node:fs/promises'),
|
|
85
|
+
import('node:url'),
|
|
86
|
+
]);
|
|
87
|
+
const url = new URL('../../../wasm/miradex-rust/miradex_rust_bg.wasm', import.meta.url);
|
|
88
|
+
const buffer = await readFile(fileURLToPath(url));
|
|
89
|
+
return new Uint8Array(buffer);
|
|
90
|
+
}
|
|
91
|
+
async function readBytesBrowser() {
|
|
92
|
+
const wasmUrl = new URL('../../../wasm/miradex-rust/miradex_rust_bg.wasm', import.meta.url);
|
|
93
|
+
const response = await fetch(wasmUrl);
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
throw new WasmError('E_WASM_FETCH', `fetch ${wasmUrl.href} returned ${response.status}`);
|
|
96
|
+
}
|
|
97
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
98
|
+
}
|
|
99
|
+
async function verifyIntegrity(bytes) {
|
|
100
|
+
const [{ sha256 }, { bytesToHex }] = await Promise.all([
|
|
101
|
+
import('@noble/hashes/sha2.js'),
|
|
102
|
+
import('@noble/hashes/utils.js'),
|
|
103
|
+
]);
|
|
104
|
+
const actual = bytesToHex(sha256(bytes));
|
|
105
|
+
if (actual !== SWAP_WASM_SHA256) {
|
|
106
|
+
throw new WasmError('E_WASM_INTEGRITY', `swap-wasm integrity check failed: expected ${SWAP_WASM_SHA256}, got ${actual}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function instantiate(bytes) {
|
|
110
|
+
const wasmBindgen = (await import('miradex-rust'));
|
|
111
|
+
await wasmBindgen.default({ module_or_path: bytes });
|
|
112
|
+
return wasmBindgen;
|
|
113
|
+
}
|
|
114
|
+
// Cache introspection / direct injection. `initKeygen` is the testing seam —
|
|
115
|
+
// production code only ever reaches the cache through `ensureWasm`.
|
|
116
|
+
export function isKeygenAvailable() {
|
|
117
|
+
return cached !== null;
|
|
118
|
+
}
|
|
119
|
+
export function initKeygen(mod) {
|
|
120
|
+
cached = mod;
|
|
121
|
+
}
|
|
122
|
+
// Synchronous wrappers below — every caller must `await ensureWasm()` first.
|
|
123
|
+
const ClientKeysSchema = z.object({
|
|
124
|
+
s_b_bitcoin: z.string(),
|
|
125
|
+
s_b_monero: z.string(),
|
|
126
|
+
s_b: z.string(),
|
|
127
|
+
dleq_proof: z.string(),
|
|
128
|
+
v_b: z.string(),
|
|
129
|
+
b: z.string(),
|
|
130
|
+
B: z.string(),
|
|
131
|
+
});
|
|
132
|
+
function parseClientKeys(jsonStr) {
|
|
133
|
+
const parsed = ClientKeysSchema.safeParse(JSON.parse(jsonStr));
|
|
134
|
+
if (!parsed.success) {
|
|
135
|
+
throw new WasmError('E_CLIENT_KEYS_SHAPE', `Invalid key format from WASM: ${parsed.error.message}`);
|
|
136
|
+
}
|
|
137
|
+
return parsed.data;
|
|
138
|
+
}
|
|
139
|
+
export function generateClientKeys() {
|
|
140
|
+
return parseClientKeys(getModule().generate_client_keys());
|
|
141
|
+
}
|
|
142
|
+
export function generateClientKeysFromSeed(sBHex, vBHex, bHex) {
|
|
143
|
+
return parseClientKeys(getModule().generate_client_keys_from_seed(sBHex, vBHex, bHex));
|
|
144
|
+
}
|
|
145
|
+
export function verifyDleqProof(sBitcoinHex, sMoneroHex, proofHex) {
|
|
146
|
+
return getModule().verify_dleq_proof(sBitcoinHex, sMoneroHex, proofHex);
|
|
147
|
+
}
|
|
148
|
+
export function signDigest(bHex, digestHex) {
|
|
149
|
+
return getModule().sign_digest(bHex, digestHex);
|
|
150
|
+
}
|
|
151
|
+
export function encsignDigest(bHex, encryptionKeyHex, digestHex) {
|
|
152
|
+
return getModule().encsign_digest(bHex, encryptionKeyHex, digestHex);
|
|
153
|
+
}
|
|
154
|
+
export function decryptSignature(scalarHex, encsigHex) {
|
|
155
|
+
return getModule().decrypt_signature(scalarHex, encsigHex);
|
|
156
|
+
}
|
|
157
|
+
export function verifyEncsig(verificationKeyHex, encryptionKeyHex, digestHex, encsigHex) {
|
|
158
|
+
return getModule().verify_encsig(verificationKeyHex, encryptionKeyHex, digestHex, encsigHex);
|
|
159
|
+
}
|
|
160
|
+
export function recoverAdaptorScalar(sigHex, encsigHex, encryptionKeyHex) {
|
|
161
|
+
return getModule().recover_adaptor_scalar(sigHex, encsigHex, encryptionKeyHex);
|
|
162
|
+
}
|
|
163
|
+
export function deriveKeyImages(outputsJson, viewKeyHex, spendKeyHex) {
|
|
164
|
+
return getModule().derive_key_images(outputsJson, viewKeyHex, spendKeyHex);
|
|
165
|
+
}
|
|
166
|
+
export function selectDecoys(realOutputIndex, distributionJson, ringSize) {
|
|
167
|
+
return getModule().select_decoys(BigInt(realOutputIndex), distributionJson, ringSize);
|
|
168
|
+
}
|
|
169
|
+
export function signSweepTx(constructionDataJson, spendKeyHex, viewKeyHex) {
|
|
170
|
+
return getModule().sign_sweep_tx(constructionDataJson, spendKeyHex, viewKeyHex);
|
|
171
|
+
}
|
|
172
|
+
export function computeCommitmentMask(viewKeyHex, txPublicKeyHex, outputIndex) {
|
|
173
|
+
return getModule().compute_commitment_mask(viewKeyHex, txPublicKeyHex, BigInt(outputIndex));
|
|
174
|
+
}
|
|
175
|
+
export function verifyCommitment(viewKeyHex, txPublicKeyHex, outputIndex, amount, onChainCommitmentHex) {
|
|
176
|
+
return getModule().verify_commitment(viewKeyHex, txPublicKeyHex, BigInt(outputIndex), BigInt(amount), onChainCommitmentHex);
|
|
177
|
+
}
|
|
178
|
+
export function decryptAmount(viewKeyHex, txPublicKeyHex, outputIndex, encryptedAmountHex) {
|
|
179
|
+
return getModule().decrypt_amount(viewKeyHex, txPublicKeyHex, BigInt(outputIndex), encryptedAmountHex);
|
|
180
|
+
}
|
|
181
|
+
export function secp256k1ScalarToEd25519(secpScalarHex) {
|
|
182
|
+
return getModule().secp256k1_scalar_to_ed25519(secpScalarHex);
|
|
183
|
+
}
|
|
184
|
+
export function ed25519ScalarAdd(scalarAHex, scalarBHex) {
|
|
185
|
+
return getModule().ed25519_scalar_add(scalarAHex, scalarBHex);
|
|
186
|
+
}
|
|
187
|
+
/** Test-only: reset the cache so successive tests can re-init the module. */
|
|
188
|
+
export function __resetWasmCache() {
|
|
189
|
+
cached = null;
|
|
190
|
+
initInFlight = null;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=wasm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../../src/lib/crypto/wasm.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAiB,MAAM,e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,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB;IAC9B,MAAM,GAAG,IAAI,CAAC;IACd,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized default configuration values.
|
|
3
|
+
*
|
|
4
|
+
* Every hardcoded default used across the codebase lives here.
|
|
5
|
+
* Individual modules import what they need — no magic strings scattered
|
|
6
|
+
* across files. When adding new infrastructure defaults, put them here.
|
|
7
|
+
*/
|
|
8
|
+
export declare const API_URL = "http://127.0.0.1:7001/";
|
|
9
|
+
export declare const API_TOR_URL = "http://miradextor.onion:7001";
|
|
10
|
+
export declare const API_TIMEOUT_MS = 30000;
|
|
11
|
+
export declare const API_MAX_RETRIES = 3;
|
|
12
|
+
export declare const API_RETRY_BASE_MS = 1000;
|
|
13
|
+
export declare const TOR_SOCKS_PROXY = "socks5://127.0.0.1:9050";
|
|
14
|
+
export declare const TOR_MANAGED_PORT = 47652;
|
|
15
|
+
export declare const TOR_EXTERNAL_PORT = 9050;
|
|
16
|
+
export declare const TOR_MODE: 'external' | 'bundled';
|
|
17
|
+
export interface ElectrumServerEntry {
|
|
18
|
+
readonly host: string;
|
|
19
|
+
readonly port: number;
|
|
20
|
+
readonly ssl: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Primary Electrum server URL (used in config schema default). */
|
|
23
|
+
export declare const ELECTRUM_PRIMARY_URL = "ssl://electrum.blockstream.info:50002";
|
|
24
|
+
/** Testnet Electrum server URL. */
|
|
25
|
+
export declare const ELECTRUM_TESTNET_URL = "ssl://electrum.blockstream.info:60002";
|
|
26
|
+
/** Resolve the correct Electrum server URL for a given network. */
|
|
27
|
+
export declare function electrumUrlForNetwork(configuredUrl: string, network: 'mainnet' | 'testnet' | 'regtest'): string;
|
|
28
|
+
/** Ordered list of Electrum servers. First entry is the primary. */
|
|
29
|
+
export declare const ELECTRUM_SERVERS: readonly ElectrumServerEntry[];
|
|
30
|
+
export declare const ELECTRUM_CONNECT_TIMEOUT_MS = 8000;
|
|
31
|
+
export declare const ELECTRUM_REQUEST_TIMEOUT_MS = 10000;
|
|
32
|
+
/** Chain the node list applies to. */
|
|
33
|
+
export type DefaultNodeBlockchain = 'bitcoin' | 'monero';
|
|
34
|
+
/**
|
|
35
|
+
* Curated Monero mainnet RPC endpoints. Browser-hit directly (no proxy)
|
|
36
|
+
* by design — for real-money swaps the client must not trust a single
|
|
37
|
+
* server-side proxy. Every entry below was probed (2026-05) and confirmed
|
|
38
|
+
* to:
|
|
39
|
+
* - return `Access-Control-Allow-Origin: *` (browser-fetchable),
|
|
40
|
+
* - serve `nettype=mainnet`,
|
|
41
|
+
* - present a valid TLS chain.
|
|
42
|
+
*
|
|
43
|
+
* Mainnet stays out of the crypto-server proxy on purpose — see
|
|
44
|
+
* `apps/crypto-server/src/swap/routes/monero-proxy.routes.ts`. Only
|
|
45
|
+
* stagenet/testnet runs through the proxy because there's no real-money
|
|
46
|
+
* trust to preserve in test flows.
|
|
47
|
+
*/
|
|
48
|
+
export declare const MONERO_MAINNET_NODES: readonly string[];
|
|
49
|
+
/**
|
|
50
|
+
* Curated Monero stagenet RPC endpoints. Stagenet is Monero's public test
|
|
51
|
+
* network (the Monero analogue of Bitcoin testnet).
|
|
52
|
+
*/
|
|
53
|
+
export declare const MONERO_STAGENET_NODES: readonly string[];
|
|
54
|
+
/**
|
|
55
|
+
* Default node URLs per network per chain. URLs use the `scheme://host:port`
|
|
56
|
+
* form that Electrum / monerod clients accept directly. For Monero, the
|
|
57
|
+
* `testnet` key holds stagenet endpoints (Monero has no parallel-to-Bitcoin
|
|
58
|
+
* 'testnet' notion — the closest public net is stagenet).
|
|
59
|
+
*/
|
|
60
|
+
export declare const DEFAULT_NODES: Readonly<Record<'mainnet' | 'testnet' | 'regtest', Readonly<Record<DefaultNodeBlockchain, readonly string[]>>>>;
|
|
61
|
+
export declare const MEMPOOL_API = "https://mempool.space/api";
|
|
62
|
+
export declare const MEMPOOL_TESTNET_API = "https://mempool.space/testnet/api";
|
|
63
|
+
/** Estimated vbytes for a 1-input P2WPKH → 1-output P2WSH transaction.
|
|
64
|
+
* Header(10.5) + P2WPKH input(68) + P2WSH output(43) ≈ 122 vbytes.
|
|
65
|
+
* Rounded up to 130 for safety margin (signature size variance). */
|
|
66
|
+
export declare const LOCK_TX_VBYTES = 130;
|
|
67
|
+
/** Fallback feerate when all fee sources are unreachable (sat/vbyte). */
|
|
68
|
+
export declare const FALLBACK_FEE_RATE = 10;
|
|
69
|
+
/**
|
|
70
|
+
* Minimum feerate for the funding tx (sat/vbyte). Bitcoin Core's default
|
|
71
|
+
* `minrelaytxfee` is 1.0, but many public and testnet nodes raise this to
|
|
72
|
+
* 1.5–3.0 sat/vB. Setting this floor below 3 produces sporadic
|
|
73
|
+
* "min relay fee not met" rejections that force a re-sign. 3 sat/vB covers
|
|
74
|
+
* every sane operator policy we've observed with negligible extra cost.
|
|
75
|
+
*/
|
|
76
|
+
export declare const MIN_FEE_RATE = 3;
|
|
77
|
+
/**
|
|
78
|
+
* Safety margin applied to the estimated feerate. Covers the race between
|
|
79
|
+
* estimate-at-deposit-time and broadcast-at-fund-time when mempool pressure
|
|
80
|
+
* changes. 1.25 = +25% headroom on top of the estimate.
|
|
81
|
+
*/
|
|
82
|
+
export declare const FEE_MARGIN_MULTIPLIER = 1.25;
|
|
83
|
+
/**
|
|
84
|
+
* Sanity ceilings on the broadcast feerate (sat/vbyte). Without this cap,
|
|
85
|
+
* a misbehaving fee oracle can drive the lock-tx fee above the deposit
|
|
86
|
+
* value itself. Testnet is especially prone: its mempool has no real
|
|
87
|
+
* fee market, electrum servers and mempool.space/testnet routinely
|
|
88
|
+
* return absurd `halfHourFee` values (we've seen >250 sat/vB on a chain
|
|
89
|
+
* where 1 sat/vB confirms in one block).
|
|
90
|
+
*
|
|
91
|
+
* Mainnet ceiling is set conservatively above historical peak conditions
|
|
92
|
+
* — it catches oracle bugs without gating real high-fee periods.
|
|
93
|
+
*/
|
|
94
|
+
export declare const MAX_FEE_RATE_MAINNET = 100;
|
|
95
|
+
export declare const MAX_FEE_RATE_TESTNET = 10;
|
|
96
|
+
export declare const DEPOSIT_POLL_MS = 5000;
|
|
97
|
+
export declare const FUNDING_POLL_MS = 5000;
|
|
98
|
+
export declare const FUNDING_TIMEOUT_MS = 300000;
|
|
99
|
+
export declare const FUNDING_SETTLE_MS = 15000;
|
|
100
|
+
export declare const SWEEP_POLL_MS = 30000;
|
|
101
|
+
export declare const SWEEP_TIMEOUT_MS = 3600000;
|
|
102
|
+
export declare const POW_MAX_RETRIES = 3;
|
|
103
|
+
export declare const POW_BACKOFF_MS = 2000;
|
|
104
|
+
export declare const DEFAULT_SLIPPAGE_BPS = 100;
|
|
105
|
+
export declare const DEFAULT_MAX_DEVIATION_BPS = 300;
|
|
106
|
+
export declare const DEFAULT_FROM_TOKEN = "BTC";
|
|
107
|
+
export declare const DEFAULT_TO_TOKEN = "XMR";
|
|
108
|
+
export declare const DEFAULT_FIAT = "USD";
|
|
109
|
+
export declare const BTC_P2WPKH_INPUT_VBYTES = 68n;
|
|
110
|
+
export declare const BTC_P2WSH_INPUT_VBYTES = 76n;
|
|
111
|
+
export declare const BTC_TX_OVERHEAD_VBYTES = 42n;
|
|
112
|
+
export declare const BTC_VBYTES_SINGLE_IN_SINGLE_OUT = 154n;
|
|
113
|
+
export declare const BTC_VBYTES_SINGLE_IN_TWO_OUT = 187n;
|
|
114
|
+
export declare const ELECTRUM_DEFAULT_SSL_PORT = 50002;
|
|
115
|
+
export declare const ELECTRUM_DEFAULT_TCP_PORT = 50001;
|
|
116
|
+
export declare const ELECTRUM_QUORUM = 2;
|
|
117
|
+
export declare const VERIFY_MAX_ATTEMPTS = 12;
|
|
118
|
+
export declare const VERIFY_RETRY_DELAY_MS = 5000;
|
|
119
|
+
export declare const VERIFY_FETCH_TIMEOUT_MS = 10000;
|
|
120
|
+
export declare const BROADCAST_TIMEOUT_MS = 10000;
|
|
121
|
+
export declare const MAX_DEPOSIT_UTXOS = 10;
|
|
122
|
+
export declare const MIN_XMR_CONFIRMATIONS = 10;
|
|
123
|
+
export declare const MONERO_RING_SIZE = 16;
|
|
124
|
+
export declare const MONERO_PRE_CLSAG_RING_SIZE = 11;
|
|
125
|
+
export declare const MONERO_FETCH_TIMEOUT_MS = 15000;
|
|
126
|
+
export declare const MONERO_QUORUM = 2;
|
|
127
|
+
export declare const MONERO_SWEEP_MAX_ATTEMPTS = 5;
|
|
128
|
+
export declare const MONERO_SWEEP_MAX_RING_RETRIES = 5;
|
|
129
|
+
export declare const MONERO_TX_SIZE_ESTIMATE = 3200;
|
|
130
|
+
export declare const MONERO_FALLBACK_FEE_PER_BYTE = 23000n;
|
|
131
|
+
export declare const MONERO_MIN_FEE_PICONEROS = 10n;
|
|
132
|
+
export declare const MONERO_MAX_FEE_RATIO_BPS = 1000;
|
|
133
|
+
export declare const POW_BATCH_YIELD_SIZE = 10000;
|
|
134
|
+
export declare const ENGINE_SLIPPAGE_MIN_BPS = 10;
|
|
135
|
+
export declare const ENGINE_SLIPPAGE_MAX_BPS = 500;
|
|
136
|
+
export declare const ENGINE_POLL_MIN_MS = 100;
|
|
137
|
+
export declare const ENGINE_POLL_MAX_MS = 30000;
|
|
138
|
+
export declare const ENGINE_RETRY_MIN = 1;
|
|
139
|
+
export declare const ENGINE_RETRY_MAX = 10;
|
|
140
|
+
//# sourceMappingURL=default-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-config.d.ts","sourceRoot":"","sources":["../../src/lib/default-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,WAAW,iCAAiC,CAAC;AAC1D,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AAEvC,eAAO,MAAM,eAAe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AAO,MAAM,oBAAoB,QAAS,CAAC;AAG3C,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAGpC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAC9C,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,eAAO,MAAM,4BAA4B,SAAU,CAAC;AACpD,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAG9C,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAG3C,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,KAAK,CAAC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized default configuration values.
|
|
3
|
+
*
|
|
4
|
+
* Every hardcoded default used across the codebase lives here.
|
|
5
|
+
* Individual modules import what they need — no magic strings scattered
|
|
6
|
+
* across files. When adding new infrastructure defaults, put them here.
|
|
7
|
+
*/
|
|
8
|
+
export const API_URL = 'http://127.0.0.1:7001/';
|
|
9
|
+
export const API_TOR_URL = 'http://miradextor.onion:7001';
|
|
10
|
+
export const API_TIMEOUT_MS = 30_000;
|
|
11
|
+
export const API_MAX_RETRIES = 3;
|
|
12
|
+
export const API_RETRY_BASE_MS = 1_000;
|
|
13
|
+
export const TOR_SOCKS_PROXY = 'socks5://127.0.0.1:9050';
|
|
14
|
+
// IANA-unassigned private port. Picked deliberately to avoid collisions with
|
|
15
|
+
// Feather Wallet (19_450), system Tor (9_050), and other common dev services.
|
|
16
|
+
export const TOR_MANAGED_PORT = 47_652;
|
|
17
|
+
export const TOR_EXTERNAL_PORT = 9_050;
|
|
18
|
+
export const TOR_MODE = 'bundled';
|
|
19
|
+
/** Primary Electrum server URL (used in config schema default). */
|
|
20
|
+
export const ELECTRUM_PRIMARY_URL = 'ssl://electrum.blockstream.info:50002';
|
|
21
|
+
/** Testnet Electrum server URL. */
|
|
22
|
+
export const ELECTRUM_TESTNET_URL = 'ssl://electrum.blockstream.info:60002';
|
|
23
|
+
/** Resolve the correct Electrum server URL for a given network. */
|
|
24
|
+
export function electrumUrlForNetwork(configuredUrl, network) {
|
|
25
|
+
// If user explicitly configured a server, respect it regardless of network
|
|
26
|
+
if (configuredUrl !== ELECTRUM_PRIMARY_URL)
|
|
27
|
+
return configuredUrl;
|
|
28
|
+
// Default server: swap to testnet variant
|
|
29
|
+
return network === 'testnet' ? ELECTRUM_TESTNET_URL : configuredUrl;
|
|
30
|
+
}
|
|
31
|
+
/** Ordered list of Electrum servers. First entry is the primary. */
|
|
32
|
+
export const ELECTRUM_SERVERS = [
|
|
33
|
+
{ host: 'electrum.blockstream.info', port: 50002, ssl: true },
|
|
34
|
+
{ host: 'electrum.eigenwallet.org', port: 22293, ssl: false },
|
|
35
|
+
{ host: 'bitcoin.stackwallet.com', port: 50002, ssl: true },
|
|
36
|
+
{ host: 'b.1209k.com', port: 50002, ssl: true },
|
|
37
|
+
{ host: 'mainnet.foundationdevices.com', port: 50002, ssl: true },
|
|
38
|
+
{ host: 'bitcoin.lu.ke', port: 50001, ssl: false },
|
|
39
|
+
{ host: 'electrum.coinfinity.co', port: 50002, ssl: true },
|
|
40
|
+
{ host: 'electrum1.bluewallet.io', port: 50001, ssl: false },
|
|
41
|
+
{ host: 'electrum2.bluewallet.io', port: 50001, ssl: false },
|
|
42
|
+
{ host: 'electrum3.bluewallet.io', port: 50001, ssl: false },
|
|
43
|
+
{ host: 'btc-electrum.cakewallet.com', port: 50002, ssl: true },
|
|
44
|
+
{ host: 'bitcoin.aranguren.org', port: 50001, ssl: false },
|
|
45
|
+
];
|
|
46
|
+
export const ELECTRUM_CONNECT_TIMEOUT_MS = 8_000;
|
|
47
|
+
export const ELECTRUM_REQUEST_TIMEOUT_MS = 10_000;
|
|
48
|
+
/**
|
|
49
|
+
* Curated Monero mainnet RPC endpoints. Browser-hit directly (no proxy)
|
|
50
|
+
* by design — for real-money swaps the client must not trust a single
|
|
51
|
+
* server-side proxy. Every entry below was probed (2026-05) and confirmed
|
|
52
|
+
* to:
|
|
53
|
+
* - return `Access-Control-Allow-Origin: *` (browser-fetchable),
|
|
54
|
+
* - serve `nettype=mainnet`,
|
|
55
|
+
* - present a valid TLS chain.
|
|
56
|
+
*
|
|
57
|
+
* Mainnet stays out of the crypto-server proxy on purpose — see
|
|
58
|
+
* `apps/crypto-server/src/swap/routes/monero-proxy.routes.ts`. Only
|
|
59
|
+
* stagenet/testnet runs through the proxy because there's no real-money
|
|
60
|
+
* trust to preserve in test flows.
|
|
61
|
+
*/
|
|
62
|
+
export const MONERO_MAINNET_NODES = [
|
|
63
|
+
'https://node.sethforprivacy.com',
|
|
64
|
+
'https://node.sethforprivacy.com:443',
|
|
65
|
+
'https://dewitte.fiatfaucet.com',
|
|
66
|
+
'https://chad.fiatfaucet.com',
|
|
67
|
+
'https://kowalski.fiatfaucet.com',
|
|
68
|
+
'https://connect.xmr-node.org',
|
|
69
|
+
'https://connect.xmr-node.org:443',
|
|
70
|
+
'https://monerod.not.futbol',
|
|
71
|
+
'https://xmr.0xrpc.io',
|
|
72
|
+
'https://xmr.jayjonkman.nl:18089',
|
|
73
|
+
'https://monero.definitelynotafed.com',
|
|
74
|
+
'https://monero.definitelynotafed.com:443',
|
|
75
|
+
'https://xmr1.doggett.tech:18089',
|
|
76
|
+
'https://xmr2.doggett.tech:18089',
|
|
77
|
+
'https://xmr3.doggett.tech:18089',
|
|
78
|
+
'https://xmr4.doggett.tech:18089',
|
|
79
|
+
'https://xmr5.doggett.tech:18089',
|
|
80
|
+
'https://public-monero-node.xyz',
|
|
81
|
+
'https://public-monero-node.xyz:443',
|
|
82
|
+
'https://xmr.hexide.com',
|
|
83
|
+
'https://xmr.greyfox.tech:443',
|
|
84
|
+
'https://xmr-node.cakewallet.com:18081',
|
|
85
|
+
'https://xmr.surveillance.monster',
|
|
86
|
+
'https://node.xmr.surf',
|
|
87
|
+
'https://xmr.thinhhv.com:443',
|
|
88
|
+
'https://xmr.unshakled.net',
|
|
89
|
+
'https://xmr.unshakled.net:443',
|
|
90
|
+
'https://xmr.cryptostorm.is:18081',
|
|
91
|
+
'https://xmr.qu.ax:443',
|
|
92
|
+
'https://monero-rpc.cheems.de.box.skhron.com.ua:18089',
|
|
93
|
+
'https://xmr.letmego.me',
|
|
94
|
+
'https://xmr.letmego.me:443',
|
|
95
|
+
'https://xmr.ci.vet:443',
|
|
96
|
+
'https://xmr.winslow.cloud:18089',
|
|
97
|
+
'https://xmr.visnova.pl',
|
|
98
|
+
'https://monero.openinternet.io',
|
|
99
|
+
'https://xmr.support:18089',
|
|
100
|
+
];
|
|
101
|
+
/**
|
|
102
|
+
* Curated Monero stagenet RPC endpoints. Stagenet is Monero's public test
|
|
103
|
+
* network (the Monero analogue of Bitcoin testnet).
|
|
104
|
+
*/
|
|
105
|
+
export const MONERO_STAGENET_NODES = [
|
|
106
|
+
'https://node.sethforprivacy.com:38089',
|
|
107
|
+
'https://testnet.miradex.io/api/v1/swap/proxy/monero/stagenet',
|
|
108
|
+
'https://testnet.miradex.io/api/v1/swap/proxy/monero/stagenet'
|
|
109
|
+
];
|
|
110
|
+
/**
|
|
111
|
+
* Default node URLs per network per chain. URLs use the `scheme://host:port`
|
|
112
|
+
* form that Electrum / monerod clients accept directly. For Monero, the
|
|
113
|
+
* `testnet` key holds stagenet endpoints (Monero has no parallel-to-Bitcoin
|
|
114
|
+
* 'testnet' notion — the closest public net is stagenet).
|
|
115
|
+
*/
|
|
116
|
+
export const DEFAULT_NODES = {
|
|
117
|
+
testnet: {
|
|
118
|
+
bitcoin: [
|
|
119
|
+
'ssl://blackie.c3-soft.com:57006',
|
|
120
|
+
'ssl://v22019051929289916.bestsrv.de:50002',
|
|
121
|
+
'tcp://v22019051929289916.bestsrv.de:50001',
|
|
122
|
+
'ssl://electrum.blockstream.info:60002',
|
|
123
|
+
'ssl://blockstream.info:993',
|
|
124
|
+
'tcp://testnet.aranguren.org:51001',
|
|
125
|
+
'ssl://testnet.aranguren.org:51002',
|
|
126
|
+
'ssl://bitcoin.devmole.eu:5010',
|
|
127
|
+
'tcp://bitcoin.devmole.eu:5000',
|
|
128
|
+
],
|
|
129
|
+
monero: MONERO_STAGENET_NODES,
|
|
130
|
+
},
|
|
131
|
+
mainnet: {
|
|
132
|
+
bitcoin: [
|
|
133
|
+
'tcp://electrum.eigenwallet.org:22293',
|
|
134
|
+
'ssl://electrum.blockstream.info:50002',
|
|
135
|
+
'ssl://bitcoin.stackwallet.com:50002',
|
|
136
|
+
'ssl://b.1209k.com:50002',
|
|
137
|
+
'ssl://mainnet.foundationdevices.com:50002',
|
|
138
|
+
'tcp://bitcoin.lu.ke:50001',
|
|
139
|
+
'ssl://electrum.coinfinity.co:50002',
|
|
140
|
+
'tcp://electrum1.bluewallet.io:50001',
|
|
141
|
+
'tcp://electrum2.bluewallet.io:50001',
|
|
142
|
+
'tcp://electrum3.bluewallet.io:50001',
|
|
143
|
+
'ssl://btc-electrum.cakewallet.com:50002',
|
|
144
|
+
'tcp://bitcoin.aranguren.org:50001',
|
|
145
|
+
],
|
|
146
|
+
monero: MONERO_MAINNET_NODES,
|
|
147
|
+
},
|
|
148
|
+
regtest: {
|
|
149
|
+
bitcoin: [],
|
|
150
|
+
monero: [],
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
export const MEMPOOL_API = 'https://mempool.space/api';
|
|
154
|
+
export const MEMPOOL_TESTNET_API = 'https://mempool.space/testnet/api';
|
|
155
|
+
/** Estimated vbytes for a 1-input P2WPKH → 1-output P2WSH transaction.
|
|
156
|
+
* Header(10.5) + P2WPKH input(68) + P2WSH output(43) ≈ 122 vbytes.
|
|
157
|
+
* Rounded up to 130 for safety margin (signature size variance). */
|
|
158
|
+
export const LOCK_TX_VBYTES = 130;
|
|
159
|
+
/** Fallback feerate when all fee sources are unreachable (sat/vbyte). */
|
|
160
|
+
export const FALLBACK_FEE_RATE = 10;
|
|
161
|
+
/**
|
|
162
|
+
* Minimum feerate for the funding tx (sat/vbyte). Bitcoin Core's default
|
|
163
|
+
* `minrelaytxfee` is 1.0, but many public and testnet nodes raise this to
|
|
164
|
+
* 1.5–3.0 sat/vB. Setting this floor below 3 produces sporadic
|
|
165
|
+
* "min relay fee not met" rejections that force a re-sign. 3 sat/vB covers
|
|
166
|
+
* every sane operator policy we've observed with negligible extra cost.
|
|
167
|
+
*/
|
|
168
|
+
export const MIN_FEE_RATE = 3;
|
|
169
|
+
/**
|
|
170
|
+
* Safety margin applied to the estimated feerate. Covers the race between
|
|
171
|
+
* estimate-at-deposit-time and broadcast-at-fund-time when mempool pressure
|
|
172
|
+
* changes. 1.25 = +25% headroom on top of the estimate.
|
|
173
|
+
*/
|
|
174
|
+
export const FEE_MARGIN_MULTIPLIER = 1.25;
|
|
175
|
+
/**
|
|
176
|
+
* Sanity ceilings on the broadcast feerate (sat/vbyte). Without this cap,
|
|
177
|
+
* a misbehaving fee oracle can drive the lock-tx fee above the deposit
|
|
178
|
+
* value itself. Testnet is especially prone: its mempool has no real
|
|
179
|
+
* fee market, electrum servers and mempool.space/testnet routinely
|
|
180
|
+
* return absurd `halfHourFee` values (we've seen >250 sat/vB on a chain
|
|
181
|
+
* where 1 sat/vB confirms in one block).
|
|
182
|
+
*
|
|
183
|
+
* Mainnet ceiling is set conservatively above historical peak conditions
|
|
184
|
+
* — it catches oracle bugs without gating real high-fee periods.
|
|
185
|
+
*/
|
|
186
|
+
export const MAX_FEE_RATE_MAINNET = 100;
|
|
187
|
+
export const MAX_FEE_RATE_TESTNET = 10;
|
|
188
|
+
export const DEPOSIT_POLL_MS = 5_000;
|
|
189
|
+
export const FUNDING_POLL_MS = 5_000;
|
|
190
|
+
export const FUNDING_TIMEOUT_MS = 300_000;
|
|
191
|
+
export const FUNDING_SETTLE_MS = 15_000;
|
|
192
|
+
export const SWEEP_POLL_MS = 30_000;
|
|
193
|
+
export const SWEEP_TIMEOUT_MS = 3_600_000;
|
|
194
|
+
export const POW_MAX_RETRIES = 3;
|
|
195
|
+
export const POW_BACKOFF_MS = 2_000;
|
|
196
|
+
export const DEFAULT_SLIPPAGE_BPS = 100;
|
|
197
|
+
export const DEFAULT_MAX_DEVIATION_BPS = 300;
|
|
198
|
+
export const DEFAULT_FROM_TOKEN = 'BTC';
|
|
199
|
+
export const DEFAULT_TO_TOKEN = 'XMR';
|
|
200
|
+
export const DEFAULT_FIAT = 'USD';
|
|
201
|
+
// BTC
|
|
202
|
+
export const BTC_P2WPKH_INPUT_VBYTES = 68n;
|
|
203
|
+
export const BTC_P2WSH_INPUT_VBYTES = 76n;
|
|
204
|
+
export const BTC_TX_OVERHEAD_VBYTES = 42n;
|
|
205
|
+
export const BTC_VBYTES_SINGLE_IN_SINGLE_OUT = 154n;
|
|
206
|
+
export const BTC_VBYTES_SINGLE_IN_TWO_OUT = 187n;
|
|
207
|
+
// Bitcoin Electrum
|
|
208
|
+
export const ELECTRUM_DEFAULT_SSL_PORT = 50_002;
|
|
209
|
+
export const ELECTRUM_DEFAULT_TCP_PORT = 50_001;
|
|
210
|
+
export const ELECTRUM_QUORUM = 2;
|
|
211
|
+
// Verification
|
|
212
|
+
export const VERIFY_MAX_ATTEMPTS = 12;
|
|
213
|
+
export const VERIFY_RETRY_DELAY_MS = 5_000;
|
|
214
|
+
export const VERIFY_FETCH_TIMEOUT_MS = 10_000;
|
|
215
|
+
export const BROADCAST_TIMEOUT_MS = 10_000;
|
|
216
|
+
// Deposit safety
|
|
217
|
+
export const MAX_DEPOSIT_UTXOS = 10;
|
|
218
|
+
// XMR / Monero
|
|
219
|
+
export const MIN_XMR_CONFIRMATIONS = 10;
|
|
220
|
+
export const MONERO_RING_SIZE = 16;
|
|
221
|
+
export const MONERO_PRE_CLSAG_RING_SIZE = 11;
|
|
222
|
+
export const MONERO_FETCH_TIMEOUT_MS = 15_000;
|
|
223
|
+
export const MONERO_QUORUM = 2;
|
|
224
|
+
export const MONERO_SWEEP_MAX_ATTEMPTS = 5;
|
|
225
|
+
export const MONERO_SWEEP_MAX_RING_RETRIES = 5;
|
|
226
|
+
export const MONERO_TX_SIZE_ESTIMATE = 3_200;
|
|
227
|
+
export const MONERO_FALLBACK_FEE_PER_BYTE = 23000n;
|
|
228
|
+
export const MONERO_MIN_FEE_PICONEROS = 10n;
|
|
229
|
+
export const MONERO_MAX_FEE_RATIO_BPS = 1_000;
|
|
230
|
+
// PoW
|
|
231
|
+
export const POW_BATCH_YIELD_SIZE = 10_000;
|
|
232
|
+
// Engine bounds (Fix 8.4.8)
|
|
233
|
+
export const ENGINE_SLIPPAGE_MIN_BPS = 10;
|
|
234
|
+
export const ENGINE_SLIPPAGE_MAX_BPS = 500;
|
|
235
|
+
export const ENGINE_POLL_MIN_MS = 100;
|
|
236
|
+
export const ENGINE_POLL_MAX_MS = 30_000;
|
|
237
|
+
export const ENGINE_RETRY_MIN = 1;
|
|
238
|
+
export const ENGINE_RETRY_MAX = 10;
|
|
239
|
+
//# sourceMappingURL=default-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-config.js","sourceRoot":"","sources":["../../src/lib/default-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAC1D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAA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[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBrE;AAED,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,gBAAgB;;CAI9B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function delay(ms, signal) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
if (signal?.aborted) {
|
|
4
|
+
reject(new AbortError());
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const timer = setTimeout(resolve, ms);
|
|
8
|
+
signal?.addEventListener('abort', () => {
|
|
9
|
+
clearTimeout(timer);
|
|
10
|
+
reject(new AbortError());
|
|
11
|
+
}, { once: true });
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export class AbortError extends Error {
|
|
15
|
+
name = 'AbortError';
|
|
16
|
+
constructor() {
|
|
17
|
+
super('Aborted');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=delay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../src/lib/delay.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,EAAU,EAAE,MAAoB;IACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;YACzB,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACtC,MAAM,EAAE,gBAAgB,CACtB,OAAO,EACP,GAAG,EAAE;YACH,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;QAC3B,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,GAAG,YAAY,CAAC;IAC7B;QACE,KAAK,CAAC,SAAS,CAAC,CAAC;IACnB,CAAC;CACF"}
|