-
Notifications
You must be signed in to change notification settings - Fork 2
fix and make scripts smaller #1
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
fix and make scripts smaller #1
Conversation
06328cb to
43f45e8
Compare
577ab05 to
fe5a289
Compare
fe5a289 to
c696608
Compare
+ script layout and readability
c696608 to
dba17e7
Compare
I wrote a simple program to confirm this: https://go.dev/play/p/ZOo7zkr0Dew. The output is: As expected, things fail due to the clean stack consensus rule. It makes things a bit harder to understand at a glance, but I guess saving that extra byte is worth 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.
Solid PR, thanks for all the heavy lifting!
I wrote a small program to confirm the new (sorta hacky/clever) sequence usage and things check out. I think we might still want to run things thru mini script to further optimize (tho maybe that's what you did in the first place?).
| The final witness to spend a script path output is: | ||
| ``` | ||
| control_block || leaf_script || witness | ||
| <witness1> ... <witnessN> <leaf_script> <control_block> |
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 guess we visualize the stack differently ;)
| <local_delayedpubkey> | ||
| OP_CHECKSIGVERIFY | ||
| <local_delayedpubkey> OP_CHECKSIG | ||
| <to_self_delay> OP_CHECKSEQUENCEVERIFY OP_DROP |
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.
👍
| * where: | ||
| * `taproot_nums_point = 0245b18183a06ee58228f07d9716f0f121cd194e4d924b037522503a7160432f15` | ||
| * `to_remote_output_key = taproot_nums_point + tagged_hash("TapTweak", taproot_nums_point|| to_remote_script_root` | ||
| * `to_remote_output_key = taproot_nums_point + tagged_hash("TapTweak", taproot_nums_point || to_remote_script_root)` |
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.
FWIW, the NUMs point here will soon be removed (will just be the multi-sig script).
| ``` | ||
| <remotepubkey> OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY | ||
| <remotepubkey> OP_CHECKSIG | ||
| OP_CHECKSEQUENCEVERIFY |
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.
Clever...but will need to double check the semantics here to ensure this doesn't become an any-one-can-spend...
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.
Confirmed that it all checks out: #1 (comment)
| (output_key_y_parity | 0xc0) || anchor_internal_key | ||
| ``` | ||
| `nSequence` needs to be set to 16. |
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.
Nice addition 👍
| <local_htlcpubkey> OP_CHECKSIGADD <remote_htlcpubkey> OP_CHECKSIGADD 2 OP_EQUALVERIFY | ||
| 1 OP_CHECKSEQUENCEVERIFY | ||
| <local_htlcpubkey> OP_CHECKSIGVERIFY | ||
| <remote_htlcpubkey> OP_CHECKSIG |
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 isn't correct, the sequence is still need here as we want to make sure all spends need to wait a block.
| <remote_htlcpubkey> OP_CHECKSIG | ||
| ``` | ||
| Note that there is no `OP_CHECKSEQUENCEVERIFY` in the offered HTLC's timeout path |
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.
Thanks for this note, makes sense, and isn't too big of a departure w.r.t how things work today.
no problem :)
havent used miniscript |
lightning#995
fixed some tapscripts, made some smaller and fixed witness stack order (bip 341)