public class MarriedKeyChain extends DeterministicKeyChain
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.
Modifier and Type | Class and Description |
---|---|
static class |
MarriedKeyChain.Builder<T extends MarriedKeyChain.Builder<T>>
Builds a
MarriedKeyChain |
KeyChain.KeyPurpose
ACCOUNT_ONE_PATH, ACCOUNT_ZERO_PATH, BIP44_ACCOUNT_ZERO_PATH, DEFAULT_PASSPHRASE_FOR_MNEMONIC, EXTERNAL_SUBPATH, INTERNAL_SUBPATH, lock, lookaheadSize, lookaheadThreshold, sigsRequiredToSpend
Modifier | Constructor and Description |
---|---|
protected |
MarriedKeyChain(DeterministicKey accountKey,
Script.ScriptType outputScriptType)
This constructor is not stable across releases! If you need a stable API, use
builder() to use a
MarriedKeyChain.Builder . |
protected |
MarriedKeyChain(DeterministicSeed seed,
KeyCrypter crypter,
Script.ScriptType outputScriptType,
java.util.List<ChildNumber> accountPath)
This constructor is not stable across releases! If you need a stable API, use
builder() to use a
MarriedKeyChain.Builder . |
Modifier and Type | Method and Description |
---|---|
static MarriedKeyChain.Builder<?> |
builder() |
RedeemData |
findRedeemDataByScriptHash(com.google.protobuf.ByteString bytes)
Returns the redeem script by its hash or null if this keychain did not generate the script.
|
protected void |
formatAddresses(boolean includeLookahead,
boolean includePrivateKeys,
org.bouncycastle.crypto.params.KeyParameter aesKey,
NetworkParameters params,
java.lang.StringBuilder builder) |
Script |
freshOutputScript(KeyChain.KeyPurpose purpose)
Create a new married key and return the matching output script
|
BloomFilter |
getFilter(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.
|
RedeemData |
getRedeemData(DeterministicKey followedKey)
Get the redeem data for a key in this married chain
|
boolean |
isMarried()
Whether the keychain is married.
|
void |
maybeLookAheadScripts()
Housekeeping call to call when lookahead might be needed.
|
int |
numBloomFilterEntries()
Returns the number of elements this chain wishes to insert into the Bloom filter.
|
java.util.List<Protos.Key> |
serializeToProtobuf()
Returns a list of keys serialized to the bitcoinj protobuf format.
|
void |
setLookaheadSize(int lookaheadSize)
Sets a new lookahead size.
|
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
protected MarriedKeyChain(DeterministicKey accountKey, Script.ScriptType outputScriptType)
builder()
to use a
MarriedKeyChain.Builder
.protected MarriedKeyChain(DeterministicSeed seed, KeyCrypter crypter, Script.ScriptType outputScriptType, java.util.List<ChildNumber> accountPath)
builder()
to use a
MarriedKeyChain.Builder
.public static MarriedKeyChain.Builder<?> builder()
public boolean isMarried()
DeterministicKeyChain
isMarried
in class DeterministicKeyChain
MarriedKeyChain
public Script freshOutputScript(KeyChain.KeyPurpose purpose)
freshOutputScript
in class DeterministicKeyChain
public RedeemData getRedeemData(DeterministicKey followedKey)
getRedeemData
in class DeterministicKeyChain
public void setLookaheadSize(int lookaheadSize)
DeterministicKeyChain
DeterministicKeyChain.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.setLookaheadSize
in class DeterministicKeyChain
public java.util.List<Protos.Key> serializeToProtobuf()
KeyChain
serializeToProtobuf
in interface KeyChain
serializeToProtobuf
in class DeterministicKeyChain
protected void formatAddresses(boolean includeLookahead, boolean includePrivateKeys, @Nullable org.bouncycastle.crypto.params.KeyParameter aesKey, NetworkParameters params, java.lang.StringBuilder builder)
formatAddresses
in class DeterministicKeyChain
public void maybeLookAheadScripts()
DeterministicKeyChain
maybeLookAheadScripts
in class DeterministicKeyChain
@Nullable public RedeemData findRedeemDataByScriptHash(com.google.protobuf.ByteString bytes)
DeterministicKeyChain
findRedeemDataByScriptHash
in class DeterministicKeyChain
public BloomFilter getFilter(int size, double falsePositiveRate, long tweak)
KeyChain
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. 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 BloomFilter
which can be BloomFilter.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.BloomFilter(int, double, long)
for a brief
explanation of anonymity when using bloom filters, and for the meaning of these parameters.
getFilter
in interface KeyChain
getFilter
in class DeterministicKeyChain
public int numBloomFilterEntries()
KeyChain
KeyChain.getFilter(int, double, long)
should be at least this large.numBloomFilterEntries
in interface KeyChain
numBloomFilterEntries
in class DeterministicKeyChain