-
Notifications
You must be signed in to change notification settings - Fork 115
feat(taproot): support withdrawing to taproot addresses #2625
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
Changes from 1 commit
909ad1d
13f9734
8f919d3
ea64c54
31a22e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -61,6 +61,18 @@ impl Builder { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /// Builds p2tr script pubkey | ||||||||||||||||||||||||
| pub fn build_p2tr(address_hash: &AddressHashEnum) -> Result<Script, Error> { | ||||||||||||||||||||||||
| match address_hash { | ||||||||||||||||||||||||
| // TODO: Don't use AddressHashEnum::WitnessScriptHash variant. | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's worth to add the reason here.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry i should have converted this to draft earlier. i only pushed this PR early to support withdrawal thinking it was gonna be merged quickly. but since it doesnt share a linear history with the full taproot support PR, we better just ignore this one and merge the full support one. this PR will be auto closed with the merger of the full support one. |
||||||||||||||||||||||||
| AddressHashEnum::WitnessScriptHash(x_only_pubkey) => Ok(Builder::default() | ||||||||||||||||||||||||
| .push_opcode(Opcode::OP_1) | ||||||||||||||||||||||||
| .push_data(x_only_pubkey.as_ref()) | ||||||||||||||||||||||||
| .into_script()), | ||||||||||||||||||||||||
| AddressHashEnum::AddressHash(_) => Err(Error::WitnessHashMismatched), | ||||||||||||||||||||||||
|
Comment on lines
+67
to
+72
|
||||||||||||||||||||||||
| // TODO: Don't use AddressHashEnum::WitnessScriptHash variant. | |
| AddressHashEnum::WitnessScriptHash(x_only_pubkey) => Ok(Builder::default() | |
| .push_opcode(Opcode::OP_1) | |
| .push_data(x_only_pubkey.as_ref()) | |
| .into_script()), | |
| AddressHashEnum::AddressHash(_) => Err(Error::WitnessHashMismatched), | |
| AddressHashEnum::XOnlyPubkey(x_only_pubkey) => Ok(Builder::default() | |
| .push_opcode(Opcode::OP_1) | |
| .push_data(x_only_pubkey.as_ref()) | |
| .into_script()), | |
| _ => Err(Error::WitnessHashMismatched), |
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.
@shamardy here i didn't add a new variant as i still didn't fix this yet in my working branch.
this works fine though for now.
when i push the other complete PR, this will be fixed (either by adding another variant or renaming/generalizing the witnesscript hash variant).
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 would also suggest renaming AddressHashEnum as it's not quite accurate and now there is even more to it as it now contains not only hashes.
Naming to consider (from chatgpt): scriptPubKey payload or locking script data.
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 think this code is very dangerous to maintain. Any mistake on the order would easily cause a bug which would be pretty annoying to figure/find out.