You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding new (person) public key in transfer function recipient, Invalid transaction (InvalidSignature): Transaction signature is invalid.","status":400
#502
Open
imvvk11 opened this issue
Aug 23, 2019
· 0 comments
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])
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
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/')
The text was updated successfully, but these errors were encountered: