@babylonlabs-io/ts-sdk 0.39.5 → 0.40.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/dist/{PeginManager-B1qjHs90.js → PeginManager-D9ZZ8wx2.js} +2 -2
- package/dist/{PeginManager-B1qjHs90.js.map → PeginManager-D9ZZ8wx2.js.map} +1 -1
- package/dist/{PeginManager-Dof0ZO1S.cjs → PeginManager-UqbOj2oV.cjs} +2 -2
- package/dist/{PeginManager-Dof0ZO1S.cjs.map → PeginManager-UqbOj2oV.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +74 -73
- package/dist/{mempoolApi-CAIge7Nj.js → mempoolApi-C7hkVkym.js} +31 -22
- package/dist/mempoolApi-C7hkVkym.js.map +1 -0
- package/dist/mempoolApi-DEAS9wVa.cjs +2 -0
- package/dist/mempoolApi-DEAS9wVa.cjs.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +33 -32
- package/dist/tbv/core/clients/mempool/index.d.ts +1 -1
- package/dist/tbv/core/clients/mempool/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/mempool/mempoolApi.d.ts +11 -0
- package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +74 -73
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +74 -73
- package/package.json +3 -3
- package/dist/mempoolApi-CAIge7Nj.js.map +0 -1
- package/dist/mempoolApi-YNkKjQCU.cjs +0 -2
- package/dist/mempoolApi-YNkKjQCU.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./challengeAssert-rpDaS3fH.cjs"),c=require("@babylonlabs-io/babylon-tbv-rust-wasm"),u=require("./assertPsbtUnsignedTxMatches-r1svclbd.cjs"),A=require("./peginInput-DH6X4ITS.cjs"),_=require("./noPayout-B06Z9RTe.cjs"),r=require("./bitcoin-CHfKAhcI.cjs"),g=require("./signing-Bnsro0hE.cjs"),d=require("./validation-u8W7Lp2x.cjs"),n=require("./PeginManager-Dof0ZO1S.cjs"),S=require("./PayoutManager-B5bovfkD.cjs"),p=require("./ProtocolParams.abi-DQhcqsNr.cjs"),m=require("./BTCVaultRegistry.abi-CHFGevwa.cjs"),P=require("./errors-BP73_stm.cjs"),I=require("./shared/index.cjs"),i=require("./waitForTransactionReceiptSmartAware-tv1mtSIY.cjs"),a=require("./fundPeginTransaction-BBE3wTjR.cjs"),l=require("./reservation-hjXStM03.cjs"),s=require("./mempoolApi-YNkKjQCU.cjs"),t=require("./types-Be3sAYzr.cjs"),o=require("./types-eYlq0p1o.cjs"),R=require("./errors-Bu0H-dZD.cjs"),e=require("./buildAndBroadcastRefund-Cj8JDI7F.cjs"),T=require("./peginState-BijNNT15.cjs");exports.buildChallengeAssertPsbt=E.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=E.buildDepositorPayoutPsbt;exports.computeNumLocalChallengers=E.computeNumLocalChallengers;Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>c.computeMinClaimValue});Object.defineProperty(exports,"deriveVaultId",{enumerable:!0,get:()=>c.deriveVaultId});Object.defineProperty(exports,"expandAuthAnchor",{enumerable:!0,get:()=>c.expandAuthAnchor});Object.defineProperty(exports,"expandHashlockSecret",{enumerable:!0,get:()=>c.expandHashlockSecret});Object.defineProperty(exports,"expandWotsSeed",{enumerable:!0,get:()=>c.expandWotsSeed});exports.PsbtSubstitutionError=u.PsbtSubstitutionError;exports.assertPsbtUnsignedTxMatches=u.assertPsbtUnsignedTxMatches;exports.buildPayoutPsbt=u.buildPayoutPsbt;exports.buildPeginTxFromFundedPrePegin=u.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=u.buildPrePeginPsbt;exports.createPayoutScript=u.createPayoutScript;exports.extractPayoutSignature=u.extractPayoutSignature;exports.buildPeginInputPsbt=A.buildPeginInputPsbt;exports.extractPeginInputSignature=A.extractPeginInputSignature;exports.finalizePeginInputPsbt=A.finalizePeginInputPsbt;exports.buildNoPayoutPsbt=_.buildNoPayoutPsbt;exports.buildRefundPsbt=_.buildRefundPsbt;exports.deriveBip86ScriptPubKeyHex=r.deriveBip86ScriptPubKeyHex;exports.deriveNativeSegwitAddress=r.deriveNativeSegwitAddress;exports.deriveTaprootAddress=r.deriveTaprootAddress;exports.ensureHexPrefix=r.ensureHexPrefix;exports.formatSatoshisToBtc=r.formatSatoshisToBtc;exports.getNetwork=r.getNetwork;exports.getSortedXOnlyPubkeys=r.getSortedXOnlyPubkeys;exports.hexToUint8Array=r.hexToUint8Array;exports.isAddressFromPublicKey=r.isAddressFromPublicKey;exports.isValidHex=r.isValidHex;exports.processPublicKeyToXOnly=r.processPublicKeyToXOnly;exports.stripHexPrefix=r.stripHexPrefix;exports.toXOnly=r.toXOnly;exports.uint8ArrayToHex=r.uint8ArrayToHex;exports.validateWalletPubkey=r.validateWalletPubkey;exports.createTaprootScriptPathSignOptions=g.createTaprootScriptPathSignOptions;exports.BITCOIN_ADDRESS_RE=d.BITCOIN_ADDRESS_RE;exports.HEX_RE=d.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=d.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=d.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=d.TXID_RE;exports.PeginManager=n.PeginManager;exports.VAULT_APP_NAME=n.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=n.buildFundingOutpointsCommitment;exports.buildVaultContext=n.buildVaultContext;exports.computeWotsBlockPublicKeysHash=n.computeWotsBlockPublicKeysHash;exports.deriveVaultRoot=n.deriveVaultRoot;exports.deriveWotsBlocksFromSeed=n.deriveWotsBlocksFromSeed;exports.estimateSubmitPeginRequestBatchGas=n.estimateSubmitPeginRequestBatchGas;exports.PayoutManager=S.PayoutManager;exports.computeHashlock=S.computeHashlock;exports.validateSecretAgainstHashlock=S.validateSecretAgainstHashlock;exports.ApplicationRegistryABI=p.ApplicationRegistryABI;exports.ProtocolParamsABI=p.ProtocolParamsABI;exports.BTCVaultRegistryABI=m.BTCVaultRegistryABI;exports.CONTRACT_ERRORS=P.CONTRACT_ERRORS;exports.extractErrorData=P.extractErrorData;exports.getContractErrorMessage=P.getContractErrorMessage;exports.handleContractError=P.handleContractError;exports.isKnownContractError=P.isKnownContractError;exports.BitcoinNetworks=I.BitcoinNetworks;exports.BitcoinScriptType=i.BitcoinScriptType;exports.applyChangeOutputPolicy=i.applyChangeOutputPolicy;exports.calculateBtcTxHash=i.calculateBtcTxHash;exports.computeChangeOutputFeeSats=i.computeChangeOutputFeeSats;exports.computeMaxDeposit=i.computeMaxDeposit;exports.computePeginBaseFeeSats=i.computePeginBaseFeeSats;exports.getDustThreshold=i.getDustThreshold;exports.getPsbtInputFields=i.getPsbtInputFields;exports.getScriptType=i.getScriptType;exports.selectUtxosForPegin=i.selectUtxosForPegin;exports.shouldAddChangeOutput=i.shouldAddChangeOutput;exports.waitForTransactionReceiptSmartAware=i.waitForTransactionReceiptSmartAware;exports.BTC_DUST_SAT=a.BTC_DUST_SAT;exports.DUST_THRESHOLD=a.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=a.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=a.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=a.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=a.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=a.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=a.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=a.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=a.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=a.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=a.fundPeginTransaction;exports.parseUnfundedWasmTransaction=a.parseUnfundedWasmTransaction;exports.peginOutputCount=a.peginOutputCount;exports.rateBasedTxBufferFee=a.rateBasedTxBufferFee;exports.UtxoNotAvailableError=l.UtxoNotAvailableError;exports.assertUtxosAvailable=l.assertUtxosAvailable;exports.collectReservedUtxoRefs=l.collectReservedUtxoRefs;exports.extractInputsFromTransaction=l.extractInputsFromTransaction;exports.selectUtxosForDeposit=l.selectUtxosForDeposit;exports.validateUtxosAvailable=l.validateUtxosAvailable;exports.MEMPOOL_API_URLS=s.MEMPOOL_API_URLS;exports.getAddressTxs=s.getAddressTxs;exports.getAddressUtxos=s.getAddressUtxos;exports.getMempoolApiUrl=s.getMempoolApiUrl;exports.getNetworkFees=s.getNetworkFees;exports.getTxHex=s.getTxHex;exports.getTxInfo=s.getTxInfo;exports.getUtxoInfo=s.getUtxoInfo;exports.pushTx=s.pushTx;exports.OnChainBtcVaultStatus=t.OnChainBtcVaultStatus;exports.ServerIdentityError=t.ServerIdentityError;exports.VaultProviderRpcClient=t.VaultProviderRpcClient;exports.ViemProtocolParamsReader=t.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=t.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=t.ViemVaultKeeperReader;exports.ViemVaultRegistryReader=t.ViemVaultRegistryReader;exports.VpResponseValidationError=t.VpResponseValidationError;exports.VpTokenRegistry=t.VpTokenRegistry;exports.batchPollByProvider=t.batchPollByProvider;exports.createAuthenticatedVpClient=t.createAuthenticatedVpClient;exports.primeVpTokenRegistry=t.primeVpTokenRegistry;exports.resolveProtocolAddresses=t.resolveProtocolAddresses;exports.validateOffchainParams=t.validateOffchainParams;exports.validatePegInConfiguration=t.validatePegInConfiguration;exports.validateRequestDepositorClaimerArtifactsResponse=t.validateRequestDepositorClaimerArtifactsResponse;exports.validateTBVProtocolParams=t.validateTBVProtocolParams;exports.verifyServerIdentity=t.verifyServerIdentity;exports.vpTokenRegistry=t.vpTokenRegistry;exports.AUTH_EXPIRED_DATA_KIND=o.AUTH_EXPIRED_DATA_KIND;exports.DaemonStatus=o.DaemonStatus;exports.JSON_RPC_ERROR_CODES=o.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=o.JsonRpcClient;exports.JsonRpcError=o.JsonRpcError;exports.POST_WOTS_STATUSES=o.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=o.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=o.RpcErrorCode;exports.VP_BATCH_MAX_SIZE=o.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=o.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=o.VP_TRANSIENT_STATUSES;exports.isWotsMismatchError=R.isWotsMismatchError;exports.parseFundingOutpointsFromTx=R.parseFundingOutpointsFromTx;exports.BIP68NotMatureError=e.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=e.ClaimerPegoutStatusValue;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=e.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=e.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=e.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=e.REFUND_VSIZE;exports.RegisteredVaultVersionMismatchError=e.RegisteredVaultVersionMismatchError;exports.activateVault=e.activateVault;exports.buildAndBroadcastRefund=e.buildAndBroadcastRefund;exports.estimateRefundFeeSats=e.estimateRefundFeeSats;exports.isDepositAmountValid=e.isDepositAmountValid;exports.isPegoutTerminalStatus=e.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=e.isRecognizedPegoutStatus;exports.isRegisteredVaultVersionMismatchError=e.isRegisteredVaultVersionMismatchError;exports.runDepositorPresignFlow=e.runDepositorPresignFlow;exports.signDepositorGraph=e.signDepositorGraph;exports.submitWotsPublicKey=e.submitWotsPublicKey;exports.validateDepositAmount=e.validateDepositAmount;exports.validateMultiVaultDepositInputs=e.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=e.validateOnChainParticipantKeys;exports.validateProviderSelection=e.validateProviderSelection;exports.validateRemainingCapacity=e.validateRemainingCapacity;exports.validateVaultAmounts=e.validateVaultAmounts;exports.validateVaultProviderPubkey=e.validateVaultProviderPubkey;exports.verifyRegisteredVaultVersions=e.verifyRegisteredVaultVersions;exports.waitForPeginStatus=e.waitForPeginStatus;exports.ContractStatus=T.ContractStatus;exports.PeginAction=T.PeginAction;exports.canPerformAction=T.canPerformAction;exports.getPeginProtocolState=T.getPeginProtocolState;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./challengeAssert-rpDaS3fH.cjs"),c=require("@babylonlabs-io/babylon-tbv-rust-wasm"),u=require("./assertPsbtUnsignedTxMatches-r1svclbd.cjs"),A=require("./peginInput-DH6X4ITS.cjs"),_=require("./noPayout-B06Z9RTe.cjs"),r=require("./bitcoin-CHfKAhcI.cjs"),g=require("./signing-Bnsro0hE.cjs"),d=require("./validation-u8W7Lp2x.cjs"),n=require("./PeginManager-UqbOj2oV.cjs"),S=require("./PayoutManager-B5bovfkD.cjs"),p=require("./ProtocolParams.abi-DQhcqsNr.cjs"),m=require("./BTCVaultRegistry.abi-CHFGevwa.cjs"),P=require("./errors-BP73_stm.cjs"),I=require("./shared/index.cjs"),a=require("./waitForTransactionReceiptSmartAware-tv1mtSIY.cjs"),i=require("./fundPeginTransaction-BBE3wTjR.cjs"),l=require("./reservation-hjXStM03.cjs"),s=require("./mempoolApi-DEAS9wVa.cjs"),t=require("./types-Be3sAYzr.cjs"),o=require("./types-eYlq0p1o.cjs"),R=require("./errors-Bu0H-dZD.cjs"),e=require("./buildAndBroadcastRefund-Cj8JDI7F.cjs"),T=require("./peginState-BijNNT15.cjs");exports.buildChallengeAssertPsbt=E.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=E.buildDepositorPayoutPsbt;exports.computeNumLocalChallengers=E.computeNumLocalChallengers;Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>c.computeMinClaimValue});Object.defineProperty(exports,"deriveVaultId",{enumerable:!0,get:()=>c.deriveVaultId});Object.defineProperty(exports,"expandAuthAnchor",{enumerable:!0,get:()=>c.expandAuthAnchor});Object.defineProperty(exports,"expandHashlockSecret",{enumerable:!0,get:()=>c.expandHashlockSecret});Object.defineProperty(exports,"expandWotsSeed",{enumerable:!0,get:()=>c.expandWotsSeed});exports.PsbtSubstitutionError=u.PsbtSubstitutionError;exports.assertPsbtUnsignedTxMatches=u.assertPsbtUnsignedTxMatches;exports.buildPayoutPsbt=u.buildPayoutPsbt;exports.buildPeginTxFromFundedPrePegin=u.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=u.buildPrePeginPsbt;exports.createPayoutScript=u.createPayoutScript;exports.extractPayoutSignature=u.extractPayoutSignature;exports.buildPeginInputPsbt=A.buildPeginInputPsbt;exports.extractPeginInputSignature=A.extractPeginInputSignature;exports.finalizePeginInputPsbt=A.finalizePeginInputPsbt;exports.buildNoPayoutPsbt=_.buildNoPayoutPsbt;exports.buildRefundPsbt=_.buildRefundPsbt;exports.deriveBip86ScriptPubKeyHex=r.deriveBip86ScriptPubKeyHex;exports.deriveNativeSegwitAddress=r.deriveNativeSegwitAddress;exports.deriveTaprootAddress=r.deriveTaprootAddress;exports.ensureHexPrefix=r.ensureHexPrefix;exports.formatSatoshisToBtc=r.formatSatoshisToBtc;exports.getNetwork=r.getNetwork;exports.getSortedXOnlyPubkeys=r.getSortedXOnlyPubkeys;exports.hexToUint8Array=r.hexToUint8Array;exports.isAddressFromPublicKey=r.isAddressFromPublicKey;exports.isValidHex=r.isValidHex;exports.processPublicKeyToXOnly=r.processPublicKeyToXOnly;exports.stripHexPrefix=r.stripHexPrefix;exports.toXOnly=r.toXOnly;exports.uint8ArrayToHex=r.uint8ArrayToHex;exports.validateWalletPubkey=r.validateWalletPubkey;exports.createTaprootScriptPathSignOptions=g.createTaprootScriptPathSignOptions;exports.BITCOIN_ADDRESS_RE=d.BITCOIN_ADDRESS_RE;exports.HEX_RE=d.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=d.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=d.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=d.TXID_RE;exports.PeginManager=n.PeginManager;exports.VAULT_APP_NAME=n.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=n.buildFundingOutpointsCommitment;exports.buildVaultContext=n.buildVaultContext;exports.computeWotsBlockPublicKeysHash=n.computeWotsBlockPublicKeysHash;exports.deriveVaultRoot=n.deriveVaultRoot;exports.deriveWotsBlocksFromSeed=n.deriveWotsBlocksFromSeed;exports.estimateSubmitPeginRequestBatchGas=n.estimateSubmitPeginRequestBatchGas;exports.PayoutManager=S.PayoutManager;exports.computeHashlock=S.computeHashlock;exports.validateSecretAgainstHashlock=S.validateSecretAgainstHashlock;exports.ApplicationRegistryABI=p.ApplicationRegistryABI;exports.ProtocolParamsABI=p.ProtocolParamsABI;exports.BTCVaultRegistryABI=m.BTCVaultRegistryABI;exports.CONTRACT_ERRORS=P.CONTRACT_ERRORS;exports.extractErrorData=P.extractErrorData;exports.getContractErrorMessage=P.getContractErrorMessage;exports.handleContractError=P.handleContractError;exports.isKnownContractError=P.isKnownContractError;exports.BitcoinNetworks=I.BitcoinNetworks;exports.BitcoinScriptType=a.BitcoinScriptType;exports.applyChangeOutputPolicy=a.applyChangeOutputPolicy;exports.calculateBtcTxHash=a.calculateBtcTxHash;exports.computeChangeOutputFeeSats=a.computeChangeOutputFeeSats;exports.computeMaxDeposit=a.computeMaxDeposit;exports.computePeginBaseFeeSats=a.computePeginBaseFeeSats;exports.getDustThreshold=a.getDustThreshold;exports.getPsbtInputFields=a.getPsbtInputFields;exports.getScriptType=a.getScriptType;exports.selectUtxosForPegin=a.selectUtxosForPegin;exports.shouldAddChangeOutput=a.shouldAddChangeOutput;exports.waitForTransactionReceiptSmartAware=a.waitForTransactionReceiptSmartAware;exports.BTC_DUST_SAT=i.BTC_DUST_SAT;exports.DUST_THRESHOLD=i.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=i.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=i.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=i.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=i.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=i.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=i.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=i.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=i.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=i.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=i.fundPeginTransaction;exports.parseUnfundedWasmTransaction=i.parseUnfundedWasmTransaction;exports.peginOutputCount=i.peginOutputCount;exports.rateBasedTxBufferFee=i.rateBasedTxBufferFee;exports.UtxoNotAvailableError=l.UtxoNotAvailableError;exports.assertUtxosAvailable=l.assertUtxosAvailable;exports.collectReservedUtxoRefs=l.collectReservedUtxoRefs;exports.extractInputsFromTransaction=l.extractInputsFromTransaction;exports.selectUtxosForDeposit=l.selectUtxosForDeposit;exports.validateUtxosAvailable=l.validateUtxosAvailable;exports.MEMPOOL_API_URLS=s.MEMPOOL_API_URLS;exports.getAddressTxs=s.getAddressTxs;exports.getAddressUtxos=s.getAddressUtxos;exports.getMempoolApiUrl=s.getMempoolApiUrl;exports.getNetworkFees=s.getNetworkFees;exports.getTipHeight=s.getTipHeight;exports.getTxHex=s.getTxHex;exports.getTxInfo=s.getTxInfo;exports.getUtxoInfo=s.getUtxoInfo;exports.pushTx=s.pushTx;exports.OnChainBtcVaultStatus=t.OnChainBtcVaultStatus;exports.ServerIdentityError=t.ServerIdentityError;exports.VaultProviderRpcClient=t.VaultProviderRpcClient;exports.ViemProtocolParamsReader=t.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=t.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=t.ViemVaultKeeperReader;exports.ViemVaultRegistryReader=t.ViemVaultRegistryReader;exports.VpResponseValidationError=t.VpResponseValidationError;exports.VpTokenRegistry=t.VpTokenRegistry;exports.batchPollByProvider=t.batchPollByProvider;exports.createAuthenticatedVpClient=t.createAuthenticatedVpClient;exports.primeVpTokenRegistry=t.primeVpTokenRegistry;exports.resolveProtocolAddresses=t.resolveProtocolAddresses;exports.validateOffchainParams=t.validateOffchainParams;exports.validatePegInConfiguration=t.validatePegInConfiguration;exports.validateRequestDepositorClaimerArtifactsResponse=t.validateRequestDepositorClaimerArtifactsResponse;exports.validateTBVProtocolParams=t.validateTBVProtocolParams;exports.verifyServerIdentity=t.verifyServerIdentity;exports.vpTokenRegistry=t.vpTokenRegistry;exports.AUTH_EXPIRED_DATA_KIND=o.AUTH_EXPIRED_DATA_KIND;exports.DaemonStatus=o.DaemonStatus;exports.JSON_RPC_ERROR_CODES=o.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=o.JsonRpcClient;exports.JsonRpcError=o.JsonRpcError;exports.POST_WOTS_STATUSES=o.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=o.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=o.RpcErrorCode;exports.VP_BATCH_MAX_SIZE=o.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=o.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=o.VP_TRANSIENT_STATUSES;exports.isWotsMismatchError=R.isWotsMismatchError;exports.parseFundingOutpointsFromTx=R.parseFundingOutpointsFromTx;exports.BIP68NotMatureError=e.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=e.ClaimerPegoutStatusValue;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=e.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=e.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=e.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=e.REFUND_VSIZE;exports.RegisteredVaultVersionMismatchError=e.RegisteredVaultVersionMismatchError;exports.activateVault=e.activateVault;exports.buildAndBroadcastRefund=e.buildAndBroadcastRefund;exports.estimateRefundFeeSats=e.estimateRefundFeeSats;exports.isDepositAmountValid=e.isDepositAmountValid;exports.isPegoutTerminalStatus=e.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=e.isRecognizedPegoutStatus;exports.isRegisteredVaultVersionMismatchError=e.isRegisteredVaultVersionMismatchError;exports.runDepositorPresignFlow=e.runDepositorPresignFlow;exports.signDepositorGraph=e.signDepositorGraph;exports.submitWotsPublicKey=e.submitWotsPublicKey;exports.validateDepositAmount=e.validateDepositAmount;exports.validateMultiVaultDepositInputs=e.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=e.validateOnChainParticipantKeys;exports.validateProviderSelection=e.validateProviderSelection;exports.validateRemainingCapacity=e.validateRemainingCapacity;exports.validateVaultAmounts=e.validateVaultAmounts;exports.validateVaultProviderPubkey=e.validateVaultProviderPubkey;exports.verifyRegisteredVaultVersions=e.verifyRegisteredVaultVersions;exports.waitForPeginStatus=e.waitForPeginStatus;exports.ContractStatus=T.ContractStatus;exports.PeginAction=T.PeginAction;exports.canPerformAction=T.canPerformAction;exports.getPeginProtocolState=T.getPeginProtocolState;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { a as b, b as I } from "./noPayout-CS2wnluA.js";
|
|
|
6
6
|
import { d as O, a as v, b as F, e as V, f as U, j as h, g as N, h as y, i as D, c as B, p as M, s as H, t as L, u as k, v as X } from "./bitcoin-B5aNKtsk.js";
|
|
7
7
|
import { c as w } from "./signing-DaLvGwQe.js";
|
|
8
8
|
import { B as G, H as Y, K as Z, M as J, T as j } from "./validation-CxqROCno.js";
|
|
9
|
-
import { P as z, V as Q, b as $, a as aa, c as ea, f as sa, d as ta, e as ra } from "./PeginManager-
|
|
9
|
+
import { P as z, V as Q, b as $, a as aa, c as ea, f as sa, d as ta, e as ra } from "./PeginManager-D9ZZ8wx2.js";
|
|
10
10
|
import { P as ia, c as na, v as ua } from "./PayoutManager-DChODEOJ.js";
|
|
11
11
|
import { A as pa, P as da } from "./ProtocolParams.abi-C2brDWTI.js";
|
|
12
12
|
import { B as ca } from "./BTCVaultRegistry.abi-Cq9-JlqT.js";
|
|
@@ -15,76 +15,76 @@ import { BitcoinNetworks as ma } from "./shared/index.js";
|
|
|
15
15
|
import { B as fa, a as ba, f as Ia, c as Ca, b as Oa, d as va, g as Fa, i as Va, h as Ua, s as ha, e as Na, w as ya } from "./waitForTransactionReceiptSmartAware-CmgFXFza.js";
|
|
16
16
|
import { B as Ba, D as Ma, F as Ha, L as La, M as ka, P as Xa, b as Wa, a as wa, S as Ka, T as Ga, W as Ya, f as Za, c as Ja, p as ja, r as qa } from "./fundPeginTransaction-t-6TsHAY.js";
|
|
17
17
|
import { U as Qa, a as $a, c as ae, e as ee, s as se, v as te } from "./reservation-CB-4FBPk.js";
|
|
18
|
-
import { M as oe, g as ie, a as ne, b as ue, c as le, d as pe, e as de, f as Pe,
|
|
19
|
-
import { O as
|
|
20
|
-
import { A as
|
|
21
|
-
import { i as
|
|
22
|
-
import { B as
|
|
23
|
-
import { C as
|
|
18
|
+
import { M as oe, g as ie, a as ne, b as ue, c as le, d as pe, e as de, f as Pe, h as ce, p as Te } from "./mempoolApi-C7hkVkym.js";
|
|
19
|
+
import { O as Ae, S as Se, V as Re, j as _e, k as ge, l as me, m as xe, a as fe, d as be, b as Ie, f as Ce, p as Oe, r as ve, g as Fe, h as Ve, v as Ue, i as he, c as Ne, e as ye } from "./types-0bvDGR4x.js";
|
|
20
|
+
import { A as Be, D as Me, b as He, J as Le, a as ke, d as Xe, P as We, R as we, e as Ke, c as Ge, V as Ye } from "./types-BqGAMOZM.js";
|
|
21
|
+
import { i as Je, p as je } from "./errors-9AkghWyk.js";
|
|
22
|
+
import { B as ze, C as Qe, p as $e, q as as, t as es, u as ss, R as ts, a as rs, n as os, o as is, i as ns, m as us, l as ls, j as ps, r as ds, b as Ps, s as cs, v as Ts, g as Es, h as As, d as Ss, c as Rs, e as _s, f as gs, k as ms, w as xs } from "./buildAndBroadcastRefund-fIHDHiFh.js";
|
|
23
|
+
import { C as bs, P as Is, c as Cs, g as Os } from "./peginState-CBAlxgXk.js";
|
|
24
24
|
export {
|
|
25
|
-
|
|
25
|
+
Be as AUTH_EXPIRED_DATA_KIND,
|
|
26
26
|
pa as ApplicationRegistryABI,
|
|
27
|
-
|
|
27
|
+
ze as BIP68NotMatureError,
|
|
28
28
|
G as BITCOIN_ADDRESS_RE,
|
|
29
29
|
ca as BTCVaultRegistryABI,
|
|
30
30
|
Ba as BTC_DUST_SAT,
|
|
31
31
|
ma as BitcoinNetworks,
|
|
32
32
|
fa as BitcoinScriptType,
|
|
33
33
|
Ea as CONTRACT_ERRORS,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
Qe as ClaimerPegoutStatusValue,
|
|
35
|
+
bs as ContractStatus,
|
|
36
36
|
Ma as DUST_THRESHOLD,
|
|
37
|
-
|
|
37
|
+
Me as DaemonStatus,
|
|
38
38
|
Ha as FEE_SAFETY_MARGIN,
|
|
39
39
|
Y as HEX_RE,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
He as JSON_RPC_ERROR_CODES,
|
|
41
|
+
Le as JsonRpcClient,
|
|
42
|
+
ke as JsonRpcError,
|
|
43
43
|
Z as KNOWN_SCRIPT_PREFIXES,
|
|
44
44
|
La as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
|
|
45
45
|
ka as MAX_NON_LEGACY_OUTPUT_SIZE,
|
|
46
46
|
J as MAX_REASONABLE_FEE_SATS,
|
|
47
47
|
oe as MEMPOOL_API_URLS,
|
|
48
|
-
|
|
48
|
+
Ae as OnChainBtcVaultStatus,
|
|
49
49
|
Xa as P2TR_INPUT_SIZE,
|
|
50
50
|
Wa as PEGIN_AUTH_ANCHOR_OUTPUTS,
|
|
51
51
|
wa as PEGIN_FIXED_OUTPUTS,
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
Xe as POST_WOTS_STATUSES,
|
|
53
|
+
We as PRE_DEPOSITOR_SIGNATURES_STATES,
|
|
54
54
|
ia as PayoutManager,
|
|
55
|
-
|
|
55
|
+
Is as PeginAction,
|
|
56
56
|
z as PeginManager,
|
|
57
57
|
da as ProtocolParamsABI,
|
|
58
58
|
P as PsbtSubstitutionError,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
$e as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
|
|
60
|
+
as as REFUND_MAX_FEE_FRACTION_NUMERATOR,
|
|
61
|
+
es as REFUND_MAX_FEE_RATE_SATS_VB,
|
|
62
|
+
ss as REFUND_VSIZE,
|
|
63
|
+
ts as RegisteredVaultVersionMismatchError,
|
|
64
|
+
we as RpcErrorCode,
|
|
65
65
|
Ka as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
|
|
66
|
-
|
|
66
|
+
Se as ServerIdentityError,
|
|
67
67
|
j as TXID_RE,
|
|
68
68
|
Ga as TX_BUFFER_SIZE_OVERHEAD,
|
|
69
69
|
Qa as UtxoNotAvailableError,
|
|
70
70
|
Q as VAULT_APP_NAME,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
Ke as VP_BATCH_MAX_SIZE,
|
|
72
|
+
Ge as VP_TERMINAL_FAILURE_STATUSES,
|
|
73
|
+
Ye as VP_TRANSIENT_STATUSES,
|
|
74
|
+
Re as VaultProviderRpcClient,
|
|
75
|
+
_e as ViemProtocolParamsReader,
|
|
76
|
+
ge as ViemUniversalChallengerReader,
|
|
77
|
+
me as ViemVaultKeeperReader,
|
|
78
|
+
xe as ViemVaultRegistryReader,
|
|
79
|
+
fe as VpResponseValidationError,
|
|
80
|
+
be as VpTokenRegistry,
|
|
81
81
|
Ya as WALLET_RELAY_FEE_RATE_THRESHOLD,
|
|
82
|
-
|
|
82
|
+
rs as activateVault,
|
|
83
83
|
ba as applyChangeOutputPolicy,
|
|
84
84
|
c as assertPsbtUnsignedTxMatches,
|
|
85
85
|
$a as assertUtxosAvailable,
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
Ie as batchPollByProvider,
|
|
87
|
+
os as buildAndBroadcastRefund,
|
|
88
88
|
s as buildChallengeAssertPsbt,
|
|
89
89
|
t as buildDepositorPayoutPsbt,
|
|
90
90
|
$ as buildFundingOutpointsCommitment,
|
|
@@ -96,7 +96,7 @@ export {
|
|
|
96
96
|
I as buildRefundPsbt,
|
|
97
97
|
aa as buildVaultContext,
|
|
98
98
|
Ia as calculateBtcTxHash,
|
|
99
|
-
|
|
99
|
+
Cs as canPerformAction,
|
|
100
100
|
ae as collectReservedUtxoRefs,
|
|
101
101
|
Ca as computeChangeOutputFeeSats,
|
|
102
102
|
na as computeHashlock,
|
|
@@ -105,7 +105,7 @@ export {
|
|
|
105
105
|
r as computeNumLocalChallengers,
|
|
106
106
|
va as computePeginBaseFeeSats,
|
|
107
107
|
ea as computeWotsBlockPublicKeysHash,
|
|
108
|
-
|
|
108
|
+
Ce as createAuthenticatedVpClient,
|
|
109
109
|
S as createPayoutScript,
|
|
110
110
|
w as createTaprootScriptPathSignOptions,
|
|
111
111
|
O as deriveBip86ScriptPubKeyHex,
|
|
@@ -115,7 +115,7 @@ export {
|
|
|
115
115
|
sa as deriveVaultRoot,
|
|
116
116
|
ta as deriveWotsBlocksFromSeed,
|
|
117
117
|
V as ensureHexPrefix,
|
|
118
|
-
|
|
118
|
+
is as estimateRefundFeeSats,
|
|
119
119
|
ra as estimateSubmitPeginRequestBatchGas,
|
|
120
120
|
u as expandAuthAnchor,
|
|
121
121
|
l as expandHashlockSecret,
|
|
@@ -134,58 +134,59 @@ export {
|
|
|
134
134
|
ue as getMempoolApiUrl,
|
|
135
135
|
h as getNetwork,
|
|
136
136
|
le as getNetworkFees,
|
|
137
|
-
|
|
137
|
+
Os as getPeginProtocolState,
|
|
138
138
|
Va as getPsbtInputFields,
|
|
139
139
|
Ua as getScriptType,
|
|
140
140
|
N as getSortedXOnlyPubkeys,
|
|
141
|
-
pe as
|
|
142
|
-
de as
|
|
143
|
-
Pe as
|
|
141
|
+
pe as getTipHeight,
|
|
142
|
+
de as getTxHex,
|
|
143
|
+
Pe as getTxInfo,
|
|
144
|
+
ce as getUtxoInfo,
|
|
144
145
|
Ra as handleContractError,
|
|
145
146
|
y as hexToUint8Array,
|
|
146
147
|
D as isAddressFromPublicKey,
|
|
147
|
-
|
|
148
|
+
ns as isDepositAmountValid,
|
|
148
149
|
_a as isKnownContractError,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
us as isPegoutTerminalStatus,
|
|
151
|
+
ls as isRecognizedPegoutStatus,
|
|
152
|
+
ps as isRegisteredVaultVersionMismatchError,
|
|
152
153
|
B as isValidHex,
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
Je as isWotsMismatchError,
|
|
155
|
+
je as parseFundingOutpointsFromTx,
|
|
155
156
|
Ja as parseUnfundedWasmTransaction,
|
|
156
157
|
ja as peginOutputCount,
|
|
157
|
-
|
|
158
|
+
Oe as primeVpTokenRegistry,
|
|
158
159
|
M as processPublicKeyToXOnly,
|
|
159
|
-
|
|
160
|
+
Te as pushTx,
|
|
160
161
|
qa as rateBasedTxBufferFee,
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
ve as resolveProtocolAddresses,
|
|
163
|
+
ds as runDepositorPresignFlow,
|
|
163
164
|
se as selectUtxosForDeposit,
|
|
164
165
|
ha as selectUtxosForPegin,
|
|
165
166
|
Na as shouldAddChangeOutput,
|
|
166
|
-
|
|
167
|
+
Ps as signDepositorGraph,
|
|
167
168
|
H as stripHexPrefix,
|
|
168
|
-
|
|
169
|
+
cs as submitWotsPublicKey,
|
|
169
170
|
L as toXOnly,
|
|
170
171
|
k as uint8ArrayToHex,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
Ts as validateDepositAmount,
|
|
173
|
+
Es as validateMultiVaultDepositInputs,
|
|
174
|
+
Fe as validateOffchainParams,
|
|
175
|
+
As as validateOnChainParticipantKeys,
|
|
176
|
+
Ve as validatePegInConfiguration,
|
|
177
|
+
Ss as validateProviderSelection,
|
|
178
|
+
Rs as validateRemainingCapacity,
|
|
179
|
+
Ue as validateRequestDepositorClaimerArtifactsResponse,
|
|
179
180
|
ua as validateSecretAgainstHashlock,
|
|
180
|
-
|
|
181
|
+
he as validateTBVProtocolParams,
|
|
181
182
|
te as validateUtxosAvailable,
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
_s as validateVaultAmounts,
|
|
184
|
+
gs as validateVaultProviderPubkey,
|
|
184
185
|
X as validateWalletPubkey,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
ms as verifyRegisteredVaultVersions,
|
|
187
|
+
Ne as verifyServerIdentity,
|
|
188
|
+
ye as vpTokenRegistry,
|
|
189
|
+
xs as waitForPeginStatus,
|
|
189
190
|
ya as waitForTransactionReceiptSmartAware
|
|
190
191
|
};
|
|
191
192
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { B as $, H as p, K as E, T as F } from "./validation-CxqROCno.js";
|
|
2
|
-
const
|
|
2
|
+
const I = 21e6 * 1e8, u = 3e4;
|
|
3
3
|
async function i(e, r) {
|
|
4
4
|
const t = new AbortController(), n = setTimeout(
|
|
5
5
|
() => t.abort(),
|
|
@@ -20,9 +20,9 @@ async function i(e, r) {
|
|
|
20
20
|
}
|
|
21
21
|
const l = 1e4;
|
|
22
22
|
function w(e) {
|
|
23
|
-
return Number.isInteger(e) && e > 0 && e <=
|
|
23
|
+
return Number.isInteger(e) && e > 0 && e <= I;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function g(e) {
|
|
26
26
|
return Number.isInteger(e) && e > 0 && e <= l;
|
|
27
27
|
}
|
|
28
28
|
function m(e, r) {
|
|
@@ -48,7 +48,7 @@ function d(e, r) {
|
|
|
48
48
|
`Unrecognized scriptPubKey type for ${r}: prefix ${e.slice(0, 6)} does not match any known Bitcoin script type`
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
|
-
const
|
|
51
|
+
const y = {
|
|
52
52
|
mainnet: "https://mempool.space/api",
|
|
53
53
|
testnet: "https://mempool.space/testnet/api",
|
|
54
54
|
signet: "https://mempool.space/signet/api"
|
|
@@ -94,9 +94,17 @@ async function v(e, r) {
|
|
|
94
94
|
throw t instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${t.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
async function
|
|
97
|
+
async function T(e, r) {
|
|
98
98
|
return c(e), s(`${r}/tx/${e}`);
|
|
99
99
|
}
|
|
100
|
+
async function b(e) {
|
|
101
|
+
const r = await s(`${e}/blocks/tip/height`), t = r.trim();
|
|
102
|
+
if (!/^\d+$/.test(t))
|
|
103
|
+
throw new Error(
|
|
104
|
+
`Mempool API returned an invalid block tip height: "${r}"`
|
|
105
|
+
);
|
|
106
|
+
return Number.parseInt(t, 10);
|
|
107
|
+
}
|
|
100
108
|
async function A(e, r) {
|
|
101
109
|
c(e);
|
|
102
110
|
try {
|
|
@@ -112,9 +120,9 @@ async function A(e, r) {
|
|
|
112
120
|
throw t instanceof Error ? new Error(`Failed to get transaction hex for ${e}: ${t.message}`) : new Error(`Failed to get transaction hex for ${e}: Unknown error`);
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
|
-
async function
|
|
123
|
+
async function P(e, r, t) {
|
|
116
124
|
c(e);
|
|
117
|
-
const n = await
|
|
125
|
+
const n = await T(e, t);
|
|
118
126
|
if (!m(r, n.vout.length))
|
|
119
127
|
throw new Error(
|
|
120
128
|
`Invalid vout ${r} for transaction ${e} (has ${n.vout.length} outputs)`
|
|
@@ -129,7 +137,7 @@ async function b(e, r, t) {
|
|
|
129
137
|
scriptPubKey: a.scriptpubkey
|
|
130
138
|
};
|
|
131
139
|
}
|
|
132
|
-
async function
|
|
140
|
+
async function O(e, r) {
|
|
133
141
|
h(e);
|
|
134
142
|
try {
|
|
135
143
|
const t = await s(`${r}/address/${e}/utxo`), n = await s(`${r}/v1/validate-address/${e}`);
|
|
@@ -161,13 +169,13 @@ async function P(e, r) {
|
|
|
161
169
|
);
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
|
-
function
|
|
165
|
-
return
|
|
172
|
+
function U(e) {
|
|
173
|
+
return y[e];
|
|
166
174
|
}
|
|
167
|
-
async function
|
|
175
|
+
async function k(e, r) {
|
|
168
176
|
return h(e), s(`${r}/address/${e}/txs`);
|
|
169
177
|
}
|
|
170
|
-
async function
|
|
178
|
+
async function M(e) {
|
|
171
179
|
const r = await i(`${e}/v1/fees/recommended`);
|
|
172
180
|
if (!r.ok)
|
|
173
181
|
throw new Error(
|
|
@@ -181,7 +189,7 @@ async function S(e) {
|
|
|
181
189
|
"minimumFee"
|
|
182
190
|
];
|
|
183
191
|
for (const a of n)
|
|
184
|
-
if (!
|
|
192
|
+
if (!g(t[a]))
|
|
185
193
|
throw new Error(
|
|
186
194
|
`Invalid fee rate ${a}=${t[a]} from mempool API: expected a positive number ≤ ${l}`
|
|
187
195
|
);
|
|
@@ -192,14 +200,15 @@ async function S(e) {
|
|
|
192
200
|
return t;
|
|
193
201
|
}
|
|
194
202
|
export {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
+
y as M,
|
|
204
|
+
O as a,
|
|
205
|
+
U as b,
|
|
206
|
+
M as c,
|
|
207
|
+
b as d,
|
|
208
|
+
A as e,
|
|
209
|
+
T as f,
|
|
210
|
+
k as g,
|
|
211
|
+
P as h,
|
|
203
212
|
v as p
|
|
204
213
|
};
|
|
205
|
-
//# sourceMappingURL=mempoolApi-
|
|
214
|
+
//# sourceMappingURL=mempoolApi-C7hkVkym.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mempoolApi-C7hkVkym.js","sources":["../src/tbv/core/clients/mempool/mempoolApi.ts"],"sourcesContent":["/**\n * Mempool API Client\n *\n * Client for interacting with mempool.space API for Bitcoin network operations.\n * Used for broadcasting transactions and fetching UTXO data.\n *\n * @module clients/mempool/mempoolApi\n */\n\nimport {\n BITCOIN_ADDRESS_RE,\n HEX_RE,\n KNOWN_SCRIPT_PREFIXES,\n TXID_RE,\n} from \"../../utils/validation\";\n\nimport type { MempoolUTXO, NetworkFees, TxInfo, UtxoInfo } from \"./types\";\n\n/** Maximum valid satoshi value: 21 million BTC × 10^8 sats/BTC */\nconst MAX_SATOSHIS = 21_000_000 * 1e8;\n\n/** Timeout for mempool API requests — prevents indefinite hangs from stalled endpoints */\nconst MEMPOOL_REQUEST_TIMEOUT_MS = 30_000;\n\n/**\n * Fetch wrapper with AbortController-based timeout.\n * Ensures all mempool API requests fail bounded rather than hanging indefinitely.\n */\nasync function fetchWithTimeout(\n url: string,\n options?: RequestInit,\n): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(\n () => controller.abort(),\n MEMPOOL_REQUEST_TIMEOUT_MS,\n );\n\n // Compose timeout signal with any caller-supplied signal so both can cancel\n const signals = [controller.signal, options?.signal].filter(\n Boolean,\n ) as AbortSignal[];\n\n try {\n // Don't clear timeout here — let it cover body consumption by callers\n return await fetch(url, {\n ...options,\n signal: AbortSignal.any(signals),\n });\n } catch (error) {\n clearTimeout(timeoutId);\n if (\n error != null &&\n typeof error === \"object\" &&\n \"name\" in error &&\n error.name === \"AbortError\"\n ) {\n throw new Error(\n `Mempool API request timed out after ${MEMPOOL_REQUEST_TIMEOUT_MS}ms: ${url}`,\n );\n }\n throw error;\n }\n}\n\n/**\n * Maximum sane fee rate in sat/vByte.\n * The April 2024 Runes spike peaked around 1,805 sat/vB — 10,000 provides ample headroom.\n */\nconst MAX_FEE_RATE = 10_000;\n\nfunction isValidSatoshiValue(value: number): boolean {\n return Number.isInteger(value) && value > 0 && value <= MAX_SATOSHIS;\n}\n\nfunction isValidFeeRate(value: number): boolean {\n return Number.isInteger(value) && value > 0 && value <= MAX_FEE_RATE;\n}\n\nfunction isValidVout(vout: number, outputCount?: number): boolean {\n if (!Number.isInteger(vout) || vout < 0) return false;\n return outputCount === undefined || vout < outputCount;\n}\n\n\nfunction assertValidTxid(txid: string): void {\n if (!TXID_RE.test(txid)) {\n throw new Error(`Invalid transaction ID format: ${txid}`);\n }\n}\n\nfunction assertValidAddress(address: string): void {\n if (!BITCOIN_ADDRESS_RE.test(address)) {\n throw new Error(`Invalid Bitcoin address format: ${address}`);\n }\n}\n\nfunction assertValidScriptPubKey(scriptPubKey: string, context: string): void {\n if (!HEX_RE.test(scriptPubKey)) {\n throw new Error(\n `Invalid scriptPubKey: not valid hex for ${context}`,\n );\n }\n const matchesKnownType = KNOWN_SCRIPT_PREFIXES.some((prefix) =>\n scriptPubKey.toLowerCase().startsWith(prefix),\n );\n if (!matchesKnownType) {\n throw new Error(\n `Unrecognized scriptPubKey type for ${context}: ` +\n `prefix ${scriptPubKey.slice(0, 6)} does not match any known Bitcoin script type`,\n );\n }\n}\n\n/**\n * Default mempool API URLs by network.\n */\nexport const MEMPOOL_API_URLS = {\n mainnet: \"https://mempool.space/api\",\n testnet: \"https://mempool.space/testnet/api\",\n signet: \"https://mempool.space/signet/api\",\n} as const;\n\n/**\n * Fetch wrapper with error handling.\n */\nasync function fetchApi<T>(\n url: string,\n options?: RequestInit,\n): Promise<T> {\n try {\n const response = await fetchWithTimeout(url, options);\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `Mempool API error (${response.status}): ${errorText || response.statusText}`,\n );\n }\n\n const contentType = response.headers.get(\"content-type\");\n if (contentType?.includes(\"application/json\")) {\n return (await response.json()) as T;\n } else {\n return (await response.text()) as T;\n }\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to fetch from mempool API: ${error.message}`);\n }\n throw new Error(\"Failed to fetch from mempool API: Unknown error\");\n }\n}\n\n/**\n * Push a signed transaction to the Bitcoin network.\n *\n * @param txHex - The signed transaction hex string\n * @param apiUrl - Mempool API base URL\n * @returns The transaction ID\n * @throws Error if broadcasting fails\n */\nexport async function pushTx(txHex: string, apiUrl: string): Promise<string> {\n try {\n const response = await fetchWithTimeout(`${apiUrl}/tx`, {\n method: \"POST\",\n body: txHex,\n headers: {\n \"Content-Type\": \"text/plain\",\n },\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n // Try to extract error message from response using robust JSON parsing\n let message: string | undefined;\n try {\n const errorJson = JSON.parse(errorText);\n message = errorJson.message;\n } catch {\n // Not JSON, use raw text\n message = errorText;\n }\n throw new Error(\n message || `Failed to broadcast transaction: ${response.statusText}`,\n );\n }\n\n // Response is the transaction ID (plain text)\n const txId = await response.text();\n return txId;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to broadcast BTC transaction: ${error.message}`);\n }\n throw new Error(\"Failed to broadcast BTC transaction: Unknown error\");\n }\n}\n\n/**\n * Get transaction information from mempool.\n *\n * @param txid - The transaction ID\n * @param apiUrl - Mempool API base URL\n * @returns Transaction information\n */\nexport async function getTxInfo(txid: string, apiUrl: string): Promise<TxInfo> {\n assertValidTxid(txid);\n return fetchApi<TxInfo>(`${apiUrl}/tx/${txid}`);\n}\n\n/**\n * Get the current block tip height.\n *\n * Source: mempool.space API — `GET /api/blocks/tip/height` returns the height\n * of the most recent block as a plain-text integer.\n *\n * @param apiUrl - Mempool API base URL\n * @returns The height of the most recent block\n * @throws Error if the response is not a whole number\n */\nexport async function getTipHeight(apiUrl: string): Promise<number> {\n const raw = await fetchApi<string>(`${apiUrl}/blocks/tip/height`);\n const trimmed = raw.trim();\n if (!/^\\d+$/.test(trimmed)) {\n throw new Error(\n `Mempool API returned an invalid block tip height: \"${raw}\"`,\n );\n }\n return Number.parseInt(trimmed, 10);\n}\n\n/**\n * Get the hex representation of a transaction.\n *\n * @param txid - The transaction ID\n * @param apiUrl - Mempool API base URL\n * @returns The transaction hex string\n * @throws Error if the request fails or transaction is not found\n */\nexport async function getTxHex(txid: string, apiUrl: string): Promise<string> {\n assertValidTxid(txid);\n try {\n const response = await fetchWithTimeout(`${apiUrl}/tx/${txid}/hex`);\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `Mempool API error (${response.status}): ${errorText || response.statusText}`,\n );\n }\n\n return await response.text();\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to get transaction hex for ${txid}: ${error.message}`);\n }\n throw new Error(`Failed to get transaction hex for ${txid}: Unknown error`);\n }\n}\n\n/**\n * Get UTXO information for a specific transaction output.\n *\n * This is used for constructing PSBTs where we need the witnessUtxo data.\n * Only supports Taproot (P2TR) and native SegWit (P2WPKH, P2WSH) script types.\n *\n * @param txid - The transaction ID containing the UTXO\n * @param vout - The output index\n * @param apiUrl - Mempool API base URL\n * @returns UTXO information with value and scriptPubKey\n */\nexport async function getUtxoInfo(\n txid: string,\n vout: number,\n apiUrl: string,\n): Promise<UtxoInfo> {\n assertValidTxid(txid);\n const txInfo = await getTxInfo(txid, apiUrl);\n\n if (!isValidVout(vout, txInfo.vout.length)) {\n throw new Error(\n `Invalid vout ${vout} for transaction ${txid} (has ${txInfo.vout.length} outputs)`,\n );\n }\n\n const output = txInfo.vout[vout];\n if (!isValidSatoshiValue(output.value)) {\n throw new Error(`Invalid UTXO value ${output.value} for ${txid}:${vout}`);\n }\n assertValidScriptPubKey(output.scriptpubkey, `${txid}:${vout}`);\n\n return {\n txid,\n vout,\n value: output.value,\n scriptPubKey: output.scriptpubkey,\n };\n}\n\n/**\n * Get all UTXOs for a Bitcoin address.\n *\n * @param address - The Bitcoin address\n * @param apiUrl - Mempool API base URL\n * @returns Array of UTXOs sorted by value (largest first)\n */\nexport async function getAddressUtxos(\n address: string,\n apiUrl: string,\n): Promise<MempoolUTXO[]> {\n assertValidAddress(address);\n try {\n // Fetch UTXOs for the address\n const utxos = await fetchApi<\n {\n txid: string;\n vout: number;\n value: number;\n status: {\n confirmed: boolean;\n };\n }[]\n >(`${apiUrl}/address/${address}/utxo`);\n\n // Fetch scriptPubKey for the address\n const addressInfo = await fetchApi<{\n isvalid: boolean;\n scriptPubKey: string;\n }>(`${apiUrl}/v1/validate-address/${address}`);\n\n if (!addressInfo.isvalid) {\n throw new Error(\n `Invalid Bitcoin address: ${address}. Mempool API validation failed.`,\n );\n }\n assertValidScriptPubKey(addressInfo.scriptPubKey, address);\n\n // Validate UTXO fields from the listing endpoint.\n // Per-UTXO cross-verification against /tx/{txid} is intentionally NOT done\n // here — it would be expensive (N API calls) and redundant: the broadcast\n // path already verifies each selected input via getUtxoInfo before signing.\n // Both endpoints come from the same mempool API, so cross-checking one\n // against the other on the same server does not add real security.\n for (const utxo of utxos) {\n assertValidTxid(utxo.txid);\n if (!isValidVout(utxo.vout)) {\n throw new Error(`Invalid vout ${utxo.vout} for ${utxo.txid}`);\n }\n if (!isValidSatoshiValue(utxo.value)) {\n throw new Error(\n `Invalid UTXO value ${utxo.value} for ${utxo.txid}:${utxo.vout}`,\n );\n }\n }\n\n // Sort by value (largest first) and map to our UTXO format\n const sortedUTXOs = utxos.sort((a, b) => b.value - a.value);\n\n return sortedUTXOs.map((utxo) => ({\n txid: utxo.txid,\n vout: utxo.vout,\n value: utxo.value,\n scriptPubKey: addressInfo.scriptPubKey,\n confirmed: utxo.status.confirmed,\n }));\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(\n `Failed to get UTXOs for address ${address}: ${error.message}`,\n );\n }\n throw new Error(\n `Failed to get UTXOs for address ${address}: Unknown error`,\n );\n }\n}\n\n/**\n * Get the mempool API URL for a given network.\n *\n * @param network - Bitcoin network (mainnet, testnet, signet)\n * @returns The mempool API URL\n */\nexport function getMempoolApiUrl(\n network: \"mainnet\" | \"testnet\" | \"signet\",\n): string {\n return MEMPOOL_API_URLS[network];\n}\n\n/**\n * Transaction summary from address transactions endpoint.\n */\nexport interface AddressTx {\n txid: string;\n status: {\n confirmed: boolean;\n block_height?: number;\n };\n}\n\n/**\n * Get recent transactions for a Bitcoin address.\n *\n * Returns the last 25 confirmed transactions plus any unconfirmed (mempool) transactions.\n * This is useful for checking if a specific transaction has been broadcast.\n *\n * @param address - The Bitcoin address\n * @param apiUrl - Mempool API base URL\n * @returns Array of recent transactions\n */\nexport async function getAddressTxs(\n address: string,\n apiUrl: string,\n): Promise<AddressTx[]> {\n assertValidAddress(address);\n return fetchApi<AddressTx[]>(`${apiUrl}/address/${address}/txs`);\n}\n\n/**\n * Fetches Bitcoin network fee recommendations from mempool.space API.\n *\n * @param apiUrl - Mempool API base URL\n * @returns Fee rates in sat/vbyte for different confirmation times\n * @throws Error if request fails or returns invalid data\n *\n * @see https://mempool.space/docs/api/rest#get-recommended-fees\n */\nexport async function getNetworkFees(apiUrl: string): Promise<NetworkFees> {\n const response = await fetchWithTimeout(`${apiUrl}/v1/fees/recommended`);\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch network fees: ${response.status} ${response.statusText}`,\n );\n }\n\n const data = await response.json();\n\n const feeFields = [\n \"fastestFee\",\n \"halfHourFee\",\n \"hourFee\",\n \"economyFee\",\n \"minimumFee\",\n ] as const;\n\n for (const field of feeFields) {\n if (!isValidFeeRate(data[field])) {\n throw new Error(\n `Invalid fee rate ${field}=${data[field]} from mempool API: expected a positive number ≤ ${MAX_FEE_RATE}`,\n );\n }\n }\n\n if (\n data.minimumFee > data.economyFee ||\n data.economyFee > data.hourFee ||\n data.hourFee > data.halfHourFee ||\n data.halfHourFee > data.fastestFee\n ) {\n throw new Error(\n `Fee rate ordering violation from mempool API: expected ` +\n `minimumFee (${data.minimumFee}) <= economyFee (${data.economyFee}) <= ` +\n `hourFee (${data.hourFee}) <= halfHourFee (${data.halfHourFee}) <= ` +\n `fastestFee (${data.fastestFee}).`,\n );\n }\n\n return data as NetworkFees;\n}\n\n"],"names":["MAX_SATOSHIS","MEMPOOL_REQUEST_TIMEOUT_MS","fetchWithTimeout","url","options","controller","timeoutId","signals","error","MAX_FEE_RATE","isValidSatoshiValue","value","isValidFeeRate","isValidVout","vout","outputCount","assertValidTxid","txid","TXID_RE","assertValidAddress","address","BITCOIN_ADDRESS_RE","assertValidScriptPubKey","scriptPubKey","context","HEX_RE","KNOWN_SCRIPT_PREFIXES","prefix","MEMPOOL_API_URLS","fetchApi","response","errorText","contentType","pushTx","txHex","apiUrl","message","getTxInfo","getTipHeight","raw","trimmed","getTxHex","getUtxoInfo","txInfo","output","getAddressUtxos","utxos","addressInfo","utxo","a","b","getMempoolApiUrl","network","getAddressTxs","getNetworkFees","data","feeFields","field"],"mappings":";AAmBA,MAAMA,IAAe,OAAa,KAG5BC,IAA6B;AAMnC,eAAeC,EACbC,GACAC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EAAK,WAAW,oBAC9CA,EAAK,UAAU;AAAA,IAAA;AAIpC,SAAOA;AACT;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const i=require("./validation-u8W7Lp2x.cjs"),g=21e6*1e8,l=3e4;async function c(e,r){const t=new AbortController,n=setTimeout(()=>t.abort(),l),s=[t.signal,r==null?void 0:r.signal].filter(Boolean);try{return await fetch(e,{...r,signal:AbortSignal.any(s)})}catch(o){throw clearTimeout(n),o!=null&&typeof o=="object"&&"name"in o&&o.name==="AbortError"?new Error(`Mempool API request timed out after ${l}ms: ${e}`):o}}const w=1e4;function m(e){return Number.isInteger(e)&&e>0&&e<=g}function I(e){return Number.isInteger(e)&&e>0&&e<=w}function h(e,r){return!Number.isInteger(e)||e<0?!1:r===void 0||e<r}function f(e){if(!i.TXID_RE.test(e))throw new Error(`Invalid transaction ID format: ${e}`)}function d(e){if(!i.BITCOIN_ADDRESS_RE.test(e))throw new Error(`Invalid Bitcoin address format: ${e}`)}function $(e,r){if(!i.HEX_RE.test(e))throw new Error(`Invalid scriptPubKey: not valid hex for ${r}`);if(!i.KNOWN_SCRIPT_PREFIXES.some(n=>e.toLowerCase().startsWith(n)))throw new Error(`Unrecognized scriptPubKey type for ${r}: prefix ${e.slice(0,6)} does not match any known Bitcoin script type`)}const p={mainnet:"https://mempool.space/api",testnet:"https://mempool.space/testnet/api",signet:"https://mempool.space/signet/api"};async function a(e,r){try{const t=await c(e,r);if(!t.ok){const s=await t.text();throw new Error(`Mempool API error (${t.status}): ${s||t.statusText}`)}const n=t.headers.get("content-type");return n!=null&&n.includes("application/json")?await t.json():await t.text()}catch(t){throw t instanceof Error?new Error(`Failed to fetch from mempool API: ${t.message}`):new Error("Failed to fetch from mempool API: Unknown error")}}async function F(e,r){try{const t=await c(`${r}/tx`,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}});if(!t.ok){const s=await t.text();let o;try{o=JSON.parse(s).message}catch{o=s}throw new Error(o||`Failed to broadcast transaction: ${t.statusText}`)}return await t.text()}catch(t){throw t instanceof Error?new Error(`Failed to broadcast BTC transaction: ${t.message}`):new Error("Failed to broadcast BTC transaction: Unknown error")}}async function E(e,r){return f(e),a(`${r}/tx/${e}`)}async function T(e){const r=await a(`${e}/blocks/tip/height`),t=r.trim();if(!/^\d+$/.test(t))throw new Error(`Mempool API returned an invalid block tip height: "${r}"`);return Number.parseInt(t,10)}async function x(e,r){f(e);try{const t=await c(`${r}/tx/${e}/hex`);if(!t.ok){const n=await t.text();throw new Error(`Mempool API error (${t.status}): ${n||t.statusText}`)}return await t.text()}catch(t){throw t instanceof Error?new Error(`Failed to get transaction hex for ${e}: ${t.message}`):new Error(`Failed to get transaction hex for ${e}: Unknown error`)}}async function y(e,r,t){f(e);const n=await E(e,t);if(!h(r,n.vout.length))throw new Error(`Invalid vout ${r} for transaction ${e} (has ${n.vout.length} outputs)`);const s=n.vout[r];if(!m(s.value))throw new Error(`Invalid UTXO value ${s.value} for ${e}:${r}`);return $(s.scriptpubkey,`${e}:${r}`),{txid:e,vout:r,value:s.value,scriptPubKey:s.scriptpubkey}}async function v(e,r){d(e);try{const t=await a(`${r}/address/${e}/utxo`),n=await a(`${r}/v1/validate-address/${e}`);if(!n.isvalid)throw new Error(`Invalid Bitcoin address: ${e}. Mempool API validation failed.`);$(n.scriptPubKey,e);for(const o of t){if(f(o.txid),!h(o.vout))throw new Error(`Invalid vout ${o.vout} for ${o.txid}`);if(!m(o.value))throw new Error(`Invalid UTXO value ${o.value} for ${o.txid}:${o.vout}`)}return t.sort((o,u)=>u.value-o.value).map(o=>({txid:o.txid,vout:o.vout,value:o.value,scriptPubKey:n.scriptPubKey,confirmed:o.status.confirmed}))}catch(t){throw t instanceof Error?new Error(`Failed to get UTXOs for address ${e}: ${t.message}`):new Error(`Failed to get UTXOs for address ${e}: Unknown error`)}}function A(e){return p[e]}async function b(e,r){return d(e),a(`${r}/address/${e}/txs`)}async function P(e){const r=await c(`${e}/v1/fees/recommended`);if(!r.ok)throw new Error(`Failed to fetch network fees: ${r.status} ${r.statusText}`);const t=await r.json(),n=["fastestFee","halfHourFee","hourFee","economyFee","minimumFee"];for(const s of n)if(!I(t[s]))throw new Error(`Invalid fee rate ${s}=${t[s]} from mempool API: expected a positive number ≤ ${w}`);if(t.minimumFee>t.economyFee||t.economyFee>t.hourFee||t.hourFee>t.halfHourFee||t.halfHourFee>t.fastestFee)throw new Error(`Fee rate ordering violation from mempool API: expected minimumFee (${t.minimumFee}) <= economyFee (${t.economyFee}) <= hourFee (${t.hourFee}) <= halfHourFee (${t.halfHourFee}) <= fastestFee (${t.fastestFee}).`);return t}exports.MEMPOOL_API_URLS=p;exports.getAddressTxs=b;exports.getAddressUtxos=v;exports.getMempoolApiUrl=A;exports.getNetworkFees=P;exports.getTipHeight=T;exports.getTxHex=x;exports.getTxInfo=E;exports.getUtxoInfo=y;exports.pushTx=F;
|
|
2
|
+
//# sourceMappingURL=mempoolApi-DEAS9wVa.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mempoolApi-DEAS9wVa.cjs","sources":["../src/tbv/core/clients/mempool/mempoolApi.ts"],"sourcesContent":["/**\n * Mempool API Client\n *\n * Client for interacting with mempool.space API for Bitcoin network operations.\n * Used for broadcasting transactions and fetching UTXO data.\n *\n * @module clients/mempool/mempoolApi\n */\n\nimport {\n BITCOIN_ADDRESS_RE,\n HEX_RE,\n KNOWN_SCRIPT_PREFIXES,\n TXID_RE,\n} from \"../../utils/validation\";\n\nimport type { MempoolUTXO, NetworkFees, TxInfo, UtxoInfo } from \"./types\";\n\n/** Maximum valid satoshi value: 21 million BTC × 10^8 sats/BTC */\nconst MAX_SATOSHIS = 21_000_000 * 1e8;\n\n/** Timeout for mempool API requests — prevents indefinite hangs from stalled endpoints */\nconst MEMPOOL_REQUEST_TIMEOUT_MS = 30_000;\n\n/**\n * Fetch wrapper with AbortController-based timeout.\n * Ensures all mempool API requests fail bounded rather than hanging indefinitely.\n */\nasync function fetchWithTimeout(\n url: string,\n options?: RequestInit,\n): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(\n () => controller.abort(),\n MEMPOOL_REQUEST_TIMEOUT_MS,\n );\n\n // Compose timeout signal with any caller-supplied signal so both can cancel\n const signals = [controller.signal, options?.signal].filter(\n Boolean,\n ) as AbortSignal[];\n\n try {\n // Don't clear timeout here — let it cover body consumption by callers\n return await fetch(url, {\n ...options,\n signal: AbortSignal.any(signals),\n });\n } catch (error) {\n clearTimeout(timeoutId);\n if (\n error != null &&\n typeof error === \"object\" &&\n \"name\" in error &&\n error.name === \"AbortError\"\n ) {\n throw new Error(\n `Mempool API request timed out after ${MEMPOOL_REQUEST_TIMEOUT_MS}ms: ${url}`,\n );\n }\n throw error;\n }\n}\n\n/**\n * Maximum sane fee rate in sat/vByte.\n * The April 2024 Runes spike peaked around 1,805 sat/vB — 10,000 provides ample headroom.\n */\nconst MAX_FEE_RATE = 10_000;\n\nfunction isValidSatoshiValue(value: number): boolean {\n return Number.isInteger(value) && value > 0 && value <= MAX_SATOSHIS;\n}\n\nfunction isValidFeeRate(value: number): boolean {\n return Number.isInteger(value) && value > 0 && value <= MAX_FEE_RATE;\n}\n\nfunction isValidVout(vout: number, outputCount?: number): boolean {\n if (!Number.isInteger(vout) || vout < 0) return false;\n return outputCount === undefined || vout < outputCount;\n}\n\n\nfunction assertValidTxid(txid: string): void {\n if (!TXID_RE.test(txid)) {\n throw new Error(`Invalid transaction ID format: ${txid}`);\n }\n}\n\nfunction assertValidAddress(address: string): void {\n if (!BITCOIN_ADDRESS_RE.test(address)) {\n throw new Error(`Invalid Bitcoin address format: ${address}`);\n }\n}\n\nfunction assertValidScriptPubKey(scriptPubKey: string, context: string): void {\n if (!HEX_RE.test(scriptPubKey)) {\n throw new Error(\n `Invalid scriptPubKey: not valid hex for ${context}`,\n );\n }\n const matchesKnownType = KNOWN_SCRIPT_PREFIXES.some((prefix) =>\n scriptPubKey.toLowerCase().startsWith(prefix),\n );\n if (!matchesKnownType) {\n throw new Error(\n `Unrecognized scriptPubKey type for ${context}: ` +\n `prefix ${scriptPubKey.slice(0, 6)} does not match any known Bitcoin script type`,\n );\n }\n}\n\n/**\n * Default mempool API URLs by network.\n */\nexport const MEMPOOL_API_URLS = {\n mainnet: \"https://mempool.space/api\",\n testnet: \"https://mempool.space/testnet/api\",\n signet: \"https://mempool.space/signet/api\",\n} as const;\n\n/**\n * Fetch wrapper with error handling.\n */\nasync function fetchApi<T>(\n url: string,\n options?: RequestInit,\n): Promise<T> {\n try {\n const response = await fetchWithTimeout(url, options);\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `Mempool API error (${response.status}): ${errorText || response.statusText}`,\n );\n }\n\n const contentType = response.headers.get(\"content-type\");\n if (contentType?.includes(\"application/json\")) {\n return (await response.json()) as T;\n } else {\n return (await response.text()) as T;\n }\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to fetch from mempool API: ${error.message}`);\n }\n throw new Error(\"Failed to fetch from mempool API: Unknown error\");\n }\n}\n\n/**\n * Push a signed transaction to the Bitcoin network.\n *\n * @param txHex - The signed transaction hex string\n * @param apiUrl - Mempool API base URL\n * @returns The transaction ID\n * @throws Error if broadcasting fails\n */\nexport async function pushTx(txHex: string, apiUrl: string): Promise<string> {\n try {\n const response = await fetchWithTimeout(`${apiUrl}/tx`, {\n method: \"POST\",\n body: txHex,\n headers: {\n \"Content-Type\": \"text/plain\",\n },\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n // Try to extract error message from response using robust JSON parsing\n let message: string | undefined;\n try {\n const errorJson = JSON.parse(errorText);\n message = errorJson.message;\n } catch {\n // Not JSON, use raw text\n message = errorText;\n }\n throw new Error(\n message || `Failed to broadcast transaction: ${response.statusText}`,\n );\n }\n\n // Response is the transaction ID (plain text)\n const txId = await response.text();\n return txId;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to broadcast BTC transaction: ${error.message}`);\n }\n throw new Error(\"Failed to broadcast BTC transaction: Unknown error\");\n }\n}\n\n/**\n * Get transaction information from mempool.\n *\n * @param txid - The transaction ID\n * @param apiUrl - Mempool API base URL\n * @returns Transaction information\n */\nexport async function getTxInfo(txid: string, apiUrl: string): Promise<TxInfo> {\n assertValidTxid(txid);\n return fetchApi<TxInfo>(`${apiUrl}/tx/${txid}`);\n}\n\n/**\n * Get the current block tip height.\n *\n * Source: mempool.space API — `GET /api/blocks/tip/height` returns the height\n * of the most recent block as a plain-text integer.\n *\n * @param apiUrl - Mempool API base URL\n * @returns The height of the most recent block\n * @throws Error if the response is not a whole number\n */\nexport async function getTipHeight(apiUrl: string): Promise<number> {\n const raw = await fetchApi<string>(`${apiUrl}/blocks/tip/height`);\n const trimmed = raw.trim();\n if (!/^\\d+$/.test(trimmed)) {\n throw new Error(\n `Mempool API returned an invalid block tip height: \"${raw}\"`,\n );\n }\n return Number.parseInt(trimmed, 10);\n}\n\n/**\n * Get the hex representation of a transaction.\n *\n * @param txid - The transaction ID\n * @param apiUrl - Mempool API base URL\n * @returns The transaction hex string\n * @throws Error if the request fails or transaction is not found\n */\nexport async function getTxHex(txid: string, apiUrl: string): Promise<string> {\n assertValidTxid(txid);\n try {\n const response = await fetchWithTimeout(`${apiUrl}/tx/${txid}/hex`);\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `Mempool API error (${response.status}): ${errorText || response.statusText}`,\n );\n }\n\n return await response.text();\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to get transaction hex for ${txid}: ${error.message}`);\n }\n throw new Error(`Failed to get transaction hex for ${txid}: Unknown error`);\n }\n}\n\n/**\n * Get UTXO information for a specific transaction output.\n *\n * This is used for constructing PSBTs where we need the witnessUtxo data.\n * Only supports Taproot (P2TR) and native SegWit (P2WPKH, P2WSH) script types.\n *\n * @param txid - The transaction ID containing the UTXO\n * @param vout - The output index\n * @param apiUrl - Mempool API base URL\n * @returns UTXO information with value and scriptPubKey\n */\nexport async function getUtxoInfo(\n txid: string,\n vout: number,\n apiUrl: string,\n): Promise<UtxoInfo> {\n assertValidTxid(txid);\n const txInfo = await getTxInfo(txid, apiUrl);\n\n if (!isValidVout(vout, txInfo.vout.length)) {\n throw new Error(\n `Invalid vout ${vout} for transaction ${txid} (has ${txInfo.vout.length} outputs)`,\n );\n }\n\n const output = txInfo.vout[vout];\n if (!isValidSatoshiValue(output.value)) {\n throw new Error(`Invalid UTXO value ${output.value} for ${txid}:${vout}`);\n }\n assertValidScriptPubKey(output.scriptpubkey, `${txid}:${vout}`);\n\n return {\n txid,\n vout,\n value: output.value,\n scriptPubKey: output.scriptpubkey,\n };\n}\n\n/**\n * Get all UTXOs for a Bitcoin address.\n *\n * @param address - The Bitcoin address\n * @param apiUrl - Mempool API base URL\n * @returns Array of UTXOs sorted by value (largest first)\n */\nexport async function getAddressUtxos(\n address: string,\n apiUrl: string,\n): Promise<MempoolUTXO[]> {\n assertValidAddress(address);\n try {\n // Fetch UTXOs for the address\n const utxos = await fetchApi<\n {\n txid: string;\n vout: number;\n value: number;\n status: {\n confirmed: boolean;\n };\n }[]\n >(`${apiUrl}/address/${address}/utxo`);\n\n // Fetch scriptPubKey for the address\n const addressInfo = await fetchApi<{\n isvalid: boolean;\n scriptPubKey: string;\n }>(`${apiUrl}/v1/validate-address/${address}`);\n\n if (!addressInfo.isvalid) {\n throw new Error(\n `Invalid Bitcoin address: ${address}. Mempool API validation failed.`,\n );\n }\n assertValidScriptPubKey(addressInfo.scriptPubKey, address);\n\n // Validate UTXO fields from the listing endpoint.\n // Per-UTXO cross-verification against /tx/{txid} is intentionally NOT done\n // here — it would be expensive (N API calls) and redundant: the broadcast\n // path already verifies each selected input via getUtxoInfo before signing.\n // Both endpoints come from the same mempool API, so cross-checking one\n // against the other on the same server does not add real security.\n for (const utxo of utxos) {\n assertValidTxid(utxo.txid);\n if (!isValidVout(utxo.vout)) {\n throw new Error(`Invalid vout ${utxo.vout} for ${utxo.txid}`);\n }\n if (!isValidSatoshiValue(utxo.value)) {\n throw new Error(\n `Invalid UTXO value ${utxo.value} for ${utxo.txid}:${utxo.vout}`,\n );\n }\n }\n\n // Sort by value (largest first) and map to our UTXO format\n const sortedUTXOs = utxos.sort((a, b) => b.value - a.value);\n\n return sortedUTXOs.map((utxo) => ({\n txid: utxo.txid,\n vout: utxo.vout,\n value: utxo.value,\n scriptPubKey: addressInfo.scriptPubKey,\n confirmed: utxo.status.confirmed,\n }));\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(\n `Failed to get UTXOs for address ${address}: ${error.message}`,\n );\n }\n throw new Error(\n `Failed to get UTXOs for address ${address}: Unknown error`,\n );\n }\n}\n\n/**\n * Get the mempool API URL for a given network.\n *\n * @param network - Bitcoin network (mainnet, testnet, signet)\n * @returns The mempool API URL\n */\nexport function getMempoolApiUrl(\n network: \"mainnet\" | \"testnet\" | \"signet\",\n): string {\n return MEMPOOL_API_URLS[network];\n}\n\n/**\n * Transaction summary from address transactions endpoint.\n */\nexport interface AddressTx {\n txid: string;\n status: {\n confirmed: boolean;\n block_height?: number;\n };\n}\n\n/**\n * Get recent transactions for a Bitcoin address.\n *\n * Returns the last 25 confirmed transactions plus any unconfirmed (mempool) transactions.\n * This is useful for checking if a specific transaction has been broadcast.\n *\n * @param address - The Bitcoin address\n * @param apiUrl - Mempool API base URL\n * @returns Array of recent transactions\n */\nexport async function getAddressTxs(\n address: string,\n apiUrl: string,\n): Promise<AddressTx[]> {\n assertValidAddress(address);\n return fetchApi<AddressTx[]>(`${apiUrl}/address/${address}/txs`);\n}\n\n/**\n * Fetches Bitcoin network fee recommendations from mempool.space API.\n *\n * @param apiUrl - Mempool API base URL\n * @returns Fee rates in sat/vbyte for different confirmation times\n * @throws Error if request fails or returns invalid data\n *\n * @see https://mempool.space/docs/api/rest#get-recommended-fees\n */\nexport async function getNetworkFees(apiUrl: string): Promise<NetworkFees> {\n const response = await fetchWithTimeout(`${apiUrl}/v1/fees/recommended`);\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch network fees: ${response.status} ${response.statusText}`,\n );\n }\n\n const data = await response.json();\n\n const feeFields = [\n \"fastestFee\",\n \"halfHourFee\",\n \"hourFee\",\n \"economyFee\",\n \"minimumFee\",\n ] as const;\n\n for (const field of feeFields) {\n if (!isValidFeeRate(data[field])) {\n throw new Error(\n `Invalid fee rate ${field}=${data[field]} from mempool API: expected a positive number ≤ ${MAX_FEE_RATE}`,\n );\n }\n }\n\n if (\n data.minimumFee > data.economyFee ||\n data.economyFee > data.hourFee ||\n data.hourFee > data.halfHourFee ||\n data.halfHourFee > data.fastestFee\n ) {\n throw new Error(\n `Fee rate ordering violation from mempool API: expected ` +\n `minimumFee (${data.minimumFee}) <= economyFee (${data.economyFee}) <= ` +\n `hourFee (${data.hourFee}) <= halfHourFee (${data.halfHourFee}) <= ` +\n `fastestFee (${data.fastestFee}).`,\n );\n }\n\n return data as NetworkFees;\n}\n\n"],"names":["MAX_SATOSHIS","MEMPOOL_REQUEST_TIMEOUT_MS","fetchWithTimeout","url","options","controller","timeoutId","signals","error","MAX_FEE_RATE","isValidSatoshiValue","value","isValidFeeRate","isValidVout","vout","outputCount","assertValidTxid","txid","TXID_RE","assertValidAddress","address","BITCOIN_ADDRESS_RE","assertValidScriptPubKey","scriptPubKey","context","HEX_RE","KNOWN_SCRIPT_PREFIXES","prefix","MEMPOOL_API_URLS","fetchApi","response","errorText","contentType","pushTx","txHex","apiUrl","message","getTxInfo","getTipHeight","raw","trimmed","getTxHex","getUtxoInfo","txInfo","output","getAddressUtxos","utxos","addressInfo","utxo","a","b","getMempoolApiUrl","network","getAddressTxs","getNetworkFees","data","feeFields","field"],"mappings":"0DAmBMA,EAAe,KAAa,IAG5BC,EAA6B,IAMnC,eAAeC,EACbC,EACAC,EACmB,CACnB,MAAMC,EAAa,IAAI,gBACjBC,EAAY,WAChB,IAAMD,EAAW,MAAA,EACjBJ,CAAA,EAIIM,EAAU,CAACF,EAAW,OAAQD,GAAA,YAAAA,EAAS,MAAM,EAAE,OACnD,OAAA,EAGF,GA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sBAAsB,EAEvE,GAAI,CAACL,EAAS,GACZ,MAAM,IAAI,MACR,iCAAiCA,EAAS,MAAM,IAAIA,EAAS,UAAU,EAAA,EAI3E,MAAMyB,EAAO,MAAMzB,EAAS,KAAA,EAEtB0B,EAAY,CAChB,aACA,cACA,UACA,aACA,YAAA,EAGF,UAAWC,KAASD,EAClB,GAAI,CAAC5C,EAAe2C,EAAKE,CAAK,CAAC,EAC7B,MAAM,IAAI,MACR,oBAAoBA,CAAK,IAAIF,EAAKE,CAAK,CAAC,mDAAmDhD,CAAY,EAAA,EAK7G,GACE8C,EAAK,WAAaA,EAAK,YACvBA,EAAK,WAAaA,EAAK,SACvBA,EAAK,QAAUA,EAAK,aACpBA,EAAK,YAAcA,EAAK,WAExB,MAAM,IAAI,MACR,sEACiBA,EAAK,UAAU,oBAAoBA,EAAK,UAAU,iBACrDA,EAAK,OAAO,qBAAqBA,EAAK,WAAW,oBAC9CA,EAAK,UAAU,IAAA,EAIpC,OAAOA,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../mempoolApi-DEAS9wVa.cjs"),e=require("../../../types-Be3sAYzr.cjs"),t=require("../../../types-eYlq0p1o.cjs");exports.MEMPOOL_API_URLS=r.MEMPOOL_API_URLS;exports.getAddressTxs=r.getAddressTxs;exports.getAddressUtxos=r.getAddressUtxos;exports.getMempoolApiUrl=r.getMempoolApiUrl;exports.getNetworkFees=r.getNetworkFees;exports.getTipHeight=r.getTipHeight;exports.getTxHex=r.getTxHex;exports.getTxInfo=r.getTxInfo;exports.getUtxoInfo=r.getUtxoInfo;exports.pushTx=r.pushTx;exports.OnChainBtcVaultStatus=e.OnChainBtcVaultStatus;exports.ServerIdentityError=e.ServerIdentityError;exports.VaultProviderRpcClient=e.VaultProviderRpcClient;exports.ViemProtocolParamsReader=e.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=e.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=e.ViemVaultKeeperReader;exports.ViemVaultRegistryReader=e.ViemVaultRegistryReader;exports.VpResponseValidationError=e.VpResponseValidationError;exports.VpTokenRegistry=e.VpTokenRegistry;exports.batchPollByProvider=e.batchPollByProvider;exports.createAuthenticatedVpClient=e.createAuthenticatedVpClient;exports.primeVpTokenRegistry=e.primeVpTokenRegistry;exports.resolveProtocolAddresses=e.resolveProtocolAddresses;exports.validateOffchainParams=e.validateOffchainParams;exports.validatePegInConfiguration=e.validatePegInConfiguration;exports.validateRequestDepositorClaimerArtifactsResponse=e.validateRequestDepositorClaimerArtifactsResponse;exports.validateTBVProtocolParams=e.validateTBVProtocolParams;exports.verifyServerIdentity=e.verifyServerIdentity;exports.vpTokenRegistry=e.vpTokenRegistry;exports.AUTH_EXPIRED_DATA_KIND=t.AUTH_EXPIRED_DATA_KIND;exports.DaemonStatus=t.DaemonStatus;exports.JSON_RPC_ERROR_CODES=t.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=t.JsonRpcClient;exports.JsonRpcError=t.JsonRpcError;exports.POST_WOTS_STATUSES=t.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=t.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=t.RpcErrorCode;exports.VP_BATCH_MAX_SIZE=t.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=t.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=t.VP_TRANSIENT_STATUSES;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
import { M as s, g as r, a as t, b as o, c as i, d as R, e as
|
|
2
|
-
import { O as
|
|
3
|
-
import { A as
|
|
1
|
+
import { M as s, g as r, a as t, b as o, c as i, d as R, e as T, f as S, h as l, p as n } from "../../../mempoolApi-C7hkVkym.js";
|
|
2
|
+
import { O as p, S as A, V as P, j as _, k as E, l as V, m as g, a as c, d as m, b as I, f as v, p as f, r as O, g as C, h as U, v as u, i as x, c as h, e as y } from "../../../types-0bvDGR4x.js";
|
|
3
|
+
import { A as N, D as M, b as k, J as b, a as B, d as H, P as J, R as L, e as F, c as K, V as X } from "../../../types-BqGAMOZM.js";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
N as AUTH_EXPIRED_DATA_KIND,
|
|
6
|
+
M as DaemonStatus,
|
|
7
|
+
k as JSON_RPC_ERROR_CODES,
|
|
8
|
+
b as JsonRpcClient,
|
|
9
|
+
B as JsonRpcError,
|
|
10
10
|
s as MEMPOOL_API_URLS,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
p as OnChainBtcVaultStatus,
|
|
12
|
+
H as POST_WOTS_STATUSES,
|
|
13
13
|
J as PRE_DEPOSITOR_SIGNATURES_STATES,
|
|
14
14
|
L as RpcErrorCode,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
A as ServerIdentityError,
|
|
16
|
+
F as VP_BATCH_MAX_SIZE,
|
|
17
|
+
K as VP_TERMINAL_FAILURE_STATUSES,
|
|
18
|
+
X as VP_TRANSIENT_STATUSES,
|
|
19
|
+
P as VaultProviderRpcClient,
|
|
20
|
+
_ as ViemProtocolParamsReader,
|
|
21
|
+
E as ViemUniversalChallengerReader,
|
|
22
|
+
V as ViemVaultKeeperReader,
|
|
23
|
+
g as ViemVaultRegistryReader,
|
|
24
24
|
c as VpResponseValidationError,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
m as VpTokenRegistry,
|
|
26
|
+
I as batchPollByProvider,
|
|
27
|
+
v as createAuthenticatedVpClient,
|
|
28
28
|
r as getAddressTxs,
|
|
29
29
|
t as getAddressUtxos,
|
|
30
30
|
o as getMempoolApiUrl,
|
|
31
31
|
i as getNetworkFees,
|
|
32
|
-
R as
|
|
32
|
+
R as getTipHeight,
|
|
33
|
+
T as getTxHex,
|
|
33
34
|
S as getTxInfo,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
l as getUtxoInfo,
|
|
36
|
+
f as primeVpTokenRegistry,
|
|
37
|
+
n as pushTx,
|
|
38
|
+
O as resolveProtocolAddresses,
|
|
39
|
+
C as validateOffchainParams,
|
|
40
|
+
U as validatePegInConfiguration,
|
|
41
|
+
u as validateRequestDepositorClaimerArtifactsResponse,
|
|
42
|
+
x as validateTBVProtocolParams,
|
|
43
|
+
h as verifyServerIdentity,
|
|
43
44
|
y as vpTokenRegistry
|
|
44
45
|
};
|
|
45
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module clients/mempool
|
|
7
7
|
*/
|
|
8
|
-
export { getAddressTxs, getAddressUtxos, getMempoolApiUrl, getNetworkFees, getTxHex, getTxInfo, getUtxoInfo, MEMPOOL_API_URLS, pushTx, } from './mempoolApi';
|
|
8
|
+
export { getAddressTxs, getAddressUtxos, getMempoolApiUrl, getNetworkFees, getTipHeight, getTxHex, getTxInfo, getUtxoInfo, MEMPOOL_API_URLS, pushTx, } from './mempoolApi';
|
|
9
9
|
export type { AddressTx } from './mempoolApi';
|
|
10
10
|
export type { MempoolUTXO, NetworkFees, TxInfo, TxInput, TxOutput, TxStatus, UtxoInfo, } from './types';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|