From fa18ec9d458bb17221fb01b6be9f4eceb354a156 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 14 Nov 2022 10:59:33 +0200 Subject: [PATCH] add walletconfig --- .../sparrowwallet/drongo/wallet/Wallet.java | 22 ++++++++++ .../drongo/wallet/WalletConfig.java | 41 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/main/java/com/sparrowwallet/drongo/wallet/WalletConfig.java diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index 1aa0129..ac26736 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -38,6 +38,7 @@ public class Wallet extends Persistable implements Comparable { private final TreeSet purposeNodes = new TreeSet<>(); private final Map transactions = new HashMap<>(); private final Map detachedLabels = new HashMap<>(); + private WalletConfig walletConfig; private MixConfig mixConfig; private final Map utxoMixes = new HashMap<>(); private Integer storedBlockHeight; @@ -441,6 +442,26 @@ public class Wallet extends Persistable implements Comparable { return detachedLabels; } + public WalletConfig getWalletConfig() { + return walletConfig; + } + + public WalletConfig getMasterWalletConfig() { + if(!isMasterWallet()) { + return getMasterWallet().getMasterWalletConfig(); + } + + if(walletConfig == null) { + walletConfig = new WalletConfig(); + } + + return walletConfig; + } + + public void setWalletConfig(WalletConfig walletConfig) { + this.walletConfig = walletConfig; + } + public MixConfig getMixConfig() { return mixConfig; } @@ -1805,6 +1826,7 @@ public class Wallet extends Persistable implements Comparable { for(String entry : detachedLabels.keySet()) { copy.detachedLabels.put(entry, detachedLabels.get(entry)); } + copy.setWalletConfig(walletConfig == null ? null : walletConfig.copy()); copy.setMixConfig(mixConfig == null ? null : mixConfig.copy()); for(Sha256Hash hash : utxoMixes.keySet()) { copy.utxoMixes.put(hash, utxoMixes.get(hash)); diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletConfig.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletConfig.java new file mode 100644 index 0000000..11e58fb --- /dev/null +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletConfig.java @@ -0,0 +1,41 @@ +package com.sparrowwallet.drongo.wallet; + +public class WalletConfig extends Persistable { + private byte[] iconData; + private boolean userIcon; + private boolean usePayNym; + + public WalletConfig() { + } + + public WalletConfig(byte[] iconData, boolean userIcon, boolean usePayNym) { + this.iconData = iconData; + this.userIcon = userIcon; + this.usePayNym = usePayNym; + } + + public byte[] getIconData() { + return iconData; + } + + public boolean isUserIcon() { + return userIcon; + } + + public void setIconData(byte[] iconData, boolean userIcon) { + this.iconData = iconData; + this.userIcon = userIcon; + } + + public boolean isUsePayNym() { + return usePayNym; + } + + public void setUsePayNym(boolean usePayNym) { + this.usePayNym = usePayNym; + } + + public WalletConfig copy() { + return new WalletConfig(iconData, userIcon, usePayNym); + } +}