LIGHTNING-DEV-SPLICE(7)

πŸ“¦
version 26.06.9 Β· 2 versions
, in nixpkgs unstable

okay bestie, welcome to the LIGHTNING-DEV-SPLICE(7) page πŸ’… this one is lowkey iconic and highkey about making splices do exactly what you want, so let’s get into it. 🫢

🌸 NAME 🌸

dev-splice β€” Command to initiate a channel to a peer ✨

✨ SYNOPSIS ✨

dev-splice script_or_json [dryrun] [force_feerate] [debug_log] [dev-wetrun]

πŸ’– DESCRIPTION πŸ’–

okay so this command was added in v24.11 β€” noted. πŸ‘‘

splice is the command that moves funds into or out of a channel. Multiple actions can be combined together into one single onchain transaction. Funds may be moved out of a channel and into another in a single batch, which enables cross-channel movement. slay. πŸ’…

  • script_or_json (string) β€” the splice script you want to execute, or the json equivalent. πŸŽ€
  • dryrun (boolean, optional) β€” don’t execute any actions; just output a transcript of what would have been done. πŸ‘€
  • force_feerate (boolean, optional) β€” by default splices fail if the fee provided looks too high, because the command is protecting you from accidentally setting your fee higher than intended. Set force_feerate to true to skip this safety check. ⚠️
  • debug_log (boolean, optional) β€” adds a verbose log of each splice calculation step to the result. πŸ”
  • dev-wetrun (boolean, optional) β€” executes the splice up until the point signatures would be sent, then aborts. πŸ’€

πŸŽ€ RETURN VALUE πŸŽ€

on success, an object is returned, containing:

  • dryrun (array of strings, optional) β€” the transcript of what the script would have done:
    • (string, optional) β€” one action line of the splice script result. ✨
  • psbt (string, optional) β€” the final psbt. πŸ¦‹
  • tx (string, optional) β€” the final transaction in hex. πŸ”₯
  • txid (string, optional) β€” the txid of the final transaction. 🌟
  • log (array of strings, optional) β€” a verbose log of each step of the splice calculations:
    • (string, optional) β€” a line of detail about the splice calculations. πŸ“

πŸ‘‘ AUTHOR πŸ‘‘

Dusty @dusty_daemon is mainly responsible. periodt. πŸ’œ

🌈 SEE ALSO 🌈

lightning-splice_signed(7), lightning-splice_update(7)

⭐ RESOURCES ⭐

Main web site: https://github.com/ElementsProject/lightning

🧚 USAGE 🧚

the primary method is to make a script containing one or more splice actions that get merged into a single transaction. If possible, the entire operation will be completed and broadcast to the mempool. no cap. 🌈

but if you specify your own inputs using psbt, then the command returns a psbt that you must sign and then pass to splice_signed. okay bestie? 🫢

It is required to pass script_or_json.

It is recommended that you first do a dryrun to confirm your script does what you expect it to do. yes, vibe check your splice first. πŸ’…

  • script β€” the splice script to execute.
  • dryrun β€” don’t execute any actions and output a transcript of what would have been done.
  • psbt β€” an initial psbt to begin the splice with.
  • user_provided_sats β€” the amount of sats being contributed by the initial psbt.
  • force_feerate β€” by default splices fail if the fee provided looks too high. This is to protect against accidentally setting your fee higher than intended. Set it to true to skip this safety check.
  • json β€” a json payload of instructions can be passed instead of script.
  • debug_log β€” adds a verbose log of each splice calculation step to the result.
  • dev-wetrun β€” executes the splice up until the point signatures would be sent, then aborts.

the primary purpose of splice script is to execute all types of splices using a single command. You can perform all these actions manually using the lower level api (see splice_init), but this splice command interface is much simpler to use and it provides some security against signing maliciously inserted inputs. πŸ’œ

πŸŽ€ SCRIPT πŸŽ€

okay bestie, a splice script is literally just a series of segments separated by newlines or semicolons ✨ Each segment = one splice action, usually adding to or removing from a channel. The funds go into or out of the channel depending on which side of the arrow -> the channel identifier is on. The amount goes on the other side. Iconic.

Like this:

8338aef0 -> 10000sat

That's how we take 10,000 sats out of channel 8338aef0 πŸ’…

To put 10,000 sats into the channel, we point the arrow into the channel:

10000sat -> 8338aef0

