Class MarriedKeyChain
- All Implemented Interfaces:
EncryptableKeyChain,KeyChain
A multi-signature keychain using synchronized HD keys (a.k.a HDM)
This keychain keeps track of following keychains that follow the account key of this keychain. You can get P2SH addresses to receive coins to from this chain. The threshold - sigsRequiredToSpend specifies how many signatures required to spend transactions for this married keychain. This value should not exceed total number of keys involved (one followed key plus number of following keys), otherwise IllegalArgumentException will be thrown.
IMPORTANT: As of Bitcoin Core 0.9 all bare (non-P2SH) multisig transactions which require more than 3 public keys are non-standard and such spends won't be processed by peers with default settings, essentially making such transactions almost nonspendable
This method will throw an IllegalStateException, if the keychain is already married or already has leaf keys issued.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMarriedKeyChain.Builder<T extends MarriedKeyChain.Builder<T>>Builds aMarriedKeyChainNested classes/interfaces inherited from interface org.bitcoinj.wallet.KeyChain
KeyChain.KeyPurpose -
Field Summary
Fields inherited from class org.bitcoinj.wallet.DeterministicKeyChain
ACCOUNT_ONE_PATH, ACCOUNT_ZERO_PATH, BIP44_ACCOUNT_ZERO_PATH, DEFAULT_PASSPHRASE_FOR_MNEMONIC, EXTERNAL_SUBPATH, INTERNAL_SUBPATH, lock, lookaheadSize, lookaheadThreshold, sigsRequiredToSpend -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMarriedKeyChain(DeterministicKey accountKey, Script.ScriptType outputScriptType) This constructor is not stable across releases! If you need a stable API, usebuilder()to use aMarriedKeyChain.Builder.protectedMarriedKeyChain(DeterministicSeed seed, KeyCrypter crypter, Script.ScriptType outputScriptType, List<ChildNumber> accountPath) This constructor is not stable across releases! If you need a stable API, usebuilder()to use aMarriedKeyChain.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic MarriedKeyChain.Builder<?>builder()findRedeemDataByScriptHash(com.google.protobuf.ByteString bytes) Returns the redeem script by its hash or null if this keychain did not generate the script.protected voidformatAddresses(boolean includeLookahead, boolean includePrivateKeys, org.bouncycastle.crypto.params.KeyParameter aesKey, NetworkParameters params, StringBuilder builder) freshOutputScript(KeyChain.KeyPurpose purpose) Create a new married key and return the matching output scriptgetFilter(int size, double falsePositiveRate, long tweak) Gets a bloom filter that contains all of the public keys from this chain, and which will provide the given false-positive rate if it has size elements.getRedeemData(DeterministicKey followedKey) Get the redeem data for a key in this married chainbooleanWhether the keychain is married.voidHousekeeping call to call when lookahead might be needed.intReturns the number of elements this chain wishes to insert into the Bloom filter.Returns a list of keys serialized to the bitcoinj protobuf format.voidsetLookaheadSize(int lookaheadSize) Sets a new lookahead size.Methods inherited from class org.bitcoinj.wallet.DeterministicKeyChain
addEventListener, addEventListener, checkAESKey, checkPassword, findKeyFromPubHash, findKeyFromPubKey, fromProtobuf, getAccountPath, getEarliestKeyCreationTime, getIssuedExternalKeys, getIssuedInternalKeys, getIssuedReceiveKeys, getKey, getKeyByPath, getKeyByPath, getKeyByPath, getKeyCrypter, getKeyLookaheadEpoch, getKeys, getLeafKeys, getLookaheadSize, getLookaheadThreshold, getMnemonicCode, getOutputScriptType, getRootKey, getSeed, getSigsRequiredToSpend, getWatchingKey, hasKey, isFollowing, isWatching, makeKeyChainFromSeed, markKeyAsUsed, markPubHashAsUsed, markPubKeyAsUsed, maybeLookAhead, numKeys, numLeafKeysIssued, removeEventListener, serializeMyselfToProtobuf, setLookaheadThreshold, setSigsRequiredToSpend, toDecrypted, toDecrypted, toEncrypted, toEncrypted, toString, toString
-
Constructor Details
-
MarriedKeyChain
This constructor is not stable across releases! If you need a stable API, usebuilder()to use aMarriedKeyChain.Builder. -
MarriedKeyChain
protected MarriedKeyChain(DeterministicSeed seed, KeyCrypter crypter, Script.ScriptType outputScriptType, List<ChildNumber> accountPath) This constructor is not stable across releases! If you need a stable API, usebuilder()to use aMarriedKeyChain.Builder.
-
-
Method Details
-
builder
-
isMarried
public boolean isMarried()Description copied from class:DeterministicKeyChainWhether the keychain is married. A keychain is married when it vends P2SH addresses from multiple keychains in a multisig relationship.- Overrides:
isMarriedin classDeterministicKeyChain- See Also:
-
freshOutputScript
Create a new married key and return the matching output script- Overrides:
freshOutputScriptin classDeterministicKeyChain
-
getRedeemData
Get the redeem data for a key in this married chain- Overrides:
getRedeemDatain classDeterministicKeyChain
-
setLookaheadSize
public void setLookaheadSize(int lookaheadSize) Description copied from class:DeterministicKeyChainSets a new lookahead size. SeeDeterministicKeyChain.getLookaheadSize()for details on what this is. Setting a new size that's larger than the current size will return immediately and the new size will only take effect next time a fresh filter is requested (e.g. due to a new peer being connected). So you should set this before starting to sync the chain, if you want to modify it. If you haven't modified the lookahead threshold manually then it will be automatically set to be a third of the new size.- Overrides:
setLookaheadSizein classDeterministicKeyChain
-
serializeToProtobuf
Description copied from interface:KeyChainReturns a list of keys serialized to the bitcoinj protobuf format.- Specified by:
serializeToProtobufin interfaceKeyChain- Overrides:
serializeToProtobufin classDeterministicKeyChain
-
formatAddresses
protected void formatAddresses(boolean includeLookahead, boolean includePrivateKeys, @Nullable org.bouncycastle.crypto.params.KeyParameter aesKey, NetworkParameters params, StringBuilder builder) - Overrides:
formatAddressesin classDeterministicKeyChain
-
maybeLookAheadScripts
public void maybeLookAheadScripts()Description copied from class:DeterministicKeyChainHousekeeping call to call when lookahead might be needed. Normally called automatically by KeychainGroup.- Overrides:
maybeLookAheadScriptsin classDeterministicKeyChain
-
findRedeemDataByScriptHash
Description copied from class:DeterministicKeyChainReturns the redeem script by its hash or null if this keychain did not generate the script.- Overrides:
findRedeemDataByScriptHashin classDeterministicKeyChain
-
getFilter
Description copied from interface:KeyChainGets a bloom filter that contains all of the public keys from this chain, and which will provide the given false-positive rate if it has size elements. Keep in mind that you will get 2 elements in the bloom filter for each key in the key chain, for the public key and the hash of the public key (address form). For this reason size should be at least 2x the result of
KeyChain.numKeys().This is used to generate a
BloomFilterwhich can beBloomFilter.merge(BloomFilter)d with another. It could also be used if you have a specific target for the filter's size.See the docs for
BloomFilter(int, double, long)for a brief explanation of anonymity when using bloom filters, and for the meaning of these parameters.- Specified by:
getFilterin interfaceKeyChain- Overrides:
getFilterin classDeterministicKeyChain
-
numBloomFilterEntries
public int numBloomFilterEntries()Description copied from interface:KeyChainReturns the number of elements this chain wishes to insert into the Bloom filter. The size passed toKeyChain.getFilter(int, double, long)should be at least this large.- Specified by:
numBloomFilterEntriesin interfaceKeyChain- Overrides:
numBloomFilterEntriesin classDeterministicKeyChain
-