mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
various minor fixes
This commit is contained in:
parent
880096a193
commit
4da82b110c
4 changed files with 28 additions and 22 deletions
|
@ -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,12 +1495,14 @@ public class AppController implements Initializable {
|
||||||
|
|
||||||
public WalletForm getSelectedWalletForm() {
|
public WalletForm getSelectedWalletForm() {
|
||||||
Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
|
Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
|
||||||
TabData tabData = (TabData)selectedTab.getUserData();
|
if(selectedTab != null) {
|
||||||
if(tabData instanceof WalletTabData) {
|
TabData tabData = (TabData)selectedTab.getUserData();
|
||||||
TabPane subTabs = (TabPane)selectedTab.getContent();
|
if(tabData instanceof WalletTabData) {
|
||||||
Tab selectedSubTab = subTabs.getSelectionModel().getSelectedItem();
|
TabPane subTabs = (TabPane)selectedTab.getContent();
|
||||||
WalletTabData subWalletTabData = (WalletTabData)selectedSubTab.getUserData();
|
Tab selectedSubTab = subTabs.getSelectionModel().getSelectedItem();
|
||||||
return subWalletTabData.getWalletForm();
|
WalletTabData subWalletTabData = (WalletTabData)selectedSubTab.getUserData();
|
||||||
|
return subWalletTabData.getWalletForm();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -328,13 +328,15 @@ 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<>();
|
||||||
try {
|
if(tx0Preview.getTx0Data().getFeeAddress() != null) {
|
||||||
Address whirlpoolFeeAddress = Address.fromString(tx0Preview.getTx0Data().getFeeAddress());
|
try {
|
||||||
Payment whirlpoolFeePayment = new Payment(whirlpoolFeeAddress, "Whirlpool Fee", tx0Preview.getFeeValue(), false);
|
Address whirlpoolFeeAddress = Address.fromString(tx0Preview.getTx0Data().getFeeAddress());
|
||||||
whirlpoolFeePayment.setType(Payment.Type.WHIRLPOOL_FEE);
|
Payment whirlpoolFeePayment = new Payment(whirlpoolFeeAddress, "Whirlpool Fee", tx0Preview.getFeeValue(), false);
|
||||||
payments.add(whirlpoolFeePayment);
|
whirlpoolFeePayment.setType(Payment.Type.WHIRLPOOL_FEE);
|
||||||
} catch(InvalidAddressException e) {
|
payments.add(whirlpoolFeePayment);
|
||||||
throw new IllegalStateException("Cannot parse whirlpool fee address " + tx0Preview.getTx0Data().getFeeAddress(), e);
|
} catch(InvalidAddressException 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);
|
||||||
|
|
Loading…
Reference in a new issue