In those last two examples we used the first 8 digits of the channel identifier. You can specify as few as 4 digits of the beginning of the channel identifier and it will be autocompleted to the matching channel. But if the code matches more than one channel or node id, the script will fail with an error 😭

vibe check: short prefixes are cute until they're ambiguous. then it's a whole error moment.

To put funds into a channel, we need to get the funds from somewhere. The simplest place is the built-in onchain wallet. The wallet operator can be placed just like channel identifiers 🫢

Take funds out of the wallet:

wallet -> 10000sat

Put funds back into the wallet:

10000sat -> wallet

Now combine them into one script:

wallet -> 10000sat
10000sat -> 8338aef0

The first line withdraws 10,000 sats from the wallet and puts them in the script's β€œgeneral script funds.” The second line takes 10,000 sats from the β€œgeneral script funds” and places them into channel 8338aef0. This example is called a β€œsplice in.” slay.

But bestie, onchain fees have to be funded from somewhere too. The simplest way is to pay the fee from the β€œgeneral script funds.” If we change the amount going into the channel to a percentage, the fee gets taken automatically from the β€œgeneral script funds” like so:

wallet -> 10000sat
100% -> 8338aef0

When you specify a percentage instead of an amount, it means take that percentage out of the β€œgeneral script fund.”

This will take 10,000 sats from the onchain wallet and put that amount less any onchain fees into channel 8338aef0. The feerate used will be the node's standard opening feerate. To use your own feerate you must use the fee operator πŸ’Έ

The fee operator is attached to an amount. If you want to take out extra to cover the fee, use +fee; if you want to reduce the amount being sent somewhere, use the -fee suffix. Example:

wallet -> 10000sat+fee
10000sat -> 8338aef0

Here we add precisely 10,000 sats to channel 8338aef0 and withdraw enough from the wallet to cover the 10,000 sats and the onchain fee. periodt.

To control the amount of fee, you can specify a fee-rate with the at @ symbol after fee. After the at symbol, specify a number of sats to pay per kiloweight (aka. perkw) like so:

wallet -> 10000sat+fee@300
10000sat -> 8338aef0

This example pays a fee rate of 300 sats per thousand weight units. To view this amount in other units (ie. sats/vbyte) execute a dryrun of the script πŸ‘€

Instead of withdrawing extra from the wallet, we can reduce the amount going to channel 8338aef0 using the -fee operator like so:

wallet -> 10000sat
10000sat-fee -> 8338aef0

This example withdraws 10,000 sats from the onchain wallet, pays the onchain fee from that amount, and puts the rest into channel 8338aef0.

You can also specify the feerate here like so:

wallet -> 10000sat
10000sat-fee@300 -> 8338aef0

Now let's build a script that takes funds out of a channel and puts them into the onchain wallet:

8338aef0 -> 10000sat
100% -> wallet

But by default, scripts that leave sats in the β€œgeneral script fund” will be automatically sent to the wallet. So the second line isn't needed β€” we can simplify the script to:

8338aef0 -> 10000sat

We can also move sats to a specific bitcoin address like so:

8338aef0 -> 10000sat+fee
100% -> 1JfbZRwdDHKZmuiZgYArJZhcuuzuw2HuMu

This example pays 10,000 sats to the address 1JfbZRwdDHKZmuiZgYArJZhcuuzuw2HuMu out of your channel balance in 8338aef0 πŸŽ€

Percentages on the right side take out that amount of available funds from a channel. For example:

8338aef0 -> 100%

This takes all available funds out of channel 8338aef0 and puts them into the onchain wallet. Note that available funds is restricted by pending HTLCs and the 1% reserve requirement. To get all the funds you need to close the channel 😭

More useful would be something like this:

8338aef0 -> 50%
100% -> 07bfddea

This example takes half the available funds from channel 8338aef0 and puts them into channel 07bfddea.

We can also split this amount like so:

8338aef0 -> 50%
50% -> 07bfddea
50% -> 09ad6278

This example takes half the funds in 8338aef0 and splits them between channels 07bfddea and 09ad6278 πŸ¦‹

If we want to send funds to more channels, calculating percentages can get unwieldy, so we can use the asterisk operator * which divides the β€œgeneral script funds” amongst all destinations using it, like so:

8338aef0 -> 50%
* -> 07bfddea
* -> 09ad6278
* -> efc2a7ff

This example takes half the available funds in 8338aef0 and splits them evenly among three achannels πŸ’€

