mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-31 19:49:04 +00:00
Fix fee estimation for send all
This commit is contained in:
parent
b1caf79c1b
commit
fea7e7a097
2 changed files with 12 additions and 18 deletions
cw_bitcoin/lib
|
@ -245,24 +245,13 @@ abstract class ElectrumWalletBase
|
|||
throw BitcoinTransactionNoInputsException();
|
||||
}
|
||||
|
||||
int estimatedSize;
|
||||
if (network is BitcoinCashNetwork) {
|
||||
estimatedSize = ForkedTransactionBuilder.estimateTransactionSize(
|
||||
utxos: utxos,
|
||||
outputs: outputs,
|
||||
network: network as BitcoinCashNetwork,
|
||||
memo: memo,
|
||||
);
|
||||
} else {
|
||||
estimatedSize = BitcoinTransactionBuilder.estimateTransactionSize(
|
||||
utxos: utxos,
|
||||
outputs: outputs,
|
||||
network: network,
|
||||
memo: memo,
|
||||
);
|
||||
}
|
||||
|
||||
int fee = feeAmountWithFeeRate(feeRate, 0, 0, size: estimatedSize);
|
||||
int fee = await calcFee(
|
||||
utxos: utxos,
|
||||
outputs: outputs,
|
||||
network: network,
|
||||
memo: memo,
|
||||
feeRate: feeRate,
|
||||
);
|
||||
|
||||
if (fee == 0) {
|
||||
throw BitcoinTransactionNoFeeException();
|
||||
|
|
|
@ -298,6 +298,11 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
return await super.calcFee(utxos: utxos, outputs: outputs,
|
||||
network: network, memo: memo, feeRate: feeRate);
|
||||
}
|
||||
if (outputs.length == 1 && outputs[0].toOutput.amount == BigInt.zero) {
|
||||
outputs = [BitcoinScriptOutput(
|
||||
script: outputs[0].toOutput.scriptPubKey,
|
||||
value: utxos.sumOfUtxosValue())];
|
||||
}
|
||||
final txb = BitcoinTransactionBuilder(utxos: utxos,
|
||||
outputs: outputs, fee: BigInt.zero, network: network);
|
||||
final scanSecret = mwebHd.derive(0x80000000).privKey!;
|
||||
|
|
Loading…
Reference in a new issue