encodes an integer as a varint
(i)
| 89 | |
| 90 | |
| 91 | def encode_varint(i): |
| 92 | '''encodes an integer as a varint''' |
| 93 | if i < 0xfd: |
| 94 | return bytes([i]) |
| 95 | elif i < 0x10000: |
| 96 | return b'\xfd' + int_to_little_endian(i, 2) |
| 97 | elif i < 0x100000000: |
| 98 | return b'\xfe' + int_to_little_endian(i, 4) |
| 99 | elif i < 0x10000000000000000: |
| 100 | return b'\xff' + int_to_little_endian(i, 8) |
| 101 | else: |
| 102 | raise ValueError('integer too large: {}'.format(i)) |
| 103 | |
| 104 | |
| 105 | def h160_to_p2pkh_address(h160, testnet=False): |
no test coverage detected