def test_06_transaction_with_witness(self): print("\n-----", sys._getframe().f_code.co_name, "-----") witness = BBcWitness() global transaction1 transaction1 = BBcTransaction() transaction1.add(witness=witness) witness.add_witness(user_id) witness.add_witness(user_id2) sig = transaction1.sign(private_key=keypair2.private_key, public_key=keypair2.public_key) if sig is None: print(bbclib.error_text) assert sig witness.add_signature(user_id=user_id2, signature=sig) sig = transaction1.sign(private_key=keypair1.private_key, public_key=keypair1.public_key) if sig is None: print(bbclib.error_text) assert sig witness.add_signature(user_id=user_id, signature=sig) print(transaction1)
def test_03_transaction_1(self): print("\n-----", sys._getframe().f_code.co_name, "-----") global transaction1 transaction1 = BBcTransaction(format_type=fmt) transaction1.add(event=[event1, event2]) dummy_cross_ref1 = BBcCrossRef(domain_id=domain_id, transaction_id=transaction1_id, format_type=fmt) transaction1.add(cross_ref=dummy_cross_ref1) dummy_cross_ref2 = BBcCrossRef(domain_id=domain_id, transaction_id=transaction2_id, format_type=fmt) transaction1.add(cross_ref=dummy_cross_ref2) witness = BBcWitness(format_type=fmt) transaction1.add(witness=witness) sig = transaction1.sign(private_key=keypair1.private_key, public_key=keypair1.public_key) if sig is None: print(bbclib.error_text) assert sig transaction1.add_signature(signature=sig) # --- for checking serialization function --- digest = transaction1.digest() dat = transaction1.serialize() print("Digest:", binascii.b2a_hex(digest)) print("Serialized data:", binascii.b2a_hex(dat)) transaction_tmp = BBcTransaction() transaction_tmp.deserialize(dat) transaction1 = transaction_tmp #transaction1.events[1].asset.add(asset_file=asset_content) print("transaction_id:", binascii.b2a_hex(transaction1.transaction_id)) print("transaction_id (recalc2):", binascii.b2a_hex(transaction1.digest())) asset_tmp = transaction1.events[0].asset print("asset_id1:", binascii.b2a_hex(asset_tmp.asset_id)) asset_tmp = transaction1.events[1].asset print("asset_id2:", binascii.b2a_hex(asset_tmp.asset_id)) print(" --> asset_file_size:", asset_tmp.asset_file_size) print(" --> asset_file_digest:", binascii.b2a_hex(asset_tmp.asset_file_digest)) ret = asset_tmp.recover_asset_file(asset_content) assert ret print(" --> asset_file (after recover):", asset_tmp.asset_file)