mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2026-08-09 08:14:43 +00:00
display output send type better, handle consolidation sends
This commit is contained in:
@@ -270,10 +270,11 @@ public class TransactionDiagram extends GridPane {
|
||||
outputsBox.setAlignment(Pos.CENTER_LEFT);
|
||||
outputsBox.getChildren().add(createSpacer());
|
||||
|
||||
boolean isConsolidation = walletTx.isConsolidationSend();
|
||||
String recipientDesc = walletTx.getRecipientAddress().toString().substring(0, 8) + "...";
|
||||
Label recipientLabel = new Label(recipientDesc, getSendGlyph());
|
||||
Label recipientLabel = new Label(recipientDesc, isConsolidation ? getConsolidationGlyph() : getPaymentGlyph());
|
||||
recipientLabel.getStyleClass().addAll("output-label", "recipient-label");
|
||||
Tooltip recipientTooltip = new Tooltip("Send " + getSatsValue(walletTx.getRecipientAmount()) + " sats to\n" + walletTx.getRecipientAddress().toString());
|
||||
Tooltip recipientTooltip = new Tooltip((isConsolidation ? "Consolidate " : "Pay ") + getSatsValue(walletTx.getRecipientAmount()) + " sats to\n" + walletTx.getRecipientAddress().toString());
|
||||
recipientLabel.setTooltip(recipientTooltip);
|
||||
outputsBox.getChildren().add(recipientLabel);
|
||||
outputsBox.getChildren().add(createSpacer());
|
||||
@@ -323,14 +324,21 @@ public class TransactionDiagram extends GridPane {
|
||||
return spacer;
|
||||
}
|
||||
|
||||
private Glyph getSendGlyph() {
|
||||
Glyph sendGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.SEND);
|
||||
sendGlyph.getStyleClass().add("send-icon");
|
||||
sendGlyph.setFontSize(12);
|
||||
return sendGlyph;
|
||||
public static Glyph getPaymentGlyph() {
|
||||
Glyph paymentGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.SEND);
|
||||
paymentGlyph.getStyleClass().add("payment-icon");
|
||||
paymentGlyph.setFontSize(12);
|
||||
return paymentGlyph;
|
||||
}
|
||||
|
||||
private Glyph getChangeGlyph() {
|
||||
public static Glyph getConsolidationGlyph() {
|
||||
Glyph consolidationGlyph = new Glyph("Font Awesome 5 Free Solid", FontAwesome5.Glyph.REPLY_ALL);
|
||||
consolidationGlyph.getStyleClass().add("consolidation-icon");
|
||||
consolidationGlyph.setFontSize(12);
|
||||
return consolidationGlyph;
|
||||
}
|
||||
|
||||
public static Glyph getChangeGlyph() {
|
||||
Glyph changeGlyph = new Glyph("Font Awesome 5 Free Solid", FontAwesome5.Glyph.COINS);
|
||||
changeGlyph.getStyleClass().add("change-icon");
|
||||
changeGlyph.setFontSize(12);
|
||||
|
||||
@@ -36,6 +36,7 @@ public class FontAwesome5 extends GlyphFont {
|
||||
PEN_FANCY('\uf5ac'),
|
||||
QRCODE('\uf029'),
|
||||
QUESTION_CIRCLE('\uf059'),
|
||||
REPLY_ALL('\uf122'),
|
||||
SATELLITE_DISH('\uf7c0'),
|
||||
SD_CARD('\uf7c2'),
|
||||
SEARCH('\uf002'),
|
||||
|
||||
@@ -9,10 +9,7 @@ import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
||||
import com.sparrowwallet.drongo.wallet.BlockTransaction;
|
||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||
import com.sparrowwallet.sparrow.EventManager;
|
||||
import com.sparrowwallet.sparrow.control.AddressLabel;
|
||||
import com.sparrowwallet.sparrow.control.CoinLabel;
|
||||
import com.sparrowwallet.sparrow.control.CopyableLabel;
|
||||
import com.sparrowwallet.sparrow.control.ScriptArea;
|
||||
import com.sparrowwallet.sparrow.control.*;
|
||||
import com.sparrowwallet.sparrow.event.BitcoinUnitChangedEvent;
|
||||
import com.sparrowwallet.sparrow.event.BlockTransactionOutputsFetchedEvent;
|
||||
import com.sparrowwallet.sparrow.event.ViewTransactionEvent;
|
||||
@@ -40,9 +37,6 @@ public class OutputController extends TransactionFormController implements Initi
|
||||
@FXML
|
||||
private CopyableLabel to;
|
||||
|
||||
@FXML
|
||||
private CopyableLabel walletType;
|
||||
|
||||
@FXML
|
||||
private AddressLabel address;
|
||||
|
||||
@@ -69,7 +63,10 @@ public class OutputController extends TransactionFormController implements Initi
|
||||
public void initializeView() {
|
||||
TransactionOutput txOutput = outputForm.getTransactionOutput();
|
||||
|
||||
outputFieldset.setText("Output #" + txOutput.getIndex());
|
||||
outputForm.signingWalletProperty().addListener((observable, oldValue, signingWallet) -> {
|
||||
updateOutputLegendFromWallet(txOutput, signingWallet);
|
||||
});
|
||||
updateOutputLegendFromWallet(txOutput, outputForm.getSigningWallet());
|
||||
|
||||
value.setValue(txOutput.getValue());
|
||||
to.setVisible(false);
|
||||
@@ -85,13 +82,6 @@ public class OutputController extends TransactionFormController implements Initi
|
||||
//ignore
|
||||
}
|
||||
|
||||
walletType.managedProperty().bind(walletType.visibleProperty());
|
||||
walletType.setVisible(false);
|
||||
outputForm.signingWalletProperty().addListener((observable, oldValue, signingWallet) -> {
|
||||
updateWalletType(txOutput, signingWallet);
|
||||
});
|
||||
updateWalletType(txOutput, outputForm.getSigningWallet());
|
||||
|
||||
spentField.managedProperty().bind(spentField.visibleProperty());
|
||||
spentByField.managedProperty().bind(spentByField.visibleProperty());
|
||||
spentByField.setVisible(false);
|
||||
@@ -109,18 +99,26 @@ public class OutputController extends TransactionFormController implements Initi
|
||||
scriptPubKeyArea.appendScript(txOutput.getScript(), null, null);
|
||||
}
|
||||
|
||||
private void updateWalletType(TransactionOutput txOutput, Wallet signingWallet) {
|
||||
private String getLegendText(TransactionOutput txOutput) {
|
||||
return "Output #" + txOutput.getIndex();
|
||||
}
|
||||
|
||||
private void updateOutputLegendFromWallet(TransactionOutput txOutput, Wallet signingWallet) {
|
||||
String baseText = getLegendText(txOutput);
|
||||
if(signingWallet != null) {
|
||||
walletType.setVisible(true);
|
||||
if(signingWallet.getWalletOutputScripts(KeyPurpose.RECEIVE).containsKey(txOutput.getScript())) {
|
||||
walletType.setText("(Consolidation)");
|
||||
outputFieldset.setText(baseText + " - Consolidation");
|
||||
outputFieldset.setIcon(TransactionDiagram.getConsolidationGlyph());
|
||||
} else if(signingWallet.getWalletOutputScripts(KeyPurpose.CHANGE).containsKey(txOutput.getScript())) {
|
||||
walletType.setText("(Change)");
|
||||
outputFieldset.setText(baseText + " - Change");
|
||||
outputFieldset.setIcon(TransactionDiagram.getChangeGlyph());
|
||||
} else {
|
||||
walletType.setText("(Payment)");
|
||||
outputFieldset.setText(baseText + " - Payment");
|
||||
outputFieldset.setIcon(TransactionDiagram.getPaymentGlyph());
|
||||
}
|
||||
} else {
|
||||
walletType.setVisible(false);
|
||||
outputFieldset.setText(baseText);
|
||||
outputFieldset.setIcon(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user