(vch)
| 416 | |
| 417 | @staticmethod |
| 418 | def decode(vch): |
| 419 | result = 0 |
| 420 | # We assume valid push_size and minimal encoding |
| 421 | value = vch[1:] |
| 422 | if len(value) == 0: |
| 423 | return result |
| 424 | for i, byte in enumerate(value): |
| 425 | result |= int(byte) << 8 * i |
| 426 | if value[-1] >= 0x80: |
| 427 | # Mask for all but the highest result bit |
| 428 | num_mask = (2 ** (len(value) * 8) - 1) >> 1 |
| 429 | result &= num_mask |
| 430 | result *= -1 |
| 431 | return result |
| 432 | |
| 433 | |
| 434 | class CScript(bytes): |
no outgoing calls