-
Notifications
You must be signed in to change notification settings - Fork 667
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
Make Address::get_payload_bytes public #978
Make Address::get_payload_bytes public #978
Conversation
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 525ea00
Thanks for the contribution! Since
To increase my understanding I went looking for the change you mention but |
Agreed, that is cleaner. Updated.
My bad, I actually relied on a fork of this repo which had this function and I didn't notice that the function was only part of the fork and did not exist in this repo. So now that |
I'm not sure i this is a good idea. It seems to leak the internal representation of |
@@ -468,6 +468,15 @@ impl Payload { | |||
program: output_key.as_inner().serialize().to_vec(), | |||
} | |||
} | |||
|
|||
/// Returns a byte slice of the payload |
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.
The documentation should be more detailed. I don't think a newbie would be able to understand what it does without reading the code.
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.
This looks to be pulled verbatim from existing code that was added in #839
match self { | ||
Payload::ScriptHash(hash) => hash, | ||
Payload::PubkeyHash(hash) => hash, | ||
Payload::WitnessProgram { program, .. } => program, |
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.
Is this even correct? Witness version is normally part of the script and it changes the semantics of the program. Omitting it could lead to serious problems but we can't return it in a slice.
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.
This make sense to me as a convenience function. The version is typically handled separately being a u5. The witness program itself without the version is analogous to both the ScriptHash and PubkeyHash that are also returned here. In the case of verifying that a key was used to derive an address, this makes a lot of sense to me.
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.
I'm also a bit uncomfortable with this, but I can see both sides of the argument.
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.
Perhaps we should add more thorough docs to this method?
Sorry for my pre-mature ACK. Initially, this seemed like a one-word change without much harm. |
Sorry for not reading the issue clearly. if let Payload::ScriptHash(addr_hash) == addr {
if expected_script_hash == addr_hash {
}
} This should satisfy your use-case? |
Looks like I was the original author of There is some discussion in that PR around whether the methods should be public or private. I'm not an official maintainer, but I approve of the changes as they stand in 7ca30b6, definitely an improvement. I'm not sure that I understand the immediate concerns. I could definitely see how this is useful though. |
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 7ca30b6
I think this is fine to expose.
@apoelstra looks like you acked but forgot to approve. I'm not acking/nacking because I don't feel qualified to judge. Can we get an ack/nack from @sanket1729 and/or @Kixunil please? |
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 7ca30b6
Sorry, clicked the wrong button last time. I should really figure out how to do this from the commandline..
All the open ended comments are really improvements to the PR. The PR is still, IMO, in its current form an improvement to the code. Perhaps in the name of making the contributor experience better we can merge this one as is. We can improve the docs and stuff later on. |
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 7ca30b6
I figured it out for you, been meaning to do this myself too.
(While on the branch and commit that you want to ack.) |
And since it took me a few minutes to work it out, if you use zsh function ack-current-commit() {
read "ack?Really ACK this commit? "
if [[ "$ack" =~ ^[Yy]$ ]]
then
gh pr review -a -b "ACK $(git log -1 --pretty=oneline --reverse | cut -d ' ' -f 1)"
fi
} |
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 7ca30b6. Sorry for the delay and congratz on your first time contribution
@tcharding thanks! FYI you can use |
Oh yes, thanks. This is much better, TIL: |
…public 7ca30b6 Move Address::payload_as_bytes to Payload::as_bytes (Fredrik Meringdal) 525ea00 Make Address::get_payload_bytes public (Fredrik Meringdal) Pull request description: Hi, thanks for the amazing work on this crate. I am trying to upgrade from v0.27 to v0.28, but unable to do so because the `Address::get_payload_bytes` was made private. My use-case is that I have a script hash address and an `Address` and need to compare the two, and in order to do so I need access to the payload bytes of `Address`. I hope you will consider making this function public again 🙏 ACKs for top commit: apoelstra: ACK 7ca30b6 tcharding: ACK 7ca30b6 sanket1729: ACK 7ca30b6. Sorry for the delay and congratz on your first time contribution Tree-SHA512: 02af4565853d93506751ed7cb004f52cb5d8c7936067e06b3e237b448ccdf5716470448eeccbe211958e095b66bb37c7027800c0470c6988dc18d8bd5b48f459
Hi, thanks for the amazing work on this crate.
I am trying to upgrade from v0.27 to v0.28, but unable to do so because the
Address::get_payload_bytes
was made private. My use-case is that I have a script hash address and anAddress
and need to compare the two, and in order to do so I need access to the payload bytes ofAddress
.I hope you will consider making this function public again 🙏