mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
add freeze utxo hyperlink to dust attack warning
This commit is contained in:
parent
82be3a52dc
commit
f176a2a04f
4 changed files with 32 additions and 7 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 38deacaeec757acaaaedada7c17e9338564cb389
|
Subproject commit d24243ce20a9d10f77cfe95f172940743a94a8a7
|
|
@ -1,17 +1,23 @@
|
||||||
package com.sparrowwallet.sparrow.control;
|
package com.sparrowwallet.sparrow.control;
|
||||||
|
|
||||||
import com.sparrowwallet.drongo.address.Address;
|
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.glyphfont.FontAwesome5;
|
||||||
import com.sparrowwallet.sparrow.wallet.Entry;
|
import com.sparrowwallet.sparrow.wallet.Entry;
|
||||||
import com.sparrowwallet.sparrow.wallet.NodeEntry;
|
import com.sparrowwallet.sparrow.wallet.NodeEntry;
|
||||||
import com.sparrowwallet.sparrow.wallet.UtxoEntry;
|
import com.sparrowwallet.sparrow.wallet.UtxoEntry;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.ContentDisplay;
|
import javafx.scene.control.ContentDisplay;
|
||||||
|
import javafx.scene.control.Hyperlink;
|
||||||
import javafx.scene.control.Tooltip;
|
import javafx.scene.control.Tooltip;
|
||||||
import javafx.scene.control.TreeTableCell;
|
import javafx.scene.control.TreeTableCell;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import org.controlsfx.glyphfont.Glyph;
|
import org.controlsfx.glyphfont.Glyph;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> {
|
public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> {
|
||||||
public AddressCell() {
|
public AddressCell() {
|
||||||
super();
|
super();
|
||||||
|
@ -40,10 +46,10 @@ public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> {
|
||||||
tooltip.setText(getTooltipText(utxoEntry, addressStatus.isDuplicate(), addressStatus.isDustAttack()));
|
tooltip.setText(getTooltipText(utxoEntry, addressStatus.isDuplicate(), addressStatus.isDustAttack()));
|
||||||
setTooltip(tooltip);
|
setTooltip(tooltip);
|
||||||
|
|
||||||
if(addressStatus.isDuplicate()) {
|
if(addressStatus.isDustAttack()) {
|
||||||
|
setGraphic(getDustAttackHyperlink(utxoEntry));
|
||||||
|
} else if(addressStatus.isDuplicate()) {
|
||||||
setGraphic(getDuplicateGlyph());
|
setGraphic(getDuplicateGlyph());
|
||||||
} else if(addressStatus.isDustAttack()) {
|
|
||||||
setGraphic(getDustAttackGlyph());
|
|
||||||
} else {
|
} else {
|
||||||
setGraphic(null);
|
setGraphic(null);
|
||||||
}
|
}
|
||||||
|
@ -63,10 +69,21 @@ public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> {
|
||||||
return duplicateGlyph;
|
return duplicateGlyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Glyph getDustAttackGlyph() {
|
public static Hyperlink getDustAttackHyperlink(UtxoEntry utxoEntry) {
|
||||||
Glyph dustAttackGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EXCLAMATION_TRIANGLE);
|
Glyph dustAttackGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EXCLAMATION_TRIANGLE);
|
||||||
dustAttackGlyph.getStyleClass().add("dust-attack-warning");
|
dustAttackGlyph.getStyleClass().add("dust-attack-warning");
|
||||||
dustAttackGlyph.setFontSize(12);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class WalletUtxosEntry extends Entry {
|
||||||
|
|
||||||
for(Entry entry : getChildren()) {
|
for(Entry entry : getChildren()) {
|
||||||
UtxoEntry utxoEntry = (UtxoEntry) entry;
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,4 +18,12 @@
|
||||||
|
|
||||||
.chart-bar.selected {
|
.chart-bar.selected {
|
||||||
-fx-bar-fill: rgba(30, 136, 207, 0.6);
|
-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…
Reference in a new issue