Browse Source

add freeze utxo hyperlink to dust attack warning

terminal
Craig Raw 3 years ago
parent
commit
f176a2a04f
  1. 2
      drongo
  2. 27
      src/main/java/com/sparrowwallet/sparrow/control/AddressCell.java
  3. 2
      src/main/java/com/sparrowwallet/sparrow/wallet/WalletUtxosEntry.java
  4. 8
      src/main/resources/com/sparrowwallet/sparrow/wallet/utxos.css

2
drongo

@ -1 +1 @@
Subproject commit 38deacaeec757acaaaedada7c17e9338564cb389
Subproject commit d24243ce20a9d10f77cfe95f172940743a94a8a7

27
src/main/java/com/sparrowwallet/sparrow/control/AddressCell.java

@ -1,17 +1,23 @@
package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.drongo.address.Address;
import com.sparrowwallet.drongo.wallet.Status;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.event.WalletUtxoStatusChangedEvent;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
import com.sparrowwallet.sparrow.wallet.Entry;
import com.sparrowwallet.sparrow.wallet.NodeEntry;
import com.sparrowwallet.sparrow.wallet.UtxoEntry;
import javafx.geometry.Pos;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Tooltip;
import javafx.scene.control.TreeTableCell;
import javafx.util.Duration;
import org.controlsfx.glyphfont.Glyph;
import java.util.Collections;
public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> {
public AddressCell() {
super();
@ -40,10 +46,10 @@ public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> {
tooltip.setText(getTooltipText(utxoEntry, addressStatus.isDuplicate(), addressStatus.isDustAttack()));
setTooltip(tooltip);
if(addressStatus.isDuplicate()) {
if(addressStatus.isDustAttack()) {
setGraphic(getDustAttackHyperlink(utxoEntry));
} else if(addressStatus.isDuplicate()) {
setGraphic(getDuplicateGlyph());
} else if(addressStatus.isDustAttack()) {
setGraphic(getDustAttackGlyph());
} else {
setGraphic(null);
}
@ -63,10 +69,21 @@ public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> {
return duplicateGlyph;
}
public static Glyph getDustAttackGlyph() {
public static Hyperlink getDustAttackHyperlink(UtxoEntry utxoEntry) {
Glyph dustAttackGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EXCLAMATION_TRIANGLE);
dustAttackGlyph.getStyleClass().add("dust-attack-warning");
dustAttackGlyph.setFontSize(12);
return dustAttackGlyph;
Hyperlink hyperlink = new Hyperlink(utxoEntry.getHashIndex().getStatus() == Status.FROZEN ? "" : "Freeze?", dustAttackGlyph);
hyperlink.getStyleClass().add("freeze-dust-utxo");
hyperlink.setOnAction(event -> {
if(utxoEntry.getHashIndex().getStatus() != Status.FROZEN) {
hyperlink.setText("");
utxoEntry.getHashIndex().setStatus(Status.FROZEN);
EventManager.get().post(new WalletUtxoStatusChangedEvent(utxoEntry.getWallet(), Collections.singletonList(utxoEntry.getHashIndex())));
}
});
return hyperlink;
}
}

2
src/main/java/com/sparrowwallet/sparrow/wallet/WalletUtxosEntry.java

@ -61,7 +61,7 @@ public class WalletUtxosEntry extends Entry {
for(Entry entry : getChildren()) {
UtxoEntry utxoEntry = (UtxoEntry) entry;
utxoEntry.setDustAttack(utxoEntry.getValue() <= dustAttackThreshold && duplicateNodes.contains(utxoEntry.getNode()));
utxoEntry.setDustAttack(utxoEntry.getValue() <= dustAttackThreshold && duplicateNodes.contains(utxoEntry.getNode()) && !utxoEntry.getWallet().allInputsFromWallet(utxoEntry.getHashIndex().getHash()));
}
}

8
src/main/resources/com/sparrowwallet/sparrow/wallet/utxos.css

@ -19,3 +19,11 @@
.chart-bar.selected {
-fx-bar-fill: rgba(30, 136, 207, 0.6);
}
.freeze-dust-utxo {
-fx-padding: 0 0 0 5px;
}
.tree-table-view:focused:row-selection .tree-table-row-cell:selected .freeze-dust-utxo {
-fx-text-fill: derive(white, -15%);
}
Loading…
Cancel
Save