mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
Add input labels into TransactionDiagram along with transaction notes
This commit is contained in:
parent
e1dab3a48e
commit
67ed382f3d
3 changed files with 30 additions and 4 deletions
|
@ -429,11 +429,18 @@ public class TransactionDiagram extends GridPane {
|
||||||
|
|
||||||
Tooltip tooltip = new Tooltip();
|
Tooltip tooltip = new Tooltip();
|
||||||
Long inputValue = null;
|
Long inputValue = null;
|
||||||
|
String inputLabel = input.getLabel();
|
||||||
if(walletNode != null) {
|
if(walletNode != null) {
|
||||||
inputValue = input.getValue();
|
inputValue = input.getValue();
|
||||||
Wallet nodeWallet = walletNode.getWallet();
|
Wallet nodeWallet = walletNode.getWallet();
|
||||||
tooltip.setText("Spending " + getSatsValue(inputValue) + " sats from " + (isFinal() ? nodeWallet.getFullDisplayName() : (nodeWallet.isNested() ? nodeWallet.getDisplayName() : "")) + " " + walletNode + "\n" +
|
StringJoiner joiner = new StringJoiner("\n");
|
||||||
input.getHashAsString() + ":" + input.getIndex() + "\n" + walletNode.getAddress());
|
joiner.add("Spending " + getSatsValue(inputValue) + " sats from " + (isFinal() ? nodeWallet.getFullDisplayName() : (nodeWallet.isNested() ? nodeWallet.getDisplayName() : "")) + " " + walletNode);
|
||||||
|
joiner.add(input.getHashAsString() + ":" + input.getIndex());
|
||||||
|
joiner.add(walletNode.getAddress().toString());
|
||||||
|
if (inputLabel != null) {
|
||||||
|
joiner.add(inputLabel);
|
||||||
|
}
|
||||||
|
tooltip.setText(joiner.toString());
|
||||||
tooltip.getStyleClass().add("input-label");
|
tooltip.getStyleClass().add("input-label");
|
||||||
|
|
||||||
if(input.getLabel() == null || input.getLabel().isEmpty()) {
|
if(input.getLabel() == null || input.getLabel().isEmpty()) {
|
||||||
|
@ -448,12 +455,15 @@ public class TransactionDiagram extends GridPane {
|
||||||
ContextMenu contextMenu = new LabelContextMenu(walletNode.getAddress(), inputValue);
|
ContextMenu contextMenu = new LabelContextMenu(walletNode.getAddress(), inputValue);
|
||||||
label.setContextMenu(contextMenu);
|
label.setContextMenu(contextMenu);
|
||||||
} else {
|
} else {
|
||||||
if(input instanceof PayjoinBlockTransactionHashIndex) {
|
if (input instanceof PayjoinBlockTransactionHashIndex) {
|
||||||
tooltip.setText("Added once transaction is signed and sent to the payjoin server");
|
tooltip.setText("Added once transaction is signed and sent to the payjoin server");
|
||||||
} else if(input instanceof AdditionalBlockTransactionHashIndex additionalReference) {
|
} else if(input instanceof AdditionalBlockTransactionHashIndex additionalReference) {
|
||||||
inputValue = input.getValue();
|
inputValue = input.getValue();
|
||||||
StringJoiner joiner = new StringJoiner("\n");
|
StringJoiner joiner = new StringJoiner("\n");
|
||||||
joiner.add("Spending " + getSatsValue(inputValue) + " sats from" + (isExpanded() ? ":" : " (click to expand):"));
|
joiner.add("Spending " + getSatsValue(inputValue) + " sats from" + (isExpanded() ? ":" : " (click to expand):"));
|
||||||
|
if (inputLabel != null) {
|
||||||
|
joiner.add(inputLabel);
|
||||||
|
}
|
||||||
for(BlockTransactionHashIndex additionalInput : additionalReference.getAdditionalInputs()) {
|
for(BlockTransactionHashIndex additionalInput : additionalReference.getAdditionalInputs()) {
|
||||||
joiner.add(getInputDescription(additionalInput));
|
joiner.add(getInputDescription(additionalInput));
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,9 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
@FXML
|
@FXML
|
||||||
private IdLabel id;
|
private IdLabel id;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private IdLabel txNotes;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ToggleButton copyTxid;
|
private ToggleButton copyTxid;
|
||||||
|
|
||||||
|
@ -860,7 +863,17 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTxId() {
|
private void updateTxId() {
|
||||||
id.setText(headersForm.getTransaction().calculateTxId(false).toString());
|
Sha256Hash txid = headersForm.getTransaction().calculateTxId(false);
|
||||||
|
id.setText(txid.toString());
|
||||||
|
txNotes.setText(headersForm.getName());
|
||||||
|
|
||||||
|
Wallet w = getWalletFromTransactionInputs();
|
||||||
|
if (w != null) {
|
||||||
|
BlockTransaction txn = w.getWalletTransaction(txid);
|
||||||
|
if (txn != null) {
|
||||||
|
txNotes.setText(txn.getLabel());
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!headersForm.isTransactionFinalized()) {
|
if(!headersForm.isTransactionFinalized()) {
|
||||||
addStyleClass(id, UNFINALIZED_TXID_CLASS);
|
addStyleClass(id, UNFINALIZED_TXID_CLASS);
|
||||||
addStyleClass(size, UNFINALIZED_TXID_CLASS);
|
addStyleClass(size, UNFINALIZED_TXID_CLASS);
|
||||||
|
|
|
@ -67,6 +67,9 @@
|
||||||
</buttons>
|
</buttons>
|
||||||
</SegmentedButton>
|
</SegmentedButton>
|
||||||
</Field>
|
</Field>
|
||||||
|
<Field text="Notes:" styleClass="label-button">
|
||||||
|
<IdLabel fx:id="txNotes"/>
|
||||||
|
</Field>
|
||||||
</Fieldset>
|
</Fieldset>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue