Beispiel #1
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
Beispiel #2
0
def sign_verify(tx, txs, out,
                DB):  #check the validity of a transaction of type sign.
    a = tools.addr(tx)
    B = tx[
        'B']  #verify a proof that addr(tx) actually owned that much money long*2-medium ago.
    M = custom.all_money
    address = tools.addr(tx)
    block = tools.db_get(tx['on_block'])
    num = max(0, tx['on_block'] - (custom.long_time * 2 - custom.medium_time))
    election_block = tools.db_get(num)
    if not signature_check(tx):
        out[0] += 'signature check'
        return False
    if 'root_hash' not in election_block:
        out[0] += 'no root hash'
        return False
    v = tools.db_verify(election_block['root_hash'], address, tx['proof'])
    if v == False:
        tools.log('your address did not exist that long ago.')
        return False
    if v['amount'] != tx['B']:
        tools.log('that is not how much money you had that long ago')
        return False
    if 'secret_hash' not in tx:
        tools.log('need the hash of a secret')
        return False
    for t in txs:
        if tools.addr(t) == address and t['type'] == 'sign':
            #tools.log('can only have one sign tx per block')
            return False
    if len(tx['jackpots']) < 1:
        tools.log('insufficient jackpots')
        return False
    if not signature_check(tx):
        out[0] += 'signature check'
        return False
    length = tools.local_get('length')
    if int(tx['on_block']) != int(length + 1):
        out[0] += 'this tx is for the wrong block. have ' + str(
            length + 1) + ' need: ' + str(tx['on_block'])
        return False
    if tx['on_block'] > 0:
        if not tx['prev'] == tools.db_get(length)['block_hash']:
            tools.log('must give hash of previous block')
            return False
    ran = tools.det_random(tx['on_block'])
    for j in tx['jackpots']:
        if type(j) != int or j not in range(200):
            tools.log('bad jackpot')
            return False
        if len(filter(lambda x: x == j, tx['jackpots'])) != 1:
            tools.log('no repeated jackpots')
            return False
        if not tools.winner(B, M, ran, address, j):
            tools.log('that jackpot is not valid: ' + str(j))
            return False
    if tx['amount'] < custom.minimum_deposit:
        tools.log('you have to deposit more than that')
        return False
    return True
Beispiel #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
Beispiel #4
0
def sign_verify(tx, txs, out, DB):#check the validity of a transaction of type sign.
    a=tools.addr(tx)
    B=tx['B']#verify a proof that addr(tx) actually owned that much money long*2-medium ago.
    M=custom.all_money
    address=tools.addr(tx)
    block=tools.db_get(tx['on_block'])
    num=max(0,tx['on_block']-(custom.long_time*2-custom.medium_time))
    election_block=tools.db_get(num)
    if not signature_check(tx):
        out[0]+='signature check'
        return False
    if 'root_hash' not in election_block:
        out[0]+='no root hash'
        return False
    v=tools.db_verify(election_block['root_hash'], address, tx['proof'])
    if v==False:
        tools.log('your address did not exist that long ago.')
        return False
    if v['amount']!=tx['B']:
        tools.log('that is not how much money you had that long ago')
        return False
    if 'secret_hash' not in tx:
        tools.log('need the hash of a secret')
        return False
    for t in txs:
        if tools.addr(t)==address and t['type']=='sign':
            #tools.log('can only have one sign tx per block')
            return False
    if len(tx['jackpots'])<1: 
        tools.log('insufficient jackpots')
        return False
    if not signature_check(tx):
        out[0]+='signature check'
        return False
    length=tools.local_get('length')
    if int(tx['on_block'])!=int(length+1):
        out[0]+='this tx is for the wrong block. have '+str(length+1) +' need: ' +str(tx['on_block'])
        return False
    if tx['on_block']>0:
        if not tx['prev']==tools.db_get(length)['block_hash']:
            tools.log('must give hash of previous block')
            return False
    ran=tools.det_random(tx['on_block'])
    for j in tx['jackpots']:
        if type(j)!=int or j not in range(200):
               tools.log('bad jackpot')
               return False
        if len(filter(lambda x: x==j, tx['jackpots']))!=1:
               tools.log('no repeated jackpots')
               return False
        if not tools.winner(B, M, ran, address, j):
            tools.log('that jackpot is not valid: '+str(j))
            return False
    if tx['amount']<custom.minimum_deposit:
        tools.log('you have to deposit more than that')
        return False
    return True
