Package org.bitcoinj.wallet
Class DeterministicSeed
java.lang.Object
org.bitcoinj.wallet.DeterministicSeed
- All Implemented Interfaces:
EncryptableItem
Holds the seed bytes for the BIP32 deterministic wallet algorithm, inside a
DeterministicKeyChain
. The purpose of this wrapper is to simplify the encryption
code.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
ConstructorDescriptionDeterministicSeed
(byte[] entropy, String passphrase, long creationTimeSeconds) Constructs a seed from a BIP 39 mnemonic code.DeterministicSeed
(byte[] seed, List<String> mnemonic, long creationTimeSeconds) DeterministicSeed
(String mnemonicString, byte[] seed, String passphrase, long creationTimeSeconds) DeterministicSeed
(SecureRandom random, int bits, String passphrase) Constructs a seed from a BIP 39 mnemonic code.DeterministicSeed
(List<String> mnemonicCode, byte[] seed, String passphrase, long creationTimeSeconds) Constructs a seed from a BIP 39 mnemonic code.DeterministicSeed
(EncryptedData encryptedMnemonic, EncryptedData encryptedSeed, long creationTimeSeconds) -
Method Summary
Modifier and TypeMethodDescriptionvoid
check()
Check if our mnemonic is a valid mnemonic phrase for our word list.decrypt
(KeyCrypter crypter, String passphrase, org.bouncycastle.crypto.params.KeyParameter aesKey) encrypt
(KeyCrypter keyCrypter, org.bouncycastle.crypto.params.KeyParameter aesKey) boolean
long
Returns the time in seconds since the UNIX epoch at which this encryptable item was first created/derived.Returns the initialization vector and encrypted secret bytes, or null if not encrypted.Returns an enum constant describing what algorithm was used to encrypt the key or UNENCRYPTED.Get the mnemonic code, or null if unknown.Get the mnemonic code as string, or null if unknown.byte[]
Returns the raw bytes of the item, if not encrypted, or null if encrypted or the secret is missing.byte[]
int
hashCode()
boolean
Returns whether the item is encrypted or not.void
setCreationTimeSeconds
(long creationTimeSeconds) Returns the seed as hex or null if encrypted.toString()
toString
(boolean includePrivate)
-
Field Details
-
DEFAULT_SEED_ENTROPY_BITS
public static final int DEFAULT_SEED_ENTROPY_BITS- See Also:
-
MAX_SEED_ENTROPY_BITS
public static final int MAX_SEED_ENTROPY_BITS- See Also:
-
-
Constructor Details
-
DeterministicSeed
public DeterministicSeed(String mnemonicString, byte[] seed, String passphrase, long creationTimeSeconds) throws UnreadableWalletException - Throws:
UnreadableWalletException
-
DeterministicSeed
-
DeterministicSeed
public DeterministicSeed(EncryptedData encryptedMnemonic, @Nullable EncryptedData encryptedSeed, long creationTimeSeconds) -
DeterministicSeed
public DeterministicSeed(List<String> mnemonicCode, @Nullable byte[] seed, String passphrase, long creationTimeSeconds) Constructs a seed from a BIP 39 mnemonic code. SeeMnemonicCode
for more details on this scheme.- Parameters:
mnemonicCode
- A list of words.seed
- The derived seed, or pass null to derive it from mnemonicCode (slow)passphrase
- A user supplied passphrase, or an empty string if there is no passphrasecreationTimeSeconds
- When the seed was originally created, UNIX time.
-
DeterministicSeed
Constructs a seed from a BIP 39 mnemonic code. SeeMnemonicCode
for more details on this scheme.- Parameters:
random
- Entropy sourcebits
- number of bits, must be divisible by 32passphrase
- A user supplied passphrase, or an empty string if there is no passphrase
-
DeterministicSeed
Constructs a seed from a BIP 39 mnemonic code. SeeMnemonicCode
for more details on this scheme.- Parameters:
entropy
- entropy bits, length must be divisible by 32passphrase
- A user supplied passphrase, or an empty string if there is no passphrasecreationTimeSeconds
- When the seed was originally created, UNIX time.
-
-
Method Details
-
isEncrypted
public boolean isEncrypted()Description copied from interface:EncryptableItem
Returns whether the item is encrypted or not. If it is, thenEncryptableItem.getSecretBytes()
will return null.- Specified by:
isEncrypted
in interfaceEncryptableItem
-
toString
-
toString
-
toHexString
Returns the seed as hex or null if encrypted. -
getSecretBytes
@Nullable public byte[] getSecretBytes()Description copied from interface:EncryptableItem
Returns the raw bytes of the item, if not encrypted, or null if encrypted or the secret is missing.- Specified by:
getSecretBytes
in interfaceEncryptableItem
-
getSeedBytes
@Nullable public byte[] getSeedBytes() -
getEncryptedData
Description copied from interface:EncryptableItem
Returns the initialization vector and encrypted secret bytes, or null if not encrypted.- Specified by:
getEncryptedData
in interfaceEncryptableItem
-
getEncryptionType
Description copied from interface:EncryptableItem
Returns an enum constant describing what algorithm was used to encrypt the key or UNENCRYPTED.- Specified by:
getEncryptionType
in interfaceEncryptableItem
-
getEncryptedSeedData
-
getCreationTimeSeconds
public long getCreationTimeSeconds()Description copied from interface:EncryptableItem
Returns the time in seconds since the UNIX epoch at which this encryptable item was first created/derived.- Specified by:
getCreationTimeSeconds
in interfaceEncryptableItem
-
setCreationTimeSeconds
public void setCreationTimeSeconds(long creationTimeSeconds) -
encrypt
public DeterministicSeed encrypt(KeyCrypter keyCrypter, org.bouncycastle.crypto.params.KeyParameter aesKey) -
decrypt
public DeterministicSeed decrypt(KeyCrypter crypter, String passphrase, org.bouncycastle.crypto.params.KeyParameter aesKey) -
equals
-
hashCode
public int hashCode() -
check
Check if our mnemonic is a valid mnemonic phrase for our word list. Does nothing if we are encrypted.- Throws:
MnemonicException
- if check fails
-
getMnemonicCode
Get the mnemonic code, or null if unknown. -
getMnemonicString
Get the mnemonic code as string, or null if unknown.
-