Interface KeyBag

All Known Implementing Classes:
DecryptingKeyBag, KeyChainGroup, Wallet

public interface KeyBag
A KeyBag is simply an object that can map public keys, their 160-bit hashes and script hashes to ECKey and RedeemData objects.
  • Method Summary

    Modifier and Type
    Method
    Description
    findKeyFromPubKey(byte[] pubKey)
    Locates a keypair from the keychain given the raw public key bytes.
    findKeyFromPubKeyHash(byte[] pubKeyHash, Script.ScriptType scriptType)
    Locates a keypair from the keychain given the hash of the public key, and (optionally) by usage for a specific script type.
    findRedeemDataFromScriptHash(byte[] scriptHash)
    Locates a redeem data (redeem script and keys) from the keychain given the hash of the script.
  • Method Details

    • findKeyFromPubKeyHash

      @Nullable ECKey findKeyFromPubKeyHash(byte[] pubKeyHash, @Nullable Script.ScriptType scriptType)
      Locates a keypair from the keychain given the hash of the public key, and (optionally) by usage for a specific script type. This is needed when finding out which key we need to use to redeem a transaction output.
      Parameters:
      pubKeyHash - hash of the keypair to look for
      scriptType - only look for given usage (currently Script.ScriptType.P2PKH or Script.ScriptType.P2WPKH) or null if we don't care
      Returns:
      found key or null if no such key was found.
    • findKeyFromPubKey

      @Nullable ECKey findKeyFromPubKey(byte[] pubKey)
      Locates a keypair from the keychain given the raw public key bytes.
      Returns:
      ECKey or null if no such key was found.
    • findRedeemDataFromScriptHash

      @Nullable RedeemData findRedeemDataFromScriptHash(byte[] scriptHash)
      Locates a redeem data (redeem script and keys) from the keychain given the hash of the script. This is needed when finding out which key and script we need to use to locally sign a P2SH transaction input. It is assumed that wallet should not have more than one private key for a single P2SH tx for security reasons. Returns RedeemData object or null if no such data was found.