multisigns-sdk 1.0.10 → 1.0.11

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.
@@ -0,0 +1,107 @@
1
+ // src/strategies/btcServices/utils/btc-utils.ts
2
+ var getBTCUTXOs = async (address, network) => {
3
+ const apiUrl = network === "mainnet" ? "https://mempool.space/api" : "https://mempool.space/testnet/api";
4
+ try {
5
+ const response = await fetch(`${apiUrl}/address/${address}/utxo`);
6
+ if (!response.ok) {
7
+ throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
8
+ }
9
+ return await response.json();
10
+ } catch (error) {
11
+ console.error("Error fetching UTXOs:", error);
12
+ throw new Error("Failed to fetch UTXOs.");
13
+ }
14
+ };
15
+ var fetchBTCFee = async (network) => {
16
+ const btcFetchFeeRpc = network !== "mainnet" ? "https://mempool.space/testnet/api/v1/fees/recommended" : "https://mempool.space/api/v1/fees/recommended";
17
+ try {
18
+ const response = await fetch(btcFetchFeeRpc);
19
+ const data = await response.json();
20
+ return network !== "mainnet" ? data.fastestFee : data.hourFee;
21
+ } catch (error) {
22
+ console.error("Error fetching BTC fee:", error);
23
+ throw new Error("Failed to fetch recommended fee.");
24
+ }
25
+ };
26
+ var broadcastBtcTransaction = async (txHex, network) => {
27
+ const apiUrl = network === "mainnet" ? "https://mempool.space/api" : "https://mempool.space/testnet/api";
28
+ try {
29
+ const response = await fetch(`${apiUrl}/tx`, {
30
+ method: "POST",
31
+ body: txHex
32
+ });
33
+ if (!response.ok) {
34
+ const errorText = await response.text();
35
+ try {
36
+ if (errorText.includes("RPC error: ")) {
37
+ const rpcErrorPart = errorText.split("RPC error: ")[1];
38
+ const rpcError = JSON.parse(rpcErrorPart);
39
+ if (rpcError.message.includes("dust") || rpcError.message.includes("non-standard")) {
40
+ throw new Error(
41
+ "The transaction amount is too small to be broadcasted. Please increase the amount."
42
+ );
43
+ }
44
+ }
45
+ } catch (parseError) {
46
+ }
47
+ throw new Error(`Error: Failed to broadcast transaction. Details: ${errorText}`);
48
+ }
49
+ return await response.text();
50
+ } catch (error) {
51
+ console.error("Error broadcasting transaction:", error);
52
+ throw error;
53
+ }
54
+ };
55
+ var addInputSafe = (psbt, input) => {
56
+ try {
57
+ psbt.addInput({
58
+ ...input,
59
+ witnessUtxo: {
60
+ script: input.witnessUtxo.script,
61
+ value: BigInt(input.witnessUtxo.value)
62
+ }
63
+ });
64
+ } catch (e) {
65
+ try {
66
+ psbt.addInput({
67
+ ...input,
68
+ witnessUtxo: {
69
+ script: input.witnessUtxo.script,
70
+ value: Number(input.witnessUtxo.value)
71
+ }
72
+ });
73
+ } catch (e2) {
74
+ console.error("Failed to add input with BigInt:", e);
75
+ console.error("Failed to add input with Number:", e2);
76
+ throw e;
77
+ }
78
+ }
79
+ };
80
+ var addOutputSafe = (psbt, output) => {
81
+ try {
82
+ psbt.addOutput({
83
+ address: output.address,
84
+ value: BigInt(output.value)
85
+ });
86
+ } catch (e) {
87
+ try {
88
+ psbt.addOutput({
89
+ address: output.address,
90
+ value: Number(output.value)
91
+ });
92
+ } catch (e2) {
93
+ console.error("Failed to add output with BigInt:", e);
94
+ console.error("Failed to add output with Number:", e2);
95
+ throw e;
96
+ }
97
+ }
98
+ };
99
+
100
+ export {
101
+ getBTCUTXOs,
102
+ fetchBTCFee,
103
+ broadcastBtcTransaction,
104
+ addInputSafe,
105
+ addOutputSafe
106
+ };
107
+ //# sourceMappingURL=chunk-WQBQUQDF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/strategies/btcServices/utils/btc-utils.ts"],"sourcesContent":["import { Buffer } from \"buffer\";\nimport * as bitcoin from \"bitcoinjs-lib\";\n\nexport interface BtcUtxo {\n txid: string;\n vout: number;\n value: number;\n script?: string;\n nonWitnessUtxo?: string;\n}\n\nexport const hexToUint8Array = (hex: string): Uint8Array => {\n const cleanHex = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n\n if (cleanHex.length % 2 !== 0) {\n throw new Error(\"Invalid Hex String Length\");\n }\n\n const bytes = [];\n for (let i = 0; i < cleanHex.length; i += 2) {\n bytes.push(parseInt(cleanHex.substring(i, i + 2), 16));\n }\n return new Uint8Array(bytes);\n};\n\nexport const getBTCUTXOs = async (\n address: string,\n network: \"mainnet\" | \"testnet\" | \"devnet\"\n): Promise<BtcUtxo[]> => {\n const apiUrl =\n network === \"mainnet\"\n ? \"https://mempool.space/api\"\n : \"https://mempool.space/testnet/api\";\n\n try {\n const response = await fetch(`${apiUrl}/address/${address}/utxo`);\n if (!response.ok) {\n throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);\n }\n return await response.json();\n } catch (error) {\n console.error(\"Error fetching UTXOs:\", error);\n throw new Error(\"Failed to fetch UTXOs.\");\n }\n};\n\nexport const fetchBTCFee = async (\n network: \"mainnet\" | \"testnet\" | \"devnet\"\n): Promise<number> => {\n const btcFetchFeeRpc =\n network !== \"mainnet\"\n ? \"https://mempool.space/testnet/api/v1/fees/recommended\"\n : \"https://mempool.space/api/v1/fees/recommended\";\n\n try {\n const response = await fetch(btcFetchFeeRpc);\n const data = await response.json();\n return network !== \"mainnet\" ? data.fastestFee : data.hourFee;\n } catch (error) {\n console.error(\"Error fetching BTC fee:\", error);\n throw new Error(\"Failed to fetch recommended fee.\");\n }\n};\n\nexport const broadcastBtcTransaction = async (\n txHex: string,\n network: \"mainnet\" | \"testnet\" | \"devnet\"\n): Promise<string> => {\n const apiUrl =\n network === \"mainnet\"\n ? \"https://mempool.space/api\"\n : \"https://mempool.space/testnet/api\";\n\n try {\n const response = await fetch(`${apiUrl}/tx`, {\n method: \"POST\",\n body: txHex,\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n // Emulate User's error checking logic:\n // \"JSON.parse(errorMessage.split(\"RPC error: \")[1])\"\n // But fetch might return plain text.\n try {\n if (errorText.includes(\"RPC error: \")) {\n const rpcErrorPart = errorText.split(\"RPC error: \")[1];\n const rpcError = JSON.parse(rpcErrorPart);\n if (\n rpcError.message.includes(\"dust\") ||\n rpcError.message.includes(\"non-standard\")\n ) {\n throw new Error(\n \"The transaction amount is too small to be broadcasted. Please increase the amount.\"\n );\n }\n }\n } catch (parseError) {\n // Ignore parse error, throw original\n }\n throw new Error(`Error: Failed to broadcast transaction. Details: ${errorText}`);\n }\n\n return await response.text();\n } catch (error: any) {\n console.error(\"Error broadcasting transaction:\", error);\n throw error;\n }\n};\n\nexport const addInputSafe = (psbt: bitcoin.Psbt, input: any) => {\n try {\n // Try v6 (BigInt) first\n psbt.addInput({\n ...input,\n witnessUtxo: {\n script: input.witnessUtxo.script,\n value: BigInt(input.witnessUtxo.value) as any,\n },\n });\n } catch (e: any) {\n // If ANY validation fails (likely expecting Number for v5), try Number\n try {\n psbt.addInput({\n ...input,\n witnessUtxo: {\n script: input.witnessUtxo.script,\n value: Number(input.witnessUtxo.value),\n },\n });\n } catch (e2) {\n // If both fail, throw the original error (or the new one)\n console.error(\"Failed to add input with BigInt:\", e);\n console.error(\"Failed to add input with Number:\", e2);\n throw e;\n }\n }\n};\n\nexport const addOutputSafe = (psbt: bitcoin.Psbt, output: { address: string; value: bigint | number | string }) => {\n try {\n // Try v6 (BigInt)\n psbt.addOutput({\n address: output.address,\n value: BigInt(output.value) as any,\n });\n } catch (e: any) {\n // Fallback to Number (v5) on ANY error\n try {\n psbt.addOutput({\n address: output.address,\n value: Number(output.value),\n });\n } catch (e2) {\n console.error(\"Failed to add output with BigInt:\", e);\n console.error(\"Failed to add output with Number:\", e2);\n throw e;\n }\n }\n};\n"],"mappings":"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","names":[]}
package/dist/index.cjs CHANGED
@@ -3004,6 +3004,111 @@ var init_createSolanaMultisigOrder = __esm({
3004
3004
  }
3005
3005
  });
