mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
retrieve stored index from mixconfig on whirlpool wallet load
This commit is contained in:
parent
237f97852d
commit
813e0f3ab1
3 changed files with 9 additions and 6 deletions
|
@ -1145,6 +1145,7 @@ public class SendController extends WalletFormController implements Initializabl
|
|||
AppServices.showErrorDialog("Error broadcasting premix transaction", exception.getMessage());
|
||||
});
|
||||
ServiceProgressDialog progressDialog = new ServiceProgressDialog("Whirlpool", "Broadcast Premix Transaction", "/image/whirlpool.png", tx0BroadcastService);
|
||||
AppServices.moveToActiveWindowScreen(progressDialog);
|
||||
tx0BroadcastService.start();
|
||||
}
|
||||
|
||||
|
|
|
@ -89,8 +89,10 @@ public class SparrowDataSource extends WalletResponseDataSource {
|
|||
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);
|
||||
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;
|
||||
address.change_index = wallet.getNode(KeyPurpose.CHANGE).getHighestUsedIndex() == null ? 0 : wallet.getNode(KeyPurpose.CHANGE).getHighestUsedIndex() + 1;
|
||||
int receiveIndex = wallet.getNode(KeyPurpose.RECEIVE).getHighestUsedIndex() == null ? 0 : wallet.getNode(KeyPurpose.RECEIVE).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();
|
||||
addresses.add(address);
|
||||
|
||||
|
|
|
@ -60,13 +60,13 @@ public class SparrowIndexHandler extends AbstractIndexHandler {
|
|||
|
||||
private void setStoredIndex(int index) {
|
||||
if(wallet.getMixConfig() != null) {
|
||||
if(walletNode.getKeyPurpose() == KeyPurpose.RECEIVE) {
|
||||
if(walletNode.getKeyPurpose() == KeyPurpose.RECEIVE && wallet.getMixConfig().getReceiveIndex() != index) {
|
||||
wallet.getMixConfig().setReceiveIndex(index);
|
||||
} else if(walletNode.getKeyPurpose() == KeyPurpose.CHANGE) {
|
||||
wallet.getMixConfig().setChangeIndex(index);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue