From c6c93553ebaaf6529cf30d5ee8310bee5f6bd8ab Mon Sep 17 00:00:00 2001 From: CsterKuroi <412681778@qq.com> Date: Tue, 20 Dec 2016 17:45:57 +0800 Subject: [PATCH] Validate Signature --- create_and_validate_tx.py | 10 ++++++++++ tx.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 create_and_validate_tx.py diff --git a/create_and_validate_tx.py b/create_and_validate_tx.py new file mode 100644 index 0000000..1f1ed6c --- /dev/null +++ b/create_and_validate_tx.py @@ -0,0 +1,10 @@ +import tx +from bigchaindb.models import Transaction + +ctx=tx.create() +print(ctx) +tx_obj = Transaction.from_dict(ctx) +input_conditions = [] +input_conditions.append(tx_obj.conditions[0]) +print(tx_obj.fulfillments_valid(input_conditions)) + diff --git a/tx.py b/tx.py index 086ffb3..ff91cf2 100644 --- a/tx.py +++ b/tx.py @@ -1,5 +1,6 @@ from bigchaindb_driver import BigchainDB from bigchaindb_driver.crypto import generate_keypair +from bigchaindb.models import Transaction def create(): bdb = BigchainDB('http://localhost:9984/api/v1') @@ -26,6 +27,13 @@ def create(): # print(txid) return(fulfilled_creation_tx) -if __name__=="__main__": - create() +def validate(ctx): + tx_obj = Transaction.from_dict(ctx) + input_conditions = [] + input_conditions.append(tx_obj.conditions[0]) +# print(tx_obj.fulfillments_valid(input_conditions)) + return(tx_obj.fulfillments_valid(input_conditions)) +if __name__=="__main__": + validate(create()) +