bitcoinlib.main module

bitcoinlib.main.deprecated(func)[source]

This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.

bitcoinlib.main.get_encoding_from_witness(witness_type=None)[source]

Derive address encoding (base58 or bech32) from transaction witness type.

Returns ‘base58’ for legacy and p2sh-segwit witness type and ‘bech32’ for segwit

Parameters:

witness_type (str) – Witness type: legacy, p2sh-segwit or segwit

Return str:

bitcoinlib.main.get_key_structure_data(witness_type, multisig=False, purpose=None, encoding=None)[source]

Get data from wallet key structure. Provide witness_type and multisig to determine key path, purpose (BIP44 reference) and encoding.

Parameters:
  • witness_type (str) – Witness type used for transaction validation

  • multisig (bool) – Multisig or single keys wallet, default is False: single key / 1-of-1 wallet

  • purpose (int) – Overrule purpose found in wallet structure. Do not use unless you known what you are doing.

  • encoding (str) – Overrule encoding found in wallet structure. Do not use unless you known what you are doing.

Returns:

(key_path, purpose, encoding)

bitcoinlib.main.script_type_default(witness_type=None, multisig=False, locking_script=False)[source]

Determine default script type for provided witness type and key type combination used in this library.

>>> script_type_default('segwit', locking_script=True)
'p2wpkh'
Parameters:
  • witness_type (str) – Witness type used: standard, p2sh-segwit or segwit

  • multisig (bool) – Multi-signature key or not, default is False

  • locking_script (bool) – Limit search to locking_script. Specify False for locking scripts and True for unlocking scripts

Return str:

Default script type