Encode feature bits BOLT-style: big-endian, bit 0 is the last byte's LSB.
(*bits)
| 5202 | |
| 5203 | |
| 5204 | def featurebits(*bits): |
| 5205 | """Encode feature bits BOLT-style: big-endian, bit 0 is the last byte's LSB.""" |
| 5206 | if not bits: |
| 5207 | return b'' |
| 5208 | nbytes = max(bits) // 8 + 1 |
| 5209 | arr = bytearray(nbytes) |
| 5210 | for b in bits: |
| 5211 | arr[nbytes - 1 - b // 8] |= 1 << (b % 8) |
| 5212 | return bytes(arr) |
| 5213 | |
| 5214 | |
| 5215 | def feature_offered(bits, b): |