Beispiel #5
0
 def block_check(block, DB):
     def log_(txt): pass #return tools.log(txt)
     def tx_check(txs):
         start = copy.deepcopy(txs)
         out = []
         start_copy = []
         invalid_because = ['']
         while start != start_copy:
             if start == []:
                 return False  # Block passes this test
             start_copy = copy.deepcopy(start)
             if transactions.tx_check[start[0]['type']](start[0], out, invalid_because, DB):
                 out.append(start.pop())
             else:
                 tools.log('invalid tx: '+str(invalid_because[0]))
                 return True  # Block is invalid
         tools.log('block invalid because it has no txs')
         return True  # Block is invalid
     if 'error' in block: 
         log_('error in block')
         return False
     length =tools.local_get('length')
     if type(block['length'])!=type(1): 
         log_('wrong length type')
         return False
     if int(block['length']) != int(length) + 1:
         log_('wrong longth')
         return False
     block_creator_address=tools.addr(block)
     mint_address=tools.addr(filter(lambda t: t['type']=='mint', block['txs'])[0])
     if block_creator_address!=mint_address:
         log_('bad mint')
         return False
     if block['root_hash']!=tools.db_root():
         log_('bad root, have: '+str(tools.db_root())+'  need ' +str(block['root_hash']))
         return False
     txs=filter(lambda x: x['type']=='mint', block['txs'])
     if len(txs)!=1:
         log_('wrong number of mint txs')
         return False
     txs=filter(lambda x: x['type']=='sign', block['txs'])
     txs=map(lambda x: len(x['jackpots']), txs)
     if sum(txs)<custom.signers*2/3 and length>-1:
         log_('not enough signatures')
         return False
     if length >= 0:
         prev_block=tools.db_get(length)
         to_hash={'prev_hash':prev_block['block_hash'], 'txs':block['txs']}
         if not block['block_hash']==tools.det_hash(to_hash):
             log_('det hash error')
             return False
     #total money spent must be less than the total amount of money in signed deposits for this block.
     if tx_check(block['txs']): 
         log_('tx check')
         return False
     return True
Beispiel #6
0
 def block_check(block, DB):
     def log_(txt): pass #return tools.log(txt)
     def tx_check(txs):
         start = copy.deepcopy(txs)
         out = []
         start_copy = []
         invalid_because = ['']
         while start != start_copy:
             if start == []:
                 return False  # Block passes this test
             start_copy = copy.deepcopy(start)
             if transactions.tx_check[start[0]['type']](start[0], out, invalid_because, DB):
                 out.append(start.pop())
             else:
                 tools.log('invalid tx: '+str(invalid_because[0]))
                 return True  # Block is invalid
         tools.log('block invalid because it has no txs')
         return True  # Block is invalid
     if 'error' in block: 
         log_('error in block')
         return False
     length =tools.local_get('length')
     if type(block['length'])!=type(1): 
         log_('wrong length type')
         return False
     if int(block['length']) != int(length) + 1:
         log_('wrong longth')
         return False
     block_creator_address=tools.addr(block)
     mint_address=tools.addr(filter(lambda t: t['type']=='mint', block['txs'])[0])
     if block_creator_address!=mint_address:
         log_('bad mint')
         return False
     if block['root_hash']!=tools.db_root():
         log_('bad root, have: '+str(tools.db_root())+'  need ' +str(block['root_hash']))
         return False
     txs=filter(lambda x: x['type']=='mint', block['txs'])
     if len(txs)!=1:
         log_('wrong number of mint txs')
         return False
     txs=filter(lambda x: x['type']=='sign', block['txs'])
     txs=map(lambda x: len(x['jackpots']), txs)
     if sum(txs)<custom.signers*2/3 and length>-1:
         log_('not enough signatures')
         return False
     if length >= 0:
         prev_block=tools.db_get(length)
         to_hash={'prev_hash':prev_block['block_hash'], 'txs':block['txs']}
         if not block['block_hash']==tools.det_hash(to_hash):
             log_('det hash error')
             return False
     #total money spent must be less than the total amount of money in signed deposits for this block.
     if tx_check(block['txs']): 
         log_('tx check')
         return False
     return True
