Package org.bitcoinj.wallet
Class DeterministicSeed
- java.lang.Object
- 
- org.bitcoinj.wallet.DeterministicSeed
 
- 
- All Implemented Interfaces:
- EncryptableItem
 
 public class DeterministicSeed extends java.lang.Object implements EncryptableItem Holds the seed bytes for the BIP32 deterministic wallet algorithm, inside aDeterministicKeyChain. The purpose of this wrapper is to simplify the encryption code.
- 
- 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_SEED_ENTROPY_BITSstatic intMAX_SEED_ENTROPY_BITS
 - 
Constructor SummaryConstructors Constructor Description DeterministicSeed(byte[] entropy, java.lang.String passphrase, long creationTimeSecs)Deprecated.DeterministicSeed(java.lang.String mnemonicString, byte[] seed, java.lang.String passphrase, long creationTimeSecs)Deprecated.DeterministicSeed(java.security.SecureRandom random, int bits, java.lang.String passphrase)Deprecated.DeterministicSeed(java.util.List<java.lang.String> mnemonicCode, byte[] seed, java.lang.String passphrase, long creationTimeSecs)Deprecated.DeterministicSeed(EncryptedData encryptedMnemonic, EncryptedData encryptedSeed, long creationTimeSecs)Deprecated.will be removed in a future release
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcheck()Check if our mnemonic is a valid mnemonic phrase for our word list.voidclearCreationTime()Clears the creation time of this seed.java.util.Optional<java.time.Instant>creationTime()Returns the time at which this encryptable item was first created/derived, or empty of unknown.DeterministicSeeddecrypt(KeyCrypter crypter, java.lang.String passphrase, AesKey aesKey)DeterministicSeedencrypt(KeyCrypter keyCrypter, AesKey aesKey)booleanequals(java.lang.Object o)EncryptedDatagetEncryptedData()Returns the initialization vector and encrypted secret bytes, or null if not encrypted.EncryptedDatagetEncryptedSeedData()Protos.Wallet.EncryptionTypegetEncryptionType()Returns an enum constant describing what algorithm was used to encrypt the key or UNENCRYPTED.java.util.List<java.lang.String>getMnemonicCode()Get the mnemonic code, or null if unknown.java.lang.StringgetMnemonicString()Get the mnemonic code as string, or null if unknown.byte[]getSecretBytes()Returns the raw bytes of the item, if not encrypted, or null if encrypted or the secret is missing.byte[]getSeedBytes()inthashCode()booleanisEncrypted()Returns whether the item is encrypted or not.static DeterministicSeedofEntropy(byte[] entropy, java.lang.String passphrase)Constructs a BIP 39 mnemonic code and a seed from a given entropy.static DeterministicSeedofEntropy(byte[] entropy, java.lang.String passphrase, java.time.Instant creationTime)Constructs a BIP 39 mnemonic code and a seed from a given entropy.static DeterministicSeedofMnemonic(java.lang.String mnemonicCode, java.lang.String passphrase)Constructs a seed from a BIP 39 mnemonic code.static DeterministicSeedofMnemonic(java.lang.String mnemonicCode, java.lang.String passphrase, java.time.Instant creationTime)Constructs a seed from a BIP 39 mnemonic code.static DeterministicSeedofMnemonic(java.util.List<java.lang.String> mnemonicCode, java.lang.String passphrase)Constructs a seed from a BIP 39 mnemonic code.static DeterministicSeedofMnemonic(java.util.List<java.lang.String> mnemonicCode, java.lang.String passphrase, java.time.Instant creationTime)Constructs a seed from a BIP 39 mnemonic code.static DeterministicSeedofRandom(java.security.SecureRandom random, int bits, java.lang.String passphrase)Constructs a BIP 39 mnemonic code and a seed randomly.voidsetCreationTime(java.time.Instant creationTime)Sets the creation time of this seed.voidsetCreationTimeSeconds(long creationTimeSecs)Deprecated.java.lang.StringtoHexString()Returns the seed as hex or null if encrypted.java.lang.StringtoString()java.lang.StringtoString(boolean includePrivate)- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.bitcoinj.crypto.EncryptableItemgetCreationTimeSeconds
 
