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
Push key xonly #920
Push key xonly #920
Conversation
@mplsgrant the only current solution (before we refactor script types here) is to compose Taproot scripts using |
Having a second thought, I think there is no reasonably fast way forward with this issue: introduction of a proper script type system (which will be discussed here #921) will take many months (if not year+), and preventing library users from being able to construct tapscripts without the need to use miniscript is bad. On the other hand, adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 2ac73aa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concept ACK. Left a few comments
concept ACK but I'd also liek the method to be renamed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 03b1305
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for nit-picking. Can you please squash so that there are only 2 commits. One adding x_only_public_key. One adding test.
FWIW, you can call
This is what I am doing for rust-miniscript. But this is a cleaner solution. |
03b1305
to
10e3f06
Compare
@sanket1729 The squash ended up a little messier that I would have liked. Would you like me to revert the commits and create two fresh ones? |
Sure. As long as there are two clean commits, It doesn't matter how you did it :) |
10e3f06
to
e8c7c14
Compare
I believe we now have 2 clean commits. |
Thanks for the contribution @mplsgrant! This comment is just an FYI, no changes to the PR needed it LGTM. I'm explaining here for both of our benefits :) This PR should technically be single commit because the unit test tests new functionality added in the PR.
This is typically how we do bug fixes, the reason that the test is in a separate patch is so that reviewers can apply the test patch to master and verify that it really fails and therefore the fix really fixes something. |
Indeed, the initial PR had two commits. This is why I suggested two commits, but you are right. One commit is also good. I would like to have similar consistency for naming If we get it this before release, it's good. If not, it's not a biggie, as there is a simple work-around.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK e8c7c14. I would have preferred if you only tested the x_only_key
in the test instead of copying all the unnecessary code from the previous test.
If you plan to squash these into one commit as @tcharding suggested, I suggest also fixing so that we only test the required function and don't double-test things with a bunch of unnecessary code.
src/blockdata/script.rs
Outdated
@@ -919,6 +919,11 @@ impl Builder { | |||
} | |||
} | |||
|
|||
/// Adds instructions to push an XOnly public key onto the stack. | |||
pub fn push_x_only_key(self, key: &XOnlyPublicKey) -> Builder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to reviewers, the already existing function is called push_key
(not push_public_key
). Therefore, it makes sense to call this push_x_only_key
.
This was already existing in the previous test code. We should fix that together. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 8a042dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revoking my previous ACK. I think the test case should be improved (see the comment) to be less confusing.
You might need to squash again :( @mplsgrant |
936ab1a
to
83aaa0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 83aaa0f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs fix due to a failed CI
@mplsgrant and squash commits again - we must have each commit passing CI, this is the policy of the repo (https://github.com/rust-bitcoin/rust-bitcoin/blob/master/CONTRIBUTING.md#preparing-prs says "each commit within a PR must compile and pass unit tests with no errors") |
@mplsgrant and the fix is invalid: when I suggest code changes I give a hint, but I have no way of running my code. Please try to compile it locally and make it working. |
12bddbe
to
96b3f9d
Compare
Thanks for code hint @dr-orlovsky. |
96b3f9d
to
6e6e22c
Compare
6e6e22c
to
f27c4a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK f27c4a5
Thank you very much for going through all these iterations
You're welcome! Thank you for all the feedback and guidance. I appreciate it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK f27c4a5. Thanks a lot for keeping up the iterations with prompt responses
You're welcome. I appreciate what you folks are doing here. |
Issue
I can not use
XOnlyPublicKey
in my Scripts which prevents me from working with Taproot.Cause
The current version of
script::Builder
does not acceptXOnlyPublicKey
s.Solution
So, I created a function
push_xkey(self, key: &XOnlyPublicKey)
based on the existingpush_key
function. I also augmented an existing test in an attempt to reach testing parity with existing code.After toying around with
push_xkey
, it seems to work on my end.