mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
display output send type better, handle consolidation sends
This commit is contained in:
parent
3f68ca43c2
commit
7751f940f2
6 changed files with 42 additions and 31 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 59d610f5395cab69a33cf675b3fb116f7e09394c
|
Subproject commit c7e16a29e33d802ac209c046eddb5e040b76f704
|
|
@ -270,10 +270,11 @@ public class TransactionDiagram extends GridPane {
|
||||||
outputsBox.setAlignment(Pos.CENTER_LEFT);
|
outputsBox.setAlignment(Pos.CENTER_LEFT);
|
||||||
outputsBox.getChildren().add(createSpacer());
|
outputsBox.getChildren().add(createSpacer());
|
||||||
|
|
||||||
|
boolean isConsolidation = walletTx.isConsolidationSend();
|
||||||
String recipientDesc = walletTx.getRecipientAddress().toString().substring(0, 8) + "...";
|
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");
|
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);
|
recipientLabel.setTooltip(recipientTooltip);
|
||||||
outputsBox.getChildren().add(recipientLabel);
|
outputsBox.getChildren().add(recipientLabel);
|
||||||
outputsBox.getChildren().add(createSpacer());
|
outputsBox.getChildren().add(createSpacer());
|
||||||
|
@ -323,14 +324,21 @@ public class TransactionDiagram extends GridPane {
|
||||||
return spacer;
|
return spacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Glyph getSendGlyph() {
|
public static Glyph getPaymentGlyph() {
|
||||||
Glyph sendGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.SEND);
|
Glyph paymentGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.SEND);
|
||||||
sendGlyph.getStyleClass().add("send-icon");
|
paymentGlyph.getStyleClass().add("payment-icon");
|
||||||
sendGlyph.setFontSize(12);
|
paymentGlyph.setFontSize(12);
|
||||||
return sendGlyph;
|
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);
|
Glyph changeGlyph = new Glyph("Font Awesome 5 Free Solid", FontAwesome5.Glyph.COINS);
|
||||||
changeGlyph.getStyleClass().add("change-icon");
|
changeGlyph.getStyleClass().add("change-icon");
|
||||||
changeGlyph.setFontSize(12);
|
changeGlyph.setFontSize(12);
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class FontAwesome5 extends GlyphFont {
|
||||||
PEN_FANCY('\uf5ac'),
|
PEN_FANCY('\uf5ac'),
|
||||||
QRCODE('\uf029'),
|
QRCODE('\uf029'),
|
||||||
QUESTION_CIRCLE('\uf059'),
|
QUESTION_CIRCLE('\uf059'),
|
||||||
|
REPLY_ALL('\uf122'),
|
||||||
SATELLITE_DISH('\uf7c0'),
|
SATELLITE_DISH('\uf7c0'),
|
||||||
SD_CARD('\uf7c2'),
|
SD_CARD('\uf7c2'),
|
||||||
SEARCH('\uf002'),
|
SEARCH('\uf002'),
|
||||||
|
|
|
@ -9,10 +9,7 @@ import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
||||||
import com.sparrowwallet.drongo.wallet.BlockTransaction;
|
import com.sparrowwallet.drongo.wallet.BlockTransaction;
|
||||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||||
import com.sparrowwallet.sparrow.EventManager;
|
import com.sparrowwallet.sparrow.EventManager;
|
||||||
import com.sparrowwallet.sparrow.control.AddressLabel;
|
import com.sparrowwallet.sparrow.control.*;
|
||||||
import com.sparrowwallet.sparrow.control.CoinLabel;
|
|
||||||
import com.sparrowwallet.sparrow.control.CopyableLabel;
|
|
||||||
import com.sparrowwallet.sparrow.control.ScriptArea;
|
|
||||||
import com.sparrowwallet.sparrow.event.BitcoinUnitChangedEvent;
|
import com.sparrowwallet.sparrow.event.BitcoinUnitChangedEvent;
|
||||||
import com.sparrowwallet.sparrow.event.BlockTransactionOutputsFetchedEvent;
|
import com.sparrowwallet.sparrow.event.BlockTransactionOutputsFetchedEvent;
|
||||||
import com.sparrowwallet.sparrow.event.ViewTransactionEvent;
|
import com.sparrowwallet.sparrow.event.ViewTransactionEvent;
|
||||||
|
@ -40,9 +37,6 @@ public class OutputController extends TransactionFormController implements Initi
|
||||||
@FXML
|
@FXML
|
||||||
private CopyableLabel to;
|
private CopyableLabel to;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private CopyableLabel walletType;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private AddressLabel address;
|
private AddressLabel address;
|
||||||
|
|
||||||
|
@ -69,7 +63,10 @@ public class OutputController extends TransactionFormController implements Initi
|
||||||
public void initializeView() {
|
public void initializeView() {
|
||||||
TransactionOutput txOutput = outputForm.getTransactionOutput();
|
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());
|
value.setValue(txOutput.getValue());
|
||||||
to.setVisible(false);
|
to.setVisible(false);
|
||||||
|
@ -85,13 +82,6 @@ public class OutputController extends TransactionFormController implements Initi
|
||||||
//ignore
|
//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());
|
spentField.managedProperty().bind(spentField.visibleProperty());
|
||||||
spentByField.managedProperty().bind(spentByField.visibleProperty());
|
spentByField.managedProperty().bind(spentByField.visibleProperty());
|
||||||
spentByField.setVisible(false);
|
spentByField.setVisible(false);
|
||||||
|
@ -109,18 +99,26 @@ public class OutputController extends TransactionFormController implements Initi
|
||||||
scriptPubKeyArea.appendScript(txOutput.getScript(), null, null);
|
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) {
|
if(signingWallet != null) {
|
||||||
walletType.setVisible(true);
|
|
||||||
if(signingWallet.getWalletOutputScripts(KeyPurpose.RECEIVE).containsKey(txOutput.getScript())) {
|
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())) {
|
} else if(signingWallet.getWalletOutputScripts(KeyPurpose.CHANGE).containsKey(txOutput.getScript())) {
|
||||||
walletType.setText("(Change)");
|
outputFieldset.setText(baseText + " - Change");
|
||||||
|
outputFieldset.setIcon(TransactionDiagram.getChangeGlyph());
|
||||||
} else {
|
} else {
|
||||||
walletType.setText("(Payment)");
|
outputFieldset.setText(baseText + " - Payment");
|
||||||
|
outputFieldset.setIcon(TransactionDiagram.getPaymentGlyph());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
walletType.setVisible(false);
|
outputFieldset.setText(baseText);
|
||||||
|
outputFieldset.setIcon(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,3 +29,8 @@
|
||||||
#spentByField .input-container {
|
#spentByField .input-container {
|
||||||
-fx-alignment: center-left;
|
-fx-alignment: center-left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.legend {
|
||||||
|
-fx-content-display: RIGHT;
|
||||||
|
-fx-graphic-text-gap: 5px;
|
||||||
|
}
|
|
@ -34,7 +34,6 @@
|
||||||
<CoinLabel fx:id="value"/>
|
<CoinLabel fx:id="value"/>
|
||||||
<CopyableLabel fx:id="to" text="to" />
|
<CopyableLabel fx:id="to" text="to" />
|
||||||
<AddressLabel fx:id="address" />
|
<AddressLabel fx:id="address" />
|
||||||
<CopyableLabel fx:id="walletType" />
|
|
||||||
</Field>
|
</Field>
|
||||||
<Field fx:id="spentField" text="Spent?">
|
<Field fx:id="spentField" text="Spent?">
|
||||||
<Label fx:id="spent" />
|
<Label fx:id="spent" />
|
||||||
|
|
Loading…
Reference in a new issue