예제 #1
0
def find (db, start, stop):
    multi = {}
    # find some P2SH outputs...
    for i in range (start, stop):
        b = db.by_num (i)
        for tx in b.transactions:
            for j, out in enumerate (tx.outputs):
                if is_p2sh (parse_script (out[1])):
                    multi[(tx.name, j)] = out[1]
    # search the same range for spends of those outputs...
    for i in range (start, stop):
        b = db.by_num (i)
        for tx in b.transactions:
            for j, (outpoint, unlock, sequence) in enumerate (tx.inputs):
                if multi.has_key (outpoint):
                    print multi[outpoint].encode ('hex'), tx.raw.encode('hex'), j, b.timestamp
예제 #2
0
def find(db, start, stop):
    multi = {}
    # find some P2SH outputs...
    for i in range(start, stop):
        b = db.by_num(i)
        for tx in b.transactions:
            for j, out in enumerate(tx.outputs):
                if is_p2sh(parse_script(out[1])):
                    multi[(tx.name, j)] = out[1]
    # search the same range for spends of those outputs...
    for i in range(start, stop):
        b = db.by_num(i)
        for tx in b.transactions:
            for j, (outpoint, unlock, sequence) in enumerate(tx.inputs):
                if multi.has_key(outpoint):
                    print multi[outpoint].encode('hex'), tx.raw.encode(
                        'hex'), j, b.timestamp
예제 #3
0
# -*- Mode: Python -*-

from scan_utxo import gen_utxo
from caesure.script import parse_script, pprint_script, ScriptError
from caesure._script import ScriptError
from caesure.bitcoin import bcrepr


def frob(name):
    return name[::-1].encode('hex')


n = 0
for txname, outputs in gen_utxo():
    for (index, amt, script) in outputs:
        try:
            script = parse_script(script)
        except ScriptError:
            print frob(txname), index, bcrepr(amt), script.encode('hex'), repr(
                script)
        n += 1
print 'scanned %d scripts' % (n, )
예제 #4
0
# -*- Mode: Python -*-

from scan_utxo import gen_utxo
from caesure.script import parse_script, pprint_script, ScriptError, OPCODES, PUSH_OP
from caesure._script import ScriptError

def is_p2sh (s):
    return (
        len(s) == 3
        and s[0] == (2, OPCODES.OP_HASH160)
        and s[2] == (2, OPCODES.OP_EQUAL)
        and s[1][0] == 0
        and s[1][2] == PUSH_OP
        and len(s[1][1]) == 20
    )

for txname, index, amt, script in gen_utxo():
    try:
        script = parse_script (script)
        if is_p2sh (script):
            print pprint_script (script)
    except ScriptError:
        # there are quite a few broken outpoint scripts in the utxo set.
        pass