Example #1
0
    def do_send(self, line):
        try:
            lines = str(line).split()
            if len(lines) != 2:
                raise WrongArgs
            recipient = str(lines[0])
            amount = int(lines[1])
            if amount > 65535 or amount < 1:
                raise AmountError
            pitoshi = format(amount, 'x')
            f = open("key.txt", "r")
            sender = f.read()
            print(sender)
            tx = Transaction(pitoshi, sender, recipient)
            tx.calculation()
            # TODO validator (need to validate the transaction for the presence of all fields)
            # Serialze

        except WrongArgs:
            print("Wrong send arguments")
            return False
        except AmountError:
            print("We are limited to 4 bytes.The amount should be from 0.1 to 6553.5")
            return False