- 
 
- 
- 
- 
Field Detail- 
DEFAULT_SEED_ENTROPY_BITSpublic static final int DEFAULT_SEED_ENTROPY_BITS - See Also:
- Constant Field Values
 
 - 
MAX_SEED_ENTROPY_BITSpublic static final int MAX_SEED_ENTROPY_BITS - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
DeterministicSeed@Deprecated public DeterministicSeed(java.lang.String mnemonicString, byte[] seed, java.lang.String passphrase, long creationTimeSecs)Deprecated.
 - 
DeterministicSeed@Deprecated public DeterministicSeed(EncryptedData encryptedMnemonic, @Nullable EncryptedData encryptedSeed, long creationTimeSecs) Deprecated.will be removed in a future release
 - 
DeterministicSeed@Deprecated public DeterministicSeed(java.util.List<java.lang.String> mnemonicCode, @Nullable byte[] seed, java.lang.String passphrase, long creationTimeSecs)Deprecated.
 - 
DeterministicSeed@Deprecated public DeterministicSeed(java.security.SecureRandom random, int bits, java.lang.String passphrase)Deprecated.
 - 
DeterministicSeed@Deprecated public DeterministicSeed(byte[] entropy, java.lang.String passphrase, long creationTimeSecs)Deprecated.
 
- 
 - 
Method Detail- 
ofMnemonicpublic static DeterministicSeed ofMnemonic(java.lang.String mnemonicCode, java.lang.String passphrase, java.time.Instant creationTime) Constructs a seed from a BIP 39 mnemonic code. SeeMnemonicCodefor more details on this scheme.- Parameters:
- mnemonicCode- list of words, space separated
- passphrase- user supplied passphrase, or empty string if there is no passphrase
- creationTime- when the seed was originally created
 
 - 
ofMnemonicpublic static DeterministicSeed ofMnemonic(java.lang.String mnemonicCode, java.lang.String passphrase) Constructs a seed from a BIP 39 mnemonic code. SeeMnemonicCodefor more details on this scheme. Use this if you don't know the seed's creation time.- Parameters:
- mnemonicCode- list of words, space separated
- passphrase- user supplied passphrase, or empty string if there is no passphrase
 
 - 
ofMnemonicpublic static DeterministicSeed ofMnemonic(java.util.List<java.lang.String> mnemonicCode, java.lang.String passphrase, java.time.Instant creationTime) Constructs a seed from a BIP 39 mnemonic code. SeeMnemonicCodefor more details on this scheme.- Parameters:
- mnemonicCode- list of words
- passphrase- user supplied passphrase, or empty string if there is no passphrase
- creationTime- when the seed was originally created
 
 - 
ofMnemonicpublic static DeterministicSeed ofMnemonic(java.util.List<java.lang.String> mnemonicCode, java.lang.String passphrase) Constructs a seed from a BIP 39 mnemonic code. SeeMnemonicCodefor more details on this scheme. Use this if you don't know the seed's creation time.- Parameters:
- mnemonicCode- list of words
- passphrase- user supplied passphrase, or empty string if there is no passphrase
 
 - 
ofEntropypublic static DeterministicSeed ofEntropy(byte[] entropy, java.lang.String passphrase, java.time.Instant creationTime) Constructs a BIP 39 mnemonic code and a seed from a given entropy. SeeMnemonicCodefor more details on this scheme.- Parameters:
- entropy- entropy bits, length must be at least 128 bits and a multiple of 32 bits
- passphrase- user supplied passphrase, or empty string if there is no passphrase
- creationTime- when the seed was originally created
 
 - 
