mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-04 19:16:44 +00:00
add mix config to wallet
This commit is contained in:
parent
71b5778226
commit
67836b2b55
2 changed files with 87 additions and 0 deletions
66
src/main/java/com/sparrowwallet/drongo/wallet/MixConfig.java
Normal file
66
src/main/java/com/sparrowwallet/drongo/wallet/MixConfig.java
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
package com.sparrowwallet.drongo.wallet;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class MixConfig extends Persistable {
|
||||||
|
private String scode;
|
||||||
|
private Boolean mixOnStartup;
|
||||||
|
private File mixToWalletFile;
|
||||||
|
private String mixToWalletName;
|
||||||
|
private Integer minMixes;
|
||||||
|
|
||||||
|
public MixConfig() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MixConfig(String scode, Boolean mixOnStartup, File mixToWalletFile, String mixToWalletName, Integer minMixes) {
|
||||||
|
this.scode = scode;
|
||||||
|
this.mixOnStartup = mixOnStartup;
|
||||||
|
this.mixToWalletFile = mixToWalletFile;
|
||||||
|
this.mixToWalletName = mixToWalletName;
|
||||||
|
this.minMixes = minMixes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScode() {
|
||||||
|
return scode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScode(String scode) {
|
||||||
|
this.scode = scode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getMixOnStartup() {
|
||||||
|
return mixOnStartup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMixOnStartup(Boolean mixOnStartup) {
|
||||||
|
this.mixOnStartup = mixOnStartup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getMixToWalletFile() {
|
||||||
|
return mixToWalletFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMixToWalletFile(File mixToWalletFile) {
|
||||||
|
this.mixToWalletFile = mixToWalletFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMixToWalletName() {
|
||||||
|
return mixToWalletName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMixToWalletName(String mixToWalletName) {
|
||||||
|
this.mixToWalletName = mixToWalletName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMinMixes() {
|
||||||
|
return minMixes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinMixes(Integer minMixes) {
|
||||||
|
this.minMixes = minMixes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MixConfig copy() {
|
||||||
|
return new MixConfig(scode, mixOnStartup, mixToWalletFile, mixToWalletName, minMixes);
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,6 +36,7 @@ public class Wallet extends Persistable {
|
||||||
private List<Keystore> keystores = new ArrayList<>();
|
private List<Keystore> keystores = new ArrayList<>();
|
||||||
private final TreeSet<WalletNode> purposeNodes = new TreeSet<>();
|
private final TreeSet<WalletNode> purposeNodes = new TreeSet<>();
|
||||||
private final Map<Sha256Hash, BlockTransaction> transactions = new HashMap<>();
|
private final Map<Sha256Hash, BlockTransaction> transactions = new HashMap<>();
|
||||||
|
private MixConfig mixConfig;
|
||||||
private final Map<Sha256Hash, UtxoMixData> utxoMixes = new HashMap<>();
|
private final Map<Sha256Hash, UtxoMixData> utxoMixes = new HashMap<>();
|
||||||
private Integer storedBlockHeight;
|
private Integer storedBlockHeight;
|
||||||
private Integer gapLimit;
|
private Integer gapLimit;
|
||||||
|
@ -230,6 +231,22 @@ public class Wallet extends Persistable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MixConfig getMixConfig() {
|
||||||
|
return mixConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MixConfig getOrCreateMixConfig() {
|
||||||
|
if(mixConfig == null) {
|
||||||
|
mixConfig = new MixConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mixConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMixConfig(MixConfig mixConfig) {
|
||||||
|
this.mixConfig = mixConfig;
|
||||||
|
}
|
||||||
|
|
||||||
public UtxoMixData getUtxoMixData(BlockTransactionHashIndex utxo) {
|
public UtxoMixData getUtxoMixData(BlockTransactionHashIndex utxo) {
|
||||||
return getUtxoMixData(Sha256Hash.of(utxo.toString().getBytes(StandardCharsets.UTF_8)));
|
return getUtxoMixData(Sha256Hash.of(utxo.toString().getBytes(StandardCharsets.UTF_8)));
|
||||||
}
|
}
|
||||||
|
@ -1339,6 +1356,10 @@ public class Wallet extends Persistable {
|
||||||
for(Sha256Hash hash : transactions.keySet()) {
|
for(Sha256Hash hash : transactions.keySet()) {
|
||||||
copy.transactions.put(hash, transactions.get(hash));
|
copy.transactions.put(hash, transactions.get(hash));
|
||||||
}
|
}
|
||||||
|
copy.setMixConfig(mixConfig == null ? null : mixConfig.copy());
|
||||||
|
for(Sha256Hash hash : utxoMixes.keySet()) {
|
||||||
|
copy.utxoMixes.put(hash, utxoMixes.get(hash));
|
||||||
|
}
|
||||||
copy.setStoredBlockHeight(getStoredBlockHeight());
|
copy.setStoredBlockHeight(getStoredBlockHeight());
|
||||||
copy.gapLimit = gapLimit;
|
copy.gapLimit = gapLimit;
|
||||||
copy.birthDate = birthDate;
|
copy.birthDate = birthDate;
|
||||||
|
|
Loading…
Reference in a new issue