mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-25 17:46:44 +00:00
return zero total when some input values are not available
This commit is contained in:
parent
8ac3f47380
commit
d59da36506
1 changed files with 6 additions and 2 deletions
|
@ -91,7 +91,11 @@ public class WalletTransaction {
|
|||
}
|
||||
|
||||
public long getTotal() {
|
||||
return getSelectedUtxos().keySet().stream().mapToLong(BlockTransactionHashIndex::getValue).sum();
|
||||
return inputAmountsValid() ? getSelectedUtxos().keySet().stream().mapToLong(BlockTransactionHashIndex::getValue).sum() : 0;
|
||||
}
|
||||
|
||||
private boolean inputAmountsValid() {
|
||||
return getSelectedUtxos().keySet().stream().allMatch(ref -> ref.getValue() > 0);
|
||||
}
|
||||
|
||||
public Map<Sha256Hash, BlockTransaction> getInputTransactions() {
|
||||
|
@ -103,7 +107,7 @@ public class WalletTransaction {
|
|||
* @return the fee percentage
|
||||
*/
|
||||
public double getFeePercentage() {
|
||||
return getFee() == 0 ? 0 : (double)getFee() / (getTotal() - getFee());
|
||||
return getFee() <= 0 || getTotal() <= 0 ? 0 : (double)getFee() / (getTotal() - getFee());
|
||||
}
|
||||
|
||||
public boolean isCoinControlUsed() {
|
||||
|
|
Loading…
Reference in a new issue