mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
add view option to hide used empty addresses
This commit is contained in:
parent
2b47740539
commit
ccead92388
10 changed files with 81 additions and 4 deletions
|
@ -92,6 +92,9 @@ public class AppController implements Initializable {
|
|||
@FXML
|
||||
private CheckMenuItem openWalletsInNewWindows;
|
||||
|
||||
@FXML
|
||||
private CheckMenuItem hideEmptyUsedAddresses;
|
||||
|
||||
@FXML
|
||||
private CheckMenuItem showTxHex;
|
||||
|
||||
|
@ -214,6 +217,7 @@ public class AppController implements Initializable {
|
|||
setTheme(null);
|
||||
|
||||
openWalletsInNewWindows.setSelected(Config.get().isOpenWalletsInNewWindows());
|
||||
hideEmptyUsedAddresses.setSelected(Config.get().isHideEmptyUsedAddresses());
|
||||
showTxHex.setSelected(Config.get().isShowTransactionHex());
|
||||
exportWallet.setDisable(true);
|
||||
|
||||
|
@ -491,6 +495,12 @@ public class AppController implements Initializable {
|
|||
EventManager.get().post(new OpenWalletsNewWindowsStatusEvent(item.isSelected()));
|
||||
}
|
||||
|
||||
public void hideEmptyUsedAddresses(ActionEvent event) {
|
||||
CheckMenuItem item = (CheckMenuItem)event.getSource();
|
||||
Config.get().setHideEmptyUsedAddresses(item.isSelected());
|
||||
EventManager.get().post(new HideEmptyUsedAddressesStatusEvent(item.isSelected()));
|
||||
}
|
||||
|
||||
public void showTxHex(ActionEvent event) {
|
||||
CheckMenuItem item = (CheckMenuItem)event.getSource();
|
||||
Config.get().setShowTransactionHex(item.isSelected());
|
||||
|
@ -1260,6 +1270,11 @@ public class AppController implements Initializable {
|
|||
openWalletsInNewWindows.setSelected(event.isOpenWalletsInNewWindows());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void hideEmptyUsedAddressesStatusChanged(HideEmptyUsedAddressesStatusEvent event) {
|
||||
hideEmptyUsedAddresses.setSelected(event.isHideEmptyUsedAddresses());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void requestOpenWallets(RequestOpenWalletsEvent event) {
|
||||
EventManager.get().post(new OpenWalletsEvent(tabs.getScene().getWindow(), getOpenWallets()));
|
||||
|
|
|
@ -14,6 +14,7 @@ import javafx.scene.input.MouseButton;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class AddressTreeTable extends CoinTreeTable {
|
||||
public void initialize(NodeEntry rootEntry) {
|
||||
|
@ -60,7 +61,10 @@ public class AddressTreeTable extends CoinTreeTable {
|
|||
|
||||
Integer highestUsedIndex = rootEntry.getNode().getHighestUsedIndex();
|
||||
if(highestUsedIndex != null) {
|
||||
scrollTo(highestUsedIndex);
|
||||
OptionalInt tableIndex = rootEntry.getChildren().stream().filter(childEntry -> ((NodeEntry)childEntry).getNode().getIndex() == highestUsedIndex + 1).mapToInt(childEntry -> rootEntry.getChildren().indexOf(childEntry)).findFirst();
|
||||
if(tableIndex.isPresent() && tableIndex.getAsInt() > 5) {
|
||||
scrollTo(tableIndex.getAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
setOnMouseClicked(mouseEvent -> {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.sparrowwallet.sparrow.event;
|
||||
|
||||
public class HideEmptyUsedAddressesStatusEvent {
|
||||
private final boolean hideEmptyUsedAddresses;
|
||||
|
||||
public HideEmptyUsedAddressesStatusEvent(boolean hideEmptyUsedAddresses) {
|
||||
this.hideEmptyUsedAddresses = hideEmptyUsedAddresses;
|
||||
}
|
||||
|
||||
public boolean isHideEmptyUsedAddresses() {
|
||||
return hideEmptyUsedAddresses;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.sparrowwallet.sparrow.event;
|
||||
|
||||
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||
|
||||
/**
|
||||
* Used to indicate that the display configuration of wallet addresses has been updated
|
||||
*/
|
||||
public class WalletAddressesStatusEvent {
|
||||
private final Wallet wallet;
|
||||
|
||||
public WalletAddressesStatusEvent(Wallet wallet) {
|
||||
this.wallet = wallet;
|
||||
}
|
||||
|
||||
public Wallet getWallet() {
|
||||
return wallet;
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ public class Config {
|
|||
private boolean checkNewVersions = true;
|
||||
private Theme theme;
|
||||
private boolean openWalletsInNewWindows = false;
|
||||
private boolean hideEmptyUsedAddresses = false;
|
||||
private boolean showTransactionHex = true;
|
||||
private List<File> recentWalletFiles;
|
||||
private Integer keyDerivationPeriod;
|
||||
|
@ -195,6 +196,15 @@ public class Config {
|
|||
flush();
|
||||
}
|
||||
|
||||
public boolean isHideEmptyUsedAddresses() {
|
||||
return hideEmptyUsedAddresses;
|
||||
}
|
||||
|
||||
public void setHideEmptyUsedAddresses(boolean hideEmptyUsedAddresses) {
|
||||
this.hideEmptyUsedAddresses = hideEmptyUsedAddresses;
|
||||
flush();
|
||||
}
|
||||
|
||||
public boolean isShowTransactionHex() {
|
||||
return showTransactionHex;
|
||||
}
|
||||
|
|
|
@ -248,8 +248,8 @@ public class Storage {
|
|||
}
|
||||
|
||||
public static boolean walletExists(String walletName) {
|
||||
File encrypted = new File(getWalletsDir(), walletName);
|
||||
File unencrypted = new File(getWalletsDir(), walletName + ".json");
|
||||
File encrypted = new File(getWalletsDir(), walletName.trim());
|
||||
File unencrypted = new File(getWalletsDir(), walletName.trim() + ".json");
|
||||
|
||||
return (encrypted.exists() || unencrypted.exists());
|
||||
}
|
||||
|
|
|
@ -75,4 +75,12 @@ public class AddressesController extends WalletFormController implements Initial
|
|||
changeTable.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void walletAddressesStatusChanged(WalletAddressesStatusEvent event) {
|
||||
if(event.getWallet().equals(walletForm.getWallet())) {
|
||||
receiveTable.updateAll(getWalletForm().getNodeEntry(KeyPurpose.RECEIVE));
|
||||
changeTable.updateAll(getWalletForm().getNodeEntry(KeyPurpose.CHANGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.sparrowwallet.drongo.wallet.Wallet;
|
|||
import com.sparrowwallet.drongo.wallet.WalletNode;
|
||||
import com.sparrowwallet.sparrow.EventManager;
|
||||
import com.sparrowwallet.sparrow.event.WalletEntryLabelChangedEvent;
|
||||
import com.sparrowwallet.sparrow.io.Config;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public class NodeEntry extends Entry implements Comparable<NodeEntry> {
|
|||
public NodeEntry(Wallet wallet, WalletNode node) {
|
||||
super(wallet, node.getLabel(),
|
||||
!node.getChildren().isEmpty() ?
|
||||
node.getChildren().stream().map(childNode -> new NodeEntry(wallet, childNode)).collect(Collectors.toList()) :
|
||||
node.getChildren().stream().filter(childNode -> !Config.get().isHideEmptyUsedAddresses() || childNode.getTransactionOutputs().isEmpty() || !childNode.getUnspentTransactionOutputs().isEmpty()).map(childNode -> new NodeEntry(wallet, childNode)).collect(Collectors.toList()) :
|
||||
node.getTransactionOutputs().stream().map(txo -> new HashIndexEntry(wallet, txo, HashIndexEntry.Type.OUTPUT, node.getKeyPurpose())).collect(Collectors.toList()));
|
||||
|
||||
this.node = node;
|
||||
|
|
|
@ -262,4 +262,10 @@ public class WalletForm {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void hideEmptyUsedAddressesStatusChanged(HideEmptyUsedAddressesStatusEvent event) {
|
||||
accountEntries.clear();
|
||||
EventManager.get().post(new WalletAddressesStatusEvent(wallet));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,9 @@
|
|||
</RadioMenuItem>
|
||||
</items>
|
||||
</Menu>
|
||||
<SeparatorMenuItem />
|
||||
<CheckMenuItem fx:id="openWalletsInNewWindows" mnemonicParsing="false" text="Open Wallets in New Windows" onAction="#openWalletsInNewWindows"/>
|
||||
<CheckMenuItem fx:id="hideEmptyUsedAddresses" mnemonicParsing="false" text="Hide Empty Used Addresses" onAction="#hideEmptyUsedAddresses"/>
|
||||
<CheckMenuItem fx:id="showTxHex" mnemonicParsing="false" text="Show Transaction Hex" onAction="#showTxHex"/>
|
||||
</items>
|
||||
</Menu>
|
||||
|
|
Loading…
Reference in a new issue