Add check for neg. coins

This commit is contained in:
Manfred Karrer 2016-03-31 22:22:18 +02:00
parent f9a33a00ff
commit edbb7ddcc7

View file

@ -41,7 +41,7 @@ public class AddressTextField extends AnchorPane {
private final StringProperty address = new SimpleStringProperty(); private final StringProperty address = new SimpleStringProperty();
private final StringProperty paymentLabel = new SimpleStringProperty(); private final StringProperty paymentLabel = new SimpleStringProperty();
private final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>(); private final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>(Coin.ZERO);
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -142,6 +142,11 @@ public class AddressTextField extends AnchorPane {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private String getBitcoinURI() { private String getBitcoinURI() {
if (amountAsCoin.get().isNegative()) {
log.warn("Amount must not be negative");
setAmountAsCoin(Coin.ZERO);
}
return address.get() != null ? BitcoinURI.convertToBitcoinURI(address.get(), amountAsCoin.get(), return address.get() != null ? BitcoinURI.convertToBitcoinURI(address.get(), amountAsCoin.get(),
paymentLabel.get(), null) : ""; paymentLabel.get(), null) : "";
} }