Пример #1
0
def go (G, s):
    try:
        while 1:
            # what are the per-txn size limits?
            pktlen = s.recv_exact (4)
            if not pktlen:
                break
            else:
                pktlen, = struct.unpack ('>I', pktlen)
                packet = s.recv_exact (pktlen)
                data, size = decode (packet)
                assert size == pktlen
                [index, block_timestamp, raw_tx, lock_scripts] = data
                tx = TX()
                tx.unpack (raw_tx)
                result = True
                for i in range (len (tx.inputs)):
                    lock_script = lock_scripts[i]
                    try:
                        tx.verify (i, lock_script, block_timestamp)
                    except SystemError:
                        result = False
                pkt = encode ((result, index))
                s.writev ([struct.pack ('>I', len(pkt)), pkt])
    except EOFError:
        pass
    coro.set_exit()
Пример #2
0
def go(G, s):
    try:
        while 1:
            # what are the per-txn size limits?
            pktlen = s.recv_exact(4)
            if not pktlen:
                break
            else:
                pktlen, = struct.unpack('>I', pktlen)
                packet = s.recv_exact(pktlen)
                data, size = decode(packet)
                assert size == pktlen
                [index, block_timestamp, raw_tx, lock_scripts] = data
                tx = TX()
                tx.unpack(raw_tx)
                result = True
                for i in range(len(tx.inputs)):
                    lock_script = lock_scripts[i]
                    try:
                        tx.verify(i, lock_script, block_timestamp)
                    except SystemError:
                        result = False
                pkt = encode((result, index))
                s.writev([struct.pack('>I', len(pkt)), pkt])
    except EOFError:
        pass
    coro.set_exit()
Пример #3
0
def do_one(unlock_script, lock_script, flags):
    #W (('-' *50)+'\n')

    tx0 = TX()
    tx0.inputs = [((ZERO_NAME, 4294967295), '\x00\x00', 4294967295)]
    tx0.outputs = [(0, lock_script)]
    name = tx0.get_hash()
    tx1 = TX()
    tx1.inputs = [((name, 0), unlock_script, 4294967295)]
    tx1.outputs = [(0, '')]

    if 'P2SH' in flags:
        m = verifying_machine_p2sh(tx1, 0, KEY)
    else:
        m = verifying_machine(tx1, 0, KEY)
    m.strictenc = 'STRICTENC' in flags
    m.minimal = 'MINIMALDATA' in flags
    m.nulldummy = 'NULLDUMMY' in flags
    m.dersig = 'DERSIG' in flags
    m.low_s = 'LOW_S' in flags
    m.sigpushonly = 'SIGPUSHONLY' in flags
    m.eval_script(unlock_script, lock_script)
Пример #4
0
def do_one (unlock_script, lock_script, flags):
    #W (('-' *50)+'\n')

    tx0 = TX()
    tx0.inputs = [((ZERO_NAME, 4294967295), '\x00\x00', 4294967295)]
    tx0.outputs = [(0, lock_script)]
    name = tx0.get_hash()
    tx1 = TX()
    tx1.inputs = [((name, 0), unlock_script, 4294967295)]
    tx1.outputs = [(0, '')]

    if 'P2SH' in flags:
        m = verifying_machine_p2sh (tx1, 0, KEY)
    else:
        m = verifying_machine (tx1, 0, KEY)
    m.strictenc = 'STRICTENC' in flags
    m.minimal = 'MINIMALDATA' in flags
    m.nulldummy = 'NULLDUMMY' in flags
    m.dersig = 'DERSIG' in flags
    m.low_s = 'LOW_S' in flags
    m.sigpushonly = 'SIGPUSHONLY' in flags
    m.eval_script (unlock_script, lock_script)
Пример #5
0
def test(lock_script, tx_raw, index, block_timestamp):
    tx = TX()
    tx.unpack(tx_raw)
    tx.verify(index, lock_script, block_timestamp)
Пример #6
0
def test (lock_script, tx_raw, index, block_timestamp):
    tx = TX()
    tx.unpack (tx_raw)
    tx.verify (index, lock_script, block_timestamp)