Add input labels into TransactionDiagram along with transaction notes

This commit is contained in:
main 2024-09-22 16:28:31 -07:00
parent e1dab3a48e
commit 67ed382f3d
3 changed files with 30 additions and 4 deletions

View file

@ -429,11 +429,18 @@ public class TransactionDiagram extends GridPane {
Tooltip tooltip = new Tooltip();
Long inputValue = null;
String inputLabel = input.getLabel();
if(walletNode != null) {
inputValue = input.getValue();
Wallet nodeWallet = walletNode.getWallet();
tooltip.setText("Spending " + getSatsValue(inputValue) + " sats from " + (isFinal() ? nodeWallet.getFullDisplayName() : (nodeWallet.isNested() ? nodeWallet.getDisplayName() : "")) + " " + walletNode + "\n" +
input.getHashAsString() + ":" + input.getIndex() + "\n" + walletNode.getAddress());
StringJoiner joiner = new StringJoiner("\n");
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");
if(input.getLabel() == null || input.getLabel().isEmpty()) {
@ -454,6 +461,9 @@ public class TransactionDiagram extends GridPane {
inputValue = input.getValue();
StringJoiner joiner = new StringJoiner("\n");
joiner.add("Spending " + getSatsValue(inputValue) + " sats from" + (isExpanded() ? ":" : " (click to expand):"));
if (inputLabel != null) {
joiner.add(inputLabel);
}
for(BlockTransactionHashIndex additionalInput : additionalReference.getAdditionalInputs()) {
joiner.add(getInputDescription(additionalInput));
}

View file

@ -89,6 +89,9 @@ public class HeadersController extends TransactionFormController implements Init
@FXML
private IdLabel id;
@FXML
private IdLabel txNotes;
@FXML
private ToggleButton copyTxid;
@ -860,7 +863,17 @@ public class HeadersController extends TransactionFormController implements Init
}
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()) {
addStyleClass(id, UNFINALIZED_TXID_CLASS);
addStyleClass(size, UNFINALIZED_TXID_CLASS);

View file

@ -67,6 +67,9 @@
</buttons>
</SegmentedButton>
</Field>
<Field text="Notes:" styleClass="label-button">
<IdLabel fx:id="txNotes"/>
</Field>
</Fieldset>
</Form>