retrieve stored index from mixconfig on whirlpool wallet load

This commit is contained in:
Craig Raw 2021-10-21 14:38:13 +02:00
parent 237f97852d
commit 813e0f3ab1
3 changed files with 9 additions and 6 deletions

View file

@ -1145,6 +1145,7 @@ public class SendController extends WalletFormController implements Initializabl
AppServices.showErrorDialog("Error broadcasting premix transaction", exception.getMessage()); AppServices.showErrorDialog("Error broadcasting premix transaction", exception.getMessage());
}); });
ServiceProgressDialog progressDialog = new ServiceProgressDialog("Whirlpool", "Broadcast Premix Transaction", "/image/whirlpool.png", tx0BroadcastService); ServiceProgressDialog progressDialog = new ServiceProgressDialog("Whirlpool", "Broadcast Premix Transaction", "/image/whirlpool.png", tx0BroadcastService);
AppServices.moveToActiveWindowScreen(progressDialog);
tx0BroadcastService.start(); tx0BroadcastService.start();
} }

View file

@ -89,8 +89,10 @@ public class SparrowDataSource extends WalletResponseDataSource {
List<ExtendedKey.Header> headers = ExtendedKey.Header.getHeaders(Network.get()); List<ExtendedKey.Header> headers = ExtendedKey.Header.getHeaders(Network.get());
ExtendedKey.Header header = headers.stream().filter(head -> head.getDefaultScriptType().equals(wallet.getScriptType()) && !head.isPrivateKey()).findFirst().orElse(ExtendedKey.Header.xpub); ExtendedKey.Header header = headers.stream().filter(head -> head.getDefaultScriptType().equals(wallet.getScriptType()) && !head.isPrivateKey()).findFirst().orElse(ExtendedKey.Header.xpub);
address.address = wallet.getKeystores().get(0).getExtendedPublicKey().toString(header); address.address = wallet.getKeystores().get(0).getExtendedPublicKey().toString(header);
address.account_index = wallet.getNode(KeyPurpose.RECEIVE).getHighestUsedIndex() == null ? 0 : wallet.getNode(KeyPurpose.RECEIVE).getHighestUsedIndex() + 1; int receiveIndex = wallet.getNode(KeyPurpose.RECEIVE).getHighestUsedIndex() == null ? 0 : wallet.getNode(KeyPurpose.RECEIVE).getHighestUsedIndex() + 1;
address.change_index = wallet.getNode(KeyPurpose.CHANGE).getHighestUsedIndex() == null ? 0 : wallet.getNode(KeyPurpose.CHANGE).getHighestUsedIndex() + 1; address.account_index = wallet.getMixConfig() != null ? Math.max(receiveIndex, wallet.getMixConfig().getReceiveIndex()) : receiveIndex;
int changeIndex = wallet.getNode(KeyPurpose.CHANGE).getHighestUsedIndex() == null ? 0 : wallet.getNode(KeyPurpose.CHANGE).getHighestUsedIndex() + 1;
address.change_index = wallet.getMixConfig() != null ? Math.max(changeIndex, wallet.getMixConfig().getChangeIndex()) : changeIndex;
address.n_tx = wallet.getTransactions().size(); address.n_tx = wallet.getTransactions().size();
addresses.add(address); addresses.add(address);

View file

@ -60,13 +60,13 @@ public class SparrowIndexHandler extends AbstractIndexHandler {
private void setStoredIndex(int index) { private void setStoredIndex(int index) {
if(wallet.getMixConfig() != null) { if(wallet.getMixConfig() != null) {
if(walletNode.getKeyPurpose() == KeyPurpose.RECEIVE) { if(walletNode.getKeyPurpose() == KeyPurpose.RECEIVE && wallet.getMixConfig().getReceiveIndex() != index) {
wallet.getMixConfig().setReceiveIndex(index); wallet.getMixConfig().setReceiveIndex(index);
} else if(walletNode.getKeyPurpose() == KeyPurpose.CHANGE) {
wallet.getMixConfig().setChangeIndex(index);
}
EventManager.get().post(new WalletMixConfigChangedEvent(wallet)); EventManager.get().post(new WalletMixConfigChangedEvent(wallet));
} else if(walletNode.getKeyPurpose() == KeyPurpose.CHANGE && wallet.getMixConfig().getChangeIndex() != index) {
wallet.getMixConfig().setChangeIndex(index);
EventManager.get().post(new WalletMixConfigChangedEvent(wallet));
}
} }
} }