test_class.declarator: params = UnitTestParams.get()
test_class.modifier: static final
test_class.original_string: static final NetworkParameters params = UnitTestParams.get();
test_class.type: NetworkParameters
test_class.var_name: params
test_class.declarator: myKey
test_class.modifier: private
test_class.original_string: private ECKey myKey;
test_class.type: ECKey
test_class.var_name: myKey
test_class.declarator: myWatchedKey
test_class.modifier: private
test_class.original_string: private ECKey myWatchedKey;
test_class.type: ECKey
test_class.var_name: myWatchedKey
test_class.declarator: myAddress
test_class.modifier: private
test_class.original_string: private Address myAddress;
test_class.type: Address
test_class.var_name: myAddress
test_class.declarator: myWallet
test_class.modifier: private
test_class.original_string: private Wallet myWallet;
test_class.type: Wallet
test_class.var_name: myWallet
test_class.declarator: WALLET_DESCRIPTION  = "The quick brown fox lives in \u4f26\u6566"
test_class.modifier: public static
test_class.original_string: public static String WALLET_DESCRIPTION  = "The quick brown fox lives in \u4f26\u6566";
test_class.type: String
test_class.var_name: WALLET_DESCRIPTION
test_class.declarator: mScriptCreationTime
test_class.modifier: private
test_class.original_string: private long mScriptCreationTime;
test_class.type: long
test_class.var_name: mScriptCreationTime
test_class.file: core/src/test/java/com/google/bitcoin/store/WalletProtobufSerializerTest.java
test_class.identifier: WalletProtobufSerializerTest
test_case.body: @Test
      public void testLastBlockSeenHash() throws Exception {
          // Test the lastBlockSeenHash field works.
  
          // LastBlockSeenHash should be empty if never set.
          Wallet wallet = new Wallet(params);
          Protos.Wallet walletProto = new WalletProtobufSerializer().walletToProto(wallet);
          ByteString lastSeenBlockHash = walletProto.getLastSeenBlockHash();
          assertTrue(lastSeenBlockHash.isEmpty());
  
          // Create a block.
          Block block = new Block(params, BlockTest.blockBytes);
          Sha256Hash blockHash = block.getHash();
          wallet.setLastBlockSeenHash(blockHash);
          wallet.setLastBlockSeenHeight(1);
  
          // Roundtrip the wallet and check it has stored the blockHash.
          Wallet wallet1 = roundTrip(wallet);
          assertEquals(blockHash, wallet1.getLastBlockSeenHash());
          assertEquals(1, wallet1.getLastBlockSeenHeight());
  
          // Test the Satoshi genesis block (hash of all zeroes) is roundtripped ok.
          Block genesisBlock = MainNetParams.get().getGenesisBlock();
          wallet.setLastBlockSeenHash(genesisBlock.getHash());
          Wallet wallet2 = roundTrip(wallet);
          assertEquals(genesisBlock.getHash(), wallet2.getLastBlockSeenHash());
      }
