test_class.declarator: testNetChain
test_class.modifier: private
test_class.original_string: private BlockChain testNetChain;
test_class.type: BlockChain
test_class.var_name: testNetChain
test_class.declarator: wallet
test_class.modifier: private
test_class.original_string: private Wallet wallet;
test_class.type: Wallet
test_class.var_name: wallet
test_class.declarator: chain
test_class.modifier: private
test_class.original_string: private BlockChain chain;
test_class.type: BlockChain
test_class.var_name: chain
test_class.declarator: blockStore
test_class.modifier: private
test_class.original_string: private BlockStore blockStore;
test_class.type: BlockStore
test_class.var_name: blockStore
test_class.declarator: coinbaseTo
test_class.modifier: private
test_class.original_string: private Address coinbaseTo;
test_class.type: Address
test_class.var_name: coinbaseTo
test_class.declarator: unitTestParams
test_class.modifier: private
test_class.original_string: private NetworkParameters unitTestParams;
test_class.type: NetworkParameters
test_class.var_name: unitTestParams
test_class.declarator: block = new StoredBlock[1]
test_class.modifier: private final
test_class.original_string: private final StoredBlock[] block = new StoredBlock[1];
test_class.type: StoredBlock[]
test_class.var_name: block
test_class.declarator: coinbaseTransaction
test_class.modifier: private
test_class.original_string: private Transaction coinbaseTransaction;
test_class.type: Transaction
test_class.var_name: coinbaseTransaction
test_class.declarator: testNet = new TweakableTestNet2Params()
test_class.modifier: private static final
test_class.original_string: private static final TweakableTestNet2Params testNet = new TweakableTestNet2Params();
test_class.type: TweakableTestNet2Params
test_class.var_name: testNet
test_class.file: core/src/test/java/com/google/bitcoin/core/BlockChainTest.java
test_class.identifier: BlockChainTest
test_case.body: @Test
      public void coinbaseTransactionAvailability() throws Exception {
          // Check that a coinbase transaction is only available to spend after NetworkParameters.getSpendableCoinbaseDepth() blocks.
  
          // Create a second wallet to receive the coinbase spend.
          Wallet wallet2 = new Wallet(unitTestParams);
          ECKey receiveKey = new ECKey();
          wallet2.addKey(receiveKey);
          chain.addWallet(wallet2);
  
          Address addressToSendTo = receiveKey.toAddress(unitTestParams);
  
          // Create a block, sending the coinbase to the coinbaseTo address (which is in the wallet).
          Block b1 = unitTestParams.getGenesisBlock().createNextBlockWithCoinbase(wallet.getKeys().get(0).getPubKey());
          chain.add(b1);
  
          // Check a transaction has been received.
          assertNotNull(coinbaseTransaction);
  
          // The coinbase tx is not yet available to spend.
          assertEquals(BigInteger.ZERO, wallet.getBalance());
          assertEquals(wallet.getBalance(BalanceType.ESTIMATED), Utils.toNanoCoins(50, 0));
          assertTrue(!coinbaseTransaction.isMature());
  
          // Attempt to spend the coinbase - this should fail as the coinbase is not mature yet.
          try {
              wallet.createSend(addressToSendTo, Utils.toNanoCoins(49, 0));
              fail();
          } catch (InsufficientMoneyException e) {
          }
  
          // Check that the coinbase is unavailable to spend for the next spendableCoinbaseDepth - 2 blocks.
          for (int i = 0; i < unitTestParams.getSpendableCoinbaseDepth() - 2; i++) {
              // Non relevant tx - just for fake block creation.
              Transaction tx2 = createFakeTx(unitTestParams, Utils.toNanoCoins(1, 0),
                  new ECKey().toAddress(unitTestParams));
  
              Block b2 = createFakeBlock(blockStore, tx2).block;
              chain.add(b2);
  
              // Wallet still does not have the coinbase transaction available for spend.
              assertEquals(BigInteger.ZERO, wallet.getBalance());
              assertEquals(wallet.getBalance(BalanceType.ESTIMATED), Utils.toNanoCoins(50, 0));
  
              // The coinbase transaction is still not mature.
              assertTrue(!coinbaseTransaction.isMature());
  
              // Attempt to spend the coinbase - this should fail.
              try {
                  wallet.createSend(addressToSendTo, Utils.toNanoCoins(49, 0));
                  fail();
              } catch (InsufficientMoneyException e) {
              }
          }
  
          // Give it one more block - should now be able to spend coinbase transaction. Non relevant tx.
          Transaction tx3 = createFakeTx(unitTestParams, Utils.toNanoCoins(1, 0), new ECKey().toAddress(unitTestParams));
          Block b3 = createFakeBlock(blockStore, tx3).block;
          chain.add(b3);
  
          // Wallet now has the coinbase transaction available for spend.
          assertEquals(wallet.getBalance(), Utils.toNanoCoins(50, 0));
          assertEquals(wallet.getBalance(BalanceType.ESTIMATED), Utils.toNanoCoins(50, 0));
          assertTrue(coinbaseTransaction.isMature());
  
          // Create a spend with the coinbase BTC to the address in the second wallet - this should now succeed.
          Transaction coinbaseSend2 = wallet.createSend(addressToSendTo, Utils.toNanoCoins(49, 0));
          assertNotNull(coinbaseSend2);
  
          // Commit the coinbaseSpend to the first wallet and check the balances decrement.
          wallet.commitTx(coinbaseSend2);
          assertEquals(wallet.getBalance(BalanceType.ESTIMATED), Utils.toNanoCoins(1, 0));
          // Available balance is zero as change has not been received from a block yet.
          assertEquals(wallet.getBalance(BalanceType.AVAILABLE), Utils.toNanoCoins(0, 0));
  
          // Give it one more block - change from coinbaseSpend should now be available in the first wallet.
          Block b4 = createFakeBlock(blockStore, coinbaseSend2).block;
          chain.add(b4);
          assertEquals(wallet.getBalance(BalanceType.AVAILABLE), Utils.toNanoCoins(1, 0));
  
          // Check the balances in the second wallet.
          assertEquals(wallet2.getBalance(BalanceType.ESTIMATED), Utils.toNanoCoins(49, 0));
          assertEquals(wallet2.getBalance(BalanceType.AVAILABLE), Utils.toNanoCoins(49, 0));
      }
test_case.class_method_signature: BlockChainTest.coinbaseTransactionAvailability()
test_case.full_signature: @Test public void coinbaseTransactionAvailability()
test_case.identifier: coinbaseTransactionAvailability
test_case.invocations: addKey addWallet toAddress createNextBlockWithCoinbase getGenesisBlock getPubKey get getKeys add assertNotNull assertEquals getBalance assertEquals getBalance toNanoCoins assertTrue isMature createSend toNanoCoins fail getSpendableCoinbaseDepth createFakeTx toNanoCoins toAddress createFakeBlock add assertEquals getBalance assertEquals getBalance toNanoCoins assertTrue isMature createSend toNanoCoins fail createFakeTx toNanoCoins toAddress createFakeBlock add assertEquals getBalance toNanoCoins assertEquals getBalance toNanoCoins assertTrue isMature createSend toNanoCoins assertNotNull commitTx assertEquals getBalance toNanoCoins assertEquals getBalance toNanoCoins createFakeBlock add assertEquals getBalance toNanoCoins assertEquals getBalance toNanoCoins assertEquals getBalance toNanoCoins
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void coinbaseTransactionAvailability()
focal_class.declarator: blockStore
focal_class.modifier: protected final
focal_class.original_string: protected final BlockStore blockStore;
focal_class.type: BlockStore
focal_class.var_name: blockStore
focal_class.file: core/src/main/java/com/google/bitcoin/core/BlockChain.java
focal_class.identifier: BlockChain
focal_class.class_method_signature: BlockChain.BlockChain(NetworkParameters params, Wallet wallet, BlockStore blockStore)
focal_class.full_signature: public  BlockChain(NetworkParameters params, Wallet wallet, BlockStore blockStore)
focal_class.identifier: BlockChain
focal_class.modifiers: public
focal_class.parameters: (NetworkParameters params, Wallet wallet, BlockStore blockStore)
focal_class.signature:  BlockChain(NetworkParameters params, Wallet wallet, BlockStore blockStore)
focal_class.class_method_signature: BlockChain.BlockChain(NetworkParameters params, BlockStore blockStore)
focal_class.full_signature: public  BlockChain(NetworkParameters params, BlockStore blockStore)
focal_class.identifier: BlockChain
focal_class.modifiers: public
focal_class.parameters: (NetworkParameters params, BlockStore blockStore)
focal_class.signature:  BlockChain(NetworkParameters params, BlockStore blockStore)
focal_class.class_method_signature: BlockChain.BlockChain(NetworkParameters params, List<BlockChainListener> wallets,
                        BlockStore blockStore)
focal_class.full_signature: public  BlockChain(NetworkParameters params, List<BlockChainListener> wallets,
                        BlockStore blockStore)
focal_class.identifier: BlockChain
focal_class.modifiers: public
focal_class.parameters: (NetworkParameters params, List<BlockChainListener> wallets,
                        BlockStore blockStore)
focal_class.signature:  BlockChain(NetworkParameters params, List<BlockChainListener> wallets,
                        BlockStore blockStore)
