Ejemplo n.º 1
0
 @Test
 public void markAsUsed() throws Exception {
   Address addr1 = group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
   Address addr2 = group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
   assertEquals(addr1, addr2);
   group.markPubKeyHashAsUsed(addr1.getHash160());
   Address addr3 = group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
   assertNotEquals(addr2, addr3);
 }
Ejemplo n.º 2
0
 @Test
 public void currentP2SHAddress() throws Exception {
   group = createMarriedKeyChainGroup();
   Address a1 = group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
   assertTrue(a1.isP2SHAddress());
   Address a2 = group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
   assertEquals(a1, a2);
   Address a3 = group.currentAddress(KeyChain.KeyPurpose.CHANGE);
   assertNotEquals(a2, a3);
 }
Ejemplo n.º 3
0
  @Test
  public void serializeMarried() throws Exception {
    group = createMarriedKeyChainGroup();
    Address address1 = group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    assertTrue(group.isMarried());

    List<Protos.Key> protoKeys = group.serializeToProtobuf();
    KeyChainGroup group2 = KeyChainGroup.fromProtobufUnencrypted(params, protoKeys);
    assertTrue(group2.isMarried());
    Address address2 = group2.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    assertEquals(address1, address2);
  }
Ejemplo n.º 4
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());
  }
Ejemplo n.º 5
0
  @Test
  public void freshAddress() throws Exception {
    group = createMarriedKeyChainGroup();
    Address a1 = group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    Address a2 = group.freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    assertTrue(a1.isP2SHAddress());
    assertNotEquals(a1, a2);
    group.getBloomFilterElementCount();
    assertEquals(
        ((group.getLookaheadSize() + group.getLookaheadThreshold())
                * 2) // * 2 because of internal/external
            + (2 - group.getLookaheadThreshold()) // keys issued
            + 4 /* master, account, int, ext */,
        group.numKeys());

    Address a3 = group.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    assertEquals(a2, a3);
  }