3006
3006
 
3007
+ // src/strategies/btcServices/utils/btc-utils.ts
3008
+ var getBTCUTXOs, fetchBTCFee, broadcastBtcTransaction, addInputSafe, addOutputSafe;
3009
+ var init_btc_utils = __esm({
3010
+ "src/strategies/btcServices/utils/btc-utils.ts"() {
3011
+ "use strict";
3012
+ getBTCUTXOs = async (address3, network) => {
3013
+ const apiUrl = network === "mainnet" ? "https://mempool.space/api" : "https://mempool.space/testnet/api";
3014
+ try {
3015
+ const response = await fetch(`${apiUrl}/address/${address3}/utxo`);
3016
+ if (!response.ok) {
3017
+ throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
3018
+ }
3019
+ return await response.json();
3020
+ } catch (error) {
3021
+ console.error("Error fetching UTXOs:", error);
3022
+ throw new Error("Failed to fetch UTXOs.");
3023
+ }
3024
+ };
3025
+ fetchBTCFee = async (network) => {
3026
+ const btcFetchFeeRpc = network !== "mainnet" ? "https://mempool.space/testnet/api/v1/fees/recommended" : "https://mempool.space/api/v1/fees/recommended";
3027
+ try {
3028
+ const response = await fetch(btcFetchFeeRpc);
3029
+ const data = await response.json();
3030
+ return network !== "mainnet" ? data.fastestFee : data.hourFee;
3031
+ } catch (error) {
3032
+ console.error("Error fetching BTC fee:", error);
3033
+ throw new Error("Failed to fetch recommended fee.");
3034
+ }
3035
+ };
3036
+ broadcastBtcTransaction = async (txHex, network) => {
3037
+ const apiUrl = network === "mainnet" ? "https://mempool.space/api" : "https://mempool.space/testnet/api";
3038
+ try {
3039
+ const response = await fetch(`${apiUrl}/tx`, {
3040
+ method: "POST",
3041
+ body: txHex
3042
+ });
3043
+ if (!response.ok) {
3044
+ const errorText = await response.text();
3045
+ try {
3046
+ if (errorText.includes("RPC error: ")) {
3047
+ const rpcErrorPart = errorText.split("RPC error: ")[1];
3048
+ const rpcError = JSON.parse(rpcErrorPart);
3049
+ if (rpcError.message.includes("dust") || rpcError.message.includes("non-standard")) {
3050
+ throw new Error(
3051
+ "The transaction amount is too small to be broadcasted. Please increase the amount."
3052
+ );
3053
+ }
3054
+ }
3055
+ } catch (parseError) {
3056
+ }
3057
+ throw new Error(`Error: Failed to broadcast transaction. Details: ${errorText}`);
3058
+ }
3059
+ return await response.text();
3060
+ } catch (error) {
3061
+ console.error("Error broadcasting transaction:", error);
3062
+ throw error;
3063
+ }
3064
+ };
3065
+ addInputSafe = (psbt, input) => {
3066
+ try {
3067
+ psbt.addInput({
3068
+ ...input,
3069
+ witnessUtxo: {
3070
+ script: input.witnessUtxo.script,
3071
+ value: BigInt(input.witnessUtxo.value)
3072
+ }
3073
+ });
3074
+ } catch (e) {
3075
+ try {
3076
+ psbt.addInput({
3077
+ ...input,
3078
+ witnessUtxo: {
3079
+ script: input.witnessUtxo.script,
3080
+ value: Number(input.witnessUtxo.value)
3081
+ }
3082
+ });
3083
+ } catch (e2) {
3084
+ console.error("Failed to add input with BigInt:", e);
3085
+ console.error("Failed to add input with Number:", e2);
3086
+ throw e;
3087
+ }
3088
+ }
3089
+ };
3090
+ addOutputSafe = (psbt, output) => {
3091
+ try {
3092
+ psbt.addOutput({
3093
+ address: output.address,
3094
+ value: BigInt(output.value)
3095
+ });
3096
+ } catch (e) {
3097
+ try {
3098
+ psbt.addOutput({
3099
+ address: output.address,
3100
+ value: Number(output.value)
3101
+ });
3102
+ } catch (e2) {
3103
+ console.error("Failed to add output with BigInt:", e);
3104
+ console.error("Failed to add output with Number:", e2);
3105
+ throw e;
3106
+ }
3107
+ }
3108
+ };
3109
+ }
3110
+ });
3111
+
3007
3112
  // src/chains/evm/evm-validation.ts
