Merge branch 'eladve-master'

This commit is contained in:
vrde 2016-08-05 14:38:19 +02:00
commit 630906b4cd
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
4 changed files with 14 additions and 14 deletions

View File

@ -169,8 +169,8 @@ def create_tx(current_owners, new_owners, inputs, operation, payload=None):
Reference: Reference:
{ {
"id": "<sha3 hash>", "id": "<sha3 hash>",
"version": "transaction version number",
"transaction": { "transaction": {
"version": "transaction version number",
"fulfillments": [ "fulfillments": [
{ {
"current_owners": ["list of <pub-keys>"], "current_owners": ["list of <pub-keys>"],
@ -278,6 +278,7 @@ def create_tx(current_owners, new_owners, inputs, operation, payload=None):
}) })
tx = { tx = {
'version': 1,
'fulfillments': fulfillments, 'fulfillments': fulfillments,
'conditions': conditions, 'conditions': conditions,
'operation': operation, 'operation': operation,
@ -291,7 +292,6 @@ def create_tx(current_owners, new_owners, inputs, operation, payload=None):
# create the transaction # create the transaction
transaction = { transaction = {
'id': tx_hash, 'id': tx_hash,
'version': 1,
'transaction': tx 'transaction': tx
} }
@ -479,7 +479,7 @@ def get_fulfillment_message(transaction, fulfillment, serialized=False):
'operation': transaction['transaction']['operation'], 'operation': transaction['transaction']['operation'],
'timestamp': transaction['transaction']['timestamp'], 'timestamp': transaction['transaction']['timestamp'],
'data': transaction['transaction']['data'], 'data': transaction['transaction']['data'],
'version': transaction['version'], 'version': transaction['transaction']['version'],
'id': transaction['id'] 'id': transaction['id']
} }
# and the condition which needs to be retrieved from the output of a previous transaction # and the condition which needs to be retrieved from the output of a previous transaction

View File

@ -58,8 +58,8 @@ Assets can be mutable (changeable) or immutable. To change a mutable asset, you
```json ```json
{ {
"id": "<hash of transaction, excluding signatures (see explanation)>", "id": "<hash of transaction, excluding signatures (see explanation)>",
"version": "<version number of the transaction model>",
"transaction": { "transaction": {
"version": "<version number of the transaction model>",
"fulfillments": ["<list of fulfillments>"], "fulfillments": ["<list of fulfillments>"],
"conditions": ["<list of conditions>"], "conditions": ["<list of conditions>"],
"operation": "<string>", "operation": "<string>",
@ -75,8 +75,8 @@ Assets can be mutable (changeable) or immutable. To change a mutable asset, you
Here's some explanation of the contents of a transaction: Here's some explanation of the contents of a transaction:
- `id`: The hash of everything inside the serialized `transaction` body (i.e. `fulfillments`, `conditions`, `operation`, `timestamp` and `data`; see below), with one wrinkle: for each fulfillment in `fulfillments`, `fulfillment` is set to `null`. The `id` is also the database primary key. - `id`: The hash of everything inside the serialized `transaction` body (i.e. `fulfillments`, `conditions`, `operation`, `timestamp` and `data`; see below), with one wrinkle: for each fulfillment in `fulfillments`, `fulfillment` is set to `null`. The `id` is also the database primary key.
- `version`: Version number of the transaction model, so that software can support different transaction models.
- `transaction`: - `transaction`:
- `version`: Version number of the transaction model, so that software can support different transaction models.
- `fulfillments`: List of fulfillments. Each _fulfillment_ contains a pointer to an unspent asset - `fulfillments`: List of fulfillments. Each _fulfillment_ contains a pointer to an unspent asset
and a _crypto fulfillment_ that satisfies a spending condition set on the unspent asset. A _fulfillment_ and a _crypto fulfillment_ that satisfies a spending condition set on the unspent asset. A _fulfillment_
is usually a signature proving the ownership of the asset. is usually a signature proving the ownership of the asset.

View File

@ -38,8 +38,8 @@ class TestBigchainApi(object):
def test_create_transaction_create(self, b, user_sk): def test_create_transaction_create(self, b, user_sk):
tx = b.create_transaction(b.me, user_sk, None, 'CREATE') tx = b.create_transaction(b.me, user_sk, None, 'CREATE')
assert sorted(tx) == ['id', 'transaction', 'version'] assert sorted(tx) == ['id', 'transaction']
assert sorted(tx['transaction']) == ['conditions', 'data', 'fulfillments', 'operation', 'timestamp'] assert sorted(tx['transaction']) == ['conditions', 'data', 'fulfillments', 'operation', 'timestamp', 'version']
def test_create_transaction_with_unsupported_payload_raises(self, b): def test_create_transaction_with_unsupported_payload_raises(self, b):
with pytest.raises(TypeError): with pytest.raises(TypeError):
@ -79,8 +79,8 @@ class TestBigchainApi(object):
tx = b.create_transaction(user_vk, b.me, input_tx, 'TRANSFER') tx = b.create_transaction(user_vk, b.me, input_tx, 'TRANSFER')
assert sorted(tx) == ['id', 'transaction', 'version'] assert sorted(tx) == ['id', 'transaction']
assert sorted(tx['transaction']) == ['conditions', 'data', 'fulfillments', 'operation', 'timestamp'] assert sorted(tx['transaction']) == ['conditions', 'data', 'fulfillments', 'operation', 'timestamp', 'version']
tx_signed = b.sign_transaction(tx, user_sk) tx_signed = b.sign_transaction(tx, user_sk)
@ -1169,7 +1169,7 @@ class TestFulfillmentMessage(object):
assert fulfillment_message['fulfillment']['input'] == original_fulfillment['input'] assert fulfillment_message['fulfillment']['input'] == original_fulfillment['input']
assert fulfillment_message['operation'] == tx['transaction']['operation'] assert fulfillment_message['operation'] == tx['transaction']['operation']
assert fulfillment_message['timestamp'] == tx['transaction']['timestamp'] assert fulfillment_message['timestamp'] == tx['transaction']['timestamp']
assert fulfillment_message['version'] == tx['version'] assert fulfillment_message['version'] == tx['transaction']['version']
@pytest.mark.usefixtures('inputs') @pytest.mark.usefixtures('inputs')
def test_fulfillment_message_transfer(self, b, user_vk): def test_fulfillment_message_transfer(self, b, user_vk):
@ -1192,7 +1192,7 @@ class TestFulfillmentMessage(object):
assert fulfillment_message['fulfillment']['input'] == original_fulfillment['input'] assert fulfillment_message['fulfillment']['input'] == original_fulfillment['input']
assert fulfillment_message['operation'] == tx['transaction']['operation'] assert fulfillment_message['operation'] == tx['transaction']['operation']
assert fulfillment_message['timestamp'] == tx['transaction']['timestamp'] assert fulfillment_message['timestamp'] == tx['transaction']['timestamp']
assert fulfillment_message['version'] == tx['version'] assert fulfillment_message['version'] == tx['transaction']['version']
def test_fulfillment_message_multiple_current_owners_multiple_new_owners_multiple_inputs(self, b, user_vk): def test_fulfillment_message_multiple_current_owners_multiple_new_owners_multiple_inputs(self, b, user_vk):
# create a new users # create a new users
@ -1230,7 +1230,7 @@ class TestFulfillmentMessage(object):
assert fulfillment_message['fulfillment']['input'] == original_fulfillment['input'] assert fulfillment_message['fulfillment']['input'] == original_fulfillment['input']
assert fulfillment_message['operation'] == tx['transaction']['operation'] assert fulfillment_message['operation'] == tx['transaction']['operation']
assert fulfillment_message['timestamp'] == tx['transaction']['timestamp'] assert fulfillment_message['timestamp'] == tx['transaction']['timestamp']
assert fulfillment_message['version'] == tx['version'] assert fulfillment_message['version'] == tx['transaction']['version']
class TestTransactionMalleability(object): class TestTransactionMalleability(object):
@ -1252,7 +1252,7 @@ class TestTransactionMalleability(object):
assert b.is_valid_transaction(tx_changed) is False assert b.is_valid_transaction(tx_changed) is False
tx_changed = copy.deepcopy(tx_signed) tx_changed = copy.deepcopy(tx_signed)
tx_changed['version'] = '0' tx_changed['transaction']['version'] = '0'
assert b.validate_fulfillments(tx_changed) is False assert b.validate_fulfillments(tx_changed) is False
assert b.is_valid_transaction(tx_changed) is False assert b.is_valid_transaction(tx_changed) is False

View File

@ -151,7 +151,7 @@ def test_create_tx_with_empty_inputs():
tx = create_tx(None, None, [], None) tx = create_tx(None, None, [], None)
assert 'id' in tx assert 'id' in tx
assert 'transaction' in tx assert 'transaction' in tx
assert 'version' in tx assert 'version' in tx['transaction']
assert 'fulfillments' in tx['transaction'] assert 'fulfillments' in tx['transaction']
assert 'conditions' in tx['transaction'] assert 'conditions' in tx['transaction']
assert 'operation' in tx['transaction'] assert 'operation' in tx['transaction']