Beispiel #7
0
def sign_verify(tx, txs, out, DB):  # check the validity of a transaction of type sign.
    a = tools.addr(tx)
    acc = tools.db_get(a)
    if a["amount"] < tx["B"]:
        tools.log("you do not have that much money")
    B = tx["B"]
    M = custom.all_money
    address = tools.addr(tx)
    block = tools.db_get(tx["on_block"])
    num = max(0, tx["on_block"] - (custom.long_time * 2 - custom.medium_time))
    election_block = tools.db_get(num)
    if "root_hash" not in election_block:
        out[0] += "no root hash"
        return False
    v = tools.db_verify(election_block["root_hash"], address, tx["proof"])
    if v == False:
        tools.log("your address did not exist that long ago.")
        return False
    if v["amount"] != tx["B"]:
        tools.log("that is not how much money you had that long ago")
        return False
    if "secret_hash" not in tx:
        tools.log("need the hash of a secret")
        return False
    for t in txs:
        if tools.addr(t) == address and t["type"] == "sign":
            # tools.log('can only have one sign tx per block')
            return False
    if len(tx["jackpots"]) < 1:
        tools.log("insufficient jackpots")
        return False
    length = tools.local_get("length")
    if int(tx["on_block"]) != int(length + 1):
        out[0] += "this tx is for the wrong block. have " + str(length + 1) + " need: " + str(tx["on_block"])
        return False
    if tx["on_block"] > 0:
        if not tx["prev"] == tools.db_get(length)["block_hash"]:
            tools.log("must give hash of previous block")
            return False
    ran = tools.det_random(tx["on_block"])
    for j in tx["jackpots"]:
        if type(j) != int or j not in range(200):
            tools.log("bad jackpot")
            return False
        if len(filter(lambda x: x == j, tx["jackpots"])) != 1:
            tools.log("no repeated jackpots")
            return False
        if not tools.winner(B, M, ran, address, j):
            tools.log("that jackpot is not valid: " + str(j))
            return False
    if tx["amount"] < custom.minimum_deposit:
        tools.log("you have to deposit more than that")
        return False
    return True
Beispiel #8
0
def slasher_verify(tx, txs, out, DB):
    address = tools.addr(tx)
    acc = tools.db_get(address)
    if acc['secrets'][str(tx['on_block'])]['slashed']:
        tools.log(
            'Someone already slashed them, or they already took the reward.')
        return False
    if not sign_verify(tx['tx1'], [], [''], {}):
        tools.log('one was not a valid tx')
        return False
    if not sign_verify(tx['tx2'], [], [''], {}):
        tools.log('two was not a valid tx')
        return False
    tx1 = copy.deepcopy(tx['tx1'])
    tx2 = copy.deepcopy(tx['tx2'])
    tx1.pop('signatures')
    tx2.pop('signatures')
    tx1 = unpackage(package(tx1))
    tx2 = unpackage(package(tx2))
    msg1 = tools.det_hash(tx1)
    msg2 = tools.det_hash(tx2)
    if msg1 == msg2:
        tools.log('this is the same tx twice...')
        return False
    if tx1['on_block'] != tx2['on_block']:
        tools.log('these are on different lengths')
        return False
    return True
Beispiel #9
0
def sign_transaction(length, address):
    if length <= 0:
        return {"secret_hash": 0}
    txs = tools.db_get(length)["txs"]
    txs = filter(lambda t: t["type"] == "sign", txs)
    txs = filter(lambda t: tools.addr(t) == address, txs)
    return txs[0]
Beispiel #10
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
Beispiel #11
0
def sign_transaction(length, address):
    if length<=0:
        return {'secret_hash':0}
    txs=tools.db_get(length)['txs']
    txs=filter(lambda t: t['type']=='sign', txs)
    txs=filter(lambda t: tools.addr(t)==address, txs)
    return(txs[0])
