btc-wallet 0.5.94-beta → 0.5.96-beta

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.
@@ -1,7 +1,7 @@
1
1
  import type { ENV } from '../config';
2
- import { checkBridgeTransactionStatus, calculateGasLimit } from '../utils/satoshi';
2
+ import { checkBridgeTransactionStatus, calculateGasLimit, calculateGasStrategy } from '../utils/satoshi';
3
3
  import type { FinalExecutionOutcome, Transaction } from '@near-wallet-selector/core';
4
- export { calculateGasLimit, checkBridgeTransactionStatus };
4
+ export { calculateGasLimit, calculateGasStrategy, checkBridgeTransactionStatus };
5
5
  type CheckGasTokenDebtReturnType<T extends boolean> = T extends true ? void : {
6
6
  receiver_id: string;
7
7
  amount: string;
@@ -30,6 +30,8 @@ export declare function sendBitcoin(address: string, amount: number, feeRate: nu
30
30
  export declare function signMessage(message: string): Promise<{
31
31
  signature: string;
32
32
  publicKey: string;
33
+ signatureBase58: any;
34
+ publicKeyBase58: any;
33
35
  }>;
34
36
  /** estimate deposit receive amount, deduct protocol fee and repay amount */
35
37
  export declare function estimateDepositAmount(amount: string, option?: {
package/dist/index.js CHANGED
@@ -107,6 +107,7 @@ __export(src_exports, {
107
107
  btcRpcUrls: () => btcRpcUrls,
108
108
  calculateGasFee: () => calculateGasFee,
109
109
  calculateGasLimit: () => calculateGasLimit,
110
+ calculateGasStrategy: () => calculateGasStrategy,
110
111
  calculateWithdraw: () => calculateWithdraw,
111
112
  checkBridgeTransactionStatus: () => checkBridgeTransactionStatus,
112
113
  checkGasTokenDebt: () => checkGasTokenDebt,
@@ -3061,7 +3062,7 @@ function getWalletConfig(env) {
3061
3062
  });
3062
3063
  }
3063
3064
  var nearRpcUrls = {
3064
- mainnet: ["https://free.rpc.fastnear.com", "https://near.lava.build"],
3065
+ mainnet: ["https://near.lava.build", "https://free.rpc.fastnear.com"],
3065
3066
  testnet: ["https://rpc.testnet.near.org"]
3066
3067
  };
3067
3068
  var btcRpcUrls = {
@@ -3829,6 +3830,7 @@ function getPredictedGasAmount(_0) {
3829
3830
  var bitcoin = __toESM(require("bitcoinjs-lib"), 1);
3830
3831
  var import_coinselect = __toESM(require("coinselect"), 1);
3831
3832
  var ecc = __toESM(require("@bitcoinerlab/secp256k1"), 1);
3833
+ var import_bs582 = __toESM(require("bs58"), 1);
3832
3834
  bitcoin.initEccLib(ecc);
3833
3835
  var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
3834
3836
  var NBTC_STORAGE_DEPOSIT_AMOUNT = 800;
@@ -3978,7 +3980,14 @@ function signMessage(message) {
3978
3980
  const { signMessage: signMessage2, getPublicKey } = getBtcProvider();
3979
3981
  const publicKey = yield getPublicKey();
3980
3982
  const signature = yield signMessage2(message);
3981
- return { signature, publicKey };
3983
+ const signatureBase58 = import_bs582.default.encode(Buffer.from(signature, "base64"));
3984
+ const publicKeyBase58 = import_bs582.default.encode(Buffer.from(publicKey, "hex"));
3985
+ return {
3986
+ signature,
3987
+ publicKey,
3988
+ signatureBase58,
3989
+ publicKeyBase58
3990
+ };
3982
3991
  });
3983
3992
  }
3984
3993
  function estimateDepositAmount(amount, option) {
@@ -4435,11 +4444,25 @@ function calculateWithdraw(_0) {
4435
4444
  }
4436
4445
  const userSatoshis = Number(satoshis);
4437
4446
  const maxBtcFee = Number(brgConfig.max_btc_gas_fee);
4438
- const { inputs, outputs, fee } = (0, import_coinselect.default)(
4447
+ let { inputs, outputs, fee } = (0, import_coinselect.default)(
4439
4448
  utxos,
4440
4449
  [{ address: btcAddress, value: userSatoshis }],
4441
4450
  Math.ceil(feeRate)
4442
4451
  );
4452
+ if (inputs && inputs.length > 10) {
4453
+ const filteredUtxos = utxos.filter((utxo) => utxo.value >= userSatoshis);
4454
+ console.log("filteredUtxos", filteredUtxos);
4455
+ if (filteredUtxos.length > 0) {
4456
+ const result = (0, import_coinselect.default)(
4457
+ filteredUtxos,
4458
+ [{ address: btcAddress, value: userSatoshis }],
4459
+ Math.ceil(feeRate)
4460
+ );
4461
+ inputs = result.inputs;
4462
+ outputs = result.outputs;
4463
+ fee = result.fee;
4464
+ }
4465
+ }
4443
4466
  const newInputs = inputs;
4444
4467
  let newOutputs = outputs;
4445
4468
  let newFee = fee;
@@ -5411,7 +5434,7 @@ function getGroup(state) {
5411
5434
 
5412
5435
  // src/index.ts
5413
5436
  var getVersion = () => {
5414
- return "0.5.94-beta";
5437
+ return "0.5.96-beta";
5415
5438
  };
5416
5439
  if (typeof window !== "undefined") {
5417
5440
  window.__BTC_WALLET_VERSION = getVersion();