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)
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)
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
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