Esempio n. 1
0
def reward_verify(tx, txs, out, DB):
    address = tools.addr(tx)
    acc = tools.db_get(address)
    relative_reward = tools.relative_reward(tx['on_block'], address)
    sign_tx = sign_transaction(tx['on_block'], address)
    length = tools.local_get('length')
    if len(sign_tx['jackpots']) != tx['jackpots']:
        tools.log('wrong number of jackpots')
        return False
    if length - custom.long_time + custom.medium_time / 2 < tx[
            'on_block'] or length - custom.long_time - custom.medium_time / 2 > tx[
                'on_block']:
        tools.log('you did not wait the correct amount of time')
        return False
    if acc['secrets'][str(tx['on_block'])]['slashed']:
        tools.log(
            'you were slashed, or you already claimed your reward at this height'
        )
        return False
    if tx['amount'] != relative_reward + sign_tx['amount']:
        tools.log('reward wrong size')
        return False
    if sign_tx['secret_hash'] != tools.det_hash(tx['reveal']):
        tools.log('entropy+salt does not match')
        return False
    if tx['reveal']['entropy'] not in [0, 1]:
        tools.log('entropy must be either 0 or 1')
        return False
    return True
Esempio n. 2
0
def reward_verify(tx, txs, out, DB):
    address = tools.addr(tx)
    acc = tools.db_get(address)
    relative_reward = tools.relative_reward(tx["on_block"], address)
    sign_tx = sign_transaction(tx["on_block"], address)
    length = tools.local_get("length")
    if len(sign_tx["jackpots"]) != tx["jackpots"]:
        tools.log("wrong number of jackpots")
        return False
    if (
        length - custom.long_time + custom.medium_time / 2 < tx["on_block"]
        or length - custom.long_time - custom.medium_time / 2 > tx["on_block"]
    ):
        tools.log("you did not wait the correct amount of time")
        return False
    if acc["secrets"][str(tx["on_block"])]["slashed"]:
        tools.log("you were slashed, or you already claimed your reward at this height")
        return False
    if tx["amount"] != relative_reward + sign_tx["amount"]:
        tools.log("reward wrong size")
        return False
    if sign_tx["secret_hash"] != tools.det_hash(tx["reveal"]):
        tools.log("entropy+salt does not match")
        return False
    if tx["reveal"]["entropy"] not in [0, 1]:
        tools.log("entropy must be either 0 or 1")
        return False
    return True
Esempio n. 3
0
def create_reward_tx():
    tx={}
    tx['type']='reward'
    length=tools.local_get('length')
    tx['on_block']=length-custom.long_time+random.randint(-custom.medium_time/2, custom.medium_time/2)
    if tx['on_block']<=0:
        time.sleep(1)
        return {'error':'no rewards to collect'}
    address=tools.local_get('address')
    acc=tools.db_get(address)
    if str(tx['on_block']) in acc['entropy']:
        return {'error':'already collected that reward'}
    zeroths=tools.local_get('txs')
    zeroths=filter(lambda t: tools.addr(t)==address, zeroths)
    zeroths=filter(lambda t: t['type']=='reward', zeroths)
    if len(zeroths)>0:
        {'error':'already made the tx to collect that reward'}
    txs=tools.db_get(tx['on_block'])['txs']
    txs=filter(lambda t: t['type']=='sign', txs)
    #tools.log('on block: ' +str(tx['on_block']))
    #tools.log('txs: ' +str(txs))
    sign_tx=filter(lambda t: tools.addr(t)==address, txs)[0]
    #tools.log('txs: ' +str(sign_tx))
    relative_reward=tools.relative_reward(tx['on_block'], address)
    tx['amount']=relative_reward+sign_tx['amount']
    tx['reveal']=tools.local_get('secrets')[str(tx['on_block'])]
    tx['jackpots']=len(sign_tx['jackpots'])
    return tx
Esempio n. 4
0
def reward_verify(tx, txs, out, DB):
    address=tools.addr(tx)
    acc=tools.db_get(address)
    relative_reward=tools.relative_reward(tx['on_block'], address)
    sign_tx=sign_transaction(tx['on_block'], address)
    length=tools.local_get('length')
    if len(sign_tx['jackpots'])!=tx['jackpots']:
        tools.log('wrong number of jackpots')
        return False
    if length-custom.long_time+custom.medium_time/2<tx['on_block']or length-custom.long_time-custom.medium_time/2>tx['on_block']:
        tools.log('you did not wait the correct amount of time')
        return False
    if acc['secrets'][str(tx['on_block'])]['slashed']:
        tools.log('you were slashed, or you already claimed your reward at this height')
        return False
    if tx['amount']!=relative_reward+sign_tx['amount']:
        tools.log('reward wrong size')
        return False
    if sign_tx['secret_hash']!=tools.det_hash(tx['reveal']):
        tools.log('entropy+salt does not match')
        return False
    if tx['reveal']['entropy'] not in [0,1]:
        tools.log('entropy must be either 0 or 1')
        return False
    return True