Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting permission_id in trx.sign for multisig #47

Open
ColonelJ opened this issue Aug 11, 2019 · 1 comment
Open

Support setting permission_id in trx.sign for multisig #47

ColonelJ opened this issue Aug 11, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@ColonelJ
Copy link

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.

@serderovsh serderovsh added the enhancement New feature or request label Aug 16, 2019
@serderovsh
Copy link
Contributor

Will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants