Exemplo n.º 1
0
  @Test
  public void findRedeemData() throws Exception {
    group = createMarriedKeyChainGroup();

    // test script hash that we don't have
    assertNull(group.findRedeemDataFromScriptHash(new ECKey().getPubKey()));

    // test our script hash
    Address address = group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    RedeemData redeemData = group.findRedeemDataFromScriptHash(address.getHash160());
    assertNotNull(redeemData);
    assertNotNull(redeemData.redeemScript);
    assertEquals(2, redeemData.keys.size());
  }
Exemplo n.º 2
0
 @Test
 public void findRedeemScriptFromPubHash() throws Exception {
   group = createMarriedKeyChainGroup();
   Address address = group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
   assertTrue(group.findRedeemDataFromScriptHash(address.getHash160()) != null);
   group.getBloomFilterElementCount();
   KeyChainGroup group2 = createMarriedKeyChainGroup();
   group2.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
   group2.getBloomFilterElementCount(); // Force lookahead.
   // test address from lookahead zone and lookahead threshold zone
   for (int i = 0; i < group.getLookaheadSize() + group.getLookaheadThreshold(); i++) {
     address = group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
     assertTrue(group2.findRedeemDataFromScriptHash(address.getHash160()) != null);
   }
   assertFalse(
       group2.findRedeemDataFromScriptHash(
               group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS).getHash160())
           != null);
 }