multisigns-sdk 1.0.8 → 1.0.10

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/index.cjs CHANGED
@@ -3862,6 +3862,15 @@ var init_sendBtcTransaction = __esm({
3862
3862
  init_key_reconstructor();
3863
3863
  init_btc_utils();
3864
3864
  ECPair4 = (0, import_ecpair4.default)(ecc4);
3865
+ if (!("toJSON" in BigInt.prototype)) {
3866
+ Object.defineProperty(BigInt.prototype, "toJSON", {
3867
+ get() {
3868
+ return function() {
3869
+ return this.toString();
3870
+ };
3871
+ }
3872
+ });
3873
+ }
3865
3874
  sendBtcTransaction = async ({
3866
3875
  activeWallet,
3867
3876
  to,
@@ -3927,18 +3936,59 @@ var init_sendBtcTransaction = __esm({
3927
3936
  const amountSatsBigInt = BigInt(amountSats);
3928
3937
  const psbt = new bitcoin4.Psbt({ network: bitcoinNetwork });
3929
3938
  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
+ };
3930
3979
  for (const utxo of selectedUtxos) {
3931
- psbt.addInput({
3980
+ addInputSafe(psbt, {
3932
3981
  hash: utxo.txid,
3933
3982
  index: utxo.vout,
3934
3983
  witnessUtxo: {
3935
3984
  script: bitcoin4.address.toOutputScript(activeWallet.address, bitcoinNetwork),
3936
- value: BigInt(utxo.value)
3985
+ value: utxo.value
3986
+ // pass raw number, conversion handled in helper
3937
3987
  }
3938
3988
  });
3939
3989
  totalInputAmount += utxo.value;
3940
3990
  }
3941
- psbt.addOutput({
3991
+ addOutputSafe(psbt, {
3942
3992
  address: to,
3943
3993
  value: amountSatsBigInt
3944
3994
  });
@@ -3952,7 +4002,7 @@ var init_sendBtcTransaction = __esm({
3952
4002
  changeAmount = 0n;
3953
4003
  }
3954
4004
  if (changeAmount > 0n) {
3955
- psbt.addOutput({
4005
+ addOutputSafe(psbt, {
3956
4006
  address: activeWallet.address,
3957
4007
  value: changeAmount
3958
4008
  });
@@ -12553,7 +12603,7 @@ var BtcStrategy = class {
12553
12603
  async estimateBitcoinNativeFee(wallet, inputParams) {
12554
12604
  const fetchCurrentFeeRate = async () => {
12555
12605
  try {
12556
- const response = await fetch(`${this.getMempoolApiUrl()}v1/fees/recommended`);
12606
+ const response = await fetch(`${this.getMempoolApiUrl()}/v1/fees/recommended`);
12557
12607
  if (!response.ok) throw new Error("Failed to fetch fee rates");
12558
12608
  const data = await response.json();
12559
12609
  return data.halfHourFee || FALLBACK_FEE_RATE;