Skip to content

Commit

Permalink
fix: fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming committed May 9, 2024
1 parent 7e3cd66 commit 1eebebb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/engine/src/vaults/VaultBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,10 @@ export abstract class VaultBase extends VaultBaseChainOnly {
const confirmedUTXOs = utxos.sort((a, b) =>
new BigNumber(b.value).gt(a.value) ? 1 : -1,
);
const sum = new BigNumber(0);
let sum = new BigNumber(0);
let i = 0;
for (i = 0; i < confirmedUTXOs.length; i += 1) {
sum.plus(confirmedUTXOs[i].value);
sum = sum.plus(confirmedUTXOs[i].value);
if (sum.gt(amount)) {
break;
}
Expand Down
15 changes: 5 additions & 10 deletions packages/engine/src/vaults/impl/nexa/Vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,16 @@ export default class Vault extends VaultBase {
.reduce((acc, cur) => acc.plus(cur.value), new BigNumber(0));
throw new OneKeyInternalError(
`Too many vins, The maximum amount for this transfer is ${maximumAmount
.shiftedBy(network.decimals)
.toFixed()} satoshi.`,
.shiftedBy(-network.decimals)
.toFixed()} ${network.symbol}.`,
);
}
encodedTx.inputs = confirmedUTXOs;
return {
inputs: [],
outputs: [],
payload: {
encodedTx: {
...encodedTx,
inputs: confirmedUTXOs.map((utxo) => ({
...utxo,
satoshis: utxo.value,
})),
},
encodedTx,
},
encodedTx,
};
Expand All @@ -349,7 +344,7 @@ export default class Vault extends VaultBase {
const localEstimateFee = estimateFee(encodedTx);
const feeInfo = specifiedFeeRate
? estimateFee(encodedTx, Number(specifiedFeeRate))
: Math.min(remoteEstimateFee, localEstimateFee);
: Math.max(remoteEstimateFee, localEstimateFee);
return {
nativeSymbol: network.symbol,
nativeDecimals: network.decimals,
Expand Down

0 comments on commit 1eebebb

Please sign in to comment.