freeze and unfreeze any utxos from address cell context menu

This commit is contained in:
Craig Raw 2022-08-11 10:26:23 +02:00
parent cbfb7230a8
commit 16755e3140
2 changed files with 28 additions and 2 deletions

View file

@ -558,6 +558,32 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
getItems().add(signVerifyMessage);
}
if(nodeEntry != null && !nodeEntry.getNode().getUnspentTransactionOutputs().isEmpty()) {
List<BlockTransactionHashIndex> unfrozenUtxos = nodeEntry.getNode().getUnspentTransactionOutputs().stream().filter(utxo -> utxo.getStatus() != Status.FROZEN).collect(Collectors.toList());
if(!unfrozenUtxos.isEmpty()) {
MenuItem freezeUtxos = new MenuItem("Freeze UTXOs");
freezeUtxos.setGraphic(getFreezeGlyph());
freezeUtxos.setOnAction(AE -> {
hide();
unfrozenUtxos.forEach(utxo -> utxo.setStatus(Status.FROZEN));
EventManager.get().post(new WalletUtxoStatusChangedEvent(nodeEntry.getWallet(), unfrozenUtxos));
});
getItems().add(freezeUtxos);
}
List<BlockTransactionHashIndex> frozenUtxos = nodeEntry.getNode().getUnspentTransactionOutputs().stream().filter(utxo -> utxo.getStatus() == Status.FROZEN).collect(Collectors.toList());
if(!frozenUtxos.isEmpty()) {
MenuItem unfreezeUtxos = new MenuItem("Unfreeze UTXOs");
unfreezeUtxos.setGraphic(getUnfreezeGlyph());
unfreezeUtxos.setOnAction(AE -> {
hide();
frozenUtxos.forEach(utxo -> utxo.setStatus(null));
EventManager.get().post(new WalletUtxoStatusChangedEvent(nodeEntry.getWallet(), frozenUtxos));
});
getItems().add(unfreezeUtxos);
}
}
MenuItem copyAddress = new MenuItem("Copy Address");
copyAddress.setOnAction(AE -> {
hide();

View file

@ -89,14 +89,14 @@ public class HashIndexEntry extends Entry implements Comparable<HashIndexEntry>
if (!(o instanceof HashIndexEntry)) return false;
HashIndexEntry that = (HashIndexEntry) o;
return super.equals(that) &&
hashIndex.equals(that.hashIndex) &&
hashIndex == that.hashIndex &&
type == that.type &&
keyPurpose == that.keyPurpose;
}
@Override
public int hashCode() {
return Objects.hash(getWallet(), hashIndex, type, keyPurpose);
return Objects.hash(getWallet(), System.identityHashCode(hashIndex), type, keyPurpose);
}
@Override