mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-26 10:06:45 +00:00
add utxo mix data storage to wallet
This commit is contained in:
parent
2eedd2290c
commit
81c202198e
5 changed files with 50 additions and 1 deletions
|
@ -2,9 +2,13 @@ package com.sparrowwallet.drongo;
|
||||||
|
|
||||||
import com.sparrowwallet.drongo.crypto.ChildNumber;
|
import com.sparrowwallet.drongo.crypto.ChildNumber;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public enum KeyPurpose {
|
public enum KeyPurpose {
|
||||||
RECEIVE(ChildNumber.ZERO), CHANGE(ChildNumber.ONE);
|
RECEIVE(ChildNumber.ZERO), CHANGE(ChildNumber.ONE);
|
||||||
|
|
||||||
|
public static final List<KeyPurpose> DEFAULT_PURPOSES = List.of(RECEIVE, CHANGE);
|
||||||
|
|
||||||
private final ChildNumber pathIndex;
|
private final ChildNumber pathIndex;
|
||||||
|
|
||||||
KeyPurpose(ChildNumber pathIndex) {
|
KeyPurpose(ChildNumber pathIndex) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ public enum StandardAccount {
|
||||||
WHIRLPOOL_BADBANK("Badbank", new ChildNumber(2147483644, true));
|
WHIRLPOOL_BADBANK("Badbank", new ChildNumber(2147483644, true));
|
||||||
|
|
||||||
public static final List<StandardAccount> WHIRLPOOL_ACCOUNTS = List.of(WHIRLPOOL_PREMIX, WHIRLPOOL_POSTMIX, WHIRLPOOL_BADBANK);
|
public static final List<StandardAccount> WHIRLPOOL_ACCOUNTS = List.of(WHIRLPOOL_PREMIX, WHIRLPOOL_POSTMIX, WHIRLPOOL_BADBANK);
|
||||||
|
public static final List<StandardAccount> WHIRLPOOL_MIX_ACCOUNTS = List.of(WHIRLPOOL_PREMIX, WHIRLPOOL_POSTMIX);
|
||||||
|
|
||||||
StandardAccount(String name, ChildNumber childNumber) {
|
StandardAccount(String name, ChildNumber childNumber) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.sparrowwallet.drongo.wallet;
|
||||||
|
|
||||||
|
public class UtxoMixData extends Persistable {
|
||||||
|
private final String poolId;
|
||||||
|
private final int mixesDone;
|
||||||
|
private final Long forwarding;
|
||||||
|
|
||||||
|
public UtxoMixData(String poolId, int mixesDone, Long forwarding) {
|
||||||
|
this.poolId = poolId;
|
||||||
|
this.mixesDone = mixesDone;
|
||||||
|
this.forwarding = forwarding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPoolId() {
|
||||||
|
return poolId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMixesDone() {
|
||||||
|
return mixesDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getForwarding() {
|
||||||
|
return forwarding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "{poolId:" + poolId + ", mixesDone:" + mixesDone + ", forwarding:" + forwarding + "}";
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ import com.sparrowwallet.drongo.protocol.*;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBT;
|
import com.sparrowwallet.drongo.psbt.PSBT;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBTInput;
|
import com.sparrowwallet.drongo.psbt.PSBTInput;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -35,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 final Map<Sha256Hash, UtxoMixData> utxoMixes = new HashMap<>();
|
||||||
private Integer storedBlockHeight;
|
private Integer storedBlockHeight;
|
||||||
private Integer gapLimit;
|
private Integer gapLimit;
|
||||||
private Date birthDate;
|
private Date birthDate;
|
||||||
|
@ -167,6 +169,10 @@ public class Wallet extends Persistable {
|
||||||
return whirlpoolAccounts.isEmpty();
|
return whirlpoolAccounts.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWhirlpoolMixWallet() {
|
||||||
|
return !isMasterWallet() && StandardAccount.WHIRLPOOL_MIX_ACCOUNTS.contains(getStandardAccountType());
|
||||||
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -224,6 +230,14 @@ public class Wallet extends Persistable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UtxoMixData getUtxoMixData(BlockTransactionHashIndex utxo) {
|
||||||
|
return utxoMixes.get(Sha256Hash.of(utxo.toString().getBytes(StandardCharsets.UTF_8)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Sha256Hash, UtxoMixData> getUtxoMixes() {
|
||||||
|
return utxoMixes;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getStoredBlockHeight() {
|
public Integer getStoredBlockHeight() {
|
||||||
return storedBlockHeight;
|
return storedBlockHeight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public enum WalletModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean alwaysIncludeNonWitnessUtxo() {
|
public boolean alwaysIncludeNonWitnessUtxo() {
|
||||||
if(this == COLDCARD || this == COBO_VAULT || this == PASSPORT) {
|
if(this == COLDCARD || this == COBO_VAULT || this == PASSPORT || this == KEYSTONE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue