def network_values_for(field, output_as='default'): """ Return all prefixes mentioned field, i.e.: prefix_wif, prefix_address_p2sh, etc >>> network_values_for('prefix_wif') [b'\x99', b'\x80', b'\xef', b'\xb0', b'\xb0', b'\xef', b'\xcc', b'\xef'] >>> network_values_for('prefix_address_p2sh') [b'\x95', b'\x05', b'\xc4', b'2', b'\x05', b':', b'\x10', b'\x13'] :param field: Prefix name from networks definitions (networks.json) :type field: str :param output_as: Output as string or hexstring. Default is string or hexstring depending on field type. :type output_as: str :return str: """ r = [ _format_value(field, nv[field]) for nv in NETWORK_DEFINITIONS.values() ] if output_as == 'str': return [normalize_var(i) for i in r] elif output_as == 'hex': return [to_hexstring(i) for i in r] else: return r
def network_values_for(field, output_as='default'): """ Return all prefixes mentioned field, i.e.: prefix_wif, prefix_address_p2sh, prefix_hdkey_public, etc :param field: Prefix name from networks definitions (networks.json) :type field: str :param output_as: Output as string or hexstring. Default is string or hexstring depending on field type. :type output_as: str :return str: """ r = [_format_value(field, nv[field]) for nv in NETWORK_DEFINITIONS.values()] if output_as == 'str': return [normalize_var(i) for i in r] elif output_as == 'hex': return [to_hexstring(i) for i in r] else: return r
'22ce2db091d6fd47294c9e2144fa0291949402e3003ce' print("\n=== Convert DER encoded signature ===") print(convert_der_sig(to_bytes(der_signature))) print("\n=== Varbyte Int conversions ===") print("Number 1000 as Varbyte Integer (hexstring): %s" % to_hexstring(int_to_varbyteint(1000))) print("Converted back (3 is size in bytes: 1 size byte + integer in bytes): ", varbyteint_to_int(to_bytes('fde803'))) # Normalize data print("\n=== Normalizations ===") data = [ u"guion cruz envío papel otoño percha hazaña salir joya gorra íntimo actriz", u'\u2167', u'\uFDFA', "あじわう ちしき たわむれる おくさま しゃそう うんこう ひてい みほん たいほ てのひら りこう わかれる かいすいよく こもん ねもと", '12345', ] for dt in data: print("\nInput data", dt) print("Normalized unicode string (normalize_string): ", normalize_string(dt)) print("Normalized variable (normalize_var): ", normalize_var(dt)) # Convert Bech32 address to Public key hash address = "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4" pkh = "0014751e76e8199196d454941c45d1b3a323f1433bd6" pkh_converted = addr_bech32_to_pubkeyhash(address, prefix='bc', include_witver=True, as_hex=True) print(pkh, " == ", pkh_converted) addr = pubkeyhash_to_addr_bech32(pkh_converted, address[:2].lower())