test_case.class_method_signature: WalletProtobufSerializerTest.testLastBlockSeenHash()
test_case.full_signature: @Test public void testLastBlockSeenHash()
test_case.identifier: testLastBlockSeenHash
test_case.invocations: walletToProto getLastSeenBlockHash assertTrue isEmpty getHash setLastBlockSeenHash setLastBlockSeenHeight roundTrip assertEquals getLastBlockSeenHash assertEquals getLastBlockSeenHeight getGenesisBlock get setLastBlockSeenHash getHash roundTrip assertEquals getHash getLastBlockSeenHash
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testLastBlockSeenHash()
focal_class.declarator: log = LoggerFactory.getLogger(WalletProtobufSerializer.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(WalletProtobufSerializer.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: txMap
focal_class.modifier: protected
focal_class.original_string: protected Map<ByteString, Transaction> txMap;
focal_class.type: Map<ByteString, Transaction>
focal_class.var_name: txMap
focal_class.declarator: requireMandatoryExtensions = true
focal_class.modifier: private
focal_class.original_string: private boolean requireMandatoryExtensions = true;
focal_class.type: boolean
focal_class.var_name: requireMandatoryExtensions
focal_class.file: core/src/main/java/com/google/bitcoin/store/WalletProtobufSerializer.java
focal_class.identifier: WalletProtobufSerializer
focal_class.class_method_signature: WalletProtobufSerializer.WalletProtobufSerializer()
focal_class.full_signature: public  WalletProtobufSerializer()
focal_class.identifier: WalletProtobufSerializer
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  WalletProtobufSerializer()
focal_class.class_method_signature: WalletProtobufSerializer.setRequireMandatoryExtensions(boolean value)
focal_class.full_signature: public void setRequireMandatoryExtensions(boolean value)
focal_class.identifier: setRequireMandatoryExtensions
focal_class.modifiers: public
focal_class.parameters: (boolean value)
focal_class.return: void
focal_class.signature: void setRequireMandatoryExtensions(boolean value)
focal_class.class_method_signature: WalletProtobufSerializer.writeWallet(Wallet wallet, OutputStream output)
focal_class.full_signature: public void writeWallet(Wallet wallet, OutputStream output)
focal_class.identifier: writeWallet
focal_class.modifiers: public
focal_class.parameters: (Wallet wallet, OutputStream output)
focal_class.return: void
focal_class.signature: void writeWallet(Wallet wallet, OutputStream output)
focal_class.class_method_signature: WalletProtobufSerializer.walletToText(Wallet wallet)
focal_class.full_signature: public String walletToText(Wallet wallet)
focal_class.identifier: walletToText
focal_class.modifiers: public
focal_class.parameters: (Wallet wallet)
focal_class.return: String
focal_class.signature: String walletToText(Wallet wallet)
focal_class.class_method_signature: WalletProtobufSerializer.walletToProto(Wallet wallet)
focal_class.full_signature: public Protos.Wallet walletToProto(Wallet wallet)
focal_class.identifier: walletToProto
focal_class.modifiers: public
focal_class.parameters: (Wallet wallet)
focal_class.return: Protos.Wallet
focal_class.signature: Protos.Wallet walletToProto(Wallet wallet)
focal_class.class_method_signature: WalletProtobufSerializer.populateExtensions(Wallet wallet, Protos.Wallet.Builder walletBuilder)
focal_class.full_signature: private static void populateExtensions(Wallet wallet, Protos.Wallet.Builder walletBuilder)
focal_class.identifier: populateExtensions
focal_class.modifiers: private static
focal_class.parameters: (Wallet wallet, Protos.Wallet.Builder walletBuilder)
focal_class.return: void
focal_class.signature: void populateExtensions(Wallet wallet, Protos.Wallet.Builder walletBuilder)
focal_class.class_method_signature: WalletProtobufSerializer.makeTxProto(WalletTransaction wtx)
focal_class.full_signature: private static Protos.Transaction makeTxProto(WalletTransaction wtx)
focal_class.identifier: makeTxProto
focal_class.modifiers: private static
focal_class.parameters: (WalletTransaction wtx)
focal_class.return: Protos.Transaction
focal_class.signature: Protos.Transaction makeTxProto(WalletTransaction wtx)
focal_class.class_method_signature: WalletProtobufSerializer.getProtoPool(WalletTransaction wtx)
focal_class.full_signature: private static Protos.Transaction.Pool getProtoPool(WalletTransaction wtx)
focal_class.identifier: getProtoPool
focal_class.modifiers: private static
focal_class.parameters: (WalletTransaction wtx)
focal_class.return: Protos.Transaction.Pool
focal_class.signature: Protos.Transaction.Pool getProtoPool(WalletTransaction wtx)
focal_class.class_method_signature: WalletProtobufSerializer.writeConfidence(Protos.Transaction.Builder txBuilder,
                                          TransactionConfidence confidence,
                                          Protos.TransactionConfidence.Builder confidenceBuilder)
focal_class.full_signature: private static void writeConfidence(Protos.Transaction.Builder txBuilder,
                                          TransactionConfidence confidence,
                                          Protos.TransactionConfidence.Builder confidenceBuilder)
focal_class.identifier: writeConfidence
focal_class.modifiers: private static
focal_class.parameters: (Protos.Transaction.Builder txBuilder,
                                          TransactionConfidence confidence,
                                          Protos.TransactionConfidence.Builder confidenceBuilder)
focal_class.return: void
focal_class.signature: void writeConfidence(Protos.Transaction.Builder txBuilder,
                                          TransactionConfidence confidence,
                                          Protos.TransactionConfidence.Builder confidenceBuilder)
focal_class.class_method_signature: WalletProtobufSerializer.hashToByteString(Sha256Hash hash)
focal_class.full_signature: public static ByteString hashToByteString(Sha256Hash hash)
focal_class.identifier: hashToByteString
focal_class.modifiers: public static
focal_class.parameters: (Sha256Hash hash)
focal_class.return: ByteString
focal_class.signature: ByteString hashToByteString(Sha256Hash hash)
focal_class.class_method_signature: WalletProtobufSerializer.byteStringToHash(ByteString bs)
focal_class.full_signature: public static Sha256Hash byteStringToHash(ByteString bs)
focal_class.identifier: byteStringToHash
focal_class.modifiers: public static
focal_class.parameters: (ByteString bs)
focal_class.return: Sha256Hash
focal_class.signature: Sha256Hash byteStringToHash(ByteString bs)
focal_class.class_method_signature: WalletProtobufSerializer.readWallet(InputStream input)
focal_class.full_signature: public Wallet readWallet(InputStream input)
focal_class.identifier: readWallet
focal_class.modifiers: public
focal_class.parameters: (InputStream input)
focal_class.return: Wallet
focal_class.signature: Wallet readWallet(InputStream input)
focal_class.class_method_signature: WalletProtobufSerializer.readWallet(Protos.Wallet walletProto, Wallet wallet)
focal_class.full_signature: public void readWallet(Protos.Wallet walletProto, Wallet wallet)
focal_class.identifier: readWallet
focal_class.modifiers: public
focal_class.parameters: (Protos.Wallet walletProto, Wallet wallet)
focal_class.return: void
focal_class.signature: void readWallet(Protos.Wallet walletProto, Wallet wallet)
focal_class.class_method_signature: WalletProtobufSerializer.loadExtensions(Wallet wallet, Protos.Wallet walletProto)
focal_class.full_signature: private void loadExtensions(Wallet wallet, Protos.Wallet walletProto)
focal_class.identifier: loadExtensions
focal_class.modifiers: private
focal_class.parameters: (Wallet wallet, Protos.Wallet walletProto)
focal_class.return: void
focal_class.signature: void loadExtensions(Wallet wallet, Protos.Wallet walletProto)
focal_class.class_method_signature: WalletProtobufSerializer.parseToProto(InputStream input)
focal_class.full_signature: public static Protos.Wallet parseToProto(InputStream input)
focal_class.identifier: parseToProto
focal_class.modifiers: public static
focal_class.parameters: (InputStream input)
focal_class.return: Protos.Wallet
focal_class.signature: Protos.Wallet parseToProto(InputStream input)
focal_class.class_method_signature: WalletProtobufSerializer.readTransaction(Protos.Transaction txProto, NetworkParameters params)
focal_class.full_signature: private void readTransaction(Protos.Transaction txProto, NetworkParameters params)
focal_class.identifier: readTransaction
focal_class.modifiers: private
focal_class.parameters: (Protos.Transaction txProto, NetworkParameters params)
focal_class.return: void
focal_class.signature: void readTransaction(Protos.Transaction txProto, NetworkParameters params)
focal_class.class_method_signature: WalletProtobufSerializer.connectTransactionOutputs(org.bitcoinj.wallet.Protos.Transaction txProto)
focal_class.full_signature: private WalletTransaction connectTransactionOutputs(org.bitcoinj.wallet.Protos.Transaction txProto)
focal_class.identifier: connectTransactionOutputs
focal_class.modifiers: private
focal_class.parameters: (org.bitcoinj.wallet.Protos.Transaction txProto)
focal_class.return: WalletTransaction
focal_class.signature: WalletTransaction connectTransactionOutputs(org.bitcoinj.wallet.Protos.Transaction txProto)
focal_class.class_method_signature: WalletProtobufSerializer.readConfidence(Transaction tx, Protos.TransactionConfidence confidenceProto,
                                  TransactionConfidence confidence)
focal_class.full_signature: private void readConfidence(Transaction tx, Protos.TransactionConfidence confidenceProto,
                                  TransactionConfidence confidence)
focal_class.identifier: readConfidence
focal_class.modifiers: private
focal_class.parameters: (Transaction tx, Protos.TransactionConfidence confidenceProto,
                                  TransactionConfidence confidence)
focal_class.return: void
focal_class.signature: void readConfidence(Transaction tx, Protos.TransactionConfidence confidenceProto,
                                  TransactionConfidence confidence)
focal_method.body: public Protos.Wallet walletToProto(Wallet wallet) {
          Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder();
          walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId());
          if (wallet.getDescription() != null) {
              walletBuilder.setDescription(wallet.getDescription());
          }
  
          for (WalletTransaction wtx : wallet.getWalletTransactions()) {
              Protos.Transaction txProto = makeTxProto(wtx);
              walletBuilder.addTransaction(txProto);
          }
  
          for (ECKey key : wallet.getKeys()) {
              Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000)
                                                           // .setLabel() TODO
                                                              .setType(Protos.Key.Type.ORIGINAL);
              if (key.getPrivKeyBytes() != null)
                  keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes()));
  
              EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey();
              if (encryptedPrivateKey != null) {
                  // Key is encrypted.
                  Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder()
                      .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes()))
                      .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector()));
  
                  if (key.getKeyCrypter() == null) {
                      throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter.");
                  } else {
                      // If it is a Scrypt + AES encrypted key, set the persisted key type.
                      if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) {
                          keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES);
                      } else {
                          throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() +
                                  ". This WalletProtobufSerialiser does not understand that type of encryption.");
                      }
                  }
                  keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder);
              }
  
              // We serialize the public key even if the private key is present for speed reasons: we don't want to do
              // lots of slow EC math to load the wallet, we prefer to store the redundant data instead. It matters more
              // on mobile platforms.
              keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey()));
              walletBuilder.addKey(keyBuilder);
          }
  
          for (Script script : wallet.getWatchedScripts()) {
              Protos.Script protoScript =
                      Protos.Script.newBuilder()
                              .setProgram(ByteString.copyFrom(script.getProgram()))
                              .setCreationTimestamp(script.getCreationTimeSeconds() * 1000)
                              .build();
  
              walletBuilder.addWatchedScript(protoScript);
          }
  
          // Populate the lastSeenBlockHash field.
          Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash();
          if (lastSeenBlockHash != null) {
              walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash));
              walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight());
          }
          if (wallet.getLastBlockSeenTimeSecs() > 0)
              walletBuilder.setLastSeenBlockTimeSecs(wallet.getLastBlockSeenTimeSecs());
  
          // Populate the scrypt parameters.
          KeyCrypter keyCrypter = wallet.getKeyCrypter();
          if (keyCrypter == null) {
              // The wallet is unencrypted.
              walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED);
          } else {
              // The wallet is encrypted.
              walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType());
              if (keyCrypter instanceof KeyCrypterScrypt) {
                  KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter;
                  walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters());
              } else {
                  // Some other form of encryption has been specified that we do not know how to persist.
                  throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this.");
              }
          }
  
          if (wallet.getKeyRotationTime() != null) {
              long timeSecs = wallet.getKeyRotationTime().getTime() / 1000;
              walletBuilder.setKeyRotationTime(timeSecs);
          }
  
          populateExtensions(wallet, walletBuilder);
  
          // Populate the wallet version.
          walletBuilder.setVersion(wallet.getVersion());
  
          return walletBuilder.build();
      }
