diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletTransaction.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletTransaction.java index f224e3e..36b0282 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletTransaction.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletTransaction.java @@ -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 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() {