MCPcopy Index your code
hub / github.com/jimmysong/programmingbitcoin / encode_varint

Function encode_varint

code-ch13/helper.py:97–108  ·  view source on GitHub ↗

encodes an integer as a varint

(i)

Source from the content-addressed store, hash-verified

95
96
97def encode_varint(i):
98 '''encodes an integer as a varint'''
99 if i < 0xfd:
100 return bytes([i])
101 elif i < 0x10000:
102 return b'\xfd' + int_to_little_endian(i, 2)
103 elif i < 0x100000000:
104 return b'\xfe' + int_to_little_endian(i, 4)
105 elif i < 0x10000000000000000:
106 return b'\xff' + int_to_little_endian(i, 8)
107 else:
108 raise ValueError('integer too large: {}'.format(i))
109
110
111def h160_to_p2pkh_address(h160, testnet=False):

Callers 10

serializeMethod · 0.90
serializeMethod · 0.90
serializeMethod · 0.90
serialize_legacyMethod · 0.90
serialize_segwitMethod · 0.90
sig_hashMethod · 0.90
verify_inputMethod · 0.90
serializeMethod · 0.90
evaluateMethod · 0.90
filterloadMethod · 0.90

Calls 1

int_to_little_endianFunction · 0.70

Tested by

no test coverage detected