-
Notifications
You must be signed in to change notification settings - Fork 943
splice: Script for complex splices #6980
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
splice: Script for complex splices #6980
Conversation
5952c41
to
2640bd6
Compare
2640bd6
to
4e7edec
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.
Mh What do you mean by "Scripts"? and why now we need a "compiler" for splicing? 😕
I feel that I am missing somethings?
Proper documentation is coming but here's a quick summary: The script isn't required to be used -- there will also be a json option and, of course, the lower level api is available. When doing splices across multiple channels it quickly becomes unwieldy for users. Using the script is a nice shorthand to make it easier -- and also allows you to do "dry runs" and confirm it's doing what you'd like. Say you wanted to take 50% of funds and splice them into three other channels, in splice script it's quite simple:
While working on it, it made sense to add a bunch of other useful things like being able to specify amounts as whole numbers, percentages, or * (split amount among all *s); channel queries; onchain bitcoin addresses; and the onchain wallet. By building this more powerful part first it becomes trivial to implement the simpler splice commands. For instance: Splice out 10 million sats
Splice in 10 million sats
Cross splice 10 million sats
Pay 10M sats onchain using channel funds
|
731048c
to
ab31aa7
Compare
ab31aa7
to
e0b188a
Compare
8105050
to
737ffc2
Compare
444456e
to
f6b0b51
Compare
I changed the command to "dev-splice," updated the added tag to 24.11, and fixed a handful of issues that came up from rebasing. Can we push this one through once it passes CI @rustyrussell? |
Ack! Will apply once CI is happy! |
912211f
to
42a1029
Compare
Accidentally told GH to update to latest master and it did a merge. Gah! Rebased instead. |
Changelog-None
New compiler for splice scripts that parses splice scripts, validates them, converts them to json and back again. Changelog-Added: Splice script parser — takes a custom splice query language to bundle multiple complex splices into a single task in a simple way.
A test that puts some advanced and complex scripts into the parser and validates the results that come out.
A routine for getting a signature back out of an input’s list of pending signatures via pubkey search. This is needed for certain kinds of restarts as we lose our peer’s signature from memory but a copy is kept in the PSBT.
Changelog-None
Stores an array of channel_ids into the PSBT globals area. Changelog-None
`splice_signed` now searchs the PSBT for channel ids Changelog-Changed: `splice_signed` parameters are switched in order to make `channel_id` an optional parameter, enabling multi-splice-signatures.
This is needed to all multi-channel splices. When channeld can return the signatures to the user (based on signing order precedent), it now does from splice_update. Additionally, we move sending of the initial psbt from splice_init down to splice_update. This is also necessary for correct psbt diff detection during multi-channel splices. Changelog-Changed: splice_update can in some cases now return the remotely partiall signed psbt to the user, if so `signtures_secured` will be true.
On certain well timed restarts we lose their siganture from memory and don’t receive it from them. In these cases we can extract it from the PSBT directly.
The ability to stfu channels in bulk is required to do complex multi channel operations. When stfu’ing in this manner, the available funds at the moment of stfu is returned to the user. In order to cancel the stfu we also add a bulk tx_abort command. Changelog-Added: `stfu_channels` and `abort_channels` are added for bulk multi-channel splice commands. These allow the user to pause (and resume) multiple channels in place.
This is the sister command of addpsbtoutput. Adds inputs equal to or greater than the amount requests, reservers them, and reports important information back out to the user. Changelog-Added: New low-level RPC command addpsbtinput to fund PSBTs directly and help with complex splices & dual-opens.
When set this flag tells addpsbtoutput to add the intiator serial_id to the added output. Changelog-Changed: addpsbtoutput now allows serial_id to be set while adding which is needed for splicing and dual.
The command called “splice” can take a json payload or a ‘splice script’, process it into a list of ‘actions’ and then execute those actions. These actions include or will include everything you would want to do with a splice: * Splice into a channel * Splice out of a channel * Fund from wallet * Deposit to wallet * Send funds to bitcoin address Changelog-Added: A new magic “splice” command is added that can take a ‘splice script’ or json payload and perform any complex splice across multiple channels merging the result into a single transaction. Some features are disabled and will be added in time.
Adding schema and documentatino for how to use the scripting portion of the “splice” RPC command.
The fee maximum is used to issue a warning to the user their feerate is high in case they accidentally make a large donation to miners. During python testing the feerates are high on purpose so we raise the warning level to at least the penality feerate.
Tests that splice-in and splice-out work through the scripting process and confirm the resulting balances are correct.
If the user does not supply enough funds treat it as an abort instead of a channel warning. Also clean up some indentation while we’re there.
42a1029
to
fd25a60
Compare
Now a proper rebase, taking into account jsonrpc request API changes. Also minor fixes since it didn't bisect build before. |
PR reviewers: It might be good to start here to learn the splice script syntax: https://github.com/ddustin/lightning/blob/ddustin/splice_script/doc/lightning-splice.7.md
New compiler for splice scripts that parses splice scripts, validates them, converts them to json and back again.
A test is included that puts some advanced and complex scripts into the parser and validates the results that come out.
Changelog-Added: Splice script parser — takes a custom splice query language to bundle multiple complex splices into a single task in a simple way.