mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 14:54:15 +00:00
Wallet now delegates currentAddress/freshAddress calls to KeychainGroup
This way it's possible for KCG to yield P2H addresses in future
This commit is contained in:
parent
927d8514f5
commit
eae64a5357
@ -305,7 +305,12 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
|
||||
* Returns address for a {@link #currentKey(com.google.bitcoin.wallet.KeyChain.KeyPurpose)}
|
||||
*/
|
||||
public Address currentAddress(KeyChain.KeyPurpose purpose) {
|
||||
return currentKey(purpose).toAddress(params);
|
||||
lock.lock();
|
||||
try {
|
||||
return keychain.currentAddress(purpose, params);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -349,7 +354,14 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
|
||||
* Returns address for a {@link #freshKey(com.google.bitcoin.wallet.KeyChain.KeyPurpose)}
|
||||
*/
|
||||
public Address freshAddress(KeyChain.KeyPurpose purpose) {
|
||||
return freshKey(purpose).toAddress(params);
|
||||
lock.lock();
|
||||
try {
|
||||
Address key = keychain.freshAddress(purpose, params);
|
||||
saveNow();
|
||||
return key;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,6 +117,13 @@ public class KeyChainGroup {
|
||||
return current != null ? current : freshKey(purpose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns address for a {@link #currentKey(com.google.bitcoin.wallet.KeyChain.KeyPurpose)}
|
||||
*/
|
||||
public Address currentAddress(KeyChain.KeyPurpose purpose, NetworkParameters params) {
|
||||
return currentKey(purpose).toAddress(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a key that has not been returned by this method before (fresh). You can think of this as being
|
||||
* a newly created key, although the notion of "create" is not really valid for a
|
||||
@ -132,6 +139,13 @@ public class KeyChainGroup {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns address for a {@link #freshKey(com.google.bitcoin.wallet.KeyChain.KeyPurpose)}
|
||||
*/
|
||||
public Address freshAddress(KeyChain.KeyPurpose purpose, NetworkParameters params) {
|
||||
return freshKey(purpose).toAddress(params);
|
||||
}
|
||||
|
||||
/** Returns the key chain that's used for generation of fresh/current keys. This is always the newest HD chain. */
|
||||
public DeterministicKeyChain getActiveKeyChain() {
|
||||
if (chains.isEmpty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user