focal_class.class_method_signature: BlockChain.addToBlockStore(StoredBlock storedPrev, Block blockHeader, TransactionOutputChanges txOutChanges)
focal_class.full_signature: @Override protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader, TransactionOutputChanges txOutChanges)
focal_class.identifier: addToBlockStore
focal_class.modifiers: @Override protected
focal_class.parameters: (StoredBlock storedPrev, Block blockHeader, TransactionOutputChanges txOutChanges)
focal_class.return: StoredBlock
focal_class.signature: StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader, TransactionOutputChanges txOutChanges)
focal_class.class_method_signature: BlockChain.addToBlockStore(StoredBlock storedPrev, Block blockHeader)
focal_class.full_signature: @Override protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader)
focal_class.identifier: addToBlockStore
focal_class.modifiers: @Override protected
focal_class.parameters: (StoredBlock storedPrev, Block blockHeader)
focal_class.return: StoredBlock
focal_class.signature: StoredBlock addToBlockStore(StoredBlock storedPrev, Block blockHeader)
focal_class.class_method_signature: BlockChain.shouldVerifyTransactions()
focal_class.full_signature: @Override protected boolean shouldVerifyTransactions()
focal_class.identifier: shouldVerifyTransactions
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean shouldVerifyTransactions()
focal_class.class_method_signature: BlockChain.connectTransactions(int height, Block block)
focal_class.full_signature: @Override protected TransactionOutputChanges connectTransactions(int height, Block block)
focal_class.identifier: connectTransactions
focal_class.modifiers: @Override protected
focal_class.parameters: (int height, Block block)
focal_class.return: TransactionOutputChanges
focal_class.signature: TransactionOutputChanges connectTransactions(int height, Block block)
focal_class.class_method_signature: BlockChain.connectTransactions(StoredBlock newBlock)
focal_class.full_signature: @Override protected TransactionOutputChanges connectTransactions(StoredBlock newBlock)
focal_class.identifier: connectTransactions
focal_class.modifiers: @Override protected
focal_class.parameters: (StoredBlock newBlock)
focal_class.return: TransactionOutputChanges
focal_class.signature: TransactionOutputChanges connectTransactions(StoredBlock newBlock)
focal_class.class_method_signature: BlockChain.disconnectTransactions(StoredBlock block)
focal_class.full_signature: @Override protected void disconnectTransactions(StoredBlock block)
focal_class.identifier: disconnectTransactions
focal_class.modifiers: @Override protected
focal_class.parameters: (StoredBlock block)
focal_class.return: void
focal_class.signature: void disconnectTransactions(StoredBlock block)
focal_class.class_method_signature: BlockChain.doSetChainHead(StoredBlock chainHead)
focal_class.full_signature: @Override protected void doSetChainHead(StoredBlock chainHead)
focal_class.identifier: doSetChainHead
focal_class.modifiers: @Override protected
focal_class.parameters: (StoredBlock chainHead)
focal_class.return: void
focal_class.signature: void doSetChainHead(StoredBlock chainHead)
focal_class.class_method_signature: BlockChain.notSettingChainHead()
focal_class.full_signature: @Override protected void notSettingChainHead()
focal_class.identifier: notSettingChainHead
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void notSettingChainHead()
focal_class.class_method_signature: BlockChain.getStoredBlockInCurrentScope(Sha256Hash hash)
focal_class.full_signature: @Override protected StoredBlock getStoredBlockInCurrentScope(Sha256Hash hash)
focal_class.identifier: getStoredBlockInCurrentScope
focal_class.modifiers: @Override protected
focal_class.parameters: (Sha256Hash hash)
focal_class.return: StoredBlock
focal_class.signature: StoredBlock getStoredBlockInCurrentScope(Sha256Hash hash)
focal_class.class_method_signature: BlockChain.add(FilteredBlock block)
focal_class.full_signature: @Override public boolean add(FilteredBlock block)
focal_class.identifier: add
focal_class.modifiers: @Override public
focal_class.parameters: (FilteredBlock block)
focal_class.return: boolean
focal_class.signature: boolean add(FilteredBlock block)
focal_class.superclass: extends AbstractBlockChain
focal_method.body: @Override
      public boolean add(FilteredBlock block) throws VerificationException, PrunedException {
          boolean success = super.add(block);
          if (success) {
              trackFilteredTransactions(block.getTransactionCount());
          }
          return success;
      }
focal_method.class_method_signature: BlockChain.add(FilteredBlock block)
focal_method.full_signature: @Override public boolean add(FilteredBlock block)
focal_method.identifier: add
focal_method.invocations: add trackFilteredTransactions getTransactionCount
focal_method.modifiers: @Override public
focal_method.parameters: (FilteredBlock block)
focal_method.return: boolean
focal_method.signature: boolean add(FilteredBlock block)