3008
3113
  var evm_validation_exports = {};
3009
3114
  __export(evm_validation_exports, {
@@ -3785,67 +3890,6 @@ var init_sendSolanaTransaction = __esm({
3785
3890
  }
3786
3891
  });
3787
3892
 
3788
- // src/strategies/btcServices/utils/btc-utils.ts
3789
- var getBTCUTXOs, fetchBTCFee, broadcastBtcTransaction;
3790
- var init_btc_utils = __esm({
3791
- "src/strategies/btcServices/utils/btc-utils.ts"() {
3792
- "use strict";
3793
- getBTCUTXOs = async (address3, network) => {
3794
- const apiUrl = network === "mainnet" ? "https://mempool.space/api" : "https://mempool.space/testnet/api";
3795
- try {
3796
- const response = await fetch(`${apiUrl}/address/${address3}/utxo`);
3797
- if (!response.ok) {
3798
- throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
3799
- }
3800
- return await response.json();
3801
- } catch (error) {
3802
- console.error("Error fetching UTXOs:", error);
3803
- throw new Error("Failed to fetch UTXOs.");
3804
- }
3805
- };
3806
- fetchBTCFee = async (network) => {
3807
- const btcFetchFeeRpc = network !== "mainnet" ? "https://mempool.space/testnet/api/v1/fees/recommended" : "https://mempool.space/api/v1/fees/recommended";
3808
- try {
3809
- const response = await fetch(btcFetchFeeRpc);
3810
- const data = await response.json();
3811
- return network !== "mainnet" ? data.fastestFee : data.hourFee;
3812
- } catch (error) {
3813
- console.error("Error fetching BTC fee:", error);
3814
- throw new Error("Failed to fetch recommended fee.");
3815
- }
3816
- };
3817
- broadcastBtcTransaction = async (txHex, network) => {
3818
- const apiUrl = network === "mainnet" ? "https://mempool.space/api" : "https://mempool.space/testnet/api";
3819
- try {
3820
- const response = await fetch(`${apiUrl}/tx`, {
3821
- method: "POST",
3822
- body: txHex
3823
- });
3824
- if (!response.ok) {
3825
- const errorText = await response.text();
3826
- try {
3827
- if (errorText.includes("RPC error: ")) {
3828
- const rpcErrorPart = errorText.split("RPC error: ")[1];
3829
- const rpcError = JSON.parse(rpcErrorPart);
3830
- if (rpcError.message.includes("dust") || rpcError.message.includes("non-standard")) {
3831
- throw new Error(
3832
- "The transaction amount is too small to be broadcasted. Please increase the amount."
3833
- );
3834
- }
3835
- }
3836
- } catch (parseError) {
3837
- }
3838
- throw new Error(`Error: Failed to broadcast transaction. Details: ${errorText}`);
3839
- }
3840
- return await response.text();
3841
- } catch (error) {
3842
- console.error("Error broadcasting transaction:", error);
3843
- throw error;
3844
- }
3845
- };
3846
- }
3847
- });
3848
-
3849
3893
  // src/strategies/btcServices/sendBtcTransaction.ts
3850
3894
  var sendBtcTransaction_exports = {};
3851
3895
  __export(sendBtcTransaction_exports, {
@@ -3936,46 +3980,6 @@ var init_sendBtcTransaction = __esm({
3936
3980
  const amountSatsBigInt = BigInt(amountSats);
3937
3981
  const psbt = new bitcoin4.Psbt({ network: bitcoinNetwork });
3938
3982
  let totalInputAmount = 0;
3939
- const addInputSafe = (psbt2, input) => {
3940
- try {
3941
- psbt2.addInput({
3942
- ...input,
3943
- witnessUtxo: {
3944
- script: input.witnessUtxo.script,
3945
- value: BigInt(input.witnessUtxo.value)
3946
- }
3947
- });
3948
- } catch (e) {
3949
- if (e.message && (e.message.includes("value") || e.message.includes("Expected"))) {
3950
- psbt2.addInput({
3951
- ...input,
3952
- witnessUtxo: {
3953
- script: input.witnessUtxo.script,
3954
- value: Number(input.witnessUtxo.value)
3955
- }
3956
- });
3957
- } else {
3958
- throw e;
3959
- }
3960
- }
3961
- };
3962
- const addOutputSafe = (psbt2, output) => {
3963
- try {
3964
- psbt2.addOutput({
3965
- address: output.address,
3966
- value: output.value
3967
- });
3968
- } catch (e) {
3969
- if (e.message && (e.message.includes("value") || e.message.includes("Expected"))) {
3970
- psbt2.addOutput({
3971
- address: output.address,
3972
- value: Number(output.value)
3973
- });
3974
- } else {
3975
- throw e;
3976
- }
3977
- }
3978
- };
3979
3983
  for (const utxo of selectedUtxos) {
3980
3984
  addInputSafe(psbt, {
3981
3985
  hash: utxo.txid,
@@ -9680,6 +9684,7 @@ var import_ethers10 = require("ethers");
9680
9684
  var import_web38 = require("@solana/web3.js");
9681
9685
  var import_spl_token3 = require("@solana/spl-token");
9682
9686
  var import_tronweb3 = require("tronweb");
9687
+ init_btc_utils();
9683
9688
  var bitcoin3 = __toESM(require("bitcoinjs-lib"), 1);
9684
9689
  var import_ecpair3 = __toESM(require("ecpair"), 1);
9685
9690
  var ecc3 = __toESM(require("tiny-secp256k1"), 1);
@@ -10394,17 +10399,17 @@ var TransactionService = class {
10394
10399
  const psbt = new bitcoin3.Psbt({ network });
10395
10400
  let totalInputAmount = 0;
10396
10401
  for (const utxo of selectedUtxos) {
10397
- psbt.addInput({
10402
+ addInputSafe(psbt, {
10398
10403
  hash: utxo.txid,
10399
10404
  index: utxo.vout,
10400
10405
  witnessUtxo: {
10401
10406
  script: bitcoin3.address.toOutputScript(senderAddress, network),
10402
- value: BigInt(utxo.value)
10407
+ value: utxo.value
10403
10408
  }
10404
10409
  });
10405
10410
  totalInputAmount += utxo.value;
10406
10411
  }
10407
- psbt.addOutput({
10412
+ addOutputSafe(psbt, {
10408
10413
  address: txParams.to,
10409
10414
  value: amountSats
10410
10415
  });
@@ -10418,7 +10423,7 @@ var TransactionService = class {
10418
10423
  changeAmount = 0n;
10419
10424
  }
10420
10425
  if (changeAmount > 0n) {
10421
- psbt.addOutput({
10426
+ addOutputSafe(psbt, {
10422
10427
  address: senderAddress,
10423
10428
  value: changeAmount
10424
10429
  });
@@ -12283,6 +12288,7 @@ var TronStrategy = class {
12283
12288
  // src/strategies/btc.strategy.ts
12284
12289
  var import_buffer11 = require("buffer");
12285
12290
  init_key_reconstructor();
12291
+ init_btc_utils();
12286
12292
  init_types2();
12287
12293
  var LEGACY_INPUT_VBYTES = 148;
12288
12294
  var NESTED_INPUT_VBYTES = 74;
@@ -12534,12 +12540,12 @@ var BtcStrategy = class {
12534
12540
  value: utxo.value
12535
12541
  };
12536
12542
  }
12537
- psbt.addInput(inputData);
12543
+ addInputSafe(psbt, inputData);
12538
12544
  totalInputAmount += BigInt(utxo.value);
12539
12545
  }
12540
- psbt.addOutput({
12546
+ addOutputSafe(psbt, {
12541
12547
  address: to,
12542
- value: Number(amountSats)
12548
+ value: amountSats
12543
12549
  });
12544
12550
  const estimatedSize = BASE_VBYTES + utxos.length * NATIVE_INPUT_VBYTES + 2 * OUTPUT_VBYTES;
12545
12551
  const estimatedFeeSats = BigInt(Math.ceil(estimatedSize * feeRate));
@@ -12552,9 +12558,9 @@ var BtcStrategy = class {
12552
12558
  throw new Error(`Change amount is below the dust limit.`);
12553
12559
  }
12554
12560
  if (changeAmount > 0n) {
12555
- psbt.addOutput({
12561
+ addOutputSafe(psbt, {
12556
12562
  address: wallet.address,
12557
- value: Number(changeAmount)
12563
+ value: changeAmount
12558
12564
  });
12559
12565
  }
12560
12566
  const pubkey = import_buffer11.Buffer.from(keyPair.publicKey);