various minor fixes

This commit is contained in:
Craig Raw 2021-12-13 12:45:21 +02:00
parent 880096a193
commit 4da82b110c
4 changed files with 28 additions and 22 deletions

View file

@ -331,7 +331,7 @@ public class AppController implements Initializable {
sendToMany.disableProperty().bind(exportWallet.disableProperty()); sendToMany.disableProperty().bind(exportWallet.disableProperty());
findMixingPartner.setDisable(true); findMixingPartner.setDisable(true);
AppServices.onlineProperty().addListener((observable, oldValue, newValue) -> { AppServices.onlineProperty().addListener((observable, oldValue, newValue) -> {
findMixingPartner.setDisable(exportWallet.isDisable() || !SorobanServices.canWalletMix(getSelectedWalletForm().getWallet()) || !newValue); findMixingPartner.setDisable(exportWallet.isDisable() || getSelectedWalletForm() == null || !SorobanServices.canWalletMix(getSelectedWalletForm().getWallet()) || !newValue);
}); });
setServerType(Config.get().getServerType()); setServerType(Config.get().getServerType());
@ -1495,6 +1495,7 @@ public class AppController implements Initializable {
public WalletForm getSelectedWalletForm() { public WalletForm getSelectedWalletForm() {
Tab selectedTab = tabs.getSelectionModel().getSelectedItem(); Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
if(selectedTab != null) {
TabData tabData = (TabData)selectedTab.getUserData(); TabData tabData = (TabData)selectedTab.getUserData();
if(tabData instanceof WalletTabData) { if(tabData instanceof WalletTabData) {
TabPane subTabs = (TabPane)selectedTab.getContent(); TabPane subTabs = (TabPane)selectedTab.getContent();
@ -1502,6 +1503,7 @@ public class AppController implements Initializable {
WalletTabData subWalletTabData = (WalletTabData)selectedSubTab.getUserData(); WalletTabData subWalletTabData = (WalletTabData)selectedSubTab.getUserData();
return subWalletTabData.getWalletForm(); return subWalletTabData.getWalletForm();
} }
}
return null; return null;
} }

View file

@ -507,7 +507,7 @@ public class TransactionDiagram extends GridPane {
recipientTooltip.setShowDelay(new Duration(TOOLTIP_SHOW_DELAY)); recipientTooltip.setShowDelay(new Duration(TOOLTIP_SHOW_DELAY));
recipientTooltip.setShowDuration(Duration.INDEFINITE); recipientTooltip.setShowDuration(Duration.INDEFINITE);
recipientLabel.setTooltip(recipientTooltip); recipientLabel.setTooltip(recipientTooltip);
outputNodes.add(new OutputNode(recipientLabel, payment.getAddress())); outputNodes.add(new OutputNode(recipientLabel, payment.getAddress(), payment.getAmount()));
} }
for(Map.Entry<WalletNode, Long> changeEntry : walletTx.getChangeMap().entrySet()) { for(Map.Entry<WalletNode, Long> changeEntry : walletTx.getChangeMap().entrySet()) {
@ -543,7 +543,7 @@ public class TransactionDiagram extends GridPane {
actionBox.getChildren().add(replaceChangeLabel); actionBox.getChildren().add(replaceChangeLabel);
} }
outputNodes.add(new OutputNode(actionBox, changeAddress)); outputNodes.add(new OutputNode(actionBox, changeAddress, changeEntry.getValue()));
} }
if(isFinal()) { if(isFinal()) {
@ -634,7 +634,7 @@ public class TransactionDiagram extends GridPane {
if(payment.getType() == Payment.Type.WHIRLPOOL_FEE) { if(payment.getType() == Payment.Type.WHIRLPOOL_FEE) {
return "Whirlpool Fee"; return "Whirlpool Fee";
} else if(walletTx.isPremixSend(payment)) { } else if(walletTx.isPremixSend(payment)) {
int premixIndex = getOutputIndex(payment.getAddress()) - 2; int premixIndex = getOutputIndex(payment.getAddress(), payment.getAmount()) - 2;
return "Premix #" + premixIndex; return "Premix #" + premixIndex;
} else if(walletTx.isBadbankSend(payment)) { } else if(walletTx.isBadbankSend(payment)) {
return "Badbank Change"; return "Badbank Change";
@ -643,8 +643,8 @@ public class TransactionDiagram extends GridPane {
return null; return null;
} }
private int getOutputIndex(Address address) { private int getOutputIndex(Address address, long amount) {
return walletTx.getTransaction().getOutputs().stream().filter(txOutput -> address.equals(txOutput.getScript().getToAddress())).mapToInt(TransactionOutput::getIndex).findFirst().orElseThrow(); return walletTx.getTransaction().getOutputs().stream().filter(txOutput -> address.equals(txOutput.getScript().getToAddress()) && txOutput.getValue() == amount).mapToInt(TransactionOutput::getIndex).findFirst().orElseThrow();
} }
private Wallet getToWallet(Payment payment) { private Wallet getToWallet(Payment payment) {
@ -949,16 +949,18 @@ public class TransactionDiagram extends GridPane {
private class OutputNode implements Comparable<OutputNode> { private class OutputNode implements Comparable<OutputNode> {
public Node outputLabel; public Node outputLabel;
public Address address; public Address address;
public long amount;
public OutputNode(Node outputLabel, Address address) { public OutputNode(Node outputLabel, Address address, long amount) {
this.outputLabel = outputLabel; this.outputLabel = outputLabel;
this.address = address; this.address = address;
this.amount = amount;
} }
@Override @Override
public int compareTo(TransactionDiagram.OutputNode o) { public int compareTo(TransactionDiagram.OutputNode o) {
try { try {
return getOutputIndex(address) - getOutputIndex(o.address); return getOutputIndex(address, amount) - getOutputIndex(o.address, o.amount);
} catch(Exception e) { } catch(Exception e) {
return 0; return 0;
} }

View file

@ -1288,7 +1288,7 @@ public class SendController extends WalletFormController implements Initializabl
whirlpoolProperty.set(event.getPool()); whirlpoolProperty.set(event.getPool());
updateTransaction(event.getPayments() == null || event.getPayments().stream().anyMatch(Payment::isSendMax)); updateTransaction(event.getPayments() == null || event.getPayments().stream().anyMatch(Payment::isSendMax));
boolean isWhirlpoolPremix = (event.getPayments() != null && event.getPayments().stream().anyMatch(payment -> payment.getType().equals(Payment.Type.WHIRLPOOL_FEE))); boolean isWhirlpoolPremix = (event.getPool() != null);
setInputFieldsDisabled(isWhirlpoolPremix); setInputFieldsDisabled(isWhirlpoolPremix);
premixButton.setVisible(isWhirlpoolPremix); premixButton.setVisible(isWhirlpoolPremix);
premixButton.setDefaultButton(isWhirlpoolPremix); premixButton.setDefaultButton(isWhirlpoolPremix);

View file

@ -328,6 +328,7 @@ public class UtxosController extends WalletFormController implements Initializab
Wallet badbankWallet = masterWallet.getChildWallet(StandardAccount.WHIRLPOOL_BADBANK); Wallet badbankWallet = masterWallet.getChildWallet(StandardAccount.WHIRLPOOL_BADBANK);
List<Payment> payments = new ArrayList<>(); List<Payment> payments = new ArrayList<>();
if(tx0Preview.getTx0Data().getFeeAddress() != null) {
try { try {
Address whirlpoolFeeAddress = Address.fromString(tx0Preview.getTx0Data().getFeeAddress()); Address whirlpoolFeeAddress = Address.fromString(tx0Preview.getTx0Data().getFeeAddress());
Payment whirlpoolFeePayment = new Payment(whirlpoolFeeAddress, "Whirlpool Fee", tx0Preview.getFeeValue(), false); Payment whirlpoolFeePayment = new Payment(whirlpoolFeeAddress, "Whirlpool Fee", tx0Preview.getFeeValue(), false);
@ -336,6 +337,7 @@ public class UtxosController extends WalletFormController implements Initializab
} catch(InvalidAddressException e) { } catch(InvalidAddressException e) {
throw new IllegalStateException("Cannot parse whirlpool fee address " + tx0Preview.getTx0Data().getFeeAddress(), e); throw new IllegalStateException("Cannot parse whirlpool fee address " + tx0Preview.getTx0Data().getFeeAddress(), e);
} }
}
WalletNode badbankNode = badbankWallet.getFreshNode(KeyPurpose.RECEIVE); WalletNode badbankNode = badbankWallet.getFreshNode(KeyPurpose.RECEIVE);
Payment changePayment = new Payment(badbankWallet.getAddress(badbankNode), "Badbank Change", tx0Preview.getChangeValue(), false); Payment changePayment = new Payment(badbankWallet.getAddress(badbankNode), "Badbank Change", tx0Preview.getChangeValue(), false);