Sats can be specified with multiple suffixes including sat, msat, btc, M, or K. The M suffix is shorthand for a million satoshis and the K suffix is shorthand for a thousand satoshis. These can be combined with a decimal point like so:

07bfddea -> 1.23M
09ad6278 -> 900K
efc2a7ff -> 0.01btc

This example takes 1,230,000 sats from 07bfddea, 900,000 sats from 09ad6278, and 1,000,000 sats from efc2a7ff and puts them in the onchain wallet. math ate πŸ’…

Another way to specify channel ids is a channel query. These take the form of a node id, a colon, and a number or symbol (ie. "034645dc:0") which results in your first channel with the peer whose node id starts with 034645dc. Change the number after the colon to get a different index like so:

034645dc:0 -> 10K
034645dc:1 -> 10K
034645dc:2 -> 10K

This example takes 10,000 sats out of the first three channels with peer 034645dc and puts the total minus fees into the onchain wallet.

In addition to index numbers, the symbol after the colon can be a question mark ? or an asterisk * which mean match the first unused channel or all the remaining channels respectively like so:

* -> 034645dc:?
* -> 03e3d03e:0
03e3d03e:* -> 100%

This example takes 100% of available funds from all of 03e3d03e's channels except the first one and splits them between 03e3d03e's first channel and 034645dc's first channel ✨

The node id prefix can also be replaced with the asterisk * which means match all nodes. This can be combined with the asterisk * that matches all unused channels like so:

wallet -> 10000sat
100% -> *:*

This example takes 10,000 sats from the onchain wallet and divides them between all channels πŸ‘‘

It is possible to request a peer to add funds to a channel with a lease request. This is done using the pipe | symbol and optionally specifying the maximum fee you authorize using the at @ symbol. After the pipe you specify the amount of sats you would like to lease, followed by the at symbol and a percentage value like so:

wallet -> 10M+fee
100%|10M@1% -> 8338aef0

This example splices 10,000,000 sats into channel and requests your peer also add 10,000,000 sats to the channel. If the fee they demand is over 1% or the lease amount is too small the operation will be aborted. Whatever lease fee they do charge will come out of the 10,000,000 sats going into the channel balance. The onchain fee will be paid by taking extra funds out of the onchain wallet.

lease request = peer funds join the party, but there are limits bestie. fee too high or lease too small = abort.

Lease requests do not need to be combined with splicing in funds but you must pay the onchain fee from somewhere. One simple location to take the fees from is your existing channel balance. Doing so requires using two arrows since funds are going into and out of the channel at the same time, like so:

|10M@1% -> 8338aef0 -> 0+fee

This example makes a lease request from your peer on 8338aef0 for 10,000,000 sats and pays the onchain fee using the channel balance. This is a particularly elegant way to pay the onchain fee without adding any inputs or outputs beyond the channel funding itself 🧚

When passing via the command line, using semicolons can be simpler instead of newlines. Here are some command line examples:

Splice out 10 million satoshis to the onchain wallet

$ lightning-cli splice "8338aef0 -> 10M"

Splice in 10 thousand satoshis from the onchain wallet

$ lightning-cli splice "wallet -> 10K; 100% -> 8338aef0"

Send 900 thousand satoshis from a channel to an onchain address

$ lightning-cli splice "8338aef0 -> 0.9M+fee; 0.9M -> 1JfbZRwdDHKZmuiZgYArJZhcuuzuw2HuMu"

Move 1 bitcoin between two channels

$ lightning-cli splice "8338aef0 -> 1btc; 100% -> 07bfddea"

Splice in 100 thousand sats to the first channel with peer id 034645dc

$ lightning-cli splice "wallet -> 0.1M; 100% -> 034645dc:?"

Splice in 100 thousand sats split across all channels with peer id 034645dc

$ lightning-cli splice "wallet -> 100000; 100% -> 034645dc:*"

Take the maximum out of one chanel and split the value across peer 034645dc's channel plus one more channel

$ lightning-cli splice "8338aef0 -> 100%; * -> 034645dc:*; * -> 07bfddea"

and that's the whole script language, bestie β€” no cap, every arrow, fee, lease, wildcard, and command-line semicolon accounted for πŸ’–

Core Lightning v26.06.9 Β· LIGHTNING-DEV-SPLICE(7) Β· date says hi from the footer 🫢 mwah πŸ’‹

πŸ“¦ where this page comes from