diff --git a/bigchaindb/common/schema/transaction.yaml b/bigchaindb/common/schema/transaction.yaml index f1864cc3..28a7c53e 100644 --- a/bigchaindb/common/schema/transaction.yaml +++ b/bigchaindb/common/schema/transaction.yaml @@ -152,11 +152,6 @@ definitions: - condition - amount properties: - cid: - "$ref": "#/definitions/offset" - description: | - Index of this condition's appearance in the `Transaction.conditions`_ - array. In a transaction with 2 conditions, the ``cid``s will be 0 and 1. condition: description: | Body of the condition. Has the properties: @@ -197,10 +192,6 @@ definitions: - input - fulfillment properties: - fid: - "$ref": "#/definitions/offset" - description: | - The offset of the fulfillment within the fulfillents array. owners_before: "$ref": "#/definitions/owners_list" description: | diff --git a/bigchaindb/common/transaction.py b/bigchaindb/common/transaction.py index 6a7ec629..b2b4167b 100644 --- a/bigchaindb/common/transaction.py +++ b/bigchaindb/common/transaction.py @@ -52,19 +52,13 @@ class Fulfillment(object): # TODO: If `other !== Fulfillment` return `False` return self.to_dict() == other.to_dict() - def to_dict(self, fid=None): + def to_dict(self): """Transforms the object to a Python dictionary. Note: - A `fid` can be submitted to be included in the dictionary - representation. - If a Fulfillment hasn't been signed yet, this method returns a dictionary representation. - Args: - fid (int, optional): The Fulfillment's index in a Transaction. - Returns: dict: The Fulfillment as an alternative serialization format. """ @@ -92,8 +86,6 @@ class Fulfillment(object): 'input': tx_input, 'fulfillment': fulfillment, } - if fid is not None: - ffill['fid'] = fid return ffill @classmethod @@ -234,19 +226,13 @@ class Condition(object): # TODO: If `other !== Condition` return `False` return self.to_dict() == other.to_dict() - def to_dict(self, cid=None): + def to_dict(self): """Transforms the object to a Python dictionary. Note: - A `cid` can be submitted to be included in the dictionary - representation. - A dictionary serialization of the Fulfillment the Condition was derived from is always provided. - Args: - cid (int, optional): The Condition's index in a Transaction. - Returns: dict: The Condition as an alternative serialization format. """ @@ -268,8 +254,6 @@ class Condition(object): 'condition': condition, 'amount': self.amount } - if cid is not None: - cond['cid'] = cid return cond @classmethod @@ -858,11 +842,12 @@ class Transaction(object): """ # NOTE: If no condition indices are passed, we just assume to # take all conditions as inputs. + indices = condition_indices or range(len(self.conditions)) return [ Fulfillment(self.conditions[cid].fulfillment, self.conditions[cid].owners_after, TransactionLink(self.id, cid)) - for cid in condition_indices or range(len(self.conditions)) + for cid in indices ] def add_fulfillment(self, fulfillment): @@ -1179,10 +1164,10 @@ class Transaction(object): asset = {'id': self.asset.data_id} tx_body = { - 'fulfillments': [fulfillment.to_dict(fid) for fid, fulfillment - in enumerate(self.fulfillments)], - 'conditions': [condition.to_dict(cid) for cid, condition - in enumerate(self.conditions)], + 'fulfillments': [fulfillment.to_dict() for fulfillment + in self.fulfillments], + 'conditions': [condition.to_dict() for condition + in self.conditions], 'operation': str(self.operation), 'metadata': metadata, 'asset': asset, diff --git a/docs/server/source/data-models/crypto-conditions.md b/docs/server/source/data-models/crypto-conditions.md index 4d76757a..3ef868fb 100644 --- a/docs/server/source/data-models/crypto-conditions.md +++ b/docs/server/source/data-models/crypto-conditions.md @@ -32,7 +32,6 @@ If there is only one _new owner_, the condition will be a simple signature condi ```json { - "cid": "", "condition": { "details": { "bitmask": "", @@ -49,8 +48,6 @@ If there is only one _new owner_, the condition will be a simple signature condi ``` - **Condition header**: - - `cid`: Condition index so that we can reference this output as an input to another transaction. It also matches - the input `fid`, making this the condition to fulfill in order to spend the asset used as input with `fid`. - `owners_after`: A list containing one item: the public key of the new owner. - `amount`: The amount of shares for a divisible asset to send to the new owners. - **Condition body**: @@ -66,7 +63,6 @@ to spend the asset. For example: ```json { - "cid": "", "condition": { "details": { "bitmask": 41, @@ -115,7 +111,6 @@ If there is only one _current owner_, the fulfillment will be a simple signature ```json { "owners_before": [""], - "fid": 0, "fulfillment": "cf:4:RxFzIE679tFBk8zwEgizhmTuciAylvTUwy6EL6ehddHFJOhK5F4IjwQ1xLu2oQK9iyRCZJdfWAefZVjTt3DeG5j2exqxpGliOPYseNkRAWEakqJ_UrCwgnj92dnFRAEE", "input": { "cid": 0, @@ -124,10 +119,8 @@ If there is only one _current owner_, the fulfillment will be a simple signature } ``` -- `fid`: Fulfillment index. It matches a `cid` in the conditions with a new _crypto-condition_ that the new owner - needs to fulfill to spend this asset. - `owners_before`: A list of public keys of the owners before the transaction; in this case it has just one public key. - `fulfillment`: A crypto-conditions URI that encodes the cryptographic fulfillments like signatures and others, see [crypto-conditions](https://interledger.org/five-bells-condition/spec.html). - `input`: Pointer to the asset and condition of a previous transaction - - `cid`: Condition index + - `cid`: Condition index - the index of the condition in the array of conditions in the previous transaction - `txid`: Transaction id diff --git a/docs/server/source/drivers-clients/http-client-server-api.rst b/docs/server/source/drivers-clients/http-client-server-api.rst index b38852fc..c96936c7 100644 --- a/docs/server/source/drivers-clients/http-client-server-api.rst +++ b/docs/server/source/drivers-clients/http-client-server-api.rst @@ -73,7 +73,6 @@ POST /transactions/ "transaction": { "conditions": [ { - "cid": 0, "condition": { "uri": "cc:4:20:GG-pi3CeIlySZhQoJVBh9O23PzrOuhnYI7OHqIbHjkk:96", "details": { @@ -101,7 +100,6 @@ POST /transactions/ "metadata": null, "fulfillments": [ { - "fid": 0, "input": null, "fulfillment": "cf:4:GG-pi3CeIlySZhQoJVBh9O23PzrOuhnYI7OHqIbHjkn2VnQaEWvecO1x82Qr2Va_JjFywLKIOEV1Ob9Ofkeln2K89ny2mB-s7RLNvYAVzWNiQnp18_nQEUsvwACEXTYJ", "owners_before": [ @@ -141,14 +139,12 @@ POST /transactions/ "owners_after": [ "2ePYHfV3yS3xTxF9EE3Xjo8zPwq2RmLPFAJGQqQKc3j6" ], - "cid": 0 } ], "fulfillments": [ { "input": null, "fulfillment": "cf:4:GG-pi3CeIlySZhQoJVBh9O23PzrOuhnYI7OHqIbHjkn2VnQaEWvecO1x82Qr2Va_JjFywLKIOEV1Ob9Ofkeln2K89ny2mB-s7RLNvYAVzWNiQnp18_nQEUsvwACEXTYJ", - "fid": 0, "owners_before": [ "2ePYHfV3yS3xTxF9EE3Xjo8zPwq2RmLPFAJGQqQKc3j6" ] @@ -237,7 +233,6 @@ GET /transactions/{tx_id} "transaction": { "conditions": [ { - "cid": 0, "condition": { "uri": "cc:4:20:GG-pi3CeIlySZhQoJVBh9O23PzrOuhnYI7OHqIbHjkk:96", "details": { @@ -265,7 +260,6 @@ GET /transactions/{tx_id} "metadata": null, "fulfillments": [ { - "fid": 0, "input": null, "fulfillment": "cf:4:GG-pi3CeIlySZhQoJVBh9O23PzrOuhnYI7OHqIbHjkn2VnQaEWvecO1x82Qr2Va_JjFywLKIOEV1Ob9Ofkeln2K89ny2mB-s7RLNvYAVzWNiQnp18_nQEUsvwACEXTYJ", "owners_before": [ diff --git a/docs/server/source/schema/transaction.rst b/docs/server/source/schema/transaction.rst index 766e0c4a..85c847c6 100644 --- a/docs/server/source/schema/transaction.rst +++ b/docs/server/source/schema/transaction.rst @@ -152,16 +152,6 @@ and what conditions must be met in order for it to be fulfilled. See also: fulfillment_. -Condition.cid -^^^^^^^^^^^^^ - -**type:** integer - -Index of this condition's appearance in the Transaction.conditions_ -array. In a transaction with 2 conditions, the ``cid``\ s will be 0 and 1. - - - Condition.condition ^^^^^^^^^^^^^^^^^^^ @@ -201,15 +191,6 @@ Fulfillment A fulfillment is an input to a transaction, named as such because it fulfills a condition of a previous transaction. In the case of a ``CREATE`` transaction, a fulfillment may provide no ``input``. -Fulfillment.fid -^^^^^^^^^^^^^^^ - -**type:** integer - -The offset of the fulfillment within the fulfillents array. - - - Fulfillment.owners_before ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/common/test_transaction.py b/tests/common/test_transaction.py index e6a4ac5f..6f1bbb3f 100644 --- a/tests/common/test_transaction.py +++ b/tests/common/test_transaction.py @@ -304,8 +304,8 @@ def test_transaction_serialization(user_ffill, user_cond, data, data_id): 'transaction': { # NOTE: This test assumes that Fulfillments and Conditions can # successfully be serialized - 'fulfillments': [user_ffill.to_dict(0)], - 'conditions': [user_cond.to_dict(0)], + 'fulfillments': [user_ffill.to_dict()], + 'conditions': [user_cond.to_dict()], 'operation': Transaction.CREATE, 'metadata': None, 'asset': { @@ -761,7 +761,7 @@ def test_create_create_transaction_single_io(user_cond, user_pub, data, uuid4): expected = { 'transaction': { - 'conditions': [user_cond.to_dict(0)], + 'conditions': [user_cond.to_dict()], 'metadata': { 'data': data, }, @@ -777,7 +777,6 @@ def test_create_create_transaction_single_io(user_cond, user_pub, data, uuid4): 'owners_before': [ user_pub ], - 'fid': 0, 'fulfillment': None, 'input': None } @@ -815,10 +814,9 @@ def test_create_create_transaction_multiple_io(user_cond, user2_cond, user_pub, # is a fulfillment for an implicit threshold condition with # weight = len(owners_before) ffill = Fulfillment.generate([user_pub, user2_pub]).to_dict() - ffill.update({'fid': 0}) expected = { 'transaction': { - 'conditions': [user_cond.to_dict(0), user2_cond.to_dict(1)], + 'conditions': [user_cond.to_dict(), user2_cond.to_dict()], 'metadata': { 'data': { 'message': 'hello' @@ -864,7 +862,7 @@ def test_create_create_transaction_threshold(user_pub, user2_pub, user3_pub, expected = { 'transaction': { - 'conditions': [user_user2_threshold_cond.to_dict(0)], + 'conditions': [user_user2_threshold_cond.to_dict()], 'metadata': { 'data': data, }, @@ -880,7 +878,6 @@ def test_create_create_transaction_threshold(user_pub, user2_pub, user3_pub, 'owners_before': [ user_pub, ], - 'fid': 0, 'fulfillment': None, 'input': None }, @@ -950,7 +947,7 @@ def test_create_transfer_transaction_single_io(tx, user_pub, user2_pub, expected = { 'transaction': { - 'conditions': [user2_cond.to_dict(0)], + 'conditions': [user2_cond.to_dict()], 'metadata': None, 'asset': { 'id': uuid4, @@ -960,7 +957,6 @@ def test_create_transfer_transaction_single_io(tx, user_pub, user2_pub, 'owners_before': [ user_pub ], - 'fid': 0, 'fulfillment': None, 'input': { 'txid': tx.id, @@ -1006,14 +1002,13 @@ def test_create_transfer_transaction_multiple_io(user_pub, user_priv, expected = { 'transaction': { - 'conditions': [user2_cond.to_dict(0), user2_cond.to_dict(1)], + 'conditions': [user2_cond.to_dict(), user2_cond.to_dict()], 'metadata': None, 'fulfillments': [ { 'owners_before': [ user_pub ], - 'fid': 0, 'fulfillment': None, 'input': { 'txid': tx.id, @@ -1023,7 +1018,6 @@ def test_create_transfer_transaction_multiple_io(user_pub, user_priv, 'owners_before': [ user2_pub ], - 'fid': 1, 'fulfillment': None, 'input': { 'txid': tx.id,