From 049d700688a0448a2a3c95adf727b0b75e8b8fb3 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 3 Oct 2017 21:31:16 -0400 Subject: [PATCH] manager to use ValidatorRequest --- .../manager/BitsharesAccountManager.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java index b667e9c..06e15c4 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java @@ -7,6 +7,9 @@ import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequest; import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestsListener; import cy.agorise.crystalwallet.cryptonetinforequests.ValidateImportBitsharesAccountRequest; import cy.agorise.crystalwallet.models.CryptoNetAccount; +import cy.agorise.graphenej.BrainKey; +import cy.agorise.graphenej.PublicKey; +import cy.agorise.graphenej.models.AccountProperties; /** * Created by henry on 26/9/2017. @@ -35,10 +38,25 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI ApiRequest checkAccountName = new ApiRequest(0, new ApiRequestListener() { @Override public void success(Object answer, int idPetition) { + importRequest.setAccountExists(true); ApiRequest getAccountInfo = new ApiRequest(1,new ApiRequestListener(){ @Override public void success(Object answer, int idPetition) { - //TODO compare keys + if(answer != null && answer instanceof AccountProperties) { + AccountProperties prop = (AccountProperties) answer; + //TODO change the key to compare + BrainKey bk = new BrainKey(importRequest.getMnemonic(), 0); + for(PublicKey activeKey : prop.active.getKeyAuthList()){ + if(activeKey.toBytes().equals(bk.getPublicKey())){ + importRequest.setMnemonicIsCorrect(true); + importRequest._fireOnCarryOutEvent(); + return; + } + } + importRequest.setMnemonicIsCorrect(false); + importRequest._fireOnCarryOutEvent(); + } + } @Override