mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Added verification for unspent coins while transaction creation.
This commit is contained in:
parent
4418532896
commit
b0724348a1
1 changed files with 5 additions and 4 deletions
|
@ -158,6 +158,9 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
const minAmount = 546;
|
||||
final transactionCredentials = credentials as BitcoinTransactionCredentials;
|
||||
final inputs = <BitcoinUnspent>[];
|
||||
final credentialsAmount = transactionCredentials.amount != null
|
||||
? stringDoubleToBitcoinAmount(transactionCredentials.amount)
|
||||
: 0;
|
||||
var allInputsAmount = 0;
|
||||
|
||||
if (unspentCoins.isEmpty) {
|
||||
|
@ -171,7 +174,8 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
}
|
||||
}
|
||||
|
||||
if (inputs.isEmpty) {
|
||||
if (inputs.isEmpty ||
|
||||
(credentialsAmount > 0 && allInputsAmount < credentialsAmount)) {
|
||||
throw BitcoinTransactionNoInputsException();
|
||||
}
|
||||
|
||||
|
@ -179,9 +183,6 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
|
|||
feeAmountForPriority(transactionCredentials.priority, inputs.length, 1);
|
||||
final allAmount = allInputsAmount - allAmountFee;
|
||||
|
||||
final credentialsAmount = transactionCredentials.amount != null
|
||||
? stringDoubleToBitcoinAmount(transactionCredentials.amount)
|
||||
: 0;
|
||||
final amount = transactionCredentials.amount == null ||
|
||||
allAmount - credentialsAmount < minAmount
|
||||
? allAmount
|
||||
|
|
Loading…
Reference in a new issue