Description
- bigchaindb-driver version:2.0.0b9
- Python version: python3.6
- Operating System: ubuntu 16.04
Description
I am storing patients medical data using email_id, user details in assets and appending medical records in the metadata. The first time the "signer" will be a health practitioner like a dietitian public key say dietitian name is bob, the recipient will be patient key say the patient name is Alice. So both dietitian and patient get access to the data.
If I want to add a new health practitioner like diabetologist carol for patient name Alice which can be done by passing carol's public key in transfer function to the recipient parameter. But it is failing when I am appending metadata for patient alice.
What I Did
if asset_query == None:
transaction = self.bdb.transactions.prepare(operation='CREATE', signers=bob_public_key,recipients=(alice_public_key,), asset=self.user_data, metadata=self.data)
signed_tx = self.bdb.transactions.fulfill(transaction, private_keys=bob_private_key)
create_transaction = self.bdb.transactions.send_commit(signed_tx)
if (signed_tx == create_transaction):
print ("Transaction successfully created and stored")
else:
# get the id of the asset
tx_id = asset_query["id"]
# retrieve transaction for the asset
creation_tx = self.bdb.transactions.retrieve(tx_id)
#print (creation_tx)
# get trnsaction id for the trasaction of the asset
asset_id = creation_tx['id']
# append asset transaction id to the tx_ids list
tx_ids = [asset_id]
# get all transactions id for the asset
query = self.db.transactions.find({"asset.id":asset_id},{"id":1,"_id":0})
# append to the tx_ids list
for ids in query:
tx_ids.append(ids["id"])
transfer_asset = {'id': asset_id,}
output_index = 0
output = creation_tx['outputs'][output_index]
# transfer_input should contain the last transfer transaction id for the asset from the list
transfer_input = {
'fulfillment': output['condition']['details'],
'fulfills': {
'output_index': output_index,
'transaction_id': tx_ids[-1],
},
'owners_before': output['public_keys'],
}
prepared_transfer_tx = self.bdb.transactions.prepare(operation='TRANSFER', asset=transfer_asset, inputs=transfer_input, recipients=(alice_public_key, ), metadata=self.data)
fulfilled_transfer_tx = self.bdb.transactions.fulfill(prepared_transfer_tx, private_keys=[alice_private_key, bob_private_key])
#Now i have to add a new health practitioner like diabetologist "carol" for patient name "Alice" #which can be done by passing carol's public key in transfer function to the recipient parameter.
prepared_transfer_tx = self.bdb.transactions.prepare(operation='TRANSFER', asset=transfer_asset, inputs=transfer_input, recipients=(alice_public_key, carol_public_key), metadata=self.data)
fulfilled_transfer_tx = self.bdb.transactions.fulfill(prepared_transfer_tx, private_keys=[alice_private_key, bob_private_key])
I get below error:
error - (400, '{"message":"Invalid transaction (InvalidSignature): Transaction signature is invalid.","status":400}\n', {'message': 'Invalid transaction (InvalidSignature): Transaction signature is invalid.', 'status': 400}, 'http://localhost:9984/api/v1/transactions/')