MCPcopy
hub / github.com/petertodd/python-bitcoinlib / unhexlify_str

Function unhexlify_str

bitcoin/rpc.py:44–63  ·  view source on GitHub ↗

Converts a string containing hexadecimal encoding into a bytes-object. It works by encoding the given string h as ASCII, then interpreting each of its two-character ASCII tuples as bytes: - "00" to byte 0 - "ff" to byte 255 - "FF" also to byte 255 The strin

(h)

Source from the content-addressed store, hash-verified

42DEFAULT_HTTP_TIMEOUT = 30
43
44def unhexlify_str(h):
45 """
46 Converts a string containing hexadecimal encoding into a bytes-object.
47
48 It works by encoding the given string h as ASCII, then interpreting each of
49 its two-character ASCII tuples as bytes:
50 - "00" to byte 0
51 - "ff" to byte 255
52 - "FF" also to byte 255
53
54 The string must only contain characters in the ranges 0-9, a-f and A-F.
55
56 If the string contains characters not in ASCII,
57 UnicodeEncodeError is raised.
58 If the string contains out-of-range ASCII characters,
59 binascii.Error is raised.
60 If number of encoded ASCII bytes is odd,
61 binascii.Error is raised.
62 """
63 return binascii.unhexlify(h.encode('ascii'))
64
65def hexlify_str(b):
66 """

Callers 9

fundrawtransactionMethod · 0.85
getblockheaderMethod · 0.85
getblockMethod · 0.85
getrawtransactionMethod · 0.85
gettxoutMethod · 0.85
listunspentMethod · 0.85
signrawtransactionMethod · 0.85
validateaddressMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected