From cb06e1aaf75c512272b5d09b8a9d3a4ee677b8c6 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 31 Oct 2023 11:20:10 +0100 Subject: [PATCH] freeze and unfreeze utxos in sparrow terminal by pressing f on utxos table --- .../sparrow/terminal/wallet/UtxosDialog.java | 14 ++++++++++++++ .../terminal/wallet/table/DateTableCell.java | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/UtxosDialog.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/UtxosDialog.java index 952eaf32..47defff6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/UtxosDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/UtxosDialog.java @@ -118,6 +118,20 @@ public class UtxosDialog extends WalletDialog { updateMixSelectedButton(); } }); + utxos.setInputFilter((interactable, keyStroke) -> { + if(keyStroke.getCharacter() == Character.valueOf('f')) { + if(utxos.getTableModel().getRowCount() > utxos.getSelectedRow()) { + TableCell dateCell = utxos.getTableModel().getRow(utxos.getSelectedRow()).get(0); + if(dateCell.getEntry() instanceof UtxoEntry utxoEntry) { + utxoEntry.getHashIndex().setStatus(utxoEntry.getHashIndex().getStatus() == Status.FROZEN ? null : Status.FROZEN); + utxos.invalidate(); + EventManager.get().post(new WalletUtxoStatusChangedEvent(utxoEntry.getWallet(), List.of(utxoEntry.getHashIndex()))); + } + } + } + + return true; + }); updateLabels(walletUtxosEntry); updateHistory(getWalletForm().getWalletUtxosEntry()); diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/table/DateTableCell.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/table/DateTableCell.java index fe93ca52..aa708d60 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/table/DateTableCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/table/DateTableCell.java @@ -1,5 +1,6 @@ package com.sparrowwallet.sparrow.terminal.wallet.table; +import com.sparrowwallet.drongo.wallet.Status; import com.sparrowwallet.sparrow.wallet.Entry; import com.sparrowwallet.sparrow.wallet.TransactionEntry; import com.sparrowwallet.sparrow.wallet.UtxoEntry; @@ -24,6 +25,10 @@ public class DateTableCell extends TableCell { return "(*) " + unselected.substring(Math.min(4, unselected.length())); } + if(entry instanceof UtxoEntry utxoEntry && utxoEntry.getHashIndex().getStatus() == Status.FROZEN) { + return "(f) " + unselected.substring(Math.min(4, unselected.length())); + } + return unselected; }