mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
save mix to wallet index to improve handling of mix out failures
This commit is contained in:
parent
d128401a09
commit
1d560d6aa6
2 changed files with 11 additions and 0 deletions
|
@ -533,6 +533,10 @@ public class Whirlpool {
|
|||
int startIndex = highestUsedIndex == null ? 0 : highestUsedIndex + 1;
|
||||
int mixes = minMixes == null ? DEFAULT_MIXTO_MIN_MIXES : minMixes;
|
||||
|
||||
if(mixToWallet.getMixConfig() != null) {
|
||||
startIndex = Math.max(startIndex, mixToWallet.getMixConfig().getReceiveIndex());
|
||||
}
|
||||
|
||||
IPostmixHandler postmixHandler = new SparrowPostmixHandler(whirlpoolWalletService, mixToWallet, KeyPurpose.RECEIVE, startIndex);
|
||||
ExternalDestination externalDestination = new ExternalDestination(postmixHandler, 0, startIndex, mixes, DEFAULT_MIXTO_RANDOM_FACTOR);
|
||||
config.setExternalDestination(externalDestination);
|
||||
|
|
|
@ -71,6 +71,13 @@ public class SparrowWalletStateSupplier implements WalletStateSupplier {
|
|||
throw new IllegalStateException("Cannot find wallet for external destination " + externalDestination);
|
||||
}
|
||||
|
||||
//Ensure mix config is present to save indexes
|
||||
MixConfig mixConfig = externalWallet.getMixConfig();
|
||||
if(mixConfig == null) {
|
||||
mixConfig = new MixConfig();
|
||||
externalWallet.setMixConfig(mixConfig);
|
||||
}
|
||||
|
||||
KeyPurpose keyPurpose = KeyPurpose.fromChildNumber(new ChildNumber(externalDestination.getChain()));
|
||||
WalletNode externalNode = externalWallet.getNode(keyPurpose);
|
||||
externalIndexHandler = new SparrowIndexHandler(externalWallet, externalNode, externalDestination.getStartIndex());
|
||||
|
|
Loading…
Reference in a new issue