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.

print_value(value)[source]

Return the value as string with currency symbol

Parameters:value (int, float) – Value in smallest denominitor such as Satoshi
Return str:
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’)
Returns:
[‘litecoin’]
Parameters:
  • field (str) – Prefix name from networks definitions (networks.json)
  • value (str, bytes) – Value of network prefix
Return list:

Of network name strings

bitcoinlib.networks.network_defined(network)[source]

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

Parameters:
  • 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:
bitcoinlib.networks.read_network_definitions()[source]

Returns network definitions from json file in settings dir

Return dict:Network definitions