mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
add tx tree icons and input descriptions when signing
This commit is contained in:
parent
dc33b64a9c
commit
1392199f5c
8 changed files with 101 additions and 17 deletions
|
@ -431,6 +431,17 @@ public class TransactionDiagram extends GridPane {
|
||||||
return consolidationGlyph;
|
return consolidationGlyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Glyph getTxoGlyph() {
|
||||||
|
return getChangeGlyph();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Glyph getPayjoinGlyph() {
|
||||||
|
Glyph payjoinGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.RANDOM);
|
||||||
|
payjoinGlyph.getStyleClass().add("payjoin-icon");
|
||||||
|
payjoinGlyph.setFontSize(12);
|
||||||
|
return payjoinGlyph;
|
||||||
|
}
|
||||||
|
|
||||||
public static Glyph getChangeGlyph() {
|
public static Glyph getChangeGlyph() {
|
||||||
Glyph changeGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.COINS);
|
Glyph changeGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.COINS);
|
||||||
changeGlyph.getStyleClass().add("change-icon");
|
changeGlyph.getStyleClass().add("change-icon");
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.sparrowwallet.drongo.protocol.*;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBTInput;
|
import com.sparrowwallet.drongo.psbt.PSBTInput;
|
||||||
import com.sparrowwallet.drongo.wallet.BlockTransaction;
|
import com.sparrowwallet.drongo.wallet.BlockTransaction;
|
||||||
import com.sparrowwallet.drongo.wallet.Keystore;
|
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||||
|
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||||
import com.sparrowwallet.sparrow.EventManager;
|
import com.sparrowwallet.sparrow.EventManager;
|
||||||
import com.sparrowwallet.sparrow.control.*;
|
import com.sparrowwallet.sparrow.control.*;
|
||||||
import com.sparrowwallet.sparrow.event.*;
|
import com.sparrowwallet.sparrow.event.*;
|
||||||
|
@ -120,6 +121,11 @@ public class InputController extends TransactionFormController implements Initia
|
||||||
TransactionInput txInput = inputForm.getTransactionInput();
|
TransactionInput txInput = inputForm.getTransactionInput();
|
||||||
PSBTInput psbtInput = inputForm.getPsbtInput();
|
PSBTInput psbtInput = inputForm.getPsbtInput();
|
||||||
|
|
||||||
|
inputForm.signingWalletProperty().addListener((observable, oldValue, signingWallet) -> {
|
||||||
|
updateInputLegendFromWallet(txInput, signingWallet);
|
||||||
|
});
|
||||||
|
updateInputLegendFromWallet(txInput, inputForm.getSigningWallet());
|
||||||
|
|
||||||
initializeInputFields(txInput, psbtInput);
|
initializeInputFields(txInput, psbtInput);
|
||||||
initializeScriptFields(txInput, psbtInput);
|
initializeScriptFields(txInput, psbtInput);
|
||||||
initializeStatusFields(txInput, psbtInput);
|
initializeStatusFields(txInput, psbtInput);
|
||||||
|
@ -132,9 +138,27 @@ public class InputController extends TransactionFormController implements Initia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeInputFields(TransactionInput txInput, PSBTInput psbtInput) {
|
private String getLegendText(TransactionInput txInput) {
|
||||||
inputFieldset.setText("Input #" + txInput.getIndex());
|
return "Input #" + txInput.getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateInputLegendFromWallet(TransactionInput txInput, Wallet signingWallet) {
|
||||||
|
String baseText = getLegendText(txInput);
|
||||||
|
if(signingWallet != null) {
|
||||||
|
if(inputForm.isWalletTxo()) {
|
||||||
|
inputFieldset.setText(baseText + " - Wallet");
|
||||||
|
inputFieldset.setIcon(TransactionDiagram.getTxoGlyph());
|
||||||
|
} else {
|
||||||
|
inputFieldset.setText(baseText + " - Payjoin");
|
||||||
|
inputFieldset.setIcon(TransactionDiagram.getPayjoinGlyph());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inputFieldset.setText(baseText);
|
||||||
|
inputFieldset.setIcon(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeInputFields(TransactionInput txInput, PSBTInput psbtInput) {
|
||||||
outpoint.managedProperty().bind(outpoint.visibleProperty());
|
outpoint.managedProperty().bind(outpoint.visibleProperty());
|
||||||
linkedOutpoint.managedProperty().bind(linkedOutpoint.visibleProperty());
|
linkedOutpoint.managedProperty().bind(linkedOutpoint.visibleProperty());
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,11 @@ public class InputForm extends IndexedTransactionForm {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWalletTxo() {
|
||||||
|
TransactionInput txInput = getTransactionInput();
|
||||||
|
return getSigningWallet() != null && getSigningWallet().getWalletTxos().keySet().stream().anyMatch(ref -> ref.getHash().equals(txInput.getOutpoint().getHash()) && ref.getIndex() == txInput.getOutpoint().getIndex());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node getContents() throws IOException {
|
public Node getContents() throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("input.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("input.fxml"));
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.sparrowwallet.sparrow.transaction;
|
package com.sparrowwallet.sparrow.transaction;
|
||||||
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.sparrowwallet.drongo.KeyPurpose;
|
|
||||||
import com.sparrowwallet.drongo.address.Address;
|
import com.sparrowwallet.drongo.address.Address;
|
||||||
import com.sparrowwallet.drongo.protocol.NonStandardScriptException;
|
import com.sparrowwallet.drongo.protocol.NonStandardScriptException;
|
||||||
import com.sparrowwallet.drongo.protocol.TransactionInput;
|
import com.sparrowwallet.drongo.protocol.TransactionInput;
|
||||||
|
@ -106,10 +105,10 @@ public class OutputController extends TransactionFormController implements Initi
|
||||||
private void updateOutputLegendFromWallet(TransactionOutput txOutput, Wallet signingWallet) {
|
private void updateOutputLegendFromWallet(TransactionOutput txOutput, Wallet signingWallet) {
|
||||||
String baseText = getLegendText(txOutput);
|
String baseText = getLegendText(txOutput);
|
||||||
if(signingWallet != null) {
|
if(signingWallet != null) {
|
||||||
if(signingWallet.getWalletOutputScripts(KeyPurpose.RECEIVE).containsKey(txOutput.getScript())) {
|
if(outputForm.isWalletConsolidation()) {
|
||||||
outputFieldset.setText(baseText + " - Consolidation");
|
outputFieldset.setText(baseText + " - Consolidation");
|
||||||
outputFieldset.setIcon(TransactionDiagram.getConsolidationGlyph());
|
outputFieldset.setIcon(TransactionDiagram.getConsolidationGlyph());
|
||||||
} else if(signingWallet.getWalletOutputScripts(KeyPurpose.CHANGE).containsKey(txOutput.getScript())) {
|
} else if(outputForm.isWalletChange()) {
|
||||||
outputFieldset.setText(baseText + " - Change");
|
outputFieldset.setText(baseText + " - Change");
|
||||||
outputFieldset.setIcon(TransactionDiagram.getChangeGlyph());
|
outputFieldset.setIcon(TransactionDiagram.getChangeGlyph());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.sparrowwallet.sparrow.transaction;
|
package com.sparrowwallet.sparrow.transaction;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.KeyPurpose;
|
||||||
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBTOutput;
|
import com.sparrowwallet.drongo.psbt.PSBTOutput;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
@ -30,6 +31,18 @@ public class OutputForm extends IndexedTransactionForm {
|
||||||
return psbtOutput;
|
return psbtOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWalletConsolidation() {
|
||||||
|
return (getSigningWallet() != null && getSigningWallet().getWalletOutputScripts(KeyPurpose.RECEIVE).containsKey(getTransactionOutput().getScript()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWalletChange() {
|
||||||
|
return (getSigningWallet() != null && getSigningWallet().getWalletOutputScripts(KeyPurpose.CHANGE).containsKey(getTransactionOutput().getScript()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWalletPayment() {
|
||||||
|
return getSigningWallet() != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node getContents() throws IOException {
|
public Node getContents() throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("output.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("output.fxml"));
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.sparrowwallet.drongo.wallet.BlockTransaction;
|
||||||
import com.sparrowwallet.sparrow.AppController;
|
import com.sparrowwallet.sparrow.AppController;
|
||||||
import com.sparrowwallet.sparrow.EventManager;
|
import com.sparrowwallet.sparrow.EventManager;
|
||||||
import com.sparrowwallet.sparrow.TransactionTabData;
|
import com.sparrowwallet.sparrow.TransactionTabData;
|
||||||
|
import com.sparrowwallet.sparrow.control.TransactionDiagram;
|
||||||
import com.sparrowwallet.sparrow.control.TransactionHexArea;
|
import com.sparrowwallet.sparrow.control.TransactionHexArea;
|
||||||
import com.sparrowwallet.sparrow.event.*;
|
import com.sparrowwallet.sparrow.event.*;
|
||||||
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
||||||
|
@ -17,11 +18,10 @@ import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.control.TreeCell;
|
||||||
import javafx.scene.control.TreeItem;
|
import javafx.scene.control.TreeItem;
|
||||||
import javafx.scene.control.TreeView;
|
import javafx.scene.control.TreeView;
|
||||||
import javafx.scene.control.cell.TextFieldTreeCell;
|
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.util.StringConverter;
|
|
||||||
import org.controlsfx.control.MasterDetailPane;
|
import org.controlsfx.control.MasterDetailPane;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -125,17 +125,46 @@ public class TransactionController implements Initializable {
|
||||||
rootItem.getChildren().add(outputsItem);
|
rootItem.getChildren().add(outputsItem);
|
||||||
txtree.setRoot(rootItem);
|
txtree.setRoot(rootItem);
|
||||||
|
|
||||||
txtree.setCellFactory(p -> new TextFieldTreeCell<>(new StringConverter<TransactionForm>() {
|
txtree.setCellFactory(tc -> new TreeCell<>() {
|
||||||
@Override
|
@Override
|
||||||
public String toString(TransactionForm transactionForm) {
|
protected void updateItem(TransactionForm form, boolean empty) {
|
||||||
return transactionForm.toString();
|
super.updateItem(form, empty);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
setText(null);
|
||||||
public TransactionForm fromString(String string) {
|
setGraphic(null);
|
||||||
throw new IllegalStateException("No editing");
|
setTooltip(null);
|
||||||
|
setContextMenu(null);
|
||||||
|
|
||||||
|
if(form != null) {
|
||||||
|
setText(form.toString());
|
||||||
|
|
||||||
|
if(form.getSigningWallet() != null) {
|
||||||
|
if(form instanceof InputForm) {
|
||||||
|
InputForm inputForm = (InputForm)form;
|
||||||
|
if(inputForm.isWalletTxo()) {
|
||||||
|
setGraphic(TransactionDiagram.getTxoGlyph());
|
||||||
|
} else {
|
||||||
|
setGraphic(TransactionDiagram.getPayjoinGlyph());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(form instanceof OutputForm) {
|
||||||
|
OutputForm outputForm = (OutputForm)form;
|
||||||
|
if(outputForm.isWalletConsolidation()) {
|
||||||
|
setGraphic(TransactionDiagram.getConsolidationGlyph());
|
||||||
|
} else if(outputForm.isWalletChange()) {
|
||||||
|
setGraphic(TransactionDiagram.getChangeGlyph());
|
||||||
|
} else {
|
||||||
|
setGraphic(TransactionDiagram.getPaymentGlyph());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
|
txdata.signingWalletProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
txtree.refresh();
|
||||||
|
});
|
||||||
|
|
||||||
txtree.getSelectionModel().selectedItemProperty().addListener((observable, old_val, selectedItem) -> {
|
txtree.getSelectionModel().selectedItemProperty().addListener((observable, old_val, selectedItem) -> {
|
||||||
TransactionForm transactionForm = selectedItem.getValue();
|
TransactionForm transactionForm = selectedItem.getValue();
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
-fx-base: -fx-accent ;
|
-fx-base: -fx-accent ;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-view{
|
.table-view, .tree-view {
|
||||||
/*-fx-background-color: derive(-fx-base, 10%);*/
|
/*-fx-background-color: derive(-fx-base, 10%);*/
|
||||||
-fx-selection-bar-non-focused: derive(-fx-base, 50%);
|
-fx-selection-bar-non-focused: derive(-fx-base, 50%);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,4 +24,7 @@
|
||||||
|
|
||||||
.locktime { -fx-fill: color-grey }
|
.locktime { -fx-fill: color-grey }
|
||||||
|
|
||||||
|
.legend {
|
||||||
|
-fx-content-display: RIGHT;
|
||||||
|
-fx-graphic-text-gap: 5px;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue