diff --git a/drongo b/drongo index 38deacae..d24243ce 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 38deacaeec757acaaaedada7c17e9338564cb389 +Subproject commit d24243ce20a9d10f77cfe95f172940743a94a8a7 diff --git a/src/main/java/com/sparrowwallet/sparrow/control/AddressCell.java b/src/main/java/com/sparrowwallet/sparrow/control/AddressCell.java index f65130f9..117330e6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/AddressCell.java +++ b/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 { public AddressCell() { super(); @@ -40,10 +46,10 @@ public class AddressCell extends TreeTableCell { 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 { 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; } } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletUtxosEntry.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletUtxosEntry.java index f6bb238a..6c3208ac 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletUtxosEntry.java +++ b/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())); } } diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/utxos.css b/src/main/resources/com/sparrowwallet/sparrow/wallet/utxos.css index f2eae55b..9989d353 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/utxos.css +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/utxos.css @@ -18,4 +18,12 @@ .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%); } \ No newline at end of file