TODO fix isvalid function
This commit is contained in:
parent
bdad62d2e2
commit
1f492c8a29
@ -4,6 +4,7 @@ NORMAL = 0
|
||||
REWARD = 1
|
||||
|
||||
from helpers import SignatureHelper as Signature
|
||||
from helpers import UtilityHelper as utilityHelper
|
||||
|
||||
class Tx:
|
||||
def __init__(self, type = NORMAL):
|
||||
@ -24,18 +25,19 @@ class Tx:
|
||||
self.reqd.append(addr)
|
||||
|
||||
def sign(self, private):
|
||||
ser = Signature.privateBytesToKey(private)
|
||||
message = self.__gather()
|
||||
newsig = Signature.sign(message, private)
|
||||
newsig = Signature.sign(message, ser)
|
||||
self.sigs.append(newsig)
|
||||
|
||||
def is_valid(self):
|
||||
|
||||
# if self.type == REWARD:
|
||||
# if len(self.inputs)!=0 and len(self.outputs)!=1:
|
||||
# return False
|
||||
# return True
|
||||
if self.type == REWARD:
|
||||
if len(self.inputs)!=0 and len(self.outputs)!=1:
|
||||
return False
|
||||
return True
|
||||
|
||||
# else:
|
||||
else:
|
||||
# total_in = 0
|
||||
# total_out = 0
|
||||
# message = self.__gather()
|
||||
@ -94,17 +96,17 @@ class Tx:
|
||||
|
||||
return repr_str
|
||||
|
||||
def createTransaction(self, public_key, private_key, amount, fee, recipient, reqd = None, type = NORMAL):
|
||||
self.add_input(public_key, amount + fee)
|
||||
def createTransaction(self, public_ser, private_ser, amount, fee, recipient, reqd = None, type = NORMAL):
|
||||
self.add_input(public_ser, amount + fee)
|
||||
self.add_output(recipient, amount)
|
||||
self.type = type
|
||||
if reqd != None:
|
||||
self.add_reqd(reqd)
|
||||
self.sign(private_key)
|
||||
self.sign(private_ser)
|
||||
|
||||
def createRewardTransaction(self, public_key, private_key, type):
|
||||
value = type == "mine" and MINE_REWARD_VALUE or REGISTRATION_REWARD_VALUE
|
||||
self.add_output(public_key, value)
|
||||
def createRewardTransaction(self, public_ser, private_ser, type):
|
||||
value = type == "MINE" and MINE_REWARD_VALUE or REGISTRATION_REWARD_VALUE
|
||||
self.add_output(public_ser, value)
|
||||
self.type = REWARD
|
||||
self.sign(private_key)
|
||||
self.sign(private_ser)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user