mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 09:20:04 +01:00
Wallet: improve JavaDoc for fromMasterKey()
The JavaDoc was incorrect/incomplete. The changes add `@param`/`@return` items, fix errors, add important details.
This commit is contained in:
parent
74153c321f
commit
1f7ed7f94b
1 changed files with 12 additions and 4 deletions
|
@ -582,14 +582,22 @@ public class Wallet extends BaseTaggableObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given spending key. This HAS
|
||||
* to be an account key as returned by {@link DeterministicKeyChain#getWatchingKey()}.
|
||||
* @param network network wallet will operate on
|
||||
* Creates a spending wallet that tracks payments to and from a BIP32-style HD key hierarchy rooted by {@code masterKey} and
|
||||
* {@code accountNumber}. The account path must be directly below the master key as in BIP-32.
|
||||
* <p>
|
||||
* This method should not be used for BIP-43 compliant wallets or accounts not of the form {@code m/accountNumber'}.
|
||||
* <p>
|
||||
* This wallet will not store the {@code masterKey}, only the account key.
|
||||
* @param network network the wallet will operate on
|
||||
* @param masterKey root private key (e.g. path {@code m})
|
||||
* @param outputScriptType type of addresses (aka output scripts) to generate for receiving
|
||||
* @param accountNumber account number to append, resulting in an account path of {@code m/accountNumber'}
|
||||
* @return newly created Wallet object
|
||||
*/
|
||||
public static Wallet fromMasterKey(Network network, DeterministicKey masterKey,
|
||||
ScriptType outputScriptType, ChildNumber accountNumber) {
|
||||
DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(masterKey, accountNumber);
|
||||
accountKey = accountKey.dropParent();
|
||||
accountKey = accountKey.dropParent(); // Drop the parent private key, so it won't be used or saved.
|
||||
Optional<Instant> creationTime = masterKey.creationTime();
|
||||
if (creationTime.isPresent())
|
||||
accountKey.setCreationTime(creationTime.get());
|
||||
|
|
Loading…
Add table
Reference in a new issue