check condition_uri of CREATE on validate_fulfillment

This commit is contained in:
diminator 2016-05-12 15:37:16 +02:00
parent 7630ec7fc6
commit 37f0477c89
No known key found for this signature in database
GPG Key ID: C3D8590E6D0D439A

View File

@ -276,7 +276,7 @@ def create_tx(current_owners, new_owners, inputs, operation, payload=None):
'new_owners': new_owners, 'new_owners': new_owners,
'condition': { 'condition': {
'details': json.loads(condition.serialize_json()), 'details': json.loads(condition.serialize_json()),
'uri': condition.condition.serialize_uri() 'uri': condition.condition_uri
}, },
'cid': fulfillment['fid'] 'cid': fulfillment['fid']
}) })
@ -449,12 +449,11 @@ def validate_fulfillments(signed_transaction):
is_valid = parsed_fulfillment.validate(serialize(fulfillment_message)) is_valid = parsed_fulfillment.validate(serialize(fulfillment_message))
# if transaction has an input (i.e. not a `CREATE` transaction) # if transaction has an input (i.e. not a `CREATE` transaction)
if fulfillment['input']: # TODO: avoid instantiation, pass as argument!
# TODO: avoid instantiation, pass as argument! bigchain = bigchaindb.Bigchain()
bigchain = bigchaindb.Bigchain() input_condition = get_input_condition(bigchain, fulfillment)
input_condition = get_input_condition(bigchain, fulfillment) is_valid &= parsed_fulfillment.condition.serialize_uri() == \
is_valid &= parsed_fulfillment.condition.serialize_uri() == \ input_condition['condition']['uri']
input_condition['condition']['uri']
if not is_valid: if not is_valid:
return False return False
@ -516,8 +515,14 @@ def get_input_condition(bigchain, fulfillment):
# there is no previous transaction so we need to create one on the fly # there is no previous transaction so we need to create one on the fly
else: else:
current_owner = fulfillment['current_owners'][0] current_owner = fulfillment['current_owners'][0]
condition = json.loads(cc.Ed25519Fulfillment(public_key=current_owner).serialize_json()) condition = cc.Ed25519Fulfillment(public_key=current_owner)
return {'condition': {'details': condition}}
return {
'condition': {
'details': json.loads(condition.serialize_json()),
'uri': condition.condition_uri
}
}
def get_hash_data(transaction): def get_hash_data(transaction):