logging.info('Known: %s %s' % (b2x(scriptPubKey), b2x(known_privkey.pub)))

    n = 0
    for passphrase in fd.readlines():
        n += 1
        passphrase = passphrase.strip()
        secret = hashlib.sha256(passphrase).digest()
        add_privkey(CBitcoinSecret.from_secret_bytes(secret, False))
        add_privkey(CBitcoinSecret.from_secret_bytes(secret, True))

    logging.info('Added %d known passphrases' % n)

known_txids = set()

while True:
    mempool_txids = set(rpc.getrawmempool())
    new_txids = mempool_txids.difference(known_txids)
    known_txids.update(mempool_txids)

    burn_txs = []
    for new_txid in new_txids:
        try:
            new_tx = rpc.getrawtransaction(new_txid)
        except IndexError:
            continue

        burn_txs.extend(scan_tx_for_spendable_outputs(new_tx, new_txid))

    for burn_tx in burn_txs:
        try:
            txid = rpc.sendrawtransaction(burn_tx)
示例#2
0
dict_vin_segwit = {
    'count_segwit': 0,
    'count_segwit_mixed': 0,
    'count_non_segwit': 0
}


# https://stackoverflow.com/a/312464
def chunks(l, n):
    """Yield successive n-sized chunks from l."""
    for i in range(0, len(l), n):
        yield l[i:i + n]


rawmempool = rpc.getrawmempool(False)

for chunk in chunks(rawmempool, 2000):  # creates chunks of 2000 txids

    commands = [{
        "method": "getrawtransaction",
        "params": [txid, True]
    } for txid in chunk]
    results = rpc._batch(commands)

    for tx in results:
        hasSegWitInput, hasNonSegWitInput = False, False
        for vout in tx['result']['vout']:  # for each output
            vout_type = vout['scriptPubKey']['type']
            dict_vout_type[vout_type] = dict_vout_type[
                vout_type] + 1  # increment type counter
示例#3
0
                     (b2x(scriptPubKey), b2x(known_privkey.pub)))

    n = 0
    for passphrase in fd.readlines():
        n += 1
        passphrase = passphrase.strip()
        secret = hashlib.sha256(passphrase).digest()
        add_privkey(CBitcoinSecret.from_secret_bytes(secret, False))
        add_privkey(CBitcoinSecret.from_secret_bytes(secret, True))

    logging.info('Added %d known passphrases' % n)

known_txids = set()

while True:
    mempool_txids = set(rpc.getrawmempool())
    new_txids = mempool_txids.difference(known_txids)
    known_txids.update(mempool_txids)

    burn_txs = []
    for new_txid in new_txids:
        try:
            new_tx = rpc.getrawtransaction(new_txid)
        except IndexError:
            continue

        # The scriptSigs might not sign vout, in which case we can replace the
        # whole thing with OP_RETURN.
        if not (len(new_tx.vout) == 1 and new_tx.vout[0].nValue == 0
                and new_tx.vout[0].scriptPubKey == CScript([OP_RETURN])):
示例#4
0
    if feerate >= BUCKETS[posLast]:
        return posLast
    if feerate <= BUCKETS[posFirst]:
        return posFirst

    while posFirst <= posLast:
        posMid = (posFirst + posLast) // 2
        if BUCKETS[posMid] <= feerate and BUCKETS[posMid + 1] > feerate:
            return posMid
        if BUCKETS[posMid] > feerate:
            posLast = posMid - 1
        if BUCKETS[posMid] < feerate:
            posFirst = posMid + 1


rawmempool = rpc.getrawmempool(True)

for tx in rawmempool.items():
    fee = float(tx[1]["fee"])
    size = int(tx[1]["size"])
    rate = int((fee * 100000000 / size) + .5)
    bucket = findBucketByFeerate(fee * 100000000 / size)

    if rate in rates:
        rates[rate] = rates[rate][0] + 1, rates[rate][1] + size, rates[rate][
            2] + fee
    else:
        rates[rate] = 1, size, fee

    if bucket in bucketrates:
        bucketrates[bucket] = bucketrates[bucket][0] + 1, bucketrates[bucket][