WalletPocketHD extends BitWalletBase { public BitAddress getFreshReceiveAddress() throws Bip44KeyLookAheadExceededException { lock.lock(); try { if (!canCreateFreshReceiveAddress()) { throw new Bip44KeyLookAheadExceededException(); } keys.getKey(RECEIVE_FUNDS); return currentAddress(RECEIVE_FUNDS); } finally { lock.unlock(); walletSaveNow(); } } WalletPocketHD(DeterministicKey rootKey, CoinType coinType,
                          @Nullable KeyCrypter keyCrypter, @Nullable KeyParameter key);   WalletPocketHD(SimpleHDKeyChain keys, CoinType coinType);   WalletPocketHD(String id, SimpleHDKeyChain keys, CoinType coinType); int getAccountIndex(); @Override boolean isEncryptable(); @Override boolean isEncrypted(); @Nullable @Override KeyCrypter getKeyCrypter(); @Override void encrypt(KeyCrypter keyCrypter, KeyParameter aesKey); @Override void decrypt(KeyParameter aesKey); @Override String getPublicKeySerialized(); @Override boolean isWatchedScript(Script script); @Override boolean isPayToScriptHashMine(byte[] payToScriptHash); @Nullable @Override ECKey findKeyFromPubHash(byte[] pubkeyHash); @Nullable @Override ECKey findKeyFromPubKey(byte[] pubkey); @Nullable @Override RedeemData findRedeemDataFromScriptHash(byte[] bytes); @Override byte[] getPublicKey(); @Override BitAddress getChangeAddress(); @Override BitAddress getReceiveAddress(); BitAddress getRefundAddress(); @Override boolean hasUsedAddresses(); @Override boolean canCreateNewAddresses(); @Override BitAddress getReceiveAddress(boolean isManualAddressManagement); @Override BitAddress getRefundAddress(boolean isManualAddressManagement); @Nullable BitAddress getLastUsedAddress(SimpleHDKeyChain.KeyPurpose purpose); boolean canCreateFreshReceiveAddress(); BitAddress getFreshReceiveAddress(); BitAddress getFreshReceiveAddress(boolean isManualAddressManagement); int getNumberIssuedReceiveAddresses(); List<AbstractAddress> getIssuedReceiveAddresses(); Set<AbstractAddress> getUsedAddresses(); BitAddress getAddress(SimpleHDKeyChain.KeyPurpose purpose,
                              boolean isManualAddressManagement); @VisibleForTesting void maybeInitializeAllKeys(); @Override String getPublicKeyMnemonic(); @Override List<AbstractAddress> getActiveAddresses(); @Override void markAddressAsUsed(AbstractAddress address); void markAddressAsUsed(BitAddress address); @Override String toString();  }
@Test public void serializeTransactionsVpn() throws Exception, Bip44KeyLookAheadExceededException { WalletPocketHD account = new WalletPocketHD(rootKey, VPN, null, null); Transaction tx = new Transaction(VPN); tx.setTime(0x99999999); tx.addOutput(VPN.oneCoin().toCoin(), account.getFreshReceiveAddress()); account.addNewTransactionIfNeeded(tx); WalletPocketHD newAccount = testWalletSerializationForCoin(account); Transaction newTx = newAccount.getRawTransaction(tx.getHash()); assertNotNull(newTx); assertNotNull(newTx.getExtraBytes()); assertEquals(0, newTx.getExtraBytes().length); tx = new Transaction(VPN); tx.setTime(0x99999999); tx.setExtraBytes(new byte[0]); tx.addOutput(VPN.oneCoin().toCoin(), account.getFreshReceiveAddress()); account.addNewTransactionIfNeeded(tx); newAccount = testWalletSerializationForCoin(account); newTx = newAccount.getRawTransaction(tx.getHash()); assertNotNull(newTx); assertNotNull(newTx.getExtraBytes()); assertEquals(0, newTx.getExtraBytes().length); tx = new Transaction(VPN); tx.setTime(0x99999999); byte[] bytes = {0x1, 0x2, 0x3}; tx.setExtraBytes(bytes); tx.addOutput(VPN.oneCoin().toCoin(), account.getFreshReceiveAddress()); account.addNewTransactionIfNeeded(tx); newAccount = testWalletSerializationForCoin(account); newTx = newAccount.getRawTransaction(tx.getHash()); assertNotNull(newTx); assertArrayEquals(bytes, newTx.getExtraBytes()); }