예제 #1
0
def easy_add_transaction(tx_orig, sign_over, privkey):
    state = state_library.current_state()
    pubkey = pt.privtopub(privkey)
    if pubkey not in state or "count" not in state[pubkey]:
        my_count = 1
    else:
        my_count = state[pubkey]["count"]
    txs = blockchain.load_transactions()
    my_txs = filter(lambda x: x["id"] == pubkey, txs)
    tx = copy.deepcopy(tx_orig)
    tx["count"] = len(my_txs) + my_count
    tx["signature"] = pt.ecdsa_sign(blockchain.message2signObject(tx, sign_over), privkey)
    print (blockchain.add_transaction(tx))
    if "move_number" in tx:
        for i in range(10):
            tx["move_number"] += 1
            tx["signature"] = pt.ecdsa_sign(blockchain.message2signObject(tx, sign_over), privkey)
            print (blockchain.add_transaction(tx))
    print ("tx: " + str(tx))
    blockchain.pushtx(tx, quick_mine.peers_list)
예제 #2
0
파일: gui.py 프로젝트: Aeium/go-coin
def easy_add_transaction(tx_orig, sign_over, privkey):
    state=state_library.current_state()
    pubkey=pt.privtopub(privkey)
    if pubkey not in state or 'count' not in state[pubkey]:
        my_count=1
    else:
        my_count=state[pubkey]['count']
    txs=blockchain.load_transactions()
    my_txs=filter(lambda x: x['id']==pubkey, txs)
    tx=copy.deepcopy(tx_orig)
    tx['count']=len(my_txs)+my_count
    tx['signature']=pt.ecdsa_sign(blockchain.message2signObject(tx, sign_over), privkey)
    print(blockchain.add_transaction(tx))
    if 'move_number' in tx:
        for i in range(10):
            tx['move_number']+=1
            tx['signature']=pt.ecdsa_sign(blockchain.message2signObject(tx, sign_over), privkey)
            print(blockchain.add_transaction(tx))
    print('tx: ' +str(tx))
    blockchain.pushtx(tx, config.peers_list)
예제 #3
0
파일: gui.py 프로젝트: SamPatt/CryptGo
def easy_add_transaction(tx_orig, sign_over, privkey, state):
    tx=copy.deepcopy(tx_orig)
    pubkey=pt.privtopub(privkey)
    if pubkey not in state or 'count' not in state[pubkey]:
        tx['count']=1
    else:
        tx['count']=state[pubkey]['count']
    txs=blockchain.load_transactions()
    my_txs=filter(lambda x: x['id']==pubkey, txs)
    tx['signature']=pt.ecdsa_sign(blockchain.message2signObject(tx, sign_over), privkey)
    if blockchain.add_transaction(tx):
        blockchain.pushtx(tx, config.peers_list)
        return True
    if 'move_number' in tx:
        for i in range(10):
            tx['move_number']+=1
            tx['signature']=pt.ecdsa_sign(blockchain.message2signObject(tx, sign_over), privkey)
            if blockchain.add_transaction(tx):
                blockchain.pushtx(tx, config.peers_list)
                return True
    print('SOMETHING IS BROKEN')
    return False
예제 #4
0
파일: gui.py 프로젝트: zack-bitcoin/CryptGo
def easy_add_transaction(tx_orig, sign_over, privkey, state):
    tx = copy.deepcopy(tx_orig)
    pubkey = pt.privtopub(privkey)
    if pubkey not in state or 'count' not in state[pubkey]:
        tx['count'] = 1
    else:
        tx['count'] = state[pubkey]['count']
    txs = blockchain.load_transactions()
    my_txs = filter(lambda x: x['id'] == pubkey, txs)
    tx['signature'] = pt.ecdsa_sign(go.message2signObject(tx, sign_over),
                                    privkey)
    if blockchain.add_transaction(tx):
        blockchain.pushtx(tx, config.peers_list)
        return True
    if 'move_number' in tx:
        for i in range(10):
            tx['move_number'] += 1
            tx['signature'] = pt.ecdsa_sign(
                go.message2signObject(tx, sign_over), privkey)
            if blockchain.add_transaction(tx):
                blockchain.pushtx(tx, config.peers_list)
                return True
    print('SOMETHING IS BROKEN')
    return False