WalletToolsBCH implements IWalletTools { @Override public String getWalletAddress(IMasterPrivateKey master, String cryptoCurrency, int accountIndex, int chainIndex, int index) { byte[] serializedKey = Base58.decodeChecked(master.getPRV()); ByteBuffer buffer = ByteBuffer.wrap(serializedKey); int header = buffer.getInt(); int standard = -1; switch (header) { case XPRV: standard = STANDARD_BIP44; break; } if (standard == -1) { return null; } DeterministicKey masterKey = MasterPrivateKeyBCH.getDeterministicKey(master.getPRV(),standard); if (standard == STANDARD_BIP44) { final DeterministicKey purposeKey = HDKeyDerivation.deriveChildKey(masterKey, new ChildNumber(STANDARD_BIP44, true)); final DeterministicKey coinKey = HDKeyDerivation.deriveChildKey(purposeKey, new ChildNumber(WalletTools.getCoinTypeByCryptoCurrency(cryptoCurrency), true)); final DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(coinKey, new ChildNumber(accountIndex, true)); final DeterministicKey chainKey = HDKeyDerivation.deriveChildKey(accountKey, new ChildNumber(chainIndex, false)); final DeterministicKey walletKey = HDKeyDerivation.deriveChildKey(chainKey, new ChildNumber(index, false)); return getAddress(walletKey); } return null; }  @Override String generateSeedMnemonicSeparatedBySpaces(); MasterPrivateKeyBCH getMasterPrivateKey(String seedMnemonicSeparatedBySpaces, String password, String cryptoCurrency, int standard); @Override MasterPrivateKeyBCH getMasterPrivateKey(String prv, String cryptoCurrency, int standard); @Override String getWalletAddress(IMasterPrivateKey master, String cryptoCurrency, int accountIndex, int chainIndex, int index); @Override String getWalletAddressFromAccountPUB(String accountPUB, String cryptoCurrency, int chainIndex, int index); @Override String getWalletPrivateKey(IMasterPrivateKey master, String cryptoCurrency, int accountIndex, int chainIndex, int index); @Override String getAccountPUB(IMasterPrivateKey master, String cryptoCurrency, int accountIndex); @Override String getWalletAddressFromPrivateKey(String privateKey, String cryptoCurrency); boolean isAddressValid(String address, String cryptoCurrency); @Override ISignature sign(String privateKey, byte[] hashToSign, String cryptoCurrency); @Override Classification classify(String input, String cryptoCurrencyHint); @Override Classification classify(String input); @Override Set<String> supportedCryptoCurrencies(); String generateWalletPrivateKeyWithPrefix(String prefix, String cryptoCurrency); static final int XPUB; static final int XPRV; static final String BITCOINCASH_PREFIX; }
@Test public void getWalletAddress() { String walletAddress = walletToolsBCH.getWalletAddress(masterPrivateKey, "BCH", 0, 2, 3); Assert.assertEquals("qq85rv80tn99qhzf2dzl5c6rcleavlnz7yay4yxumv", walletAddress); }