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

stakingTransaction: Do not rely on the pub key being set to set the witness #9

Open
vitsalis opened this issue Aug 17, 2024 · 5 comments

Comments

@vitsalis
Copy link
Member

...(publicKeyNoCoord && { tapInternalKey: publicKeyNoCoord }),

Identifying whether we should set a witness based on whether the publicKeyNoCoord parameter has been set is counter-intuitive. We should clearly specify in the staking transaction on whether the witness should be set, or even better, always pass the public key and identify inside the library whether we should set the witness by looking at the input.

@jrwbabylonlab
Copy link
Collaborator

I believe this will be address as part of this #11
The issue we are facing in this lib is that it does not have control of the source inputs. a lot of the logic was handled in the simple-staking.
As part of the decoupling the simple-staking, all the logic around staking tx creation including the scripts creation should all live inside the ts lib

@jrwbabylonlab
Copy link
Collaborator

This should been resolved now by the #23 PR. If no objection, i will close the issue in a few days

@vitsalis
Copy link
Member Author

vitsalis commented Oct 2, 2024

Aren't we still doing the same here and here?

@jrwbabylonlab
Copy link
Collaborator

maybe i mis-understood the description of this issue.
In the newly merged PR, the noCoordPk will always be provided by the user, and this condition

isTaproot(this.stakerInfo.address, this.network) ? Buffer.from(this.stakerInfo.publicKeyNoCoordHex, "hex") : undefined

Will check if the address is in taproot type and passing it into the lower layer method stakingTransaction if it's taproot. The caller does not need to know anything about this relationship of "taproot/witness & noCoordPk".

@vitsalis
Copy link
Member Author

vitsalis commented Oct 3, 2024

It will always be passed if the user utilises the higher level method we added. However, here we still have the same condition: We decide whether we should populate a taproot related field based on whether a public key parameter has been passed -- this is counter-intuitive.

My recommendation would be to update the above part of the codebase and make the function accept two parameters: isTaprootAddress: bool and publicKeyNoCoord: Buffer. Both of them are always required to be set. The internal staking function makes a decision on whether to utilise tapInternalKey based on a clear scenario of whether isTaprootAddress == true.

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

No branches or pull requests

2 participants