def get_transaction(self, data, node): dprint("Getting the transactions") system = GetBlock() system.createTrans(sequance_number=data["sequance_number"], signature=data["signature"], fromUser=data["fromUser"], toUser=data["to_user"], data=data["data"], amount=data["amount"], transaction_fee=data["transaction_fee"], transaction_sender=node, transaction_time=data["transaction_time"])
def send(my_public_key, my_private_key, to_user, data=None, amount=None): """ The main function for sending the transaction. Inputs: * my_public_key: Sender's public key. * my_private_key: Sender's private key. * to_user: Receiver's address. * data: A text that can be written into the transaction. (Can be None) * amount: A int or float amount to be sent. (Can be None) """ my_public_key = "".join([ l.strip() for l in my_public_key.splitlines() if l and not l.startswith("-----") ]) system = GetBlock() sequance_number = GetSequanceNumber(my_public_key, system) + 1 # Get the current fee transaction_fee = system.transaction_fee tx_time = int(time.time()) system.createTrans( sequance_number=sequance_number, signature=Ecdsa.sign( str(sequance_number) + str(my_public_key) + str(to_user) + str(data) + str(amount) + str(transaction_fee) + str(tx_time), PrivateKey.fromPem(my_private_key)).toBase64(), fromUser=str(my_public_key), toUser=str(to_user), data=data, amount=amount, transaction_fee=transaction_fee, transaction_sender=None, transaction_time=tx_time)