ofEntropypublic static DeterministicSeed ofEntropy(byte[] entropy, java.lang.String passphrase) Constructs a BIP 39 mnemonic code and a seed from a given entropy. SeeMnemonicCodefor more details on this scheme. Use this if you don't know the seed's creation time.- Parameters:
- entropy- entropy bits, length must be at least 128 bits and a multiple of 32 bits
- passphrase- user supplied passphrase, or empty string if there is no passphrase
 
 - 
ofRandompublic static DeterministicSeed ofRandom(java.security.SecureRandom random, int bits, java.lang.String passphrase) Constructs a BIP 39 mnemonic code and a seed randomly. SeeMnemonicCodefor more details on this scheme.- Parameters:
- random- random source for the entropy
- bits- number of bits of entropy, must be at least 128 bits and a multiple of 32 bits
- passphrase- user supplied passphrase, or empty string if there is no passphrase
 
 - 
isEncryptedpublic boolean isEncrypted() Description copied from interface:EncryptableItemReturns whether the item is encrypted or not. If it is, thenEncryptableItem.getSecretBytes()will return null.- Specified by:
- isEncryptedin interface- EncryptableItem
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString(boolean includePrivate) 
 - 
toHexString@Nullable public java.lang.String toHexString() Returns the seed as hex or null if encrypted.
 - 
getSecretBytes@Nullable public byte[] getSecretBytes() Description copied from interface:EncryptableItemReturns the raw bytes of the item, if not encrypted, or null if encrypted or the secret is missing.- Specified by:
- getSecretBytesin interface- EncryptableItem
 
 - 
getSeedBytes@Nullable public byte[] getSeedBytes() 
 - 
getEncryptedData@Nullable public EncryptedData getEncryptedData() Description copied from interface:EncryptableItemReturns the initialization vector and encrypted secret bytes, or null if not encrypted.- Specified by:
- getEncryptedDatain interface- EncryptableItem
 
 - 
getEncryptionTypepublic Protos.Wallet.EncryptionType getEncryptionType() Description copied from interface:EncryptableItemReturns an enum constant describing what algorithm was used to encrypt the key or UNENCRYPTED.- Specified by:
- getEncryptionTypein interface- EncryptableItem
 
 - 
getEncryptedSeedData@Nullable public EncryptedData getEncryptedSeedData() 
 - 
creationTimepublic java.util.Optional<java.time.Instant> creationTime() Description copied from interface:EncryptableItemReturns the time at which this encryptable item was first created/derived, or empty of unknown.- Specified by:
- creationTimein interface- EncryptableItem
 
 - 
setCreationTimepublic void setCreationTime(java.time.Instant creationTime) Sets the creation time of this seed.- Parameters:
- creationTime- creation time of this seed
 
 - 
clearCreationTimepublic void clearCreationTime() Clears the creation time of this seed. This is mainly used deserialization and cloning. Normally you should not need to use this, as keys should have proper creation times whenever possible.
 - 
setCreationTimeSeconds@Deprecated public void setCreationTimeSeconds(long creationTimeSecs) Deprecated.
 - 
encryptpublic DeterministicSeed encrypt(KeyCrypter keyCrypter, AesKey aesKey) 
 - 
decryptpublic DeterministicSeed decrypt(KeyCrypter crypter, java.lang.String passphrase, AesKey aesKey) 
 - 
equalspublic boolean equals(java.lang.Object o) - Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
checkpublic void check() throws MnemonicExceptionCheck if our mnemonic is a valid mnemonic phrase for our word list. Does nothing if we are encrypted.- Throws:
- MnemonicException- if check fails
 
 - 
getMnemonicCode@Nullable public java.util.List<java.lang.String> getMnemonicCode() Get the mnemonic code, or null if unknown.
 - 
getMnemonicString@Nullable public java.lang.String getMnemonicString() Get the mnemonic code as string, or null if unknown.
 
- 
 
-