mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 07:12:17 +00:00
Add Wallet.getIssuedReceiveKeys() and Wallet.getIssuedReceiveAddresses() so that derived addresses can be shown in an UI.
This commit is contained in:
parent
b3c761388f
commit
46ed65935c
@ -448,6 +448,30 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
|
||||
return freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns only the keys that have been issued by {@link #freshReceiveKey()}, {@link #freshReceiveAddress()},
|
||||
* {@link #currentReceiveKey()} or {@link #currentReceiveAddress()}.
|
||||
*/
|
||||
public List<ECKey> getIssuedReceiveKeys() {
|
||||
keychainLock.lock();
|
||||
try {
|
||||
return keychain.getActiveKeyChain().getIssuedReceiveKeys();
|
||||
} finally {
|
||||
keychainLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns only the addresses that have been issued by {@link #freshReceiveKey()}, {@link #freshReceiveAddress()},
|
||||
* {@link #currentReceiveKey()} or {@link #currentReceiveAddress()}.
|
||||
*/
|
||||
public List<Address> getIssuedReceiveAddresses() {
|
||||
final List<ECKey> keys = getIssuedReceiveKeys();
|
||||
List<Address> addresses = new ArrayList<Address>(keys.size());
|
||||
for (ECKey key : keys)
|
||||
addresses.add(key.toAddress(getParams()));
|
||||
return addresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrades the wallet to be deterministic (BIP32). You should call this, possibly providing the users encryption
|
||||
|
@ -1200,6 +1200,12 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns only the keys that have been issued by this chain, lookahead not included.
|
||||
*/
|
||||
public List<ECKey> getIssuedReceiveKeys() {
|
||||
return getKeys(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns leaf keys issued by this chain (including lookahead zone)
|
||||
|
Loading…
Reference in New Issue
Block a user