Support setting permission_id in trx.sign for multisig
ColonelJ opened this issue · 1 comments
When trying to do multi-signature using an 'active' permission you need to be able to set the Permission_id in the transaction's contract e.g.
create_tx["raw_data"]["contract"][0]["Permission_id"] = 2
However, the problem here is that the transaction's raw data, and therefore the txID will need to be changed as a result of updating the transaction.
TronWeb handles this situation by taking a permissionId argument to its trx.multisign function, which if >0 where the transaction's contract doesn't have a Permission_id already, causes TronWeb to add the Permission_id to the contract before POSTing the transaction to wallet/getsignweight which then returns an updated transaction (in transaction.transaction) containing a corrected txID, which can then be signed.
This is how the code might look using tronapi to do the signing after this issue is fixed (in this case the wallet/getsignweight is only done on the first call to trx.sign):
create_tx = tron.transaction_builder.send_transaction('to', 1, 'from')
tron.private_key = 'first private_key'
signed1_tx = tron.trx.sign(create_tx, multisig=true, permission_id=2)
tron.private_key = 'second private_key'
signed2_tx = tron.trx.sign(signed1_tx, multisig=true, permission_id=2)
response = tron.trx.broadcast(signed2_tx)
Something like this should be added to your examples scripts to show how multisign should be used.
Will do