コード例 #1
0
 @Test
 public void getKey() {
   ECKey key1 = chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
   assertTrue(onKeysAddedRan.getAndSet(false));
   assertEquals(key1, onKeysAdded.getAndSet(null).get(0));
   ECKey key2 = chain.getKey(KeyChain.KeyPurpose.CHANGE);
   assertFalse(onKeysAddedRan.getAndSet(false));
   assertEquals(key2, key1);
 }
コード例 #2
0
  @Test(expected = KeyCrypterException.class)
  public void cannotImportEncryptedKey() {
    final ECKey key1 = new ECKey();
    chain.importKeys(ImmutableList.of(key1));
    chain = chain.toEncrypted("foobar");
    ECKey encryptedKey = chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    assertTrue(encryptedKey.isEncrypted());

    BasicKeyChain chain2 = new BasicKeyChain();
    chain2.importKeys(ImmutableList.of(encryptedKey));
  }