Ejemplo n.º 1
0
def check_script_size(script: bytes) -> None:
    try:
        r = BufferReader(script)
        n = read_uint32_be(r)
        r.read(n)
        n = read_uint32_be(r)
        ensure(r.remaining_count() == n)
    except (AssertionError, EOFError):
        raise wire.DataError("Invalid script")
Ejemplo n.º 2
0
def check_tx_params_size(params: bytes) -> None:
    try:
        r = BufferReader(params)
        tag = r.get()
        if tag == EP_TAG_NAMED:
            n = r.get()
            r.read(n)
        elif tag > 4:
            raise wire.DataError("Unknown entrypoint tag")
        n = read_uint32_be(r)
        ensure(r.remaining_count() == n)
    except (AssertionError, EOFError):
        raise wire.DataError("Invalid transaction parameters")
Ejemplo n.º 3
0
def decode_seq(data: memoryview) -> list[memoryview]:
    r = BufferReader(data)

    if r.get() != 0x30:
        raise ValueError
    n = read_length(r)

    seq = []
    end = r.offset + n
    while r.offset < end:
        i = read_int(r)
        seq.append(i)

    if r.offset != end or r.remaining_count():
        raise ValueError

    return seq
Ejemplo n.º 4
0
def decode_seq(data: bytes) -> List[bytes]:
    r = BufferReader(data)

    if r.get() != 0x30:
        raise ValueError
    n = decode_length(r)

    seq = []
    end = r.offset + n
    while r.offset < end:
        i = decode_int(r)
        seq.append(i)

    if r.offset != end or r.remaining_count():
        raise ValueError

    return seq