focal_method.class_method_signature: WalletProtobufSerializer.walletToProto(Wallet wallet)
focal_method.full_signature: public Protos.Wallet walletToProto(Wallet wallet)
focal_method.identifier: walletToProto
focal_method.invocations: newBuilder setNetworkIdentifier getId getNetworkParameters getDescription setDescription getDescription getWalletTransactions makeTxProto addTransaction getKeys setType setCreationTimestamp newBuilder getCreationTimeSeconds getPrivKeyBytes setPrivateKey copyFrom getPrivKeyBytes getEncryptedPrivateKey setInitialisationVector setEncryptedPrivateKey newBuilder copyFrom getEncryptedBytes copyFrom getInitialisationVector getKeyCrypter toString getUnderstoodEncryptionType getKeyCrypter setType toString getUnderstoodEncryptionType getKeyCrypter setEncryptedPrivateKey setPublicKey copyFrom getPubKey addKey getWatchedScripts build setCreationTimestamp setProgram newBuilder copyFrom getProgram getCreationTimeSeconds addWatchedScript getLastBlockSeenHash setLastSeenBlockHash hashToByteString setLastSeenBlockHeight getLastBlockSeenHeight getLastBlockSeenTimeSecs setLastSeenBlockTimeSecs getLastBlockSeenTimeSecs getKeyCrypter setEncryptionType setEncryptionType getUnderstoodEncryptionType setEncryptionParameters getScryptParameters getUnderstoodEncryptionType getKeyRotationTime getTime getKeyRotationTime setKeyRotationTime populateExtensions setVersion getVersion build
focal_method.modifiers: public
focal_method.parameters: (Wallet wallet)
focal_method.return: Protos.Wallet
focal_method.signature: Protos.Wallet walletToProto(Wallet wallet)