freeze and unfreeze utxos in sparrow terminal by pressing f on utxos table

This commit is contained in:
Craig Raw 2023-10-31 11:20:10 +01:00
parent d881e47ec9
commit cb06e1aaf7
2 changed files with 19 additions and 0 deletions

View file

@ -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());

View file

@ -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;
}