multisigns-sdk 1.0.9 → 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
@@ -3936,18 +3936,59 @@ var init_sendBtcTransaction = __esm({
3936
3936
  const amountSatsBigInt = BigInt(amountSats);
3937
3937
  const psbt = new bitcoin4.Psbt({ network: bitcoinNetwork });
3938
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
+ };
3939
3979
  for (const utxo of selectedUtxos) {
3940
- psbt.addInput({
3980
+ addInputSafe(psbt, {
3941
3981
  hash: utxo.txid,
3942
3982
  index: utxo.vout,
3943
3983
  witnessUtxo: {
3944
3984
  script: bitcoin4.address.toOutputScript(activeWallet.address, bitcoinNetwork),
3945
- value: BigInt(utxo.value)
3985
+ value: utxo.value
3986
+ // pass raw number, conversion handled in helper
3946
3987
  }
3947
3988
  });
3948
3989
  totalInputAmount += utxo.value;
3949
3990
  }
3950
- psbt.addOutput({
3991
+ addOutputSafe(psbt, {
3951
3992
  address: to,
3952
3993
  value: amountSatsBigInt
3953
3994
  });
@@ -3961,7 +4002,7 @@ var init_sendBtcTransaction = __esm({
3961
4002
  changeAmount = 0n;
3962
4003
  }
3963
4004
  if (changeAmount > 0n) {
3964
- psbt.addOutput({
4005
+ addOutputSafe(psbt, {
3965
4006
  address: activeWallet.address,
3966
4007
  value: changeAmount
3967
4008
  });