mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge pull request #373 from bigchaindb/bug/#/fix-cc-integration
Update cc API usage
This commit is contained in:
commit
a3b37f0984
@ -275,7 +275,7 @@ def create_tx(current_owners, new_owners, inputs, operation, payload=None):
|
|||||||
conditions.append({
|
conditions.append({
|
||||||
'new_owners': new_owners,
|
'new_owners': new_owners,
|
||||||
'condition': {
|
'condition': {
|
||||||
'details': rapidjson.loads(condition.serialize_json()),
|
'details': condition.to_dict(),
|
||||||
'uri': condition.condition_uri
|
'uri': condition.condition_uri
|
||||||
},
|
},
|
||||||
'cid': fulfillment['fid']
|
'cid': fulfillment['fid']
|
||||||
@ -333,7 +333,7 @@ def sign_tx(transaction, signing_keys):
|
|||||||
# 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)
|
||||||
parsed_fulfillment = cc.Fulfillment.from_json(input_condition['condition']['details'])
|
parsed_fulfillment = cc.Fulfillment.from_dict(input_condition['condition']['details'])
|
||||||
# for the case in which the type of fulfillment is not covered by this method
|
# for the case in which the type of fulfillment is not covered by this method
|
||||||
parsed_fulfillment_signed = parsed_fulfillment
|
parsed_fulfillment_signed = parsed_fulfillment
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ def get_input_condition(bigchain, fulfillment):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'condition': {
|
'condition': {
|
||||||
'details': rapidjson.loads(condition.serialize_json()),
|
'details': condition.to_dict(),
|
||||||
'uri': condition.condition_uri
|
'uri': condition.condition_uri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,6 @@ We'll illustrate this by a threshold condition where 2 out of 3 `new_owners` nee
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
import copy
|
import copy
|
||||||
import json
|
|
||||||
|
|
||||||
import cryptoconditions as cc
|
import cryptoconditions as cc
|
||||||
from bigchaindb import util, crypto
|
from bigchaindb import util, crypto
|
||||||
@ -559,7 +558,7 @@ threshold_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=threshol
|
|||||||
|
|
||||||
# Update the condition in the newly created transaction
|
# Update the condition in the newly created transaction
|
||||||
threshold_tx['transaction']['conditions'][0]['condition'] = {
|
threshold_tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(threshold_condition.serialize_json()),
|
'details': threshold_condition.to_dict(),
|
||||||
'uri': threshold_condition.condition.serialize_uri()
|
'uri': threshold_condition.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,7 +666,7 @@ tx_retrieved_id = b.get_owned_ids(thresholduser1_pub).pop()
|
|||||||
threshold_tx_transfer = b.create_transaction([thresholduser1_pub, thresholduser2_pub, thresholduser3_pub], thresholduser4_pub, tx_retrieved_id, 'TRANSFER')
|
threshold_tx_transfer = b.create_transaction([thresholduser1_pub, thresholduser2_pub, thresholduser3_pub], thresholduser4_pub, tx_retrieved_id, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
threshold_fulfillment = cc.Fulfillment.from_json(threshold_tx['transaction']['conditions'][0]['condition']['details'])
|
threshold_fulfillment = cc.Fulfillment.from_dict(threshold_tx['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment1 = threshold_fulfillment.get_subcondition_from_vk(thresholduser1_pub)[0]
|
subfulfillment1 = threshold_fulfillment.get_subcondition_from_vk(thresholduser1_pub)[0]
|
||||||
subfulfillment2 = threshold_fulfillment.get_subcondition_from_vk(thresholduser2_pub)[0]
|
subfulfillment2 = threshold_fulfillment.get_subcondition_from_vk(thresholduser2_pub)[0]
|
||||||
@ -911,7 +910,7 @@ condition_timeout = cc.TimeoutFulfillment(expire_time=time_expire)
|
|||||||
# The conditions list is empty, so we need to append a new condition
|
# The conditions list is empty, so we need to append a new condition
|
||||||
tx_timeout['transaction']['conditions'].append({
|
tx_timeout['transaction']['conditions'].append({
|
||||||
'condition': {
|
'condition': {
|
||||||
'details': json.loads(condition_timeout.serialize_json()),
|
'details': condition_timeout.to_dict(),
|
||||||
'uri': condition_timeout.condition.serialize_uri()
|
'uri': condition_timeout.condition.serialize_uri()
|
||||||
},
|
},
|
||||||
'cid': 0,
|
'cid': 0,
|
||||||
@ -977,7 +976,7 @@ from time import sleep
|
|||||||
tx_timeout_transfer = b.create_transaction(None, testuser1_pub, {'txid': tx_timeout['id'], 'cid': 0}, 'TRANSFER')
|
tx_timeout_transfer = b.create_transaction(None, testuser1_pub, {'txid': tx_timeout['id'], 'cid': 0}, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the timeout condition and create the corresponding fulfillment
|
# Parse the timeout condition and create the corresponding fulfillment
|
||||||
timeout_fulfillment = cc.Fulfillment.from_json(
|
timeout_fulfillment = cc.Fulfillment.from_dict(
|
||||||
tx_timeout['transaction']['conditions'][0]['condition']['details'])
|
tx_timeout['transaction']['conditions'][0]['condition']['details'])
|
||||||
tx_timeout_transfer['transaction']['fulfillments'][0]['fulfillment'] = timeout_fulfillment.serialize_uri()
|
tx_timeout_transfer['transaction']['fulfillments'][0]['fulfillment'] = timeout_fulfillment.serialize_uri()
|
||||||
|
|
||||||
@ -1078,7 +1077,7 @@ condition_escrow.add_subfulfillment(condition_abort)
|
|||||||
|
|
||||||
# Update the condition in the newly created transaction
|
# Update the condition in the newly created transaction
|
||||||
tx_escrow['transaction']['conditions'][0]['condition'] = {
|
tx_escrow['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(condition_escrow.serialize_json()),
|
'details': condition_escrow.to_dict(),
|
||||||
'uri': condition_escrow.condition.serialize_uri()
|
'uri': condition_escrow.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1209,7 +1208,7 @@ In the case of `testuser1`, we create the `execute` fulfillment:
|
|||||||
tx_escrow_execute = b.create_transaction([testuser2_pub, testuser1_pub], testuser1_pub, {'txid': tx_escrow_signed['id'], 'cid': 0}, 'TRANSFER')
|
tx_escrow_execute = b.create_transaction([testuser2_pub, testuser1_pub], testuser1_pub, {'txid': tx_escrow_signed['id'], 'cid': 0}, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the Escrow cryptocondition
|
# Parse the Escrow cryptocondition
|
||||||
escrow_fulfillment = cc.Fulfillment.from_json(
|
escrow_fulfillment = cc.Fulfillment.from_dict(
|
||||||
tx_escrow['transaction']['conditions'][0]['condition']['details'])
|
tx_escrow['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment_testuser1 = escrow_fulfillment.get_subcondition_from_vk(testuser1_pub)[0]
|
subfulfillment_testuser1 = escrow_fulfillment.get_subcondition_from_vk(testuser1_pub)[0]
|
||||||
@ -1250,7 +1249,7 @@ In the case of `testuser2`, we create the `abort` fulfillment:
|
|||||||
tx_escrow_abort = b.create_transaction([testuser2_pub, testuser1_pub], testuser2_pub, {'txid': tx_escrow_signed['id'], 'cid': 0}, 'TRANSFER')
|
tx_escrow_abort = b.create_transaction([testuser2_pub, testuser1_pub], testuser2_pub, {'txid': tx_escrow_signed['id'], 'cid': 0}, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
escrow_fulfillment = cc.Fulfillment.from_json(
|
escrow_fulfillment = cc.Fulfillment.from_dict(
|
||||||
tx_escrow['transaction']['conditions'][0]['condition']['details'])
|
tx_escrow['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment_testuser1 = escrow_fulfillment.get_subcondition_from_vk(testuser1_pub)[0]
|
subfulfillment_testuser1 = escrow_fulfillment.get_subcondition_from_vk(testuser1_pub)[0]
|
||||||
|
6
setup.py
6
setup.py
@ -95,7 +95,7 @@ setup(
|
|||||||
'rethinkdb==2.3.0',
|
'rethinkdb==2.3.0',
|
||||||
'pysha3==0.3',
|
'pysha3==0.3',
|
||||||
'pytz==2015.7',
|
'pytz==2015.7',
|
||||||
'cryptoconditions==0.3.1',
|
'cryptoconditions==0.4.1',
|
||||||
'statsd==3.2.1',
|
'statsd==3.2.1',
|
||||||
'python-rapidjson==0.0.6',
|
'python-rapidjson==0.0.6',
|
||||||
'logstats==0.2.1',
|
'logstats==0.2.1',
|
||||||
@ -108,7 +108,7 @@ setup(
|
|||||||
tests_require=tests_require,
|
tests_require=tests_require,
|
||||||
extras_require={
|
extras_require={
|
||||||
'test': tests_require,
|
'test': tests_require,
|
||||||
'dev': dev_require + tests_require + docs_require + benchmarks_require,
|
'dev': dev_require + tests_require + docs_require + benchmarks_require,
|
||||||
'docs': docs_require,
|
'docs': docs_require,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,6 @@ import copy
|
|||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
import json
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import rethinkdb as r
|
import rethinkdb as r
|
||||||
@ -1504,9 +1503,9 @@ class TestCryptoconditions(object):
|
|||||||
tx = b.create_transaction(b.me, user_vk, None, 'CREATE')
|
tx = b.create_transaction(b.me, user_vk, None, 'CREATE')
|
||||||
condition = tx['transaction']['conditions'][0]['condition']
|
condition = tx['transaction']['conditions'][0]['condition']
|
||||||
condition_from_uri = cc.Condition.from_uri(condition['uri'])
|
condition_from_uri = cc.Condition.from_uri(condition['uri'])
|
||||||
condition_from_json = cc.Fulfillment.from_json(condition['details']).condition
|
condition_from_dict = cc.Fulfillment.from_dict(condition['details']).condition
|
||||||
|
|
||||||
assert condition_from_uri.serialize_uri() == condition_from_json.serialize_uri()
|
assert condition_from_uri.serialize_uri() == condition_from_dict.serialize_uri()
|
||||||
assert condition['details']['public_key'] == user_vk
|
assert condition['details']['public_key'] == user_vk
|
||||||
|
|
||||||
tx_signed = b.sign_transaction(tx, b.me_private)
|
tx_signed = b.sign_transaction(tx, b.me_private)
|
||||||
@ -1528,16 +1527,16 @@ class TestCryptoconditions(object):
|
|||||||
prev_tx = b.get_transaction(prev_tx_id['txid'])
|
prev_tx = b.get_transaction(prev_tx_id['txid'])
|
||||||
prev_condition = prev_tx['transaction']['conditions'][0]['condition']
|
prev_condition = prev_tx['transaction']['conditions'][0]['condition']
|
||||||
prev_condition_from_uri = cc.Condition.from_uri(prev_condition['uri'])
|
prev_condition_from_uri = cc.Condition.from_uri(prev_condition['uri'])
|
||||||
prev_condition_from_json = cc.Fulfillment.from_json(prev_condition['details']).condition
|
prev_condition_from_dict = cc.Fulfillment.from_dict(prev_condition['details']).condition
|
||||||
|
|
||||||
assert prev_condition_from_uri.serialize_uri() == prev_condition_from_json.serialize_uri()
|
assert prev_condition_from_uri.serialize_uri() == prev_condition_from_dict.serialize_uri()
|
||||||
assert prev_condition['details']['public_key'] == user_vk
|
assert prev_condition['details']['public_key'] == user_vk
|
||||||
|
|
||||||
condition = tx['transaction']['conditions'][0]['condition']
|
condition = tx['transaction']['conditions'][0]['condition']
|
||||||
condition_from_uri = cc.Condition.from_uri(condition['uri'])
|
condition_from_uri = cc.Condition.from_uri(condition['uri'])
|
||||||
condition_from_json = cc.Fulfillment.from_json(condition['details']).condition
|
condition_from_dict = cc.Fulfillment.from_dict(condition['details']).condition
|
||||||
|
|
||||||
assert condition_from_uri.serialize_uri() == condition_from_json.serialize_uri()
|
assert condition_from_uri.serialize_uri() == condition_from_dict.serialize_uri()
|
||||||
assert condition['details']['public_key'] == other_vk
|
assert condition['details']['public_key'] == other_vk
|
||||||
|
|
||||||
tx_signed = b.sign_transaction(tx, user_sk)
|
tx_signed = b.sign_transaction(tx, user_sk)
|
||||||
@ -1554,7 +1553,7 @@ class TestCryptoconditions(object):
|
|||||||
tx = b.create_transaction(b.me, user_vk, None, 'CREATE')
|
tx = b.create_transaction(b.me, user_vk, None, 'CREATE')
|
||||||
fulfillment = cc.Ed25519Fulfillment(public_key=user_vk)
|
fulfillment = cc.Ed25519Fulfillment(public_key=user_vk)
|
||||||
tx['transaction']['conditions'][0]['condition'] = {
|
tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(fulfillment.serialize_json()),
|
'details': fulfillment.to_dict(),
|
||||||
'uri': fulfillment.condition.serialize_uri()
|
'uri': fulfillment.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1577,7 +1576,7 @@ class TestCryptoconditions(object):
|
|||||||
|
|
||||||
fulfillment = cc.Ed25519Fulfillment(public_key=other_vk)
|
fulfillment = cc.Ed25519Fulfillment(public_key=other_vk)
|
||||||
tx['transaction']['conditions'][0]['condition'] = {
|
tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(fulfillment.serialize_json()),
|
'details': fulfillment.to_dict(),
|
||||||
'uri': fulfillment.condition.serialize_uri()
|
'uri': fulfillment.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1627,7 +1626,7 @@ class TestCryptoconditions(object):
|
|||||||
|
|
||||||
first_tx_condition = cc.Ed25519Fulfillment(public_key=other_vk)
|
first_tx_condition = cc.Ed25519Fulfillment(public_key=other_vk)
|
||||||
first_tx['transaction']['conditions'][0]['condition'] = {
|
first_tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(first_tx_condition.serialize_json()),
|
'details': first_tx_condition.to_dict(),
|
||||||
'uri': first_tx_condition.condition.serialize_uri()
|
'uri': first_tx_condition.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1674,7 +1673,7 @@ class TestCryptoconditions(object):
|
|||||||
first_tx_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=other3_vk))
|
first_tx_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=other3_vk))
|
||||||
|
|
||||||
first_tx['transaction']['conditions'][0]['condition'] = {
|
first_tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(first_tx_condition.serialize_json()),
|
'details': first_tx_condition.to_dict(),
|
||||||
'uri': first_tx_condition.condition.serialize_uri()
|
'uri': first_tx_condition.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
# conditions have been updated, so hash needs updating
|
# conditions have been updated, so hash needs updating
|
||||||
@ -1713,7 +1712,7 @@ class TestCryptoconditions(object):
|
|||||||
assert b.is_valid_transaction(next_tx) == next_tx
|
assert b.is_valid_transaction(next_tx) == next_tx
|
||||||
|
|
||||||
@pytest.mark.usefixtures('inputs')
|
@pytest.mark.usefixtures('inputs')
|
||||||
def test_override_condition_and_fulfillment_transfer_threshold_from_json(self, b, user_vk, user_sk):
|
def test_override_condition_and_fulfillment_transfer_threshold_from_dict(self, b, user_vk, user_sk):
|
||||||
other1_sk, other1_vk = crypto.generate_key_pair()
|
other1_sk, other1_vk = crypto.generate_key_pair()
|
||||||
other2_sk, other2_vk = crypto.generate_key_pair()
|
other2_sk, other2_vk = crypto.generate_key_pair()
|
||||||
other3_sk, other3_vk = crypto.generate_key_pair()
|
other3_sk, other3_vk = crypto.generate_key_pair()
|
||||||
@ -1727,7 +1726,7 @@ class TestCryptoconditions(object):
|
|||||||
first_tx_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=other3_vk))
|
first_tx_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=other3_vk))
|
||||||
|
|
||||||
first_tx['transaction']['conditions'][0]['condition'] = {
|
first_tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(first_tx_condition.serialize_json()),
|
'details': first_tx_condition.to_dict(),
|
||||||
'uri': first_tx_condition.condition.serialize_uri()
|
'uri': first_tx_condition.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
# conditions have been updated, so hash needs updating
|
# conditions have been updated, so hash needs updating
|
||||||
@ -1752,7 +1751,7 @@ class TestCryptoconditions(object):
|
|||||||
next_tx_fulfillment_message = util.get_fulfillment_message(next_tx, next_tx_fulfillment, serialized=True)
|
next_tx_fulfillment_message = util.get_fulfillment_message(next_tx, next_tx_fulfillment, serialized=True)
|
||||||
|
|
||||||
# parse the threshold cryptocondition
|
# parse the threshold cryptocondition
|
||||||
next_tx_fulfillment = cc.Fulfillment.from_json(first_tx['transaction']['conditions'][0]['condition']['details'])
|
next_tx_fulfillment = cc.Fulfillment.from_dict(first_tx['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment1 = next_tx_fulfillment.get_subcondition_from_vk(other1_vk)[0]
|
subfulfillment1 = next_tx_fulfillment.get_subcondition_from_vk(other1_vk)[0]
|
||||||
subfulfillment2 = next_tx_fulfillment.get_subcondition_from_vk(other2_vk)[0]
|
subfulfillment2 = next_tx_fulfillment.get_subcondition_from_vk(other2_vk)[0]
|
||||||
@ -1783,7 +1782,7 @@ class TestCryptoconditions(object):
|
|||||||
first_tx_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=other2_vk))
|
first_tx_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=other2_vk))
|
||||||
|
|
||||||
first_tx['transaction']['conditions'][0]['condition'] = {
|
first_tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(first_tx_condition.serialize_json()),
|
'details': first_tx_condition.to_dict(),
|
||||||
'uri': first_tx_condition.condition.serialize_uri()
|
'uri': first_tx_condition.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
# conditions have been updated, so hash needs updating
|
# conditions have been updated, so hash needs updating
|
||||||
@ -1835,7 +1834,7 @@ class TestCryptoconditions(object):
|
|||||||
expected_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=user_vk))
|
expected_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=user_vk))
|
||||||
expected_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=user2_vk))
|
expected_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=user2_vk))
|
||||||
tx_expected_condition = {
|
tx_expected_condition = {
|
||||||
'details': json.loads(expected_condition.serialize_json()),
|
'details': expected_condition.to_dict(),
|
||||||
'uri': expected_condition.condition.serialize_uri()
|
'uri': expected_condition.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1857,7 +1856,7 @@ class TestCryptoconditions(object):
|
|||||||
tx_transfer_signed = b.sign_transaction(tx_transfer, [user_sk, user2_sk])
|
tx_transfer_signed = b.sign_transaction(tx_transfer, [user_sk, user2_sk])
|
||||||
|
|
||||||
# expected fulfillment
|
# expected fulfillment
|
||||||
expected_fulfillment = cc.Fulfillment.from_json(
|
expected_fulfillment = cc.Fulfillment.from_dict(
|
||||||
tx_create['transaction']['conditions'][0]['condition']['details'])
|
tx_create['transaction']['conditions'][0]['condition']['details'])
|
||||||
subfulfillment1 = expected_fulfillment.subconditions[0]['body']
|
subfulfillment1 = expected_fulfillment.subconditions[0]['body']
|
||||||
subfulfillment2 = expected_fulfillment.subconditions[1]['body']
|
subfulfillment2 = expected_fulfillment.subconditions[1]['body']
|
||||||
@ -1881,7 +1880,7 @@ class TestCryptoconditions(object):
|
|||||||
|
|
||||||
hashlock_tx['transaction']['conditions'].append({
|
hashlock_tx['transaction']['conditions'].append({
|
||||||
'condition': {
|
'condition': {
|
||||||
'details': json.loads(first_tx_condition.serialize_json()),
|
'details': first_tx_condition.to_dict(),
|
||||||
'uri': first_tx_condition.condition.serialize_uri()
|
'uri': first_tx_condition.condition.serialize_uri()
|
||||||
},
|
},
|
||||||
'cid': 0,
|
'cid': 0,
|
||||||
@ -1912,7 +1911,7 @@ class TestCryptoconditions(object):
|
|||||||
|
|
||||||
hashlock_tx['transaction']['conditions'].append({
|
hashlock_tx['transaction']['conditions'].append({
|
||||||
'condition': {
|
'condition': {
|
||||||
'details': json.loads(first_tx_condition.serialize_json()),
|
'details': first_tx_condition.to_dict(),
|
||||||
'uri': first_tx_condition.condition.serialize_uri()
|
'uri': first_tx_condition.condition.serialize_uri()
|
||||||
},
|
},
|
||||||
'cid': 0,
|
'cid': 0,
|
||||||
@ -1943,7 +1942,7 @@ class TestCryptoconditions(object):
|
|||||||
|
|
||||||
hashlock_tx['transaction']['conditions'].append({
|
hashlock_tx['transaction']['conditions'].append({
|
||||||
'condition': {
|
'condition': {
|
||||||
'details': json.loads(first_tx_condition.serialize_json()),
|
'details': first_tx_condition.to_dict(),
|
||||||
'uri': first_tx_condition.condition.serialize_uri()
|
'uri': first_tx_condition.condition.serialize_uri()
|
||||||
},
|
},
|
||||||
'cid': 0,
|
'cid': 0,
|
||||||
@ -2013,7 +2012,7 @@ class TestCryptoconditions(object):
|
|||||||
|
|
||||||
# create a transaction with multiple new_owners
|
# create a transaction with multiple new_owners
|
||||||
tx = b.create_transaction(b.me, new_owners, None, 'CREATE')
|
tx = b.create_transaction(b.me, new_owners, None, 'CREATE')
|
||||||
condition = cc.Fulfillment.from_json(tx['transaction']['conditions'][0]['condition']['details'])
|
condition = cc.Fulfillment.from_dict(tx['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
for new_owner in new_owners:
|
for new_owner in new_owners:
|
||||||
subcondition = condition.get_subcondition_from_vk(new_owner)[0]
|
subcondition = condition.get_subcondition_from_vk(new_owner)[0]
|
||||||
@ -2051,7 +2050,7 @@ class TestCryptoconditions(object):
|
|||||||
|
|
||||||
# Update the condition in the newly created transaction
|
# Update the condition in the newly created transaction
|
||||||
escrow_tx['transaction']['conditions'][0]['condition'] = {
|
escrow_tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(condition_escrow.serialize_json()),
|
'details': condition_escrow.to_dict(),
|
||||||
'uri': condition_escrow.condition.serialize_uri()
|
'uri': condition_escrow.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2077,7 +2076,7 @@ class TestCryptoconditions(object):
|
|||||||
escrow_tx_transfer = b.create_transaction([user_vk, user2_vk], user2_vk, tx_retrieved_id, 'TRANSFER')
|
escrow_tx_transfer = b.create_transaction([user_vk, user2_vk], user2_vk, tx_retrieved_id, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
escrow_fulfillment = cc.Fulfillment.from_json(
|
escrow_fulfillment = cc.Fulfillment.from_dict(
|
||||||
escrow_tx['transaction']['conditions'][0]['condition']['details'])
|
escrow_tx['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment_user = escrow_fulfillment.get_subcondition_from_vk(user_vk)[0]
|
subfulfillment_user = escrow_fulfillment.get_subcondition_from_vk(user_vk)[0]
|
||||||
@ -2118,7 +2117,7 @@ class TestCryptoconditions(object):
|
|||||||
escrow_tx_abort = b.create_transaction([user_vk, user2_vk], user_vk, tx_retrieved_id, 'TRANSFER')
|
escrow_tx_abort = b.create_transaction([user_vk, user2_vk], user_vk, tx_retrieved_id, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
escrow_fulfillment = cc.Fulfillment.from_json(
|
escrow_fulfillment = cc.Fulfillment.from_dict(
|
||||||
escrow_tx['transaction']['conditions'][0]['condition']['details'])
|
escrow_tx['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment_user = escrow_fulfillment.get_subcondition_from_vk(user_vk)[0]
|
subfulfillment_user = escrow_fulfillment.get_subcondition_from_vk(user_vk)[0]
|
||||||
@ -2180,7 +2179,7 @@ class TestCryptoconditions(object):
|
|||||||
|
|
||||||
# Update the condition in the newly created transaction
|
# Update the condition in the newly created transaction
|
||||||
escrow_tx['transaction']['conditions'][0]['condition'] = {
|
escrow_tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(condition_escrow.serialize_json()),
|
'details': condition_escrow.to_dict(),
|
||||||
'uri': condition_escrow.condition.serialize_uri()
|
'uri': condition_escrow.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2206,7 +2205,7 @@ class TestCryptoconditions(object):
|
|||||||
escrow_tx_transfer = b.create_transaction([user_vk, user2_vk], user2_vk, tx_retrieved_id, 'TRANSFER')
|
escrow_tx_transfer = b.create_transaction([user_vk, user2_vk], user2_vk, tx_retrieved_id, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
escrow_fulfillment = cc.Fulfillment.from_json(
|
escrow_fulfillment = cc.Fulfillment.from_dict(
|
||||||
escrow_tx['transaction']['conditions'][0]['condition']['details'])
|
escrow_tx['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment_user = escrow_fulfillment.get_subcondition_from_vk(user_vk)[0]
|
subfulfillment_user = escrow_fulfillment.get_subcondition_from_vk(user_vk)[0]
|
||||||
@ -2253,7 +2252,7 @@ class TestCryptoconditions(object):
|
|||||||
escrow_tx_abort = b.create_transaction([user_vk, user2_vk], user_vk, tx_retrieved_id, 'TRANSFER')
|
escrow_tx_abort = b.create_transaction([user_vk, user2_vk], user_vk, tx_retrieved_id, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
escrow_fulfillment = cc.Fulfillment.from_json(
|
escrow_fulfillment = cc.Fulfillment.from_dict(
|
||||||
escrow_tx['transaction']['conditions'][0]['condition']['details'])
|
escrow_tx['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment_user = escrow_fulfillment.get_subcondition_from_vk(user_vk)[0]
|
subfulfillment_user = escrow_fulfillment.get_subcondition_from_vk(user_vk)[0]
|
||||||
|
@ -182,7 +182,7 @@ threshold_condition.add_subfulfillment(cc.Ed25519Fulfillment(public_key=threshol
|
|||||||
|
|
||||||
# update the condition in the newly created transaction
|
# update the condition in the newly created transaction
|
||||||
threshold_tx['transaction']['conditions'][0]['condition'] = {
|
threshold_tx['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(threshold_condition.serialize_json()),
|
'details': threshold_condition.to_dict(),
|
||||||
'uri': threshold_condition.condition.serialize_uri()
|
'uri': threshold_condition.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ threshold_tx_transfer = b.create_transaction([thresholduser1_pub, thresholduser2
|
|||||||
thresholduser4_pub, tx_retrieved_id, 'TRANSFER')
|
thresholduser4_pub, tx_retrieved_id, 'TRANSFER')
|
||||||
|
|
||||||
# parse the threshold cryptocondition
|
# parse the threshold cryptocondition
|
||||||
threshold_fulfillment = cc.Fulfillment.from_json(threshold_tx['transaction']['conditions'][0]['condition']['details'])
|
threshold_fulfillment = cc.Fulfillment.from_dict(threshold_tx['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment1 = threshold_fulfillment.get_subcondition_from_vk(thresholduser1_pub)[0]
|
subfulfillment1 = threshold_fulfillment.get_subcondition_from_vk(thresholduser1_pub)[0]
|
||||||
subfulfillment2 = threshold_fulfillment.get_subcondition_from_vk(thresholduser2_pub)[0]
|
subfulfillment2 = threshold_fulfillment.get_subcondition_from_vk(thresholduser2_pub)[0]
|
||||||
@ -323,7 +323,7 @@ condition_timeout = cc.TimeoutFulfillment(expire_time=time_expire)
|
|||||||
# The conditions list is empty, so we need to append a new condition
|
# The conditions list is empty, so we need to append a new condition
|
||||||
tx_timeout['transaction']['conditions'].append({
|
tx_timeout['transaction']['conditions'].append({
|
||||||
'condition': {
|
'condition': {
|
||||||
'details': json.loads(condition_timeout.serialize_json()),
|
'details': condition_timeout.to_dict(),
|
||||||
'uri': condition_timeout.condition.serialize_uri()
|
'uri': condition_timeout.condition.serialize_uri()
|
||||||
},
|
},
|
||||||
'cid': 0,
|
'cid': 0,
|
||||||
@ -347,7 +347,7 @@ tx_timeout_id = {'txid': tx_timeout['id'], 'cid': 0}
|
|||||||
tx_timeout_transfer = b.create_transaction(None, testuser1_pub, tx_timeout_id, 'TRANSFER')
|
tx_timeout_transfer = b.create_transaction(None, testuser1_pub, tx_timeout_id, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
timeout_fulfillment = cc.Fulfillment.from_json(
|
timeout_fulfillment = cc.Fulfillment.from_dict(
|
||||||
tx_timeout['transaction']['conditions'][0]['condition']['details'])
|
tx_timeout['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
tx_timeout_transfer['transaction']['fulfillments'][0]['fulfillment'] = timeout_fulfillment.serialize_uri()
|
tx_timeout_transfer['transaction']['fulfillments'][0]['fulfillment'] = timeout_fulfillment.serialize_uri()
|
||||||
@ -392,7 +392,7 @@ condition_escrow.add_subfulfillment(condition_abort)
|
|||||||
|
|
||||||
# Update the condition in the newly created transaction
|
# Update the condition in the newly created transaction
|
||||||
tx_escrow['transaction']['conditions'][0]['condition'] = {
|
tx_escrow['transaction']['conditions'][0]['condition'] = {
|
||||||
'details': json.loads(condition_escrow.serialize_json()),
|
'details': condition_escrow.to_dict(),
|
||||||
'uri': condition_escrow.condition.serialize_uri()
|
'uri': condition_escrow.condition.serialize_uri()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ tx_escrow_id = {'txid': tx_escrow_signed['id'], 'cid': 0}
|
|||||||
tx_escrow_execute = b.create_transaction([testuser2_pub, testuser1_pub], testuser1_pub, tx_escrow_id, 'TRANSFER')
|
tx_escrow_execute = b.create_transaction([testuser2_pub, testuser1_pub], testuser1_pub, tx_escrow_id, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
escrow_fulfillment = cc.Fulfillment.from_json(
|
escrow_fulfillment = cc.Fulfillment.from_dict(
|
||||||
tx_escrow['transaction']['conditions'][0]['condition']['details'])
|
tx_escrow['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment_testuser1 = escrow_fulfillment.get_subcondition_from_vk(testuser1_pub)[0]
|
subfulfillment_testuser1 = escrow_fulfillment.get_subcondition_from_vk(testuser1_pub)[0]
|
||||||
@ -453,7 +453,7 @@ tx_escrow_execute['transaction']['fulfillments'][0]['fulfillment'] = escrow_fulf
|
|||||||
tx_escrow_abort = b.create_transaction([testuser2_pub, testuser1_pub], testuser2_pub, tx_escrow_id, 'TRANSFER')
|
tx_escrow_abort = b.create_transaction([testuser2_pub, testuser1_pub], testuser2_pub, tx_escrow_id, 'TRANSFER')
|
||||||
|
|
||||||
# Parse the threshold cryptocondition
|
# Parse the threshold cryptocondition
|
||||||
escrow_fulfillment = cc.Fulfillment.from_json(
|
escrow_fulfillment = cc.Fulfillment.from_dict(
|
||||||
tx_escrow['transaction']['conditions'][0]['condition']['details'])
|
tx_escrow['transaction']['conditions'][0]['condition']['details'])
|
||||||
|
|
||||||
subfulfillment_testuser1 = escrow_fulfillment.get_subcondition_from_vk(testuser1_pub)[0]
|
subfulfillment_testuser1 = escrow_fulfillment.get_subcondition_from_vk(testuser1_pub)[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user