Beispiel #12
0
def slasher_verify(tx, txs, out, DB):
    address=tools.addr(tx)
    acc=tools.db_get(address)
    if acc['secrets'][str(tx['on_block'])]['slashed']:
        tools.log('Someone already slashed them, or they already took the reward.')
        return False
    if not sign_verify(tx['tx1'], [], [''], {}):
        tools.log('one was not a valid tx')
        return False
    if not sign_verify(tx['tx2'], [], [''], {}):
        tools.log('two was not a valid tx')
        return False
    tx1=copy.deepcopy(tx['tx1'])
    tx2=copy.deepcopy(tx['tx2'])
    tx1.pop('signatures')
    tx2.pop('signatures')
    tx1=unpackage(package(tx1))
    tx2=unpackage(package(tx2))
    msg1=tools.det_hash(tx1)
    msg2=tools.det_hash(tx2)
    if msg1==msg2:
        tools.log('this is the same tx twice...')
        return False
    if tx1['on_block']!=tx2['on_block']:
        tools.log('these are on different lengths')
        return False
    return True
Beispiel #13
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
Beispiel #14
0
def sign(tx, DB, add_block):  #should include hash(entroy_bit and salt)
    address = tools.addr(tx)
    adjust_int(['amount'], address, -int(tx['amount']), DB, add_block)
    adjust_dict(['secrets'], address, False,
                {str(tx['on_block']): {
                     'slashed': False
                 }}, DB, add_block)
Beispiel #15
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
Beispiel #16
0
def slasher_verify(tx, txs, out, DB):
    address = tools.addr(tx)
    acc = tools.db_get(address)
    if acc["secrets"][str(tx["on_block"])]["slashed"]:
        tools.log("Someone already slashed them, or they already took the reward.")
        return False
    if not sign_verify(tx["tx1"], [], [""], {}):
        tools.log("one was not a valid tx")
        return False
    if not sign_verify(tx["tx2"], [], [""], {}):
        tools.log("two was not a valid tx")
        return False
    tx1 = copy.deepcopy(tx["tx1"])
    tx2 = copy.deepcopy(tx["tx2"])
    tx1.pop("signatures")
    tx2.pop("signatures")
    tx1 = unpackage(package(tx1))
    tx2 = unpackage(package(tx2))
    msg1 = tools.det_hash(tx1)
    msg2 = tools.det_hash(tx2)
    if msg1 == msg2:
        tools.log("this is the same tx twice...")
        return False
    if tx1["on_block"] != tx2["on_block"]:
        tools.log("these are on different lengths")
        return False
    return True
Beispiel #17
0
def sign_transaction(length, address):
    if length <= 0:
        return {'secret_hash': 0}
    txs = tools.db_get(length)['txs']
    txs = filter(lambda t: t['type'] == 'sign', txs)
    txs = filter(lambda t: tools.addr(t) == address, txs)
    return (txs[0])
Beispiel #18
0
def spend_verify(tx, txs, out, DB):
    txaddr = tools.addr(tx)
    a = len(tx['to'])
    if a <= 30 or a >= 100:
        out[0] += 'that address is wrong size'
        out[0] += 'tx: ' + str(tx)
        return False
    return True
Beispiel #19
0
def spend_verify(tx, txs, out, DB):
    txaddr = tools.addr(tx)
    a = len(tx["to"])
    if a <= 30 or a >= 100:
        out[0] += "that address is wrong size"
        out[0] += "tx: " + str(tx)
        return False
    return True
