mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 21:32:35 +01:00
HD Wallets: add getImportedKeys() method that returns just the basic key chain.
This commit is contained in:
parent
6951a6bc65
commit
dbf504faa0
@ -358,6 +358,18 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the non-deterministic keys that have been imported into the wallet, or the empty list if none.
|
||||
*/
|
||||
public List<ECKey> getImportedKeys() {
|
||||
lock.lock();
|
||||
try {
|
||||
return keychain.getImportedKeys();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the address used for change outputs. Note: this will probably go away in future. */
|
||||
public Address getChangeAddress() {
|
||||
return currentKey(KeyChain.KeyPurpose.CHANGE).toAddress(params);
|
||||
|
@ -276,6 +276,13 @@ public class KeyChainGroup {
|
||||
/** Returns the key crypter or null if the group is not encrypted. */
|
||||
@Nullable public KeyCrypter getKeyCrypter() { return keyCrypter; }
|
||||
|
||||
/**
|
||||
* Returns a list of the non-deterministic keys that have been imported into the wallet, or the empty list if none.
|
||||
*/
|
||||
public List<ECKey> getImportedKeys() {
|
||||
return basic.getKeys();
|
||||
}
|
||||
|
||||
public long getEarliestKeyCreationTime() {
|
||||
long time = basic.getEarliestKeyCreationTime(); // Long.MAX_VALUE if empty.
|
||||
for (DeterministicKeyChain chain : chains)
|
||||
|
@ -1417,6 +1417,8 @@ public class WalletTest extends TestWithWallet {
|
||||
public void importAndEncrypt() throws IOException, InsufficientMoneyException {
|
||||
final ECKey key = new ECKey();
|
||||
encryptedWallet.importKeysAndEncrypt(ImmutableList.of(key), PASSWORD1);
|
||||
assertEquals(1, encryptedWallet.getImportedKeys().size());
|
||||
assertEquals(key.getPubKeyPoint(), encryptedWallet.getImportedKeys().get(0).getPubKeyPoint());
|
||||
sendMoneyToWallet(encryptedWallet, Utils.COIN, key.toAddress(params), AbstractBlockChain.NewBlockType.BEST_CHAIN);
|
||||
assertEquals(Utils.COIN, encryptedWallet.getBalance());
|
||||
SendRequest req = Wallet.SendRequest.emptyWallet(new ECKey().toAddress(params));
|
||||
|
Loading…
Reference in New Issue
Block a user