bitcoinlib.networks module

class bitcoinlib.networks.Network(network_name='bitcoin')[source]

Bases: object

Network class with all network definitions.

Prefixes for WIF, P2SH keys, HD public and private keys, addresses. A currency symbol and type, the denominator (such as satoshi) and a BIP0044 cointype.


Return the value as string with currency symbol

Parameters:value (int, float) – Value in smallest denominitor such as Satoshi
Return str:
wif_prefix(is_private=False, witness_type='legacy', multisig=False)[source]

Get WIF prefix for this network and specifications in arguments

  • is_private (bool) – Private or public key, default is True
  • witness_type (str) – Legacy, segwit or p2sh-segwit
  • multisig (True) – Multisignature or single signature wallet. Default is not multisig
Return bytes:
exception bitcoinlib.networks.NetworkError(msg='')[source]

Bases: Exception

Network Exception class

bitcoinlib.networks.network_by_value(field, value)[source]

Return all networks for field and (prefix) value.

For Example:
network_by_value(‘prefix_wif’, ‘B0’)
  • field (str) – Prefix name from networks definitions (networks.json)
  • value (str, bytes) – Value of network prefix
Return list:

Of network name strings


Is network defined?

Networks of this library are defined in networks.json in the operating systems user path.

Parameters:network (str) – Network name
Return bool:
bitcoinlib.networks.network_values_for(field, output_as='default')[source]

Return all prefixes mentioned field, i.e.: prefix_wif, prefix_address_p2sh, prefix_hdkey_public, etc

  • field (str) – Prefix name from networks definitions (networks.json)
  • output_as (str) – Output as string or hexstring. Default is string or hexstring depending on field type.
Return str:

Extract network, script type and public/private information from WIF prefix.

  • wif (str, bytes) – WIF string or prefix in bytes or hexadecimal string
  • network (str) – Limit search to specified network
Return dict:

Returns network definitions from json file in settings dir

Return dict:Network definitions