Beispiel #20
0
def make_contract(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_int(['amount'], address, -int(tx['amount']), DB, add_block)
    contract = {
        'gas': int(tx['amount']) - custom.make_contract_fee,
        'mem': tx['mem'],
        'stack': []
    }
    symmetric_put(tx['id'], contract, DB, add_block)
Beispiel #21
0
def contract_do(tx, DB, add_block):
    address = tools.addr(tx)
    contract = tools.db_get(tx['contract_id'])
    contract['gas'] = tx['amount'] - custom.contract_do_fee
    new_contract = forth.forth(tx['code'], forth.ex_language, contract)
    tools.log('new contract: ' + str(new_contract))
    new_contract['stack'] = []
    adjust_int(['amount'], address, -int(tx['amount']), DB, add_block)
    adjust_string(['mem'], tx['contract_id'], contract, new_contract['mem'],
                  DB, add_block)
Beispiel #22
0
def reward(tx, DB, add_block):
    address = tools.addr(tx)
    length = tools.db_get('length')
    adjust_string(['secrets', tx['on_block'], 'slashed'], address, False, True,
                  DB, add_block)
    adjust_dict(
        ['entropy'], address, False,
        {str(tx['on_block']): {
             'power': tx['jackpots'],
             'vote': tx['reveal']
         }}, DB, add_block)
    adjust_int(['amount'], address, tx['amount'], DB,
               add_block)  #relative_reward(on_block)+signer_bond
Beispiel #23
0
def reward(tx, DB, add_block):
    address = tools.addr(tx)
    length = tools.db_get("length")
    adjust_string(["secrets", tx["on_block"], "slashed"], address, False, True, DB, add_block)
    adjust_dict(
        ["entropy"],
        address,
        False,
        {str(tx["on_block"]): {"power": tx["jackpots"], "vote": tx["reveal"]}},
        DB,
        add_block,
    )
    adjust_int(["amount"], address, tx["amount"], DB, add_block)  # relative_reward(on_block)+signer_bond
Beispiel #24
0
def spend(tx, DB):
    address = tools.addr(tx)
    if 'vote_id' in tx:
        txs_tools.initialize_to_zero_votecoin(tx['vote_id'], address, DB)
        txs_tools.initialize_to_zero_votecoin(tx['vote_id'], tx['to'], DB)
        adjust_int(['votecoin', tx['vote_id']], address, -tx['amount'], DB)
        adjust_int(['votecoin', tx['vote_id']], tx['to'], tx['amount'], DB)
        txs_tools.memory_leak_votecoin(tx['vote_id'], address, DB)#this should get rid of any zeros in the jury so we don't leak memory.
        txs_tools.memory_leak_votecoin(tx['vote_id'], tx['to'], DB)#this should get rid of any zeros in the jury so we don't leak memory.
    else:
        adjust_int(['amount'], address, -tx['amount'], DB)
        adjust_int(['amount'], tx['to'], tx['amount'], DB)
    adjust_int(['amount'], address, -custom.fee, DB)
    adjust_int(['count'], address, 1, DB)
Beispiel #25
0
def mainloop():
    while True:
        if tools.local_get('stop'):
            return
        time.sleep(1)
        txs=tools.local_get('txs')
        address=tools.local_get('address')
        txs=filter(lambda x: address==tools.addr(x), txs)
        txs=filter(lambda x: x['type']=='sign', txs)
        if len(txs)==0:
            tx=create_sign_tx()
            #tools.log('tx: ' +str(tx))
            api.easy_add_transaction(tx)
        else:
            time.sleep(1)
Beispiel #26
0
def spend(tx, DB):
    address = tools.addr(tx)
    if 'vote_id' in tx:
        txs_tools.initialize_to_zero_votecoin(tx['vote_id'], address, DB)
        txs_tools.initialize_to_zero_votecoin(tx['vote_id'], tx['to'], DB)
        adjust_int(['votecoin', tx['vote_id']], address, -tx['amount'], DB)
        adjust_int(['votecoin', tx['vote_id']], tx['to'], tx['amount'], DB)
        txs_tools.memory_leak_votecoin(
            tx['vote_id'], address, DB
        )  #this should get rid of any zeros in the jury so we don't leak memory.
        txs_tools.memory_leak_votecoin(
            tx['vote_id'], tx['to'], DB
        )  #this should get rid of any zeros in the jury so we don't leak memory.
    else:
        adjust_int(['amount'], address, -tx['amount'], DB)
        adjust_int(['amount'], tx['to'], tx['amount'], DB)
    adjust_int(['amount'], address, -custom.fee, DB)
    adjust_int(['count'], address, 1, DB)
Beispiel #27
0
def mint(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_int(['amount'], address, tx['amount'], DB, add_block)
Beispiel #28
0
def spend(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_int(['amount'], address, -int(tx['amount']), DB, add_block)
    adjust_int(['amount'], tx['to'], tx['amount'], DB, add_block)
    #adjust_int(['amount'], address, -custom.fee, DB, add_block)
    adjust_int(['amount'], address, -int(tx['fee']), DB, add_block)
Beispiel #29
0
def spend(tx, add_block):
    address = tools.addr(tx)
    adjust_int(['amount'], address, -tx['amount'], add_block)
    adjust_int(['amount'], tx['to'], tx['amount'], add_block)
    adjust_int(['amount'], address, -custom.fee, add_block)
    adjust_int(['count'], address, 1, add_block)
Beispiel #30
0
def mint(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_int(["amount"], address, -tx["fee"], DB, add_block)
Beispiel #31
0
def slasher(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_string(['secrets', tx['on_block'], 'slashed'], tools.addr(tx['tx1']), False, True, DB, add_block)
    adjust_int(['amount'], address, tx['amount']/5, DB, add_block)
Beispiel #32
0
def reward(tx, DB, add_block):
    address = tools.addr(tx)
    length=tools.db_get('length')
    adjust_string(['secrets', tx['on_block'], 'slashed'], address, False, True, DB, add_block)
    adjust_dict(['entropy'], address, False, {str(tx['on_block']):{'power':tx['jackpots'],'vote':tx['reveal']}}, DB, add_block)
    adjust_int(['amount'], address, tx['amount'], DB, add_block)#relative_reward(on_block)+signer_bond
Beispiel #33
0
def slasher(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_string(["secrets", tx["on_block"], "slashed"], tools.addr(tx["tx1"]), False, True, DB, add_block)
    adjust_int(["amount"], address, tx["amount"] / 5, DB, add_block)
Beispiel #34
0
def mint(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_int(['amount'], address, -tx['fee'], DB, add_block)
Beispiel #35
0
def spend(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_int(['amount'], address, -int(tx['amount']), DB, add_block)
    adjust_int(['amount'], tx['to'], tx['amount'], DB, add_block)
    #adjust_int(['amount'], address, -custom.fee, DB, add_block)
    adjust_int(['amount'], address, -int(tx['fee']), DB, add_block)
Beispiel #36
0
def spend(tx, DB):
    address = tools.addr(tx)
    adjust_int(['amount'], address, -tx['amount'], DB)
    adjust_int(['amount'], tx['to'], tx['amount'], DB)
    adjust_int(['amount'], address, -custom.fee, DB)
    adjust_int(['count'], address, 1, DB)
Beispiel #37
0
def slasher(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_string(['secrets', tx['on_block'], 'slashed'],
                  tools.addr(tx['tx1']), False, True, DB, add_block)
    adjust_int(['amount'], address, tx['amount'] / 5, DB, add_block)
Beispiel #38
0
def sign(tx, DB, add_block):#should include hash(entroy_bit and salt)
    address = tools.addr(tx)
    adjust_int(['amount'], address, -int(tx['amount']), DB, add_block)
    adjust_dict(['secrets'], address, False, {str(tx['on_block']):{'slashed':False}}, DB, add_block)
Beispiel #39
0
def spend(tx, DB, add_block):
    address = tools.addr(tx)
    adjust_int(["amount"], address, -int(tx["amount"]), DB, add_block)
    adjust_int(["amount"], tx["to"], tx["amount"], DB, add_block)
    # adjust_int(['amount'], address, -custom.fee, DB, add_block)
    adjust_int(["amount"], address, -int(tx["fee"]), DB, add_block)
Beispiel #40
0
def mint(tx, add_block):
    address = tools.addr(tx)
    adjust_int(['amount'], address, custom.block_reward, add_block)
    adjust_int(['count'], address, 1, add_block)
Beispiel #41
0
def mint(tx, DB):
    address = tools.addr(tx)
    adjust_int(['amount'], address, custom.block_reward, DB)
    adjust_int(['count'], address, 1, DB)
Beispiel #42
0
def sign(tx, DB, add_block):  # should include hash(entroy_bit and salt)
    address = tools.addr(tx)
    adjust_int(["amount"], address, -int(tx["amount"]), DB, add_block)
    adjust_dict(["secrets"], address, False, {str(tx["on_block"]): {"slashed": False}}, DB, add_block)