@dynamic-labs-sdk/bitcoin 1.28.0 → 1.29.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/{bitcoinTransferAmount-BBFKRh00.cjs → InvalidPsbtError-D0F2EZEI.cjs} +23 -3
- package/dist/InvalidPsbtError-D0F2EZEI.cjs.map +1 -0
- package/dist/{bitcoinTransferAmount-C-iLhaL2.esm.js → InvalidPsbtError-nAb75Fvm.esm.js} +17 -3
- package/dist/InvalidPsbtError-nAb75Fvm.esm.js.map +1 -0
- package/dist/{addBitcoinInjectedWalletsExtension-CQwCjR49.esm.js → addBitcoinInjectedWalletsExtension-Co7mtOVg.esm.js} +4 -18
- package/dist/addBitcoinInjectedWalletsExtension-Co7mtOVg.esm.js.map +1 -0
- package/dist/{addBitcoinInjectedWalletsExtension-8Hg5XjUx.cjs → addBitcoinInjectedWalletsExtension-DXYVv-LJ.cjs} +31 -51
- package/dist/addBitcoinInjectedWalletsExtension-DXYVv-LJ.cjs.map +1 -0
- package/dist/{addWaasBitcoinExtension-4PAe_tOz.cjs → addWaasBitcoinExtension-BJU5cWG0.cjs} +63 -11
- package/dist/addWaasBitcoinExtension-BJU5cWG0.cjs.map +1 -0
- package/dist/{addWaasBitcoinExtension-IrLvQh8F.esm.js → addWaasBitcoinExtension-B_rWSexg.esm.js} +54 -2
- package/dist/addWaasBitcoinExtension-B_rWSexg.esm.js.map +1 -0
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +3 -3
- package/dist/injected.cjs +4 -4
- package/dist/injected.cjs.map +1 -1
- package/dist/injected.esm.js +2 -2
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas/utils/createWalletProviderForWaasBitcoin/createWalletProviderForWaasBitcoin.d.ts.map +1 -1
- package/dist/waas/utils/getWaasAllowedSighash/getWaasAllowedSighash.d.ts +23 -0
- package/dist/waas/utils/getWaasAllowedSighash/getWaasAllowedSighash.d.ts.map +1 -0
- package/dist/waas/utils/getWaasAllowedSighash/index.d.ts +2 -0
- package/dist/waas/utils/getWaasAllowedSighash/index.d.ts.map +1 -0
- package/dist/waas/utils/getWaasSigningIndexes/getWaasSigningIndexes.d.ts +28 -0
- package/dist/waas/utils/getWaasSigningIndexes/getWaasSigningIndexes.d.ts.map +1 -0
- package/dist/waas/utils/getWaasSigningIndexes/index.d.ts +2 -0
- package/dist/waas/utils/getWaasSigningIndexes/index.d.ts.map +1 -0
- package/dist/waas.cjs +4 -4
- package/dist/waas.cjs.map +1 -1
- package/dist/waas.esm.js +2 -2
- package/package.json +4 -4
- package/dist/addBitcoinInjectedWalletsExtension-8Hg5XjUx.cjs.map +0 -1
- package/dist/addBitcoinInjectedWalletsExtension-CQwCjR49.esm.js.map +0 -1
- package/dist/addWaasBitcoinExtension-4PAe_tOz.cjs.map +0 -1
- package/dist/addWaasBitcoinExtension-IrLvQh8F.esm.js.map +0 -1
- package/dist/bitcoinTransferAmount-BBFKRh00.cjs.map +0 -1
- package/dist/bitcoinTransferAmount-C-iLhaL2.esm.js.map +0 -1
|
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const
|
|
28
|
+
const require_InvalidPsbtError = require('./InvalidPsbtError-D0F2EZEI.cjs');
|
|
29
29
|
let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
30
30
|
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
31
31
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
@@ -77,7 +77,7 @@ var TransactionRequiredError = class extends _dynamic_labs_sdk_client.BaseError
|
|
|
77
77
|
* @throws {TransactionBroadcastFailedError} if broadcasting fails
|
|
78
78
|
* @notInstrumented
|
|
79
79
|
*/
|
|
80
|
-
const broadcastTransaction = async ({ mempoolApiUrl =
|
|
80
|
+
const broadcastTransaction = async ({ mempoolApiUrl = require_InvalidPsbtError.MEMPOOL_API_URL, rawTransaction }) => {
|
|
81
81
|
if (!rawTransaction) throw new TransactionRequiredError();
|
|
82
82
|
const response = await fetch(`${mempoolApiUrl}/tx`, {
|
|
83
83
|
body: rawTransaction,
|
|
@@ -280,7 +280,7 @@ var FeeRecommendationsFetchError = class extends _dynamic_labs_sdk_client.BaseEr
|
|
|
280
280
|
* @throws FeeRecommendationsFetchError if fetching fee recommendations fails
|
|
281
281
|
* @notInstrumented
|
|
282
282
|
*/
|
|
283
|
-
const getFeeRecommendations = async ({ mempoolApiUrl =
|
|
283
|
+
const getFeeRecommendations = async ({ mempoolApiUrl = require_InvalidPsbtError.MEMPOOL_API_URL } = {}) => {
|
|
284
284
|
const response = await fetch(`${mempoolApiUrl}/v1/fees/recommended`);
|
|
285
285
|
if (!response.ok) throw new FeeRecommendationsFetchError({ response });
|
|
286
286
|
return response.json();
|
|
@@ -393,7 +393,7 @@ var UTXOsFetchError = class extends _dynamic_labs_sdk_client.BaseError {
|
|
|
393
393
|
* @throws UTXOsFetchError if fetching UTXOs fails
|
|
394
394
|
* @notInstrumented
|
|
395
395
|
*/
|
|
396
|
-
const getUTXOs = async ({ address: address$1, mempoolApiUrl =
|
|
396
|
+
const getUTXOs = async ({ address: address$1, mempoolApiUrl = require_InvalidPsbtError.MEMPOOL_API_URL }) => {
|
|
397
397
|
const response = await fetch(`${mempoolApiUrl}/address/${address$1}/utxo`);
|
|
398
398
|
if (!response.ok) throw new UTXOsFetchError({
|
|
399
399
|
address: address$1,
|
|
@@ -594,19 +594,19 @@ const getActiveBitcoinNetworkConfig = ({ networkId }) => {
|
|
|
594
594
|
switch (id) {
|
|
595
595
|
case "1": return {
|
|
596
596
|
bitcoinNetwork: "mainnet",
|
|
597
|
-
mempoolApiUrl:
|
|
597
|
+
mempoolApiUrl: require_InvalidPsbtError.MEMPOOL_API_URL,
|
|
598
598
|
networkId: id,
|
|
599
599
|
psbtNetwork: bitcoinjs_lib.networks.bitcoin
|
|
600
600
|
};
|
|
601
601
|
case "2": return {
|
|
602
602
|
bitcoinNetwork: "testnet",
|
|
603
|
-
mempoolApiUrl:
|
|
603
|
+
mempoolApiUrl: require_InvalidPsbtError.MEMPOOL_API_URL_TESTNET,
|
|
604
604
|
networkId: id,
|
|
605
605
|
psbtNetwork: bitcoinjs_lib.networks.testnet
|
|
606
606
|
};
|
|
607
607
|
case "3": return {
|
|
608
608
|
bitcoinNetwork: "testnet",
|
|
609
|
-
mempoolApiUrl:
|
|
609
|
+
mempoolApiUrl: require_InvalidPsbtError.MEMPOOL_API_URL_SIGNET,
|
|
610
610
|
networkId: id,
|
|
611
611
|
psbtNetwork: bitcoinjs_lib.networks.testnet
|
|
612
612
|
};
|
|
@@ -643,6 +643,26 @@ const getPublicKeyForWalletAccount = (walletAccount, client) => {
|
|
|
643
643
|
throw new PublicKeyNotFoundError(walletAccount.address);
|
|
644
644
|
};
|
|
645
645
|
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/waas/utils/getWaasAllowedSighash/getWaasAllowedSighash.ts
|
|
648
|
+
/**
|
|
649
|
+
* Translates the request's `allowedSighash` into the value the WaaS client takes.
|
|
650
|
+
*
|
|
651
|
+
* The two sides disagree on what an empty array means, and forwarding it
|
|
652
|
+
* verbatim would break every embedded send:
|
|
653
|
+
*
|
|
654
|
+
* - Here, `allowedSighash` is required, so `[]` is how callers say "no
|
|
655
|
+
* restriction" — `sendBitcoin` passes exactly that for its own PSBTs.
|
|
656
|
+
* - In the WaaS client, `[]` means "permit nothing" and rejects every input,
|
|
657
|
+
* while `undefined` means "permit any type the PSBT declares".
|
|
658
|
+
*
|
|
659
|
+
* So an empty list maps to `undefined`, preserving today's behaviour, and a
|
|
660
|
+
* populated list is passed through to restrict signing.
|
|
661
|
+
*
|
|
662
|
+
* @notInstrumented
|
|
663
|
+
*/
|
|
664
|
+
const getWaasAllowedSighash = ({ request }) => request.allowedSighash?.length ? request.allowedSighash : void 0;
|
|
665
|
+
|
|
646
666
|
//#endregion
|
|
647
667
|
//#region src/waas/utils/getWaasBitcoinAddressForNetwork/getWaasBitcoinAddressForNetwork.ts
|
|
648
668
|
/**
|
|
@@ -662,6 +682,31 @@ const getWaasBitcoinAddressForNetwork = ({ bitcoinNetwork, walletAccount }) => {
|
|
|
662
682
|
return walletAccount.addressesWithTypes?.find((address$1) => address$1.type === _dynamic_labs_sdk_api_core.WalletAddressType.Payment && address$1.network === bitcoinNetwork)?.address ?? walletAccount.address;
|
|
663
683
|
};
|
|
664
684
|
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region src/waas/utils/getWaasSigningIndexes/getWaasSigningIndexes.ts
|
|
687
|
+
/**
|
|
688
|
+
* Flattens the request's per-address `signature[].signingIndexes` into the flat
|
|
689
|
+
* index array the WaaS client takes, keeping only the entries that name this
|
|
690
|
+
* wallet.
|
|
691
|
+
*
|
|
692
|
+
* Returns `undefined` when the caller scoped nothing, which leaves the existing
|
|
693
|
+
* behaviour intact: the WaaS client signs every input the wallet owns.
|
|
694
|
+
*
|
|
695
|
+
* Throws when the caller scoped indexes but none of them are for this wallet.
|
|
696
|
+
* Returning `undefined` there would widen the request into "sign everything I
|
|
697
|
+
* own" — the opposite of what a caller narrowing a PSBT is asking for.
|
|
698
|
+
*
|
|
699
|
+
* @notInstrumented
|
|
700
|
+
*/
|
|
701
|
+
const getWaasSigningIndexes = ({ request, walletAddresses }) => {
|
|
702
|
+
const scopedEntries = request.signature?.filter((entry) => entry.signingIndexes?.length) ?? [];
|
|
703
|
+
if (!scopedEntries.length) return;
|
|
704
|
+
const ownAddresses = new Set(walletAddresses.filter(Boolean));
|
|
705
|
+
const indexes = scopedEntries.filter((entry) => ownAddresses.has(entry.address)).flatMap((entry) => entry.signingIndexes ?? []);
|
|
706
|
+
if (!indexes.length) throw new require_InvalidPsbtError.InvalidPsbtError("signingIndexes were provided, but none of them are for this wallet");
|
|
707
|
+
return [...new Set(indexes)].sort((a, b) => a - b);
|
|
708
|
+
};
|
|
709
|
+
|
|
665
710
|
//#endregion
|
|
666
711
|
//#region src/waas/utils/createWalletProviderForWaasBitcoin/createWalletProviderForWaasBitcoin.ts
|
|
667
712
|
/** @notInstrumented */
|
|
@@ -698,14 +743,21 @@ const createWalletProviderForWaasBitcoin = (sdkClient) => {
|
|
|
698
743
|
};
|
|
699
744
|
const signPsbt = async ({ request, walletAccount }) => {
|
|
700
745
|
(0, _dynamic_labs_sdk_client_core.assertDefined)(walletAccount, "Wallet account is required");
|
|
746
|
+
const signingIndexes = getWaasSigningIndexes({
|
|
747
|
+
request,
|
|
748
|
+
walletAddresses: [walletAccount.address, ...(walletAccount.addressesWithTypes ?? []).map(({ address: address$1 }) => address$1)]
|
|
749
|
+
});
|
|
750
|
+
const allowedSighash = getWaasAllowedSighash({ request });
|
|
701
751
|
const waasClient = await waasProvider.getWaasClient();
|
|
702
752
|
const { signature: signedSessionId } = await (0, _dynamic_labs_sdk_client_core.getSignedSessionId)(sdkClient);
|
|
703
753
|
const mfaToken = await (0, _dynamic_labs_sdk_client_core.consumeMfaTokenIfRequiredForAction)({ mfaAction: _dynamic_labs_sdk_api_core.MFAAction.WalletWaasSign }, sdkClient);
|
|
704
754
|
return { signedPsbt: await waasClient.signTransaction({
|
|
755
|
+
allowedSighash,
|
|
705
756
|
authToken: sdkClient.token ?? void 0,
|
|
706
757
|
mfaToken,
|
|
707
758
|
senderAddress: walletAccount.address,
|
|
708
759
|
signedSessionId,
|
|
760
|
+
signingIndexes,
|
|
709
761
|
transaction: request.unsignedPsbtBase64
|
|
710
762
|
}) };
|
|
711
763
|
};
|
|
@@ -778,7 +830,7 @@ const createWalletProviderForWaasBitcoin = (sdkClient) => {
|
|
|
778
830
|
...waasProvider,
|
|
779
831
|
buildPsbt: buildPsbt$1,
|
|
780
832
|
chain,
|
|
781
|
-
executeSwapTransaction: (args) =>
|
|
833
|
+
executeSwapTransaction: (args) => require_InvalidPsbtError.bitcoinExecuteSwapTransaction(args, sdkClient),
|
|
782
834
|
getActiveNetworkId,
|
|
783
835
|
getConnectedAddresses,
|
|
784
836
|
groupKey: (0, _dynamic_labs_sdk_client_core.formatWalletProviderGroupKey)(_dynamic_labs_sdk_client_waas_core.DYNAMIC_WAAS_METADATA.displayName),
|
|
@@ -792,7 +844,7 @@ const createWalletProviderForWaasBitcoin = (sdkClient) => {
|
|
|
792
844
|
signPsbt,
|
|
793
845
|
signPsbts,
|
|
794
846
|
switchActiveNetwork,
|
|
795
|
-
transferAmount: (args) =>
|
|
847
|
+
transferAmount: (args) => require_InvalidPsbtError.bitcoinTransferAmount(args, sdkClient),
|
|
796
848
|
walletProviderType
|
|
797
849
|
};
|
|
798
850
|
};
|
|
@@ -812,7 +864,7 @@ const WAAS_BITCOIN_EXTENSION_KEY = "waasBitcoin";
|
|
|
812
864
|
const addWaasBitcoinExtension = (client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
813
865
|
if ((0, _dynamic_labs_sdk_client_core.hasExtension)({ extensionKey: WAAS_BITCOIN_EXTENSION_KEY }, client)) return;
|
|
814
866
|
(0, _dynamic_labs_sdk_client_core.registerExtension)({ extensionKey: WAAS_BITCOIN_EXTENSION_KEY }, client);
|
|
815
|
-
|
|
867
|
+
require_InvalidPsbtError.registerBitcoinNetworkProviderBuilder(client);
|
|
816
868
|
const walletProviderRegistry = (0, _dynamic_labs_sdk_client_core.getWalletProviderRegistry)(client);
|
|
817
869
|
const walletProvider = createWalletProviderForWaasBitcoin(client);
|
|
818
870
|
walletProviderRegistry.register({
|
|
@@ -858,4 +910,4 @@ Object.defineProperty(exports, 'getWaasBitcoinAddressForNetwork', {
|
|
|
858
910
|
return getWaasBitcoinAddressForNetwork;
|
|
859
911
|
}
|
|
860
912
|
});
|
|
861
|
-
//# sourceMappingURL=addWaasBitcoinExtension-
|
|
913
|
+
//# sourceMappingURL=addWaasBitcoinExtension-BJU5cWG0.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addWaasBitcoinExtension-BJU5cWG0.cjs","names":["BaseError","BaseError","MEMPOOL_API_URL","BaseError","BaseError","BaseError","address","BaseError","payments","address","BaseError","MEMPOOL_API_URL","feePerByte: number","BaseError","address","MEMPOOL_API_URL","address","selected: UTXO[]","BaseError","ecc","Psbt","BaseError","MEMPOOL_API_URL","networks","MEMPOOL_API_URL_TESTNET","MEMPOOL_API_URL_SIGNET","BaseError","address","address","WalletAddressType","InvalidPsbtError","WalletProviderEnum","DYNAMIC_WAAS_METADATA","getActiveNetworkId: WaasBitcoinWalletProvider['getActiveNetworkId']","switchActiveNetwork: WaasBitcoinWalletProvider['switchActiveNetwork']","getConnectedAddresses: WaasBitcoinWalletProvider['getConnectedAddresses']","signPsbt: WaasBitcoinWalletProvider['signPsbt']","address","MFAAction","signPsbts: WaasBitcoinWalletProvider['signPsbts']","signMessage: WaasBitcoinWalletProvider['signMessage']","buildPsbt: WaasBitcoinWalletProvider['buildPsbt']","buildPsbtUtil","sendBitcoin: WaasBitcoinWalletProvider['sendBitcoin']","buildPsbt","Psbt","bitcoinExecuteSwapTransaction","bitcoinTransferAmount","WalletProviderPriority"],"sources":["../src/errors/TransactionBroadcastFailedError.ts","../src/errors/TransactionRequiredError.ts","../src/waas/utils/broadcastTransaction/broadcastTransaction.ts","../src/waas/constants.ts","../src/errors/InsufficientFundsError.ts","../src/errors/InvalidAmountError.ts","../src/errors/NoUTXOsFoundError.ts","../src/errors/SegwitOutputScriptError.ts","../src/waas/utils/addInputsToPsbt/addInputsToPsbt.ts","../src/waas/utils/addOutputsToPsbt/addOutputsToPsbt.ts","../src/errors/FeeRecommendationsFetchError.ts","../src/waas/utils/getFeeRecommendations/getFeeRecommendations.ts","../src/waas/utils/estimateTransactionFee/estimateTransactionFee.ts","../src/waas/utils/calculateFeeAndChange/calculateFeeAndChange.ts","../src/waas/utils/calculateUTXOTotal/calculateUTXOTotal.ts","../src/errors/UTXOsFetchError.ts","../src/waas/utils/getUTXOs/getUTXOs.ts","../src/waas/utils/selectUTXOsLargestFirst/selectUTXOsLargestFirst.ts","../src/waas/utils/validateAndSelectUTXOs/validateAndSelectUTXOs.ts","../src/errors/TaprootAddressNotSupportedError.ts","../src/waas/utils/validateNotTaproot/validateNotTaproot.ts","../src/waas/utils/buildPsbt/buildPsbt.ts","../src/errors/UnsupportedBitcoinNetworkError.ts","../src/waas/utils/getActiveBitcoinNetworkConfig/getActiveBitcoinNetworkConfig.ts","../src/errors/PublicKeyNotFoundError.ts","../src/waas/utils/getPublicKeyForWalletAccount/getPublicKeyForWalletAccount.ts","../src/waas/utils/getWaasAllowedSighash/getWaasAllowedSighash.ts","../src/waas/utils/getWaasBitcoinAddressForNetwork/getWaasBitcoinAddressForNetwork.ts","../src/waas/utils/getWaasSigningIndexes/getWaasSigningIndexes.ts","../src/waas/utils/createWalletProviderForWaasBitcoin/createWalletProviderForWaasBitcoin.ts","../src/waas/addWaasBitcoinExtension/addWaasBitcoinExtension.ts"],"sourcesContent":["import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype TransactionBroadcastFailedErrorParams = {\n response: Response;\n};\n\nexport class TransactionBroadcastFailedError extends BaseError {\n public readonly response: Response;\n\n constructor({ response }: TransactionBroadcastFailedErrorParams) {\n super({\n cause: null,\n code: 'transaction_broadcast_failed_error',\n details: `Status: ${response.status} ${response.statusText}`,\n docsUrl: null,\n name: 'TransactionBroadcastFailedError',\n shortMessage: 'Failed to broadcast transaction to mempool',\n });\n\n this.response = response;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class TransactionRequiredError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'transaction_required_error',\n docsUrl: null,\n name: 'TransactionRequiredError',\n shortMessage: 'No transaction specified for broadcast',\n });\n }\n}\n","import { MEMPOOL_API_URL } from '../../../constants';\nimport { TransactionBroadcastFailedError } from '../../../errors/TransactionBroadcastFailedError';\nimport { TransactionRequiredError } from '../../../errors/TransactionRequiredError';\n\n/**\n * Sends a raw Bitcoin transaction to the mempool\n *\n * @param options.rawTransaction - The raw transaction in hex format\n * @param options.mempoolApiUrl - Base mempool API URL for the active network\n * @returns The transaction ID\n * @throws {TransactionRequiredError} if no transaction is specified\n * @throws {TransactionBroadcastFailedError} if broadcasting fails\n * @notInstrumented\n */\nexport const broadcastTransaction = async ({\n mempoolApiUrl = MEMPOOL_API_URL,\n rawTransaction,\n}: {\n mempoolApiUrl?: string;\n rawTransaction: string;\n}): Promise<string> => {\n if (!rawTransaction) {\n throw new TransactionRequiredError();\n }\n\n const response = await fetch(`${mempoolApiUrl}/tx`, {\n body: rawTransaction,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n method: 'POST',\n });\n\n if (!response.ok) {\n throw new TransactionBroadcastFailedError({ response });\n }\n\n return response.text();\n};\n","/**\n * Number of satoshis per Bitcoin\n */\nexport const SATOSHIS_PER_BTC = 100_000_000;\n\n/**\n * Bitcoin's dust limit in satoshis\n * Outputs below this value are considered \"dust\" and will be rejected by nodes\n */\nexport const DUST_LIMIT = 546;\n\n/**\n * Accurate vSize constants for Native SegWit (P2WPKH) transactions\n * Used for precise fee estimation\n */\nexport const VSIZE_OVERHEAD = 10.5;\n\nexport const VSIZE_INPUT_P2WPKH = 68;\n\nexport const VSIZE_OUTPUT_P2WPKH = 31;\n\n/**\n * Minimum relay fee in satoshis\n * Added to fee estimate to ensure transaction propagation\n */\nexport const MIN_RELAY_FEE = 111;\n\n/**\n * Conservative default fee estimate in satoshis\n * Used as fallback when fee estimation fails\n */\nexport const DEFAULT_FEE_ESTIMATE = 1000;\n\n/**\n * RBF (Replace-By-Fee) sequence number\n * 0xfffffffd = 4294967293 (enables RBF, not final)\n */\nexport const RBF_SEQUENCE = 0xfffffffd;\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nimport { SATOSHIS_PER_BTC } from '../waas/constants';\n\ntype InsufficientFundsErrorParams = {\n availableSatoshis: number;\n requiredSatoshis: number;\n};\n\nexport class InsufficientFundsError extends BaseError {\n public readonly availableSatoshis: number;\n\n public readonly requiredSatoshis: number;\n\n constructor({ availableSatoshis, requiredSatoshis }: InsufficientFundsErrorParams) {\n const availableBtc = availableSatoshis / SATOSHIS_PER_BTC;\n const requiredBtc = requiredSatoshis / SATOSHIS_PER_BTC;\n\n super({\n cause: null,\n code: 'insufficient_funds_error',\n details: `Available: ${availableBtc} BTC (${availableSatoshis} satoshis), Required: ${requiredBtc} BTC (${requiredSatoshis} satoshis)`,\n docsUrl: null,\n name: 'InsufficientFundsError',\n shortMessage: 'Insufficient funds for transaction',\n });\n\n this.availableSatoshis = availableSatoshis;\n\n this.requiredSatoshis = requiredSatoshis;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype InvalidAmountErrorParams = {\n amountInSatoshis: number;\n reason: string;\n};\n\nexport class InvalidAmountError extends BaseError {\n public readonly amountInSatoshis: number;\n\n constructor({ amountInSatoshis, reason }: InvalidAmountErrorParams) {\n super({\n cause: null,\n code: 'invalid_amount_error',\n details: `Amount: ${amountInSatoshis} satoshis`,\n docsUrl: null,\n name: 'InvalidAmountError',\n shortMessage: reason,\n });\n\n this.amountInSatoshis = amountInSatoshis;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype NoUTXOsFoundErrorParams = {\n address: string;\n};\n\nexport class NoUTXOsFoundError extends BaseError {\n public readonly address: string;\n\n constructor({ address }: NoUTXOsFoundErrorParams) {\n super({\n cause: null,\n code: 'no_utxos_found_error',\n details: `Address: ${address}`,\n docsUrl: null,\n name: 'NoUTXOsFoundError',\n shortMessage: 'No UTXOs found for this address',\n });\n\n this.address = address;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class SegwitOutputScriptError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'segwit_output_script_error',\n docsUrl: null,\n name: 'SegwitOutputScriptError',\n shortMessage: 'Failed to create segwit output script',\n });\n }\n}\n","import { getBuffer } from '@dynamic-labs-sdk/client/core';\nimport type { Network, Psbt } from 'bitcoinjs-lib';\nimport { payments } from 'bitcoinjs-lib';\n\nimport { SegwitOutputScriptError } from '../../../errors/SegwitOutputScriptError';\nimport { RBF_SEQUENCE } from '../../constants';\nimport type { UTXO } from '../../WaasBitcoinWalletProvider.types';\n\ntype AddInputsToPsbtOptions = {\n network: Network;\n psbt: Psbt;\n publicKeyPair: { publicKey: Uint8Array };\n selectedUTXOs: UTXO[];\n};\n\n/**\n * Adds inputs to PSBT from selected UTXOs\n *\n * @param options.network - Bitcoin network configuration (mainnet or testnet)\n * @param options.psbt - The PSBT instance to add inputs to\n * @param options.publicKeyPair - Key pair containing the public key for witness script\n * @param options.selectedUTXOs - Array of UTXOs to add as inputs\n * @notInstrumented\n */\nexport const addInputsToPsbt = (options: AddInputsToPsbtOptions): void => {\n const { network, psbt, publicKeyPair, selectedUTXOs } = options;\n\n for (const utxo of selectedUTXOs) {\n const outputScript = payments.p2wpkh({\n network,\n pubkey: publicKeyPair.publicKey,\n }).output;\n\n if (!outputScript) {\n throw new SegwitOutputScriptError();\n }\n\n const txidBuffer = new Uint8Array(\n getBuffer().from(utxo.txid, 'hex').reverse()\n );\n\n psbt.addInput({\n hash: txidBuffer,\n index: utxo.vout,\n sequence: RBF_SEQUENCE,\n witnessUtxo: {\n script: outputScript,\n value: BigInt(utxo.value),\n },\n });\n }\n};\n","import type { Network, Psbt } from 'bitcoinjs-lib';\nimport { address } from 'bitcoinjs-lib';\n\nimport { InvalidAmountError } from '../../../errors/InvalidAmountError';\nimport { DUST_LIMIT, SATOSHIS_PER_BTC } from '../../constants';\n\ntype AddOutputsToPsbtOptions = {\n accountAddress: string;\n amountInSatoshis: number;\n changeAmount: number;\n hasChangeOutput: boolean;\n network: Network;\n psbt: Psbt;\n recipientAddress: string;\n};\n\n/**\n * Adds outputs to PSBT (recipient and optionally change)\n *\n * @param options.accountAddress - The sender's address for receiving change\n * @param options.amountInSatoshis - Amount to send to the recipient in satoshis\n * @param options.changeAmount - Amount to return as change in satoshis\n * @param options.hasChangeOutput - Whether to include a change output\n * @param options.network - Bitcoin network configuration (mainnet or testnet)\n * @param options.psbt - The PSBT instance to add outputs to\n * @param options.recipientAddress - The recipient's Bitcoin address\n * @notInstrumented\n */\nexport const addOutputsToPsbt = (options: AddOutputsToPsbtOptions): void => {\n const {\n accountAddress,\n amountInSatoshis,\n changeAmount,\n hasChangeOutput,\n network,\n psbt,\n recipientAddress,\n } = options;\n\n if (amountInSatoshis < DUST_LIMIT) {\n throw new InvalidAmountError({\n amountInSatoshis,\n reason: `Amount is below dust limit of ${DUST_LIMIT} satoshis (${DUST_LIMIT / SATOSHIS_PER_BTC} BTC)`,\n });\n }\n\n psbt.addOutput({\n script: address.toOutputScript(recipientAddress, network),\n value: BigInt(amountInSatoshis),\n });\n\n if (hasChangeOutput) {\n psbt.addOutput({\n script: address.toOutputScript(accountAddress, network),\n value: BigInt(changeAmount),\n });\n }\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype FeeRecommendationsFetchErrorParams = {\n response: Response;\n};\n\nexport class FeeRecommendationsFetchError extends BaseError {\n public readonly response: Response;\n\n constructor({ response }: FeeRecommendationsFetchErrorParams) {\n super({\n cause: null,\n code: 'fee_recommendations_fetch_error',\n details: `Status: ${response.status} ${response.statusText}`,\n docsUrl: null,\n name: 'FeeRecommendationsFetchError',\n shortMessage: 'Failed to fetch fee recommendations from mempool',\n });\n\n this.response = response;\n }\n}\n","import { MEMPOOL_API_URL } from '../../../constants';\nimport { FeeRecommendationsFetchError } from '../../../errors/FeeRecommendationsFetchError';\nimport type { FeeRecommendations } from '../../WaasBitcoinWalletProvider.types';\n\n/**\n * Gets fee recommendations from mempool.space API\n *\n * @param options.mempoolApiUrl - Base mempool API URL for the active network\n * @returns Fee recommendation data with rates in sat/vB\n * @throws FeeRecommendationsFetchError if fetching fee recommendations fails\n * @notInstrumented\n */\nexport const getFeeRecommendations = async ({\n mempoolApiUrl = MEMPOOL_API_URL,\n}: {\n mempoolApiUrl?: string;\n} = {}): Promise<FeeRecommendations> => {\n const response = await fetch(`${mempoolApiUrl}/v1/fees/recommended`);\n\n if (!response.ok) {\n throw new FeeRecommendationsFetchError({ response });\n }\n\n return response.json();\n};\n","import {\n DEFAULT_FEE_ESTIMATE,\n MIN_RELAY_FEE,\n VSIZE_INPUT_P2WPKH,\n VSIZE_OUTPUT_P2WPKH,\n VSIZE_OVERHEAD,\n} from '../../constants';\nimport type { FeePriority } from '../../WaasBitcoinWalletProvider.types';\nimport { getFeeRecommendations } from '../getFeeRecommendations';\n\ntype EstimateTransactionFeeOptions = {\n feePriority?: FeePriority;\n mempoolApiUrl?: string;\n numInputs: number;\n numOutputs: number;\n};\n\n/**\n * Estimates transaction fees based on number of inputs and outputs using accurate vSize\n *\n * @param options.feePriority - Priority level for fee estimation ('low', 'medium', or 'high')\n * @param options.numInputs - Number of transaction inputs (UTXOs being spent)\n * @param options.numOutputs - Number of transaction outputs\n * @returns Estimated fee in satoshis\n * @notInstrumented\n */\nexport const estimateTransactionFee = async ({\n feePriority = 'medium',\n mempoolApiUrl,\n numInputs,\n numOutputs,\n}: EstimateTransactionFeeOptions): Promise<number> => {\n try {\n const feeData = await getFeeRecommendations({ mempoolApiUrl });\n\n let feePerByte: number;\n\n if (feePriority === 'high') {\n feePerByte = feeData.fastestFee ?? feeData.halfHourFee ?? 1;\n } else if (feePriority === 'low') {\n feePerByte = feeData.economyFee ?? feeData.hourFee ?? 1;\n } else {\n feePerByte =\n feeData.halfHourFee ?? feeData.hourFee ?? feeData.economyFee ?? 1;\n }\n\n const vSize =\n VSIZE_OVERHEAD +\n numInputs * VSIZE_INPUT_P2WPKH +\n numOutputs * VSIZE_OUTPUT_P2WPKH;\n\n return Math.ceil(feePerByte * vSize) + MIN_RELAY_FEE;\n } catch {\n return DEFAULT_FEE_ESTIMATE;\n }\n};\n","import { DUST_LIMIT } from '../../constants';\nimport type { FeePriority, UTXO } from '../../WaasBitcoinWalletProvider.types';\nimport { estimateTransactionFee } from '../estimateTransactionFee';\n\ntype CalculateFeeAndChangeOptions = {\n amountInSatoshis: bigint;\n feePriority: FeePriority;\n mempoolApiUrl?: string;\n selectedTotalValue: number;\n selectedUTXOs: UTXO[];\n};\n\ntype CalculateFeeAndChangeResult = {\n changeAmountNumber: number;\n feeEstimate: number;\n hasChangeOutput: boolean;\n};\n\n/**\n * Calculates fee estimate and change amount, handling dust limit\n *\n * @param options.amountInSatoshis - Amount to send in satoshis\n * @param options.feePriority - Priority level for fee estimation ('low', 'medium', or 'high')\n * @param options.selectedTotalValue - Total value of selected UTXOs in satoshis\n * @param options.selectedUTXOs - Array of selected UTXOs for the transaction\n * @returns Object with feeEstimate, changeAmountNumber, and hasChangeOutput\n * @notInstrumented\n */\nexport const calculateFeeAndChange = async ({\n amountInSatoshis,\n feePriority,\n mempoolApiUrl,\n selectedTotalValue,\n selectedUTXOs,\n}: CalculateFeeAndChangeOptions): Promise<CalculateFeeAndChangeResult> => {\n let feeEstimate = await estimateTransactionFee({\n feePriority,\n mempoolApiUrl,\n numInputs: selectedUTXOs.length,\n numOutputs: 1,\n });\n\n let maxToSpend = selectedTotalValue - feeEstimate;\n let changeAmount = BigInt(maxToSpend) - amountInSatoshis;\n\n const changeAmountNumber = Number(changeAmount);\n\n if (changeAmount > 0 && changeAmountNumber >= DUST_LIMIT) {\n feeEstimate = await estimateTransactionFee({\n feePriority,\n mempoolApiUrl,\n numInputs: selectedUTXOs.length,\n numOutputs: 2,\n });\n maxToSpend = selectedTotalValue - feeEstimate;\n changeAmount = BigInt(maxToSpend) - amountInSatoshis;\n }\n\n const finalChangeAmountNumber = Number(changeAmount);\n const hasChangeOutput =\n changeAmount > 0 && finalChangeAmountNumber >= DUST_LIMIT;\n\n if (changeAmount > 0 && finalChangeAmountNumber < DUST_LIMIT) {\n feeEstimate += finalChangeAmountNumber;\n }\n\n return {\n changeAmountNumber: finalChangeAmountNumber,\n feeEstimate,\n hasChangeOutput,\n };\n};\n","import type { UTXO } from '../../WaasBitcoinWalletProvider.types';\n\n/**\n * Calculates the total value of UTXOs\n *\n * @param utxos - Array of UTXOs\n * @returns Total value in satoshis\n * @notInstrumented\n */\nexport const calculateUTXOTotal = (utxos: UTXO[]): number =>\n utxos.reduce((total: number, utxo: UTXO) => total + utxo.value, 0);\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype UTXOsFetchErrorParams = {\n address: string;\n response: Response;\n};\n\nexport class UTXOsFetchError extends BaseError {\n public readonly address: string;\n\n public readonly response: Response;\n\n constructor({ address, response }: UTXOsFetchErrorParams) {\n super({\n cause: null,\n code: 'utxos_fetch_error',\n details: `Address: ${address}, Status: ${response.status} ${response.statusText}`,\n docsUrl: null,\n name: 'UTXOsFetchError',\n shortMessage: 'Failed to fetch UTXOs from mempool',\n });\n\n this.address = address;\n\n this.response = response;\n }\n}\n","import { MEMPOOL_API_URL } from '../../../constants';\nimport { UTXOsFetchError } from '../../../errors/UTXOsFetchError';\nimport type { UTXO } from '../../WaasBitcoinWalletProvider.types';\n\n/**\n * Gets UTXOs for a Bitcoin address from mempool.space API\n *\n * @param options.address - The Bitcoin address to get UTXOs for\n * @param options.mempoolApiUrl - Base mempool API URL for the active network\n * @returns Array of UTXOs\n * @throws UTXOsFetchError if fetching UTXOs fails\n * @notInstrumented\n */\nexport const getUTXOs = async ({\n address,\n mempoolApiUrl = MEMPOOL_API_URL,\n}: {\n address: string;\n mempoolApiUrl?: string;\n}): Promise<UTXO[]> => {\n const response = await fetch(`${mempoolApiUrl}/address/${address}/utxo`);\n\n if (!response.ok) {\n throw new UTXOsFetchError({ address, response });\n }\n\n return response.json();\n};\n","import type { UTXO } from '../../WaasBitcoinWalletProvider.types';\n\ntype SelectUTXOsLargestFirstOptions = {\n targetAmount: number;\n utxos: UTXO[];\n};\n\n/**\n * Selects UTXOs using Largest-First (Accumulator) strategy\n * Sorts UTXOs by value (descending) and selects until we have enough to cover amount + fees\n *\n * @param options.targetAmount - Target amount in satoshis (amount + fees + dust limit)\n * @param options.utxos - Array of available UTXOs to select from\n * @returns Selected UTXOs\n * @notInstrumented\n */\nexport const selectUTXOsLargestFirst = (\n options: SelectUTXOsLargestFirstOptions\n) => {\n const { targetAmount, utxos } = options;\n\n const sortedUTXOs = [...utxos].sort((a, b) => b.value - a.value);\n\n const selected: UTXO[] = [];\n let total = 0;\n\n for (const utxo of sortedUTXOs) {\n selected.push(utxo);\n total += utxo.value;\n\n if (total >= targetAmount) {\n break;\n }\n }\n\n return selected;\n};\n","import { InsufficientFundsError } from '../../../errors/InsufficientFundsError';\nimport type { UTXO } from '../../WaasBitcoinWalletProvider.types';\nimport { calculateUTXOTotal } from '../calculateUTXOTotal';\n\ntype ValidateAndSelectUTXOsOptions = {\n allUTXOs: UTXO[];\n amountInSatoshis: number;\n feeEstimate: number;\n selectedTotal: number;\n selectedUTXOs: UTXO[];\n};\n\n/**\n * Validates and ensures sufficient funds for the transaction\n *\n * @param options.allUTXOs - Complete array of available UTXOs for the address\n * @param options.amountInSatoshis - Amount to send in satoshis\n * @param options.feeEstimate - Estimated transaction fee in satoshis\n * @param options.selectedTotal - Total value of initially selected UTXOs in satoshis\n * @param options.selectedUTXOs - Array of initially selected UTXOs\n * @returns Validated selected UTXOs\n * @throws InsufficientFundsError if insufficient funds\n * @notInstrumented\n */\nexport const validateAndSelectUTXOs = (\n options: ValidateAndSelectUTXOsOptions\n) => {\n const {\n allUTXOs,\n amountInSatoshis,\n feeEstimate,\n selectedTotal,\n selectedUTXOs,\n } = options;\n\n const requiredAmount = amountInSatoshis + feeEstimate;\n\n if (selectedTotal >= requiredAmount) {\n return selectedUTXOs;\n }\n\n if (selectedUTXOs.length < allUTXOs.length) {\n const allTotal = calculateUTXOTotal(allUTXOs);\n\n if (allTotal < requiredAmount) {\n throw new InsufficientFundsError({\n availableSatoshis: allTotal,\n requiredSatoshis: amountInSatoshis,\n });\n }\n\n return allUTXOs;\n }\n\n throw new InsufficientFundsError({\n availableSatoshis: selectedTotal,\n requiredSatoshis: amountInSatoshis,\n });\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class TaprootAddressNotSupportedError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'taproot_address_not_supported',\n docsUrl: null,\n name: 'TaprootAddressNotSupportedError',\n shortMessage:\n 'Taproot addresses are not supported for PSBT building. Only Native SegWit (P2WPKH) addresses are allowed.',\n });\n }\n}\n","import { TaprootAddressNotSupportedError } from '../../../errors/TaprootAddressNotSupportedError';\n\n/**\n * Validates that the address is not a Taproot address\n * Only Native SegWit (P2WPKH) is supported for PSBT building\n *\n * @param accountAddress - The account address to check\n * @throws TaprootAddressNotSupportedError if address is Taproot\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const validateNotTaproot = (accountAddress: string): void => {\n if (\n accountAddress.toLowerCase().startsWith('bc1p') ||\n accountAddress.toLowerCase().startsWith('tb1p')\n ) {\n throw new TaprootAddressNotSupportedError();\n }\n};\n","import ecc from '@bitcoinerlab/secp256k1';\nimport { getBuffer } from '@dynamic-labs-sdk/client/core';\nimport type { Network } from 'bitcoinjs-lib';\nimport { Psbt } from 'bitcoinjs-lib';\nimport { ECPairFactory } from 'ecpair';\n\nimport { InsufficientFundsError } from '../../../errors/InsufficientFundsError';\nimport { InvalidAmountError } from '../../../errors/InvalidAmountError';\nimport { NoUTXOsFoundError } from '../../../errors/NoUTXOsFoundError';\nimport { DUST_LIMIT } from '../../constants';\nimport type { FeePriority } from '../../WaasBitcoinWalletProvider.types';\nimport { addInputsToPsbt } from '../addInputsToPsbt';\nimport { addOutputsToPsbt } from '../addOutputsToPsbt';\nimport { calculateFeeAndChange } from '../calculateFeeAndChange';\nimport { calculateUTXOTotal } from '../calculateUTXOTotal';\nimport { estimateTransactionFee } from '../estimateTransactionFee';\nimport { getUTXOs } from '../getUTXOs';\nimport { selectUTXOsLargestFirst } from '../selectUTXOsLargestFirst';\nimport { validateAndSelectUTXOs } from '../validateAndSelectUTXOs';\nimport { validateNotTaproot } from '../validateNotTaproot';\n\ntype BuildPsbtOptions = {\n accountAddress: string;\n amountInSatoshis: bigint;\n feePriority?: FeePriority;\n mempoolApiUrl?: string;\n network: Network;\n publicKeyHex: string;\n recipientAddress: string;\n};\n\n/**\n * Builds a PSBT for a Bitcoin transaction with real UTXOs\n * Uses Largest-First UTXO selection strategy with accurate vSize fee estimation\n *\n * @param options.accountAddress - The sender's Bitcoin address\n * @param options.amountInSatoshis - Amount to send in satoshis\n * @param options.feePriority - Priority level for fee estimation ('low', 'medium', or 'high')\n * @param options.network - Bitcoin network configuration (mainnet or testnet)\n * @param options.publicKeyHex - The sender's public key in hexadecimal format\n * @param options.recipientAddress - The recipient's Bitcoin address\n * @returns A PSBT in Base64 format\n * @throws Error if insufficient funds, no UTXOs, or other errors\n * @notInstrumented\n */\nexport const buildPsbt = async ({\n accountAddress,\n amountInSatoshis,\n feePriority = 'medium',\n mempoolApiUrl,\n network,\n publicKeyHex,\n recipientAddress,\n}: BuildPsbtOptions): Promise<string> => {\n if (amountInSatoshis <= BigInt(0)) {\n throw new InvalidAmountError({\n amountInSatoshis: Number(amountInSatoshis),\n reason: 'Amount must be greater than 0',\n });\n }\n\n validateNotTaproot(accountAddress);\n\n const allUTXOs = await getUTXOs({ address: accountAddress, mempoolApiUrl });\n\n if (allUTXOs.length === 0) {\n throw new NoUTXOsFoundError({ address: accountAddress });\n }\n\n const publicKeyBuffer = new Uint8Array(getBuffer().from(publicKeyHex, 'hex'));\n const ECPair = ECPairFactory(ecc);\n\n // @ts-expect-error - ecpair types are incompatible with valibot >=1.2.0\n // The options are actually optional at runtime, but TypeScript infers them as required\n const publicKeyPair = ECPair.fromPublicKey(publicKeyBuffer, {\n compressed: true,\n });\n\n const amountInSatoshisNumber = Number(amountInSatoshis);\n\n const initialFeeEstimate = await estimateTransactionFee({\n feePriority,\n mempoolApiUrl,\n numInputs: 1,\n numOutputs: 1,\n });\n\n const targetAmount = amountInSatoshisNumber + initialFeeEstimate + DUST_LIMIT;\n\n let selectedUTXOs = selectUTXOsLargestFirst({\n targetAmount,\n utxos: allUTXOs,\n });\n const selectedTotal = calculateUTXOTotal(selectedUTXOs);\n\n selectedUTXOs = validateAndSelectUTXOs({\n allUTXOs,\n amountInSatoshis: amountInSatoshisNumber,\n feeEstimate: initialFeeEstimate,\n selectedTotal,\n selectedUTXOs,\n });\n\n const selectedTotalValue = calculateUTXOTotal(selectedUTXOs);\n\n const { changeAmountNumber, feeEstimate, hasChangeOutput } =\n await calculateFeeAndChange({\n amountInSatoshis,\n feePriority,\n mempoolApiUrl,\n selectedTotalValue,\n selectedUTXOs,\n });\n\n const maxToSpend = selectedTotalValue - feeEstimate;\n\n if (maxToSpend < amountInSatoshisNumber) {\n throw new InsufficientFundsError({\n availableSatoshis: maxToSpend,\n requiredSatoshis: amountInSatoshisNumber,\n });\n }\n\n const psbt = new Psbt({ network });\n\n addInputsToPsbt({\n network,\n psbt,\n publicKeyPair,\n selectedUTXOs,\n });\n\n addOutputsToPsbt({\n accountAddress,\n amountInSatoshis: amountInSatoshisNumber,\n changeAmount: changeAmountNumber,\n hasChangeOutput,\n network,\n psbt,\n recipientAddress,\n });\n\n return psbt.toBase64();\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class UnsupportedBitcoinNetworkError extends BaseError {\n // eslint-disable-next-line custom-rules/require-single-object-param\n constructor(networkId: string) {\n super({\n cause: null,\n code: 'unsupported_bitcoin_network_error',\n docsUrl: null,\n name: 'UnsupportedBitcoinNetworkError',\n shortMessage: `Unsupported Bitcoin network id: ${networkId}`,\n });\n }\n}\n","import type { Network } from 'bitcoinjs-lib';\nimport { networks } from 'bitcoinjs-lib';\n\nimport {\n MEMPOOL_API_URL,\n MEMPOOL_API_URL_SIGNET,\n MEMPOOL_API_URL_TESTNET,\n} from '../../../constants';\nimport { UnsupportedBitcoinNetworkError } from '../../../errors/UnsupportedBitcoinNetworkError';\n\nexport type ActiveBitcoinNetworkConfig = {\n /** WaaS signing network for `bitcoinConfig.network`. */\n bitcoinNetwork: 'mainnet' | 'testnet';\n /** Base mempool.space API URL for the network. */\n mempoolApiUrl: string;\n networkId: string;\n /** bitcoinjs-lib network for PSBT encoding. */\n psbtNetwork: Network;\n};\n\n/**\n * Resolves a Dynamic Bitcoin network id (1 mainnet, 2 testnet, 3 signet) to\n * the per-network configuration used by the WaaS provider. An undefined id\n * (network never switched) resolves to mainnet.\n *\n * @throws {UnsupportedBitcoinNetworkError} for any other network id\n * @notInstrumented\n */\nexport const getActiveBitcoinNetworkConfig = ({\n networkId,\n}: {\n networkId: string | undefined;\n}): ActiveBitcoinNetworkConfig => {\n const id = networkId ?? '1';\n\n switch (id) {\n case '1':\n return {\n bitcoinNetwork: 'mainnet',\n mempoolApiUrl: MEMPOOL_API_URL,\n networkId: id,\n psbtNetwork: networks.bitcoin,\n };\n case '2':\n return {\n bitcoinNetwork: 'testnet',\n mempoolApiUrl: MEMPOOL_API_URL_TESTNET,\n networkId: id,\n psbtNetwork: networks.testnet,\n };\n case '3':\n return {\n bitcoinNetwork: 'testnet',\n mempoolApiUrl: MEMPOOL_API_URL_SIGNET,\n networkId: id,\n psbtNetwork: networks.testnet,\n };\n default:\n throw new UnsupportedBitcoinNetworkError(id);\n }\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class PublicKeyNotFoundError extends BaseError {\n // eslint-disable-next-line custom-rules/require-single-object-param\n constructor(address: string) {\n super({\n cause: null,\n code: 'public_key_not_found_error',\n docsUrl: null,\n name: 'PublicKeyNotFoundError',\n shortMessage: `No public key found for address ${address}`,\n });\n }\n}\n\n","import type { DynamicClient, WalletAccount } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\nimport { PublicKeyNotFoundError } from '../../../errors/PublicKeyNotFoundError';\n\n/**\n * Gets the public key for a wallet account from the user's verified credentials\n * @notInstrumented\n */\nexport const getPublicKeyForWalletAccount = (\n walletAccount: WalletAccount,\n client: DynamicClient\n): string => {\n const user = getCore(client).state.get().user;\n\n for (const credential of user?.verifiedCredentials ?? []) {\n const additionalAddress = credential.walletAdditionalAddresses?.find(\n (addr) => addr.address === walletAccount.address\n );\n\n if (additionalAddress?.publicKey) {\n return additionalAddress.publicKey;\n }\n }\n\n throw new PublicKeyNotFoundError(walletAccount.address);\n};\n","import type { BitcoinSignPsbtRequest } from '../../../BitcoinWalletProvider.types';\n\nexport type GetWaasAllowedSighashParams = {\n /** The PSBT signing request, whose `allowedSighash` restricts permitted types. */\n request: BitcoinSignPsbtRequest;\n};\n\n/**\n * Translates the request's `allowedSighash` into the value the WaaS client takes.\n *\n * The two sides disagree on what an empty array means, and forwarding it\n * verbatim would break every embedded send:\n *\n * - Here, `allowedSighash` is required, so `[]` is how callers say \"no\n * restriction\" — `sendBitcoin` passes exactly that for its own PSBTs.\n * - In the WaaS client, `[]` means \"permit nothing\" and rejects every input,\n * while `undefined` means \"permit any type the PSBT declares\".\n *\n * So an empty list maps to `undefined`, preserving today's behaviour, and a\n * populated list is passed through to restrict signing.\n *\n * @notInstrumented\n */\nexport const getWaasAllowedSighash = ({\n request,\n}: GetWaasAllowedSighashParams): number[] | undefined =>\n request.allowedSighash?.length ? request.allowedSighash : undefined;\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\nimport { WalletAddressType } from '@dynamic-labs/sdk-api-core';\n\n/**\n * Resolves the wallet's payment address for the given Bitcoin network. One\n * WaaS wallet (one MPC key) exposes a per-network payment address via its\n * network-tagged additional addresses. Falls back to the wallet account's\n * primary address (the mainnet encoding) for legacy wallets without tagged\n * rows.\n *\n * The wallet identity (keyshare/password lookups, signing) is always the\n * primary address — this resolver is only for address-driven operations\n * (UTXOs, balance, broadcast source).\n *\n * @notInstrumented\n */\nexport const getWaasBitcoinAddressForNetwork = ({\n bitcoinNetwork,\n walletAccount,\n}: {\n bitcoinNetwork: 'mainnet' | 'testnet';\n walletAccount: WalletAccount;\n}): string => {\n const taggedAddress = walletAccount.addressesWithTypes?.find(\n (address) =>\n address.type === WalletAddressType.Payment &&\n address.network === bitcoinNetwork\n )?.address;\n\n return taggedAddress ?? walletAccount.address;\n};\n","import type { BitcoinSignPsbtRequest } from '../../../BitcoinWalletProvider.types';\nimport { InvalidPsbtError } from '../../../errors/InvalidPsbtError';\n\nexport type GetWaasSigningIndexesParams = {\n /** The PSBT signing request, whose `signature` entries scope inputs per address. */\n request: BitcoinSignPsbtRequest;\n\n /**\n * Every encoding of the signing wallet's own address. One key produces a\n * different address per network, and callers name the one they built the\n * PSBT with — on testnet that is the `tb1…` encoding, not the primary\n * (mainnet) address the wallet is identified by.\n */\n walletAddresses: string[];\n};\n\n/**\n * Flattens the request's per-address `signature[].signingIndexes` into the flat\n * index array the WaaS client takes, keeping only the entries that name this\n * wallet.\n *\n * Returns `undefined` when the caller scoped nothing, which leaves the existing\n * behaviour intact: the WaaS client signs every input the wallet owns.\n *\n * Throws when the caller scoped indexes but none of them are for this wallet.\n * Returning `undefined` there would widen the request into \"sign everything I\n * own\" — the opposite of what a caller narrowing a PSBT is asking for.\n *\n * @notInstrumented\n */\nexport const getWaasSigningIndexes = ({\n request,\n walletAddresses,\n}: GetWaasSigningIndexesParams): number[] | undefined => {\n const scopedEntries =\n request.signature?.filter((entry) => entry.signingIndexes?.length) ?? [];\n\n if (!scopedEntries.length) {\n return undefined;\n }\n\n // Bitcoin addresses are case-sensitive encodings, so an exact match is the\n // correct comparison here (`normalizeAddress` is a no-op for BIP122).\n const ownAddresses = new Set(walletAddresses.filter(Boolean));\n const indexes = scopedEntries\n .filter((entry) => ownAddresses.has(entry.address))\n .flatMap((entry) => entry.signingIndexes ?? []);\n\n if (!indexes.length) {\n throw new InvalidPsbtError(\n 'signingIndexes were provided, but none of them are for this wallet'\n );\n }\n\n return [...new Set(indexes)].sort((a, b) => a - b);\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n consumeMfaTokenIfRequiredForAction,\n formatWalletProviderGroupKey,\n formatWalletProviderKey,\n getActiveNetworkIdFromLastKnownRegistry,\n getSignedSessionId,\n switchActiveNetworkInLastKnownRegistry,\n} from '@dynamic-labs-sdk/client/core';\nimport type { BitcoinNetwork } from '@dynamic-labs-sdk/client/waas/core';\nimport {\n DYNAMIC_WAAS_METADATA,\n createWaasProvider,\n getAllUserWaasAddressesForChain,\n} from '@dynamic-labs-sdk/client/waas/core';\nimport { MFAAction, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\nimport { Psbt } from 'bitcoinjs-lib';\n\nimport type { BitcoinSendTransactionResponse } from '../../../BitcoinWalletProvider.types';\nimport { bitcoinExecuteSwapTransaction } from '../../../utils/bitcoinExecuteSwapTransaction';\nimport { bitcoinTransferAmount } from '../../../utils/bitcoinTransferAmount';\nimport type {\n WaasBitcoinTransaction,\n WaasBitcoinWalletProvider,\n} from '../../WaasBitcoinWalletProvider.types';\nimport { broadcastTransaction } from '../broadcastTransaction';\nimport { buildPsbt as buildPsbtUtil } from '../buildPsbt';\nimport { getActiveBitcoinNetworkConfig } from '../getActiveBitcoinNetworkConfig';\nimport { getPublicKeyForWalletAccount } from '../getPublicKeyForWalletAccount/getPublicKeyForWalletAccount';\nimport { getWaasAllowedSighash } from '../getWaasAllowedSighash';\nimport { getWaasBitcoinAddressForNetwork } from '../getWaasBitcoinAddressForNetwork';\nimport { getWaasSigningIndexes } from '../getWaasSigningIndexes';\n\n/** @notInstrumented */\nexport const createWalletProviderForWaasBitcoin = (\n sdkClient: DynamicClient\n): WaasBitcoinWalletProvider => {\n const chain = 'BTC' as const;\n\n const walletProviderType = WalletProviderEnum.EmbeddedWallet;\n\n const key = formatWalletProviderKey({\n chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType,\n });\n\n const waasProvider = createWaasProvider({ chain, sdkClient });\n\n const getActiveNetworkId: WaasBitcoinWalletProvider['getActiveNetworkId'] =\n async () =>\n getActiveNetworkIdFromLastKnownRegistry({\n client: sdkClient,\n walletProviderKey: key,\n });\n\n const switchActiveNetwork: WaasBitcoinWalletProvider['switchActiveNetwork'] =\n async ({ networkId }) => {\n // Validates the id before persisting it — an unsupported network must\n // fail the switch rather than silently degrade to mainnet later.\n getActiveBitcoinNetworkConfig({ networkId });\n\n return switchActiveNetworkInLastKnownRegistry({\n client: sdkClient,\n networkId,\n walletProviderKey: key,\n });\n };\n\n const getActiveNetworkConfig = async () => {\n const { networkId } = await getActiveNetworkId();\n\n return getActiveBitcoinNetworkConfig({ networkId });\n };\n\n const getConnectedAddresses: WaasBitcoinWalletProvider['getConnectedAddresses'] =\n async () => {\n const waasBitcoinAddresses = getAllUserWaasAddressesForChain(\n { chain },\n sdkClient\n );\n\n return {\n addresses: waasBitcoinAddresses,\n };\n };\n\n const signPsbt: WaasBitcoinWalletProvider['signPsbt'] = async ({\n request,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n // Resolved before any irreversible side effect: this rejects a request\n // whose indexes are scoped to another address, and consuming the one-time\n // MFA token first would make the user redo MFA for a request that was\n // never sent.\n const signingIndexes = getWaasSigningIndexes({\n request,\n walletAddresses: [\n walletAccount.address,\n ...(walletAccount.addressesWithTypes ?? []).map(\n ({ address }) => address\n ),\n ],\n });\n\n const allowedSighash = getWaasAllowedSighash({ request });\n\n const waasClient = await waasProvider.getWaasClient();\n\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const signedPsbt = await waasClient.signTransaction({\n allowedSighash,\n authToken: sdkClient.token ?? undefined,\n mfaToken,\n senderAddress: walletAccount.address,\n signedSessionId,\n signingIndexes,\n transaction: request.unsignedPsbtBase64,\n });\n\n return { signedPsbt };\n };\n\n const signPsbts: WaasBitcoinWalletProvider['signPsbts'] = async ({\n requests,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n const signedPsbts = await Promise.all(\n requests.map(async (request) => {\n const { signedPsbt } = await signPsbt({ request, walletAccount });\n\n return signedPsbt;\n })\n );\n\n return { signedPsbts };\n };\n\n const signMessage: WaasBitcoinWalletProvider['signMessage'] = async ({\n message,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n const waasClient = await waasProvider.getWaasClient();\n\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const { bitcoinNetwork } = await getActiveNetworkConfig();\n\n const signature = await waasClient.signMessage({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n bitcoinConfig: {\n network: bitcoinNetwork as BitcoinNetwork,\n },\n message,\n mfaToken,\n signedSessionId,\n });\n\n return { signature };\n };\n\n const buildPsbt: WaasBitcoinWalletProvider['buildPsbt'] = async ({\n transaction,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n const publicKeyHex = getPublicKeyForWalletAccount(walletAccount, sdkClient);\n\n const { bitcoinNetwork, mempoolApiUrl, psbtNetwork } =\n await getActiveNetworkConfig();\n\n return buildPsbtUtil({\n // UTXO source and change output use the active network's payment\n // address; signing identity stays the wallet account's primary address.\n accountAddress: getWaasBitcoinAddressForNetwork({\n bitcoinNetwork,\n walletAccount,\n }),\n amountInSatoshis: transaction.amount,\n feePriority: transaction.feePriority ?? 'medium',\n mempoolApiUrl,\n network: psbtNetwork,\n publicKeyHex,\n recipientAddress: transaction.recipientAddress,\n });\n };\n\n const sendBitcoin: WaasBitcoinWalletProvider['sendBitcoin'] = async ({\n transaction,\n walletAccount,\n }): Promise<BitcoinSendTransactionResponse> => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n const waasTransaction: WaasBitcoinTransaction = {\n amount: transaction.amount,\n recipientAddress: transaction.recipientAddress,\n };\n\n const unsignedPsbt = await buildPsbt({\n transaction: waasTransaction,\n walletAccount,\n });\n\n const { signedPsbt } = await signPsbt({\n request: { allowedSighash: [], unsignedPsbtBase64: unsignedPsbt },\n walletAccount,\n });\n\n const { mempoolApiUrl, psbtNetwork } = await getActiveNetworkConfig();\n\n const psbt = Psbt.fromBase64(signedPsbt, { network: psbtNetwork });\n\n psbt.finalizeAllInputs();\n\n const rawTx = psbt.extractTransaction().toHex();\n\n const transactionId = await broadcastTransaction({\n mempoolApiUrl,\n rawTransaction: rawTx,\n });\n\n return { transactionId };\n };\n\n return {\n ...waasProvider,\n buildPsbt,\n chain,\n executeSwapTransaction: (args) =>\n bitcoinExecuteSwapTransaction(args, sdkClient),\n getActiveNetworkId,\n getConnectedAddresses,\n groupKey: formatWalletProviderGroupKey(DYNAMIC_WAAS_METADATA.displayName),\n key,\n metadata: {\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n icon: DYNAMIC_WAAS_METADATA.icon,\n },\n sendBitcoin,\n signMessage,\n signPsbt,\n signPsbts,\n switchActiveNetwork,\n transferAmount: (args) => bitcoinTransferAmount(args, sdkClient),\n walletProviderType,\n };\n};\n","import {\n WalletProviderPriority,\n getDefaultClient,\n getWalletProviderRegistry,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { registerBitcoinNetworkProviderBuilder } from '../../registerBitcoinNetworkProviderBuilder';\nimport { createWalletProviderForWaasBitcoin } from '../utils/createWalletProviderForWaasBitcoin';\n\nexport const WAAS_BITCOIN_EXTENSION_KEY = 'waasBitcoin';\n\n/**\n * Adds the Dynamic WaaS (Wallet as a Service) Bitcoin extension to the Dynamic client.\n *\n * This extension enables embedded wallet functionality for Bitcoin blockchain,\n * allowing users to have wallets managed by Dynamic's infrastructure.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @notInstrumented\n */\nexport const addWaasBitcoinExtension = (client = getDefaultClient()): void => {\n if (hasExtension({ extensionKey: WAAS_BITCOIN_EXTENSION_KEY }, client)) {\n return;\n }\n\n registerExtension({ extensionKey: WAAS_BITCOIN_EXTENSION_KEY }, client);\n registerBitcoinNetworkProviderBuilder(client);\n\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = createWalletProviderForWaasBitcoin(client);\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n};\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAa,kCAAb,cAAqDA,mCAAU;CAC7D,AAAgB;CAEhB,YAAY,EAAE,YAAmD;AAC/D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS,WAAW,SAAS,OAAO,GAAG,SAAS;GAChD,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;AAEF,OAAK,WAAW;;;;;;ACjBpB,IAAa,2BAAb,cAA8CC,mCAAU;CACtD,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;;;;;;;;;;;;;;;;ACIN,MAAa,uBAAuB,OAAO,EACzC,gBAAgBC,0CAChB,qBAIqB;AACrB,KAAI,CAAC,eACH,OAAM,IAAI,0BAA0B;CAGtC,MAAM,WAAW,MAAM,MAAM,GAAG,cAAc,MAAM;EAClD,MAAM;EACN,SAAS,EACP,gBAAgB,qCACjB;EACD,QAAQ;EACT,CAAC;AAEF,KAAI,CAAC,SAAS,GACZ,OAAM,IAAI,gCAAgC,EAAE,UAAU,CAAC;AAGzD,QAAO,SAAS,MAAM;;;;;;;;AClCxB,MAAa,mBAAmB;;;;;AAMhC,MAAa,aAAa;;;;;AAM1B,MAAa,iBAAiB;AAE9B,MAAa,qBAAqB;AAElC,MAAa,sBAAsB;;;;;AAMnC,MAAa,gBAAgB;;;;;AAM7B,MAAa,uBAAuB;;;;;AAMpC,MAAa,eAAe;;;;AC5B5B,IAAa,yBAAb,cAA4CC,mCAAU;CACpD,AAAgB;CAEhB,AAAgB;CAEhB,YAAY,EAAE,mBAAmB,oBAAkD;EACjF,MAAM,eAAe,oBAAoB;EACzC,MAAM,cAAc,mBAA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AAe,MAAM,SAAS;GACpC,SAAS;IAAE,gBAAgB,EAAE;IAAE,oBANZ,MAAMC,YAAU;KACnC,aAN8C;MAC9C,QAAQ,YAAY;MACpB,kBAAkB,YAAY;MAC/B;KAIC;KACD,CAAC;IAGiE;GACjE;GACD,CAAC;EAEF,MAAM,EAAE,eAAe,gBAAgB,MAAM,wBAAwB;EAErE,MAAM,OAAOC,mBAAK,WAAW,YAAY,EAAE,SAAS,aAAa,CAAC;AAElE,OAAK,mBAAmB;AASxB,SAAO,EAAE,eALa,MAAM,qBAAqB;GAC/C;GACA,gBAJY,KAAK,oBAAoB,CAAC,OAAO;GAK9C,CAAC,EAEsB;;AAG1B,QAAO;EACL,GAAG;EACH;EACA;EACA,yBAAyB,SACvBC,uDAA8B,MAAM,UAAU;EAChD;EACA;EACA,0EAAuCd,yDAAsB,YAAY;EACzE;EACA,UAAU;GACR,aAAaA,yDAAsB;GACnC,MAAMA,yDAAsB;GAC7B;EACD;EACA;EACA;EACA;EACA;EACA,iBAAiB,SAASe,+CAAsB,MAAM,UAAU;EAChE;EACD;;;;;AC9PH,MAAa,6BAA6B;;;;;;;;;;AAW1C,MAAa,2BAA2B,8DAA2B,KAAW;AAC5E,qDAAiB,EAAE,cAAc,4BAA4B,EAAE,OAAO,CACpE;AAGF,sDAAkB,EAAE,cAAc,4BAA4B,EAAE,OAAO;AACvE,gEAAsC,OAAO;CAE7C,MAAM,sFAAmD,OAAO;CAEhE,MAAM,iBAAiB,mCAAmC,OAAO;AAEjE,wBAAuB,SAAS;EAC9B,UAAUC,qDAAuB;EACjC;EACD,CAAC"}
|
package/dist/{addWaasBitcoinExtension-IrLvQh8F.esm.js → addWaasBitcoinExtension-B_rWSexg.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as bitcoinExecuteSwapTransaction, d as MEMPOOL_API_URL, f as MEMPOOL_API_URL_SIGNET, l as registerBitcoinNetworkProviderBuilder, n as bitcoinTransferAmount, p as MEMPOOL_API_URL_TESTNET, t as InvalidPsbtError } from "./InvalidPsbtError-nAb75Fvm.esm.js";
|
|
2
2
|
import { WalletProviderPriority, assertDefined, consumeMfaTokenIfRequiredForAction, formatWalletProviderGroupKey, formatWalletProviderKey, getActiveNetworkIdFromLastKnownRegistry, getBuffer, getCore, getDefaultClient, getSignedSessionId, getWalletProviderRegistry, hasExtension, registerExtension, switchActiveNetworkInLastKnownRegistry } from "@dynamic-labs-sdk/client/core";
|
|
3
3
|
import { BaseError } from "@dynamic-labs-sdk/client";
|
|
4
4
|
import { MFAAction, WalletAddressType, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
@@ -615,6 +615,26 @@ const getPublicKeyForWalletAccount = (walletAccount, client) => {
|
|
|
615
615
|
throw new PublicKeyNotFoundError(walletAccount.address);
|
|
616
616
|
};
|
|
617
617
|
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region src/waas/utils/getWaasAllowedSighash/getWaasAllowedSighash.ts
|
|
620
|
+
/**
|
|
621
|
+
* Translates the request's `allowedSighash` into the value the WaaS client takes.
|
|
622
|
+
*
|
|
623
|
+
* The two sides disagree on what an empty array means, and forwarding it
|
|
624
|
+
* verbatim would break every embedded send:
|
|
625
|
+
*
|
|
626
|
+
* - Here, `allowedSighash` is required, so `[]` is how callers say "no
|
|
627
|
+
* restriction" — `sendBitcoin` passes exactly that for its own PSBTs.
|
|
628
|
+
* - In the WaaS client, `[]` means "permit nothing" and rejects every input,
|
|
629
|
+
* while `undefined` means "permit any type the PSBT declares".
|
|
630
|
+
*
|
|
631
|
+
* So an empty list maps to `undefined`, preserving today's behaviour, and a
|
|
632
|
+
* populated list is passed through to restrict signing.
|
|
633
|
+
*
|
|
634
|
+
* @notInstrumented
|
|
635
|
+
*/
|
|
636
|
+
const getWaasAllowedSighash = ({ request }) => request.allowedSighash?.length ? request.allowedSighash : void 0;
|
|
637
|
+
|
|
618
638
|
//#endregion
|
|
619
639
|
//#region src/waas/utils/getWaasBitcoinAddressForNetwork/getWaasBitcoinAddressForNetwork.ts
|
|
620
640
|
/**
|
|
@@ -634,6 +654,31 @@ const getWaasBitcoinAddressForNetwork = ({ bitcoinNetwork, walletAccount }) => {
|
|
|
634
654
|
return walletAccount.addressesWithTypes?.find((address$1) => address$1.type === WalletAddressType.Payment && address$1.network === bitcoinNetwork)?.address ?? walletAccount.address;
|
|
635
655
|
};
|
|
636
656
|
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region src/waas/utils/getWaasSigningIndexes/getWaasSigningIndexes.ts
|
|
659
|
+
/**
|
|
660
|
+
* Flattens the request's per-address `signature[].signingIndexes` into the flat
|
|
661
|
+
* index array the WaaS client takes, keeping only the entries that name this
|
|
662
|
+
* wallet.
|
|
663
|
+
*
|
|
664
|
+
* Returns `undefined` when the caller scoped nothing, which leaves the existing
|
|
665
|
+
* behaviour intact: the WaaS client signs every input the wallet owns.
|
|
666
|
+
*
|
|
667
|
+
* Throws when the caller scoped indexes but none of them are for this wallet.
|
|
668
|
+
* Returning `undefined` there would widen the request into "sign everything I
|
|
669
|
+
* own" — the opposite of what a caller narrowing a PSBT is asking for.
|
|
670
|
+
*
|
|
671
|
+
* @notInstrumented
|
|
672
|
+
*/
|
|
673
|
+
const getWaasSigningIndexes = ({ request, walletAddresses }) => {
|
|
674
|
+
const scopedEntries = request.signature?.filter((entry) => entry.signingIndexes?.length) ?? [];
|
|
675
|
+
if (!scopedEntries.length) return;
|
|
676
|
+
const ownAddresses = new Set(walletAddresses.filter(Boolean));
|
|
677
|
+
const indexes = scopedEntries.filter((entry) => ownAddresses.has(entry.address)).flatMap((entry) => entry.signingIndexes ?? []);
|
|
678
|
+
if (!indexes.length) throw new InvalidPsbtError("signingIndexes were provided, but none of them are for this wallet");
|
|
679
|
+
return [...new Set(indexes)].sort((a, b) => a - b);
|
|
680
|
+
};
|
|
681
|
+
|
|
637
682
|
//#endregion
|
|
638
683
|
//#region src/waas/utils/createWalletProviderForWaasBitcoin/createWalletProviderForWaasBitcoin.ts
|
|
639
684
|
/** @notInstrumented */
|
|
@@ -670,14 +715,21 @@ const createWalletProviderForWaasBitcoin = (sdkClient) => {
|
|
|
670
715
|
};
|
|
671
716
|
const signPsbt = async ({ request, walletAccount }) => {
|
|
672
717
|
assertDefined(walletAccount, "Wallet account is required");
|
|
718
|
+
const signingIndexes = getWaasSigningIndexes({
|
|
719
|
+
request,
|
|
720
|
+
walletAddresses: [walletAccount.address, ...(walletAccount.addressesWithTypes ?? []).map(({ address: address$1 }) => address$1)]
|
|
721
|
+
});
|
|
722
|
+
const allowedSighash = getWaasAllowedSighash({ request });
|
|
673
723
|
const waasClient = await waasProvider.getWaasClient();
|
|
674
724
|
const { signature: signedSessionId } = await getSignedSessionId(sdkClient);
|
|
675
725
|
const mfaToken = await consumeMfaTokenIfRequiredForAction({ mfaAction: MFAAction.WalletWaasSign }, sdkClient);
|
|
676
726
|
return { signedPsbt: await waasClient.signTransaction({
|
|
727
|
+
allowedSighash,
|
|
677
728
|
authToken: sdkClient.token ?? void 0,
|
|
678
729
|
mfaToken,
|
|
679
730
|
senderAddress: walletAccount.address,
|
|
680
731
|
signedSessionId,
|
|
732
|
+
signingIndexes,
|
|
681
733
|
transaction: request.unsignedPsbtBase64
|
|
682
734
|
}) };
|
|
683
735
|
};
|
|
@@ -795,4 +847,4 @@ const addWaasBitcoinExtension = (client = getDefaultClient()) => {
|
|
|
795
847
|
|
|
796
848
|
//#endregion
|
|
797
849
|
export { TransactionBroadcastFailedError as a, TransactionRequiredError as i, getWaasBitcoinAddressForNetwork as n, getActiveBitcoinNetworkConfig as r, addWaasBitcoinExtension as t };
|
|
798
|
-
//# sourceMappingURL=addWaasBitcoinExtension-
|
|
850
|
+
//# sourceMappingURL=addWaasBitcoinExtension-B_rWSexg.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addWaasBitcoinExtension-B_rWSexg.esm.js","names":["address","feePerByte: number","address","address","selected: UTXO[]","address","address","getActiveNetworkId: WaasBitcoinWalletProvider['getActiveNetworkId']","switchActiveNetwork: WaasBitcoinWalletProvider['switchActiveNetwork']","getConnectedAddresses: WaasBitcoinWalletProvider['getConnectedAddresses']","signPsbt: WaasBitcoinWalletProvider['signPsbt']","address","signPsbts: WaasBitcoinWalletProvider['signPsbts']","signMessage: WaasBitcoinWalletProvider['signMessage']","buildPsbt: WaasBitcoinWalletProvider['buildPsbt']","buildPsbtUtil","sendBitcoin: WaasBitcoinWalletProvider['sendBitcoin']","buildPsbt"],"sources":["../src/errors/TransactionBroadcastFailedError.ts","../src/errors/TransactionRequiredError.ts","../src/waas/utils/broadcastTransaction/broadcastTransaction.ts","../src/waas/constants.ts","../src/errors/InsufficientFundsError.ts","../src/errors/InvalidAmountError.ts","../src/errors/NoUTXOsFoundError.ts","../src/errors/SegwitOutputScriptError.ts","../src/waas/utils/addInputsToPsbt/addInputsToPsbt.ts","../src/waas/utils/addOutputsToPsbt/addOutputsToPsbt.ts","../src/errors/FeeRecommendationsFetchError.ts","../src/waas/utils/getFeeRecommendations/getFeeRecommendations.ts","../src/waas/utils/estimateTransactionFee/estimateTransactionFee.ts","../src/waas/utils/calculateFeeAndChange/calculateFeeAndChange.ts","../src/waas/utils/calculateUTXOTotal/calculateUTXOTotal.ts","../src/errors/UTXOsFetchError.ts","../src/waas/utils/getUTXOs/getUTXOs.ts","../src/waas/utils/selectUTXOsLargestFirst/selectUTXOsLargestFirst.ts","../src/waas/utils/validateAndSelectUTXOs/validateAndSelectUTXOs.ts","../src/errors/TaprootAddressNotSupportedError.ts","../src/waas/utils/validateNotTaproot/validateNotTaproot.ts","../src/waas/utils/buildPsbt/buildPsbt.ts","../src/errors/UnsupportedBitcoinNetworkError.ts","../src/waas/utils/getActiveBitcoinNetworkConfig/getActiveBitcoinNetworkConfig.ts","../src/errors/PublicKeyNotFoundError.ts","../src/waas/utils/getPublicKeyForWalletAccount/getPublicKeyForWalletAccount.ts","../src/waas/utils/getWaasAllowedSighash/getWaasAllowedSighash.ts","../src/waas/utils/getWaasBitcoinAddressForNetwork/getWaasBitcoinAddressForNetwork.ts","../src/waas/utils/getWaasSigningIndexes/getWaasSigningIndexes.ts","../src/waas/utils/createWalletProviderForWaasBitcoin/createWalletProviderForWaasBitcoin.ts","../src/waas/addWaasBitcoinExtension/addWaasBitcoinExtension.ts"],"sourcesContent":["import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype TransactionBroadcastFailedErrorParams = {\n response: Response;\n};\n\nexport class TransactionBroadcastFailedError extends BaseError {\n public readonly response: Response;\n\n constructor({ response }: TransactionBroadcastFailedErrorParams) {\n super({\n cause: null,\n code: 'transaction_broadcast_failed_error',\n details: `Status: ${response.status} ${response.statusText}`,\n docsUrl: null,\n name: 'TransactionBroadcastFailedError',\n shortMessage: 'Failed to broadcast transaction to mempool',\n });\n\n this.response = response;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class TransactionRequiredError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'transaction_required_error',\n docsUrl: null,\n name: 'TransactionRequiredError',\n shortMessage: 'No transaction specified for broadcast',\n });\n }\n}\n","import { MEMPOOL_API_URL } from '../../../constants';\nimport { TransactionBroadcastFailedError } from '../../../errors/TransactionBroadcastFailedError';\nimport { TransactionRequiredError } from '../../../errors/TransactionRequiredError';\n\n/**\n * Sends a raw Bitcoin transaction to the mempool\n *\n * @param options.rawTransaction - The raw transaction in hex format\n * @param options.mempoolApiUrl - Base mempool API URL for the active network\n * @returns The transaction ID\n * @throws {TransactionRequiredError} if no transaction is specified\n * @throws {TransactionBroadcastFailedError} if broadcasting fails\n * @notInstrumented\n */\nexport const broadcastTransaction = async ({\n mempoolApiUrl = MEMPOOL_API_URL,\n rawTransaction,\n}: {\n mempoolApiUrl?: string;\n rawTransaction: string;\n}): Promise<string> => {\n if (!rawTransaction) {\n throw new TransactionRequiredError();\n }\n\n const response = await fetch(`${mempoolApiUrl}/tx`, {\n body: rawTransaction,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n method: 'POST',\n });\n\n if (!response.ok) {\n throw new TransactionBroadcastFailedError({ response });\n }\n\n return response.text();\n};\n","/**\n * Number of satoshis per Bitcoin\n */\nexport const SATOSHIS_PER_BTC = 100_000_000;\n\n/**\n * Bitcoin's dust limit in satoshis\n * Outputs below this value are considered \"dust\" and will be rejected by nodes\n */\nexport const DUST_LIMIT = 546;\n\n/**\n * Accurate vSize constants for Native SegWit (P2WPKH) transactions\n * Used for precise fee estimation\n */\nexport const VSIZE_OVERHEAD = 10.5;\n\nexport const VSIZE_INPUT_P2WPKH = 68;\n\nexport const VSIZE_OUTPUT_P2WPKH = 31;\n\n/**\n * Minimum relay fee in satoshis\n * Added to fee estimate to ensure transaction propagation\n */\nexport const MIN_RELAY_FEE = 111;\n\n/**\n * Conservative default fee estimate in satoshis\n * Used as fallback when fee estimation fails\n */\nexport const DEFAULT_FEE_ESTIMATE = 1000;\n\n/**\n * RBF (Replace-By-Fee) sequence number\n * 0xfffffffd = 4294967293 (enables RBF, not final)\n */\nexport const RBF_SEQUENCE = 0xfffffffd;\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nimport { SATOSHIS_PER_BTC } from '../waas/constants';\n\ntype InsufficientFundsErrorParams = {\n availableSatoshis: number;\n requiredSatoshis: number;\n};\n\nexport class InsufficientFundsError extends BaseError {\n public readonly availableSatoshis: number;\n\n public readonly requiredSatoshis: number;\n\n constructor({ availableSatoshis, requiredSatoshis }: InsufficientFundsErrorParams) {\n const availableBtc = availableSatoshis / SATOSHIS_PER_BTC;\n const requiredBtc = requiredSatoshis / SATOSHIS_PER_BTC;\n\n super({\n cause: null,\n code: 'insufficient_funds_error',\n details: `Available: ${availableBtc} BTC (${availableSatoshis} satoshis), Required: ${requiredBtc} BTC (${requiredSatoshis} satoshis)`,\n docsUrl: null,\n name: 'InsufficientFundsError',\n shortMessage: 'Insufficient funds for transaction',\n });\n\n this.availableSatoshis = availableSatoshis;\n\n this.requiredSatoshis = requiredSatoshis;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype InvalidAmountErrorParams = {\n amountInSatoshis: number;\n reason: string;\n};\n\nexport class InvalidAmountError extends BaseError {\n public readonly amountInSatoshis: number;\n\n constructor({ amountInSatoshis, reason }: InvalidAmountErrorParams) {\n super({\n cause: null,\n code: 'invalid_amount_error',\n details: `Amount: ${amountInSatoshis} satoshis`,\n docsUrl: null,\n name: 'InvalidAmountError',\n shortMessage: reason,\n });\n\n this.amountInSatoshis = amountInSatoshis;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype NoUTXOsFoundErrorParams = {\n address: string;\n};\n\nexport class NoUTXOsFoundError extends BaseError {\n public readonly address: string;\n\n constructor({ address }: NoUTXOsFoundErrorParams) {\n super({\n cause: null,\n code: 'no_utxos_found_error',\n details: `Address: ${address}`,\n docsUrl: null,\n name: 'NoUTXOsFoundError',\n shortMessage: 'No UTXOs found for this address',\n });\n\n this.address = address;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class SegwitOutputScriptError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'segwit_output_script_error',\n docsUrl: null,\n name: 'SegwitOutputScriptError',\n shortMessage: 'Failed to create segwit output script',\n });\n }\n}\n","import { getBuffer } from '@dynamic-labs-sdk/client/core';\nimport type { Network, Psbt } from 'bitcoinjs-lib';\nimport { payments } from 'bitcoinjs-lib';\n\nimport { SegwitOutputScriptError } from '../../../errors/SegwitOutputScriptError';\nimport { RBF_SEQUENCE } from '../../constants';\nimport type { UTXO } from '../../WaasBitcoinWalletProvider.types';\n\ntype AddInputsToPsbtOptions = {\n network: Network;\n psbt: Psbt;\n publicKeyPair: { publicKey: Uint8Array };\n selectedUTXOs: UTXO[];\n};\n\n/**\n * Adds inputs to PSBT from selected UTXOs\n *\n * @param options.network - Bitcoin network configuration (mainnet or testnet)\n * @param options.psbt - The PSBT instance to add inputs to\n * @param options.publicKeyPair - Key pair containing the public key for witness script\n * @param options.selectedUTXOs - Array of UTXOs to add as inputs\n * @notInstrumented\n */\nexport const addInputsToPsbt = (options: AddInputsToPsbtOptions): void => {\n const { network, psbt, publicKeyPair, selectedUTXOs } = options;\n\n for (const utxo of selectedUTXOs) {\n const outputScript = payments.p2wpkh({\n network,\n pubkey: publicKeyPair.publicKey,\n }).output;\n\n if (!outputScript) {\n throw new SegwitOutputScriptError();\n }\n\n const txidBuffer = new Uint8Array(\n getBuffer().from(utxo.txid, 'hex').reverse()\n );\n\n psbt.addInput({\n hash: txidBuffer,\n index: utxo.vout,\n sequence: RBF_SEQUENCE,\n witnessUtxo: {\n script: outputScript,\n value: BigInt(utxo.value),\n },\n });\n }\n};\n","import type { Network, Psbt } from 'bitcoinjs-lib';\nimport { address } from 'bitcoinjs-lib';\n\nimport { InvalidAmountError } from '../../../errors/InvalidAmountError';\nimport { DUST_LIMIT, SATOSHIS_PER_BTC } from '../../constants';\n\ntype AddOutputsToPsbtOptions = {\n accountAddress: string;\n amountInSatoshis: number;\n changeAmount: number;\n hasChangeOutput: boolean;\n network: Network;\n psbt: Psbt;\n recipientAddress: string;\n};\n\n/**\n * Adds outputs to PSBT (recipient and optionally change)\n *\n * @param options.accountAddress - The sender's address for receiving change\n * @param options.amountInSatoshis - Amount to send to the recipient in satoshis\n * @param options.changeAmount - Amount to return as change in satoshis\n * @param options.hasChangeOutput - Whether to include a change output\n * @param options.network - Bitcoin network configuration (mainnet or testnet)\n * @param options.psbt - The PSBT instance to add outputs to\n * @param options.recipientAddress - The recipient's Bitcoin address\n * @notInstrumented\n */\nexport const addOutputsToPsbt = (options: AddOutputsToPsbtOptions): void => {\n const {\n accountAddress,\n amountInSatoshis,\n changeAmount,\n hasChangeOutput,\n network,\n psbt,\n recipientAddress,\n } = options;\n\n if (amountInSatoshis < DUST_LIMIT) {\n throw new InvalidAmountError({\n amountInSatoshis,\n reason: `Amount is below dust limit of ${DUST_LIMIT} satoshis (${DUST_LIMIT / SATOSHIS_PER_BTC} BTC)`,\n });\n }\n\n psbt.addOutput({\n script: address.toOutputScript(recipientAddress, network),\n value: BigInt(amountInSatoshis),\n });\n\n if (hasChangeOutput) {\n psbt.addOutput({\n script: address.toOutputScript(accountAddress, network),\n value: BigInt(changeAmount),\n });\n }\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype FeeRecommendationsFetchErrorParams = {\n response: Response;\n};\n\nexport class FeeRecommendationsFetchError extends BaseError {\n public readonly response: Response;\n\n constructor({ response }: FeeRecommendationsFetchErrorParams) {\n super({\n cause: null,\n code: 'fee_recommendations_fetch_error',\n details: `Status: ${response.status} ${response.statusText}`,\n docsUrl: null,\n name: 'FeeRecommendationsFetchError',\n shortMessage: 'Failed to fetch fee recommendations from mempool',\n });\n\n this.response = response;\n }\n}\n","import { MEMPOOL_API_URL } from '../../../constants';\nimport { FeeRecommendationsFetchError } from '../../../errors/FeeRecommendationsFetchError';\nimport type { FeeRecommendations } from '../../WaasBitcoinWalletProvider.types';\n\n/**\n * Gets fee recommendations from mempool.space API\n *\n * @param options.mempoolApiUrl - Base mempool API URL for the active network\n * @returns Fee recommendation data with rates in sat/vB\n * @throws FeeRecommendationsFetchError if fetching fee recommendations fails\n * @notInstrumented\n */\nexport const getFeeRecommendations = async ({\n mempoolApiUrl = MEMPOOL_API_URL,\n}: {\n mempoolApiUrl?: string;\n} = {}): Promise<FeeRecommendations> => {\n const response = await fetch(`${mempoolApiUrl}/v1/fees/recommended`);\n\n if (!response.ok) {\n throw new FeeRecommendationsFetchError({ response });\n }\n\n return response.json();\n};\n","import {\n DEFAULT_FEE_ESTIMATE,\n MIN_RELAY_FEE,\n VSIZE_INPUT_P2WPKH,\n VSIZE_OUTPUT_P2WPKH,\n VSIZE_OVERHEAD,\n} from '../../constants';\nimport type { FeePriority } from '../../WaasBitcoinWalletProvider.types';\nimport { getFeeRecommendations } from '../getFeeRecommendations';\n\ntype EstimateTransactionFeeOptions = {\n feePriority?: FeePriority;\n mempoolApiUrl?: string;\n numInputs: number;\n numOutputs: number;\n};\n\n/**\n * Estimates transaction fees based on number of inputs and outputs using accurate vSize\n *\n * @param options.feePriority - Priority level for fee estimation ('low', 'medium', or 'high')\n * @param options.numInputs - Number of transaction inputs (UTXOs being spent)\n * @param options.numOutputs - Number of transaction outputs\n * @returns Estimated fee in satoshis\n * @notInstrumented\n */\nexport const estimateTransactionFee = async ({\n feePriority = 'medium',\n mempoolApiUrl,\n numInputs,\n numOutputs,\n}: EstimateTransactionFeeOptions): Promise<number> => {\n try {\n const feeData = await getFeeRecommendations({ mempoolApiUrl });\n\n let feePerByte: number;\n\n if (feePriority === 'high') {\n feePerByte = feeData.fastestFee ?? feeData.halfHourFee ?? 1;\n } else if (feePriority === 'low') {\n feePerByte = feeData.economyFee ?? feeData.hourFee ?? 1;\n } else {\n feePerByte =\n feeData.halfHourFee ?? feeData.hourFee ?? feeData.economyFee ?? 1;\n }\n\n const vSize =\n VSIZE_OVERHEAD +\n numInputs * VSIZE_INPUT_P2WPKH +\n numOutputs * VSIZE_OUTPUT_P2WPKH;\n\n return Math.ceil(feePerByte * vSize) + MIN_RELAY_FEE;\n } catch {\n return DEFAULT_FEE_ESTIMATE;\n }\n};\n","import { DUST_LIMIT } from '../../constants';\nimport type { FeePriority, UTXO } from '../../WaasBitcoinWalletProvider.types';\nimport { estimateTransactionFee } from '../estimateTransactionFee';\n\ntype CalculateFeeAndChangeOptions = {\n amountInSatoshis: bigint;\n feePriority: FeePriority;\n mempoolApiUrl?: string;\n selectedTotalValue: number;\n selectedUTXOs: UTXO[];\n};\n\ntype CalculateFeeAndChangeResult = {\n changeAmountNumber: number;\n feeEstimate: number;\n hasChangeOutput: boolean;\n};\n\n/**\n * Calculates fee estimate and change amount, handling dust limit\n *\n * @param options.amountInSatoshis - Amount to send in satoshis\n * @param options.feePriority - Priority level for fee estimation ('low', 'medium', or 'high')\n * @param options.selectedTotalValue - Total value of selected UTXOs in satoshis\n * @param options.selectedUTXOs - Array of selected UTXOs for the transaction\n * @returns Object with feeEstimate, changeAmountNumber, and hasChangeOutput\n * @notInstrumented\n */\nexport const calculateFeeAndChange = async ({\n amountInSatoshis,\n feePriority,\n mempoolApiUrl,\n selectedTotalValue,\n selectedUTXOs,\n}: CalculateFeeAndChangeOptions): Promise<CalculateFeeAndChangeResult> => {\n let feeEstimate = await estimateTransactionFee({\n feePriority,\n mempoolApiUrl,\n numInputs: selectedUTXOs.length,\n numOutputs: 1,\n });\n\n let maxToSpend = selectedTotalValue - feeEstimate;\n let changeAmount = BigInt(maxToSpend) - amountInSatoshis;\n\n const changeAmountNumber = Number(changeAmount);\n\n if (changeAmount > 0 && changeAmountNumber >= DUST_LIMIT) {\n feeEstimate = await estimateTransactionFee({\n feePriority,\n mempoolApiUrl,\n numInputs: selectedUTXOs.length,\n numOutputs: 2,\n });\n maxToSpend = selectedTotalValue - feeEstimate;\n changeAmount = BigInt(maxToSpend) - amountInSatoshis;\n }\n\n const finalChangeAmountNumber = Number(changeAmount);\n const hasChangeOutput =\n changeAmount > 0 && finalChangeAmountNumber >= DUST_LIMIT;\n\n if (changeAmount > 0 && finalChangeAmountNumber < DUST_LIMIT) {\n feeEstimate += finalChangeAmountNumber;\n }\n\n return {\n changeAmountNumber: finalChangeAmountNumber,\n feeEstimate,\n hasChangeOutput,\n };\n};\n","import type { UTXO } from '../../WaasBitcoinWalletProvider.types';\n\n/**\n * Calculates the total value of UTXOs\n *\n * @param utxos - Array of UTXOs\n * @returns Total value in satoshis\n * @notInstrumented\n */\nexport const calculateUTXOTotal = (utxos: UTXO[]): number =>\n utxos.reduce((total: number, utxo: UTXO) => total + utxo.value, 0);\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\ntype UTXOsFetchErrorParams = {\n address: string;\n response: Response;\n};\n\nexport class UTXOsFetchError extends BaseError {\n public readonly address: string;\n\n public readonly response: Response;\n\n constructor({ address, response }: UTXOsFetchErrorParams) {\n super({\n cause: null,\n code: 'utxos_fetch_error',\n details: `Address: ${address}, Status: ${response.status} ${response.statusText}`,\n docsUrl: null,\n name: 'UTXOsFetchError',\n shortMessage: 'Failed to fetch UTXOs from mempool',\n });\n\n this.address = address;\n\n this.response = response;\n }\n}\n","import { MEMPOOL_API_URL } from '../../../constants';\nimport { UTXOsFetchError } from '../../../errors/UTXOsFetchError';\nimport type { UTXO } from '../../WaasBitcoinWalletProvider.types';\n\n/**\n * Gets UTXOs for a Bitcoin address from mempool.space API\n *\n * @param options.address - The Bitcoin address to get UTXOs for\n * @param options.mempoolApiUrl - Base mempool API URL for the active network\n * @returns Array of UTXOs\n * @throws UTXOsFetchError if fetching UTXOs fails\n * @notInstrumented\n */\nexport const getUTXOs = async ({\n address,\n mempoolApiUrl = MEMPOOL_API_URL,\n}: {\n address: string;\n mempoolApiUrl?: string;\n}): Promise<UTXO[]> => {\n const response = await fetch(`${mempoolApiUrl}/address/${address}/utxo`);\n\n if (!response.ok) {\n throw new UTXOsFetchError({ address, response });\n }\n\n return response.json();\n};\n","import type { UTXO } from '../../WaasBitcoinWalletProvider.types';\n\ntype SelectUTXOsLargestFirstOptions = {\n targetAmount: number;\n utxos: UTXO[];\n};\n\n/**\n * Selects UTXOs using Largest-First (Accumulator) strategy\n * Sorts UTXOs by value (descending) and selects until we have enough to cover amount + fees\n *\n * @param options.targetAmount - Target amount in satoshis (amount + fees + dust limit)\n * @param options.utxos - Array of available UTXOs to select from\n * @returns Selected UTXOs\n * @notInstrumented\n */\nexport const selectUTXOsLargestFirst = (\n options: SelectUTXOsLargestFirstOptions\n) => {\n const { targetAmount, utxos } = options;\n\n const sortedUTXOs = [...utxos].sort((a, b) => b.value - a.value);\n\n const selected: UTXO[] = [];\n let total = 0;\n\n for (const utxo of sortedUTXOs) {\n selected.push(utxo);\n total += utxo.value;\n\n if (total >= targetAmount) {\n break;\n }\n }\n\n return selected;\n};\n","import { InsufficientFundsError } from '../../../errors/InsufficientFundsError';\nimport type { UTXO } from '../../WaasBitcoinWalletProvider.types';\nimport { calculateUTXOTotal } from '../calculateUTXOTotal';\n\ntype ValidateAndSelectUTXOsOptions = {\n allUTXOs: UTXO[];\n amountInSatoshis: number;\n feeEstimate: number;\n selectedTotal: number;\n selectedUTXOs: UTXO[];\n};\n\n/**\n * Validates and ensures sufficient funds for the transaction\n *\n * @param options.allUTXOs - Complete array of available UTXOs for the address\n * @param options.amountInSatoshis - Amount to send in satoshis\n * @param options.feeEstimate - Estimated transaction fee in satoshis\n * @param options.selectedTotal - Total value of initially selected UTXOs in satoshis\n * @param options.selectedUTXOs - Array of initially selected UTXOs\n * @returns Validated selected UTXOs\n * @throws InsufficientFundsError if insufficient funds\n * @notInstrumented\n */\nexport const validateAndSelectUTXOs = (\n options: ValidateAndSelectUTXOsOptions\n) => {\n const {\n allUTXOs,\n amountInSatoshis,\n feeEstimate,\n selectedTotal,\n selectedUTXOs,\n } = options;\n\n const requiredAmount = amountInSatoshis + feeEstimate;\n\n if (selectedTotal >= requiredAmount) {\n return selectedUTXOs;\n }\n\n if (selectedUTXOs.length < allUTXOs.length) {\n const allTotal = calculateUTXOTotal(allUTXOs);\n\n if (allTotal < requiredAmount) {\n throw new InsufficientFundsError({\n availableSatoshis: allTotal,\n requiredSatoshis: amountInSatoshis,\n });\n }\n\n return allUTXOs;\n }\n\n throw new InsufficientFundsError({\n availableSatoshis: selectedTotal,\n requiredSatoshis: amountInSatoshis,\n });\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class TaprootAddressNotSupportedError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'taproot_address_not_supported',\n docsUrl: null,\n name: 'TaprootAddressNotSupportedError',\n shortMessage:\n 'Taproot addresses are not supported for PSBT building. Only Native SegWit (P2WPKH) addresses are allowed.',\n });\n }\n}\n","import { TaprootAddressNotSupportedError } from '../../../errors/TaprootAddressNotSupportedError';\n\n/**\n * Validates that the address is not a Taproot address\n * Only Native SegWit (P2WPKH) is supported for PSBT building\n *\n * @param accountAddress - The account address to check\n * @throws TaprootAddressNotSupportedError if address is Taproot\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const validateNotTaproot = (accountAddress: string): void => {\n if (\n accountAddress.toLowerCase().startsWith('bc1p') ||\n accountAddress.toLowerCase().startsWith('tb1p')\n ) {\n throw new TaprootAddressNotSupportedError();\n }\n};\n","import ecc from '@bitcoinerlab/secp256k1';\nimport { getBuffer } from '@dynamic-labs-sdk/client/core';\nimport type { Network } from 'bitcoinjs-lib';\nimport { Psbt } from 'bitcoinjs-lib';\nimport { ECPairFactory } from 'ecpair';\n\nimport { InsufficientFundsError } from '../../../errors/InsufficientFundsError';\nimport { InvalidAmountError } from '../../../errors/InvalidAmountError';\nimport { NoUTXOsFoundError } from '../../../errors/NoUTXOsFoundError';\nimport { DUST_LIMIT } from '../../constants';\nimport type { FeePriority } from '../../WaasBitcoinWalletProvider.types';\nimport { addInputsToPsbt } from '../addInputsToPsbt';\nimport { addOutputsToPsbt } from '../addOutputsToPsbt';\nimport { calculateFeeAndChange } from '../calculateFeeAndChange';\nimport { calculateUTXOTotal } from '../calculateUTXOTotal';\nimport { estimateTransactionFee } from '../estimateTransactionFee';\nimport { getUTXOs } from '../getUTXOs';\nimport { selectUTXOsLargestFirst } from '../selectUTXOsLargestFirst';\nimport { validateAndSelectUTXOs } from '../validateAndSelectUTXOs';\nimport { validateNotTaproot } from '../validateNotTaproot';\n\ntype BuildPsbtOptions = {\n accountAddress: string;\n amountInSatoshis: bigint;\n feePriority?: FeePriority;\n mempoolApiUrl?: string;\n network: Network;\n publicKeyHex: string;\n recipientAddress: string;\n};\n\n/**\n * Builds a PSBT for a Bitcoin transaction with real UTXOs\n * Uses Largest-First UTXO selection strategy with accurate vSize fee estimation\n *\n * @param options.accountAddress - The sender's Bitcoin address\n * @param options.amountInSatoshis - Amount to send in satoshis\n * @param options.feePriority - Priority level for fee estimation ('low', 'medium', or 'high')\n * @param options.network - Bitcoin network configuration (mainnet or testnet)\n * @param options.publicKeyHex - The sender's public key in hexadecimal format\n * @param options.recipientAddress - The recipient's Bitcoin address\n * @returns A PSBT in Base64 format\n * @throws Error if insufficient funds, no UTXOs, or other errors\n * @notInstrumented\n */\nexport const buildPsbt = async ({\n accountAddress,\n amountInSatoshis,\n feePriority = 'medium',\n mempoolApiUrl,\n network,\n publicKeyHex,\n recipientAddress,\n}: BuildPsbtOptions): Promise<string> => {\n if (amountInSatoshis <= BigInt(0)) {\n throw new InvalidAmountError({\n amountInSatoshis: Number(amountInSatoshis),\n reason: 'Amount must be greater than 0',\n });\n }\n\n validateNotTaproot(accountAddress);\n\n const allUTXOs = await getUTXOs({ address: accountAddress, mempoolApiUrl });\n\n if (allUTXOs.length === 0) {\n throw new NoUTXOsFoundError({ address: accountAddress });\n }\n\n const publicKeyBuffer = new Uint8Array(getBuffer().from(publicKeyHex, 'hex'));\n const ECPair = ECPairFactory(ecc);\n\n // @ts-expect-error - ecpair types are incompatible with valibot >=1.2.0\n // The options are actually optional at runtime, but TypeScript infers them as required\n const publicKeyPair = ECPair.fromPublicKey(publicKeyBuffer, {\n compressed: true,\n });\n\n const amountInSatoshisNumber = Number(amountInSatoshis);\n\n const initialFeeEstimate = await estimateTransactionFee({\n feePriority,\n mempoolApiUrl,\n numInputs: 1,\n numOutputs: 1,\n });\n\n const targetAmount = amountInSatoshisNumber + initialFeeEstimate + DUST_LIMIT;\n\n let selectedUTXOs = selectUTXOsLargestFirst({\n targetAmount,\n utxos: allUTXOs,\n });\n const selectedTotal = calculateUTXOTotal(selectedUTXOs);\n\n selectedUTXOs = validateAndSelectUTXOs({\n allUTXOs,\n amountInSatoshis: amountInSatoshisNumber,\n feeEstimate: initialFeeEstimate,\n selectedTotal,\n selectedUTXOs,\n });\n\n const selectedTotalValue = calculateUTXOTotal(selectedUTXOs);\n\n const { changeAmountNumber, feeEstimate, hasChangeOutput } =\n await calculateFeeAndChange({\n amountInSatoshis,\n feePriority,\n mempoolApiUrl,\n selectedTotalValue,\n selectedUTXOs,\n });\n\n const maxToSpend = selectedTotalValue - feeEstimate;\n\n if (maxToSpend < amountInSatoshisNumber) {\n throw new InsufficientFundsError({\n availableSatoshis: maxToSpend,\n requiredSatoshis: amountInSatoshisNumber,\n });\n }\n\n const psbt = new Psbt({ network });\n\n addInputsToPsbt({\n network,\n psbt,\n publicKeyPair,\n selectedUTXOs,\n });\n\n addOutputsToPsbt({\n accountAddress,\n amountInSatoshis: amountInSatoshisNumber,\n changeAmount: changeAmountNumber,\n hasChangeOutput,\n network,\n psbt,\n recipientAddress,\n });\n\n return psbt.toBase64();\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class UnsupportedBitcoinNetworkError extends BaseError {\n // eslint-disable-next-line custom-rules/require-single-object-param\n constructor(networkId: string) {\n super({\n cause: null,\n code: 'unsupported_bitcoin_network_error',\n docsUrl: null,\n name: 'UnsupportedBitcoinNetworkError',\n shortMessage: `Unsupported Bitcoin network id: ${networkId}`,\n });\n }\n}\n","import type { Network } from 'bitcoinjs-lib';\nimport { networks } from 'bitcoinjs-lib';\n\nimport {\n MEMPOOL_API_URL,\n MEMPOOL_API_URL_SIGNET,\n MEMPOOL_API_URL_TESTNET,\n} from '../../../constants';\nimport { UnsupportedBitcoinNetworkError } from '../../../errors/UnsupportedBitcoinNetworkError';\n\nexport type ActiveBitcoinNetworkConfig = {\n /** WaaS signing network for `bitcoinConfig.network`. */\n bitcoinNetwork: 'mainnet' | 'testnet';\n /** Base mempool.space API URL for the network. */\n mempoolApiUrl: string;\n networkId: string;\n /** bitcoinjs-lib network for PSBT encoding. */\n psbtNetwork: Network;\n};\n\n/**\n * Resolves a Dynamic Bitcoin network id (1 mainnet, 2 testnet, 3 signet) to\n * the per-network configuration used by the WaaS provider. An undefined id\n * (network never switched) resolves to mainnet.\n *\n * @throws {UnsupportedBitcoinNetworkError} for any other network id\n * @notInstrumented\n */\nexport const getActiveBitcoinNetworkConfig = ({\n networkId,\n}: {\n networkId: string | undefined;\n}): ActiveBitcoinNetworkConfig => {\n const id = networkId ?? '1';\n\n switch (id) {\n case '1':\n return {\n bitcoinNetwork: 'mainnet',\n mempoolApiUrl: MEMPOOL_API_URL,\n networkId: id,\n psbtNetwork: networks.bitcoin,\n };\n case '2':\n return {\n bitcoinNetwork: 'testnet',\n mempoolApiUrl: MEMPOOL_API_URL_TESTNET,\n networkId: id,\n psbtNetwork: networks.testnet,\n };\n case '3':\n return {\n bitcoinNetwork: 'testnet',\n mempoolApiUrl: MEMPOOL_API_URL_SIGNET,\n networkId: id,\n psbtNetwork: networks.testnet,\n };\n default:\n throw new UnsupportedBitcoinNetworkError(id);\n }\n};\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\nexport class PublicKeyNotFoundError extends BaseError {\n // eslint-disable-next-line custom-rules/require-single-object-param\n constructor(address: string) {\n super({\n cause: null,\n code: 'public_key_not_found_error',\n docsUrl: null,\n name: 'PublicKeyNotFoundError',\n shortMessage: `No public key found for address ${address}`,\n });\n }\n}\n\n","import type { DynamicClient, WalletAccount } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\nimport { PublicKeyNotFoundError } from '../../../errors/PublicKeyNotFoundError';\n\n/**\n * Gets the public key for a wallet account from the user's verified credentials\n * @notInstrumented\n */\nexport const getPublicKeyForWalletAccount = (\n walletAccount: WalletAccount,\n client: DynamicClient\n): string => {\n const user = getCore(client).state.get().user;\n\n for (const credential of user?.verifiedCredentials ?? []) {\n const additionalAddress = credential.walletAdditionalAddresses?.find(\n (addr) => addr.address === walletAccount.address\n );\n\n if (additionalAddress?.publicKey) {\n return additionalAddress.publicKey;\n }\n }\n\n throw new PublicKeyNotFoundError(walletAccount.address);\n};\n","import type { BitcoinSignPsbtRequest } from '../../../BitcoinWalletProvider.types';\n\nexport type GetWaasAllowedSighashParams = {\n /** The PSBT signing request, whose `allowedSighash` restricts permitted types. */\n request: BitcoinSignPsbtRequest;\n};\n\n/**\n * Translates the request's `allowedSighash` into the value the WaaS client takes.\n *\n * The two sides disagree on what an empty array means, and forwarding it\n * verbatim would break every embedded send:\n *\n * - Here, `allowedSighash` is required, so `[]` is how callers say \"no\n * restriction\" — `sendBitcoin` passes exactly that for its own PSBTs.\n * - In the WaaS client, `[]` means \"permit nothing\" and rejects every input,\n * while `undefined` means \"permit any type the PSBT declares\".\n *\n * So an empty list maps to `undefined`, preserving today's behaviour, and a\n * populated list is passed through to restrict signing.\n *\n * @notInstrumented\n */\nexport const getWaasAllowedSighash = ({\n request,\n}: GetWaasAllowedSighashParams): number[] | undefined =>\n request.allowedSighash?.length ? request.allowedSighash : undefined;\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\nimport { WalletAddressType } from '@dynamic-labs/sdk-api-core';\n\n/**\n * Resolves the wallet's payment address for the given Bitcoin network. One\n * WaaS wallet (one MPC key) exposes a per-network payment address via its\n * network-tagged additional addresses. Falls back to the wallet account's\n * primary address (the mainnet encoding) for legacy wallets without tagged\n * rows.\n *\n * The wallet identity (keyshare/password lookups, signing) is always the\n * primary address — this resolver is only for address-driven operations\n * (UTXOs, balance, broadcast source).\n *\n * @notInstrumented\n */\nexport const getWaasBitcoinAddressForNetwork = ({\n bitcoinNetwork,\n walletAccount,\n}: {\n bitcoinNetwork: 'mainnet' | 'testnet';\n walletAccount: WalletAccount;\n}): string => {\n const taggedAddress = walletAccount.addressesWithTypes?.find(\n (address) =>\n address.type === WalletAddressType.Payment &&\n address.network === bitcoinNetwork\n )?.address;\n\n return taggedAddress ?? walletAccount.address;\n};\n","import type { BitcoinSignPsbtRequest } from '../../../BitcoinWalletProvider.types';\nimport { InvalidPsbtError } from '../../../errors/InvalidPsbtError';\n\nexport type GetWaasSigningIndexesParams = {\n /** The PSBT signing request, whose `signature` entries scope inputs per address. */\n request: BitcoinSignPsbtRequest;\n\n /**\n * Every encoding of the signing wallet's own address. One key produces a\n * different address per network, and callers name the one they built the\n * PSBT with — on testnet that is the `tb1…` encoding, not the primary\n * (mainnet) address the wallet is identified by.\n */\n walletAddresses: string[];\n};\n\n/**\n * Flattens the request's per-address `signature[].signingIndexes` into the flat\n * index array the WaaS client takes, keeping only the entries that name this\n * wallet.\n *\n * Returns `undefined` when the caller scoped nothing, which leaves the existing\n * behaviour intact: the WaaS client signs every input the wallet owns.\n *\n * Throws when the caller scoped indexes but none of them are for this wallet.\n * Returning `undefined` there would widen the request into \"sign everything I\n * own\" — the opposite of what a caller narrowing a PSBT is asking for.\n *\n * @notInstrumented\n */\nexport const getWaasSigningIndexes = ({\n request,\n walletAddresses,\n}: GetWaasSigningIndexesParams): number[] | undefined => {\n const scopedEntries =\n request.signature?.filter((entry) => entry.signingIndexes?.length) ?? [];\n\n if (!scopedEntries.length) {\n return undefined;\n }\n\n // Bitcoin addresses are case-sensitive encodings, so an exact match is the\n // correct comparison here (`normalizeAddress` is a no-op for BIP122).\n const ownAddresses = new Set(walletAddresses.filter(Boolean));\n const indexes = scopedEntries\n .filter((entry) => ownAddresses.has(entry.address))\n .flatMap((entry) => entry.signingIndexes ?? []);\n\n if (!indexes.length) {\n throw new InvalidPsbtError(\n 'signingIndexes were provided, but none of them are for this wallet'\n );\n }\n\n return [...new Set(indexes)].sort((a, b) => a - b);\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n consumeMfaTokenIfRequiredForAction,\n formatWalletProviderGroupKey,\n formatWalletProviderKey,\n getActiveNetworkIdFromLastKnownRegistry,\n getSignedSessionId,\n switchActiveNetworkInLastKnownRegistry,\n} from '@dynamic-labs-sdk/client/core';\nimport type { BitcoinNetwork } from '@dynamic-labs-sdk/client/waas/core';\nimport {\n DYNAMIC_WAAS_METADATA,\n createWaasProvider,\n getAllUserWaasAddressesForChain,\n} from '@dynamic-labs-sdk/client/waas/core';\nimport { MFAAction, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\nimport { Psbt } from 'bitcoinjs-lib';\n\nimport type { BitcoinSendTransactionResponse } from '../../../BitcoinWalletProvider.types';\nimport { bitcoinExecuteSwapTransaction } from '../../../utils/bitcoinExecuteSwapTransaction';\nimport { bitcoinTransferAmount } from '../../../utils/bitcoinTransferAmount';\nimport type {\n WaasBitcoinTransaction,\n WaasBitcoinWalletProvider,\n} from '../../WaasBitcoinWalletProvider.types';\nimport { broadcastTransaction } from '../broadcastTransaction';\nimport { buildPsbt as buildPsbtUtil } from '../buildPsbt';\nimport { getActiveBitcoinNetworkConfig } from '../getActiveBitcoinNetworkConfig';\nimport { getPublicKeyForWalletAccount } from '../getPublicKeyForWalletAccount/getPublicKeyForWalletAccount';\nimport { getWaasAllowedSighash } from '../getWaasAllowedSighash';\nimport { getWaasBitcoinAddressForNetwork } from '../getWaasBitcoinAddressForNetwork';\nimport { getWaasSigningIndexes } from '../getWaasSigningIndexes';\n\n/** @notInstrumented */\nexport const createWalletProviderForWaasBitcoin = (\n sdkClient: DynamicClient\n): WaasBitcoinWalletProvider => {\n const chain = 'BTC' as const;\n\n const walletProviderType = WalletProviderEnum.EmbeddedWallet;\n\n const key = formatWalletProviderKey({\n chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType,\n });\n\n const waasProvider = createWaasProvider({ chain, sdkClient });\n\n const getActiveNetworkId: WaasBitcoinWalletProvider['getActiveNetworkId'] =\n async () =>\n getActiveNetworkIdFromLastKnownRegistry({\n client: sdkClient,\n walletProviderKey: key,\n });\n\n const switchActiveNetwork: WaasBitcoinWalletProvider['switchActiveNetwork'] =\n async ({ networkId }) => {\n // Validates the id before persisting it — an unsupported network must\n // fail the switch rather than silently degrade to mainnet later.\n getActiveBitcoinNetworkConfig({ networkId });\n\n return switchActiveNetworkInLastKnownRegistry({\n client: sdkClient,\n networkId,\n walletProviderKey: key,\n });\n };\n\n const getActiveNetworkConfig = async () => {\n const { networkId } = await getActiveNetworkId();\n\n return getActiveBitcoinNetworkConfig({ networkId });\n };\n\n const getConnectedAddresses: WaasBitcoinWalletProvider['getConnectedAddresses'] =\n async () => {\n const waasBitcoinAddresses = getAllUserWaasAddressesForChain(\n { chain },\n sdkClient\n );\n\n return {\n addresses: waasBitcoinAddresses,\n };\n };\n\n const signPsbt: WaasBitcoinWalletProvider['signPsbt'] = async ({\n request,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n // Resolved before any irreversible side effect: this rejects a request\n // whose indexes are scoped to another address, and consuming the one-time\n // MFA token first would make the user redo MFA for a request that was\n // never sent.\n const signingIndexes = getWaasSigningIndexes({\n request,\n walletAddresses: [\n walletAccount.address,\n ...(walletAccount.addressesWithTypes ?? []).map(\n ({ address }) => address\n ),\n ],\n });\n\n const allowedSighash = getWaasAllowedSighash({ request });\n\n const waasClient = await waasProvider.getWaasClient();\n\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const signedPsbt = await waasClient.signTransaction({\n allowedSighash,\n authToken: sdkClient.token ?? undefined,\n mfaToken,\n senderAddress: walletAccount.address,\n signedSessionId,\n signingIndexes,\n transaction: request.unsignedPsbtBase64,\n });\n\n return { signedPsbt };\n };\n\n const signPsbts: WaasBitcoinWalletProvider['signPsbts'] = async ({\n requests,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n const signedPsbts = await Promise.all(\n requests.map(async (request) => {\n const { signedPsbt } = await signPsbt({ request, walletAccount });\n\n return signedPsbt;\n })\n );\n\n return { signedPsbts };\n };\n\n const signMessage: WaasBitcoinWalletProvider['signMessage'] = async ({\n message,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n const waasClient = await waasProvider.getWaasClient();\n\n const { signature: signedSessionId } = await getSignedSessionId(sdkClient);\n\n const mfaToken = await consumeMfaTokenIfRequiredForAction(\n { mfaAction: MFAAction.WalletWaasSign },\n sdkClient\n );\n\n const { bitcoinNetwork } = await getActiveNetworkConfig();\n\n const signature = await waasClient.signMessage({\n accountAddress: walletAccount.address,\n authToken: sdkClient.token ?? undefined,\n bitcoinConfig: {\n network: bitcoinNetwork as BitcoinNetwork,\n },\n message,\n mfaToken,\n signedSessionId,\n });\n\n return { signature };\n };\n\n const buildPsbt: WaasBitcoinWalletProvider['buildPsbt'] = async ({\n transaction,\n walletAccount,\n }) => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n const publicKeyHex = getPublicKeyForWalletAccount(walletAccount, sdkClient);\n\n const { bitcoinNetwork, mempoolApiUrl, psbtNetwork } =\n await getActiveNetworkConfig();\n\n return buildPsbtUtil({\n // UTXO source and change output use the active network's payment\n // address; signing identity stays the wallet account's primary address.\n accountAddress: getWaasBitcoinAddressForNetwork({\n bitcoinNetwork,\n walletAccount,\n }),\n amountInSatoshis: transaction.amount,\n feePriority: transaction.feePriority ?? 'medium',\n mempoolApiUrl,\n network: psbtNetwork,\n publicKeyHex,\n recipientAddress: transaction.recipientAddress,\n });\n };\n\n const sendBitcoin: WaasBitcoinWalletProvider['sendBitcoin'] = async ({\n transaction,\n walletAccount,\n }): Promise<BitcoinSendTransactionResponse> => {\n assertDefined(walletAccount, 'Wallet account is required');\n\n const waasTransaction: WaasBitcoinTransaction = {\n amount: transaction.amount,\n recipientAddress: transaction.recipientAddress,\n };\n\n const unsignedPsbt = await buildPsbt({\n transaction: waasTransaction,\n walletAccount,\n });\n\n const { signedPsbt } = await signPsbt({\n request: { allowedSighash: [], unsignedPsbtBase64: unsignedPsbt },\n walletAccount,\n });\n\n const { mempoolApiUrl, psbtNetwork } = await getActiveNetworkConfig();\n\n const psbt = Psbt.fromBase64(signedPsbt, { network: psbtNetwork });\n\n psbt.finalizeAllInputs();\n\n const rawTx = psbt.extractTransaction().toHex();\n\n const transactionId = await broadcastTransaction({\n mempoolApiUrl,\n rawTransaction: rawTx,\n });\n\n return { transactionId };\n };\n\n return {\n ...waasProvider,\n buildPsbt,\n chain,\n executeSwapTransaction: (args) =>\n bitcoinExecuteSwapTransaction(args, sdkClient),\n getActiveNetworkId,\n getConnectedAddresses,\n groupKey: formatWalletProviderGroupKey(DYNAMIC_WAAS_METADATA.displayName),\n key,\n metadata: {\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n icon: DYNAMIC_WAAS_METADATA.icon,\n },\n sendBitcoin,\n signMessage,\n signPsbt,\n signPsbts,\n switchActiveNetwork,\n transferAmount: (args) => bitcoinTransferAmount(args, sdkClient),\n walletProviderType,\n };\n};\n","import {\n WalletProviderPriority,\n getDefaultClient,\n getWalletProviderRegistry,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { registerBitcoinNetworkProviderBuilder } from '../../registerBitcoinNetworkProviderBuilder';\nimport { createWalletProviderForWaasBitcoin } from '../utils/createWalletProviderForWaasBitcoin';\n\nexport const WAAS_BITCOIN_EXTENSION_KEY = 'waasBitcoin';\n\n/**\n * Adds the Dynamic WaaS (Wallet as a Service) Bitcoin extension to the Dynamic client.\n *\n * This extension enables embedded wallet functionality for Bitcoin blockchain,\n * allowing users to have wallets managed by Dynamic's infrastructure.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @notInstrumented\n */\nexport const addWaasBitcoinExtension = (client = getDefaultClient()): void => {\n if (hasExtension({ extensionKey: WAAS_BITCOIN_EXTENSION_KEY }, client)) {\n return;\n }\n\n registerExtension({ extensionKey: WAAS_BITCOIN_EXTENSION_KEY }, client);\n registerBitcoinNetworkProviderBuilder(client);\n\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = createWalletProviderForWaasBitcoin(client);\n\n walletProviderRegistry.register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n};\n\n"],"mappings":";;;;;;;;;;AAMA,IAAa,kCAAb,cAAqD,UAAU;CAC7D,AAAgB;CAEhB,YAAY,EAAE,YAAmD;AAC/D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS,WAAW,SAAS,OAAO,GAAG,SAAS;GAChD,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;AAEF,OAAK,WAAW;;;;;;ACjBpB,IAAa,2BAAb,cAA8C,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GAAG;EACH;EACA;EACA,yBAAyB,SACvB,8BAA8B,MAAM,UAAU;EAChD;EACA;EACA,UAAU,6BAA6B,sBAAsB,YAAY;EACzE;EACA,UAAU;GACR,aAAa,sBAAsB;GACnC,MAAM,sBAAsB;GAC7B;EACD;EACA;EACA;EACA;EACA;EACA,iBAAiB,SAAS,sBAAsB,MAAM,UAAU;EAChE;EACD;;;;;AC9PH,MAAa,6BAA6B;;;;;;;;;;AAW1C,MAAa,2BAA2B,SAAS,kBAAkB,KAAW;AAC5E,KAAI,aAAa,EAAE,cAAc,4BAA4B,EAAE,OAAO,CACpE;AAGF,mBAAkB,EAAE,cAAc,4BAA4B,EAAE,OAAO;AACvE,uCAAsC,OAAO;CAE7C,MAAM,yBAAyB,0BAA0B,OAAO;CAEhE,MAAM,iBAAiB,mCAAmC,OAAO;AAEjE,wBAAuB,SAAS;EAC9B,UAAU,uBAAuB;EACjC;EACD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-
|
|
2
|
-
const
|
|
3
|
-
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-
|
|
1
|
+
const require_addWaasBitcoinExtension = require('./addWaasBitcoinExtension-BJU5cWG0.cjs');
|
|
2
|
+
const require_InvalidPsbtError = require('./InvalidPsbtError-D0F2EZEI.cjs');
|
|
3
|
+
const require_addBitcoinInjectedWalletsExtension = require('./addBitcoinInjectedWalletsExtension-DXYVv-LJ.cjs');
|
|
4
4
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
5
5
|
let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
6
6
|
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
@@ -83,7 +83,7 @@ const isBitcoinNetworkProvider = (networkProvider) => networkProvider.chain ===
|
|
|
83
83
|
*/
|
|
84
84
|
const signMessageWithCustomOptions = async ({ walletAccount, message, protocol, addressType }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
85
85
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
86
|
-
if (!
|
|
86
|
+
if (!require_InvalidPsbtError.isBitcoinWalletProvider(provider)) throw new require_InvalidPsbtError.NotBitcoinProviderError({ providerKey: provider.key });
|
|
87
87
|
if (!provider.signMessage) throw new _dynamic_labs_sdk_client_core.MethodNotImplementedError("signMessage");
|
|
88
88
|
return provider.signMessage({
|
|
89
89
|
addressType,
|
|
@@ -117,7 +117,7 @@ const signMessageWithCustomOptions = async ({ walletAccount, message, protocol,
|
|
|
117
117
|
*/
|
|
118
118
|
const signPsbt = async ({ walletAccount, request }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
119
119
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
120
|
-
if (!
|
|
120
|
+
if (!require_InvalidPsbtError.isBitcoinWalletProvider(provider)) throw new require_InvalidPsbtError.NotBitcoinProviderError({ providerKey: provider.key });
|
|
121
121
|
return provider.signPsbt({
|
|
122
122
|
request,
|
|
123
123
|
walletAccount
|
|
@@ -151,7 +151,7 @@ const signPsbt = async ({ walletAccount, request }, client = (0, _dynamic_labs_s
|
|
|
151
151
|
*/
|
|
152
152
|
const signPsbts = async ({ walletAccount, requests }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
153
153
|
const provider = (0, _dynamic_labs_sdk_client_core.getWalletProviderFromWalletAccount)({ walletAccount }, client);
|
|
154
|
-
if (!
|
|
154
|
+
if (!require_InvalidPsbtError.isBitcoinWalletProvider(provider)) throw new require_InvalidPsbtError.NotBitcoinProviderError({ providerKey: provider.key });
|
|
155
155
|
return provider.signPsbts({
|
|
156
156
|
requests,
|
|
157
157
|
walletAccount
|
|
@@ -160,17 +160,17 @@ const signPsbts = async ({ walletAccount, requests }, client = (0, _dynamic_labs
|
|
|
160
160
|
|
|
161
161
|
//#endregion
|
|
162
162
|
//#region src/exports/index.ts
|
|
163
|
-
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(
|
|
163
|
+
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_InvalidPsbtError.name, require_InvalidPsbtError.version);
|
|
164
164
|
|
|
165
165
|
//#endregion
|
|
166
|
-
exports.InvalidPsbtError =
|
|
166
|
+
exports.InvalidPsbtError = require_InvalidPsbtError.InvalidPsbtError;
|
|
167
167
|
exports.TransactionBroadcastFailedError = require_addWaasBitcoinExtension.TransactionBroadcastFailedError;
|
|
168
168
|
exports.TransactionRequiredError = require_addWaasBitcoinExtension.TransactionRequiredError;
|
|
169
169
|
exports.addBitcoinExtension = addBitcoinExtension;
|
|
170
170
|
exports.isBitcoinNetworkProvider = isBitcoinNetworkProvider;
|
|
171
|
-
exports.isBitcoinWalletAccount =
|
|
172
|
-
exports.sendBitcoin =
|
|
173
|
-
exports.sendRawTransaction =
|
|
171
|
+
exports.isBitcoinWalletAccount = require_InvalidPsbtError.isBitcoinWalletAccount;
|
|
172
|
+
exports.sendBitcoin = require_InvalidPsbtError.sendBitcoin;
|
|
173
|
+
exports.sendRawTransaction = require_InvalidPsbtError.sendRawTransaction;
|
|
174
174
|
exports.signMessageWithCustomOptions = signMessageWithCustomOptions;
|
|
175
175
|
exports.signPsbt = signPsbt;
|
|
176
176
|
exports.signPsbts = signPsbts;
|