Esempio n. 1
0
def spend_verify(tx, txs, out):
    if not E_check(tx, 'to', [str, unicode]):
        out[0] += 'No address\n'
        return False

    if not signature_check(tx):
        out[0] += 'Signature check\n'
        return False

    if len(tx['to']) <= 30:
        out[0] += 'That address is too short\n'
        return False

    if not E_check(tx, 'amount', int):
        out[0] += 'No amount\n'
        return False

    if not tools.fee_check(tx, txs):
        out[0] += 'Fee check error\n'
        return False

    if 'vote_id' in tx:
        if not tx['to'][:-29] == '11':
            out[0] += 'cannot hold votecoins in a multisig address\n'
            return False
    return True
Esempio n. 2
0
def spend_verify(tx, txs, out, DB):
    txaddr=tools.addr(tx)
    h=tx['recent_hash']
    l=tools.local_get('length')
    r=range(l-10, l)
    r=filter(lambda l: l>0, r)
    recent_blocks=map(lambda x:tools.db_get(x), r)
    recent_hashes=map(lambda x: x['block_hash'], recent_blocks)
    if h not in recent_hashes:
        tools.log('recent hash error')
        return False
    recent_txs=[]
    def f(b, recent_txs=recent_txs):
        recent_txs=recent_txs+b['txs']
    map(f, recent_blocks)
    recent_txs=filter(lambda t: t['type']=='spend', recent_txs)
    recent_txs=filter(lambda t: t['recent_hash']==h, recent_txs)
    recent_txs=filter(lambda t: t['to']==tx['to'], recent_txs)
    recent_txs=filter(lambda t: t['amount']==tx['amount'], recent_txs)
    recent_txs=filter(lambda t: t['fee']==tx['fee'], recent_txs)
    recent_txs=filter(lambda t: tools.addr(t)==txaddr, recent_txs)
    if len(recent_txs)>0:
        out[0]+='no repeated spends'
        return False
    if not signature_check(tx):
        out[0]+='signature check'
        return False
    if len(tx['to'])<=30:
        out[0]+='that address is too short'
        out[0]+='tx: ' +str(tx)
        return False
    if not tools.fee_check(tx, txs, DB):
        out[0]+='fee check error'
        return False
    return True
Esempio n. 3
0
def spend_verify(tx, txs, out, DB):
    if not E_check(tx, 'to', [str, unicode]):
        out[0] += 'no to'
        return False
    if not signature_check(tx):
        out[0] += 'signature check'
        return False
    if len(tx['to']) <= 30:
        out[0] += 'that address is too short'
        out[0] += 'tx: ' + str(tx)
        return False
    if not E_check(tx, 'amount', int):
        out[0] += 'no amount'
        return False
    if not tools.fee_check(tx, txs, DB):
        out[0] += 'fee check error'
        return False
    if 'vote_id' in tx:
        if not tx['to'][:-29] == '11':
            out[0] += 'cannot hold votecoins in a multisig address'
            return False
    return True
Esempio n. 4
0
def spend_verify(tx, txs, out, DB):
    if not E_check(tx, 'to', [str, unicode]):
        out[0]+='no to'
        return False
    if not signature_check(tx):
        out[0]+='signature check'
        return False
    if len(tx['to'])<=30:
        out[0]+='that address is too short'
        out[0]+='tx: ' +str(tx)
        return False
    if not E_check(tx, 'amount', int):
        out[0]+='no amount'
        return False
    if not tools.fee_check(tx, txs, DB):
        out[0]+='fee check error'
        return False
    if 'vote_id' in tx:
        if not tx['to'][:-29]=='11':
            out[0]+='cannot hold votecoins in a multisig address'
            return False
    return True
Esempio n. 5
0
 def verify_tx(tx, txs, out):
     #do not allow tx which fail to reference one of the 10 most recent blocks. do not allow tx which have an identical copy in the last 10 blocks.
     if not type_check(tx, txs):
         out[0] += 'type error'
         return False
     if tx in txs:
         out[0] += 'no duplicates'
         return False
     #if verify_count(tx, txs):
     #    out[0]+='count error'
     #    return False
     if too_big_block(tx, txs):
         out[0] += 'too many txs'
         return False
     if not tools.fee_check(tx, txs, DB):
         out[0] += 'not enough money: ' + str(tx)
         return False
     if not tools.signature_check(tx):
         out[0] += 'bad signature: ' + str(tx)
         return False
     if not transactions.tx_check[tx['type']](tx, txs, out, DB):
         out[0] += 'tx: ' + str(tx)
         return False
     return True
Esempio n. 6
0
def mint_verify(tx, txs, out, DB):
    length=tools.local_get('length')
    height=tools.local_get('height')
    custom.block_fee(tx['height']-height)
    gap=tx['height']-height
    for t in txs:
        if t['type']=='mint': 
            out[0]+='no mint repeats'
    if not tools.fee_check(tx, txs, DB):
        out[0]+='fee check error'
        return False
    if tx['on_block']!=length+1:
        out[0]+='on wrong block'
        return False
    if len(filter(lambda x: x['type']=='mint', txs))>0:
        out[0]+='too many mints'
        return False
    amount=tools.mint_cost(txs, gap)
    if tx['amount']!=amount:
        tools.log('have: ' +str(tx['amount']))
        tools.log('need: ' +str(amount))
        tools.log('that amount is too big')
        return False
    return True
Esempio n. 7
0
 def verify_tx(tx, txs, out):
     #do not allow tx which fail to reference one of the 10 most recent blocks. do not allow tx which have an identical copy in the last 10 blocks.
     if not type_check(tx, txs):
         out[0]+='type error'
         return False
     if tx in txs:
         out[0]+='no duplicates'
         return False
     #if verify_count(tx, txs):
     #    out[0]+='count error'
     #    return False
     if too_big_block(tx, txs):
         out[0]+='too many txs'
         return False
     if not tools.fee_check(tx, txs, DB):
         out[0]+='not enough money: ' +str(tx)
         return False
     if not tools.signature_check(tx):
         out[0]+='bad signature: ' +str(tx)
         return False
     if not transactions.tx_check[tx['type']](tx, txs, out, DB):
         out[0]+= 'tx: ' + str(tx)
         return False
     return True