<oembed><type>rich</type><version>1.0</version><author_name>npub1g5zswf6y48f7fy90jf3tlcuwdmjn8znhzaa4vkmtxaeskca8hpss23ms3l</author_name><author_url>https://nostr.ae/npub1g5zswf6y48f7fy90jf3tlcuwdmjn8znhzaa4vkmtxaeskca8hpss23ms3l</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2018-10-11&#xA;📝 Original message:&#xA;Good morning Rusty,&#xA;&#xA;In BOLT #2 we currently impose a 2^24 satoshi limit on total channel capacity.  Is splicing intended to allow violation of this limit? I do not see it mentioned in the proposal. Can I splice 21 million bitcoins on a 1-satoshi channel?&#xA;&#xA;It may be good to start brainstorming possible failure modes during splice, and how to recover, and also to indicate the expected behavior in the proposal, as I believe these will be the points where splicing must be designed most precisely. What happens when a splice is ongoing and the communication gets disconnected?  What happens when some channel failure occurs during splicing and we are forced to drop onchain?  And so on.&#xA;&#xA;&#xA;Regards,&#xA;ZmnSCPxj&#xA;&#xA;&#xA;Sent with ProtonMail Secure Email.&#xA;&#xA;‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐&#xA;On Wednesday, October 10, 2018 11:45 AM, Rusty Russell &lt;rusty at rustcorp.com.au&gt; wrote:&#xA;&#xA;&gt; Hi all!&#xA;&gt;&#xA;&gt; We&#39;ve had increasing numbers of c-lightning users get upset they&#xA;&gt; can&#39;t open multiple channels, so I guess we&#39;re most motivated to allow&#xA;&gt; splicing of existing channels. Hence this rough proposal.&#xA;&gt;&#xA;&gt; For simplicity, I&#39;ve chosen to only allow a single splice at a time.&#xA;&gt; It&#39;s still complex :(&#xA;&gt;&#xA;&gt; Feedback welcome!&#xA;&gt;&#xA;&gt; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;&gt;&#xA;&gt; Splice Negotiation:&#xA;&gt;&#xA;&gt; 1.  type: 40 (`splice_add_input`) (`option_splice`)&#xA;&gt; 2.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`8`: `satoshis`]&#xA;&gt;     -   [`32`: `prevtxid`]&#xA;&gt;     -   [`4`: `prevtxoutnum`]&#xA;&gt;     -   [`2`: `scriptlen`]&#xA;&gt;     -   [`scriptlen`: `scriptpubkey`]&#xA;&gt; 3.  type: 41 (`splice_add_output`) (`option_splice`)&#xA;&gt; 4.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`8`: `satoshis`]&#xA;&gt;     -   [`2`: `scriptlen`]&#xA;&gt;     -   [`scriptlen`: `outscript`]&#xA;&gt; 5.  type: 42 (`splice_all_added`) (`option_splice`)&#xA;&gt; 6.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`4`:`feerate_per_kw`]&#xA;&gt;     -   [`4`:`minimum_depth`]&#xA;&gt;&#xA;&gt;         Each side sends 0 or more `splice_add_input` and 0 or more&#xA;&gt;         `splice_add_output` followed by `spice_all_added` to complete the splice&#xA;&gt;         proposal. This is done either to initiate a splice, or to respond to a&#xA;&gt;         `splice_*` from the other party.&#xA;&gt;&#xA;&gt;         `splice_add_input` is checked for the following:&#xA;&gt;&#xA;&gt;&#xA;&gt; -   must not be during a current splice&#xA;&gt;&#xA;&gt; -   scriptpubkey is empty, or of form &#39;HASH160 &lt;20-byte-script-hash&gt; EQUAL&#39;&#xA;&gt;&#xA;&gt; -   `satoshis` doesn&#39;t wrap on addition.&#xA;&gt;&#xA;&gt; -   MAY check that it matches outpoint specified (sig will simply be&#xA;&gt;     invalid if so), and that outpoint is segwit.&#xA;&gt;&#xA;&gt;     `splice_add_output` is checked for the following:&#xA;&gt;&#xA;&gt; -   must not be during a current splice&#xA;&gt;&#xA;&gt; -   `satoshis` is less than or equal to amount owing to proposer, minus&#xA;&gt;     current reserve, and greater than or equal to `dust_limit_satoshis` we&#xA;&gt;     sent in our open_channel/accept_channel ,sg.&#xA;&gt;&#xA;&gt; -   script is one of the approved forms as it is for `shutdown`.&#xA;&gt;&#xA;&gt;     FIXME: Do we disallow splice-out if they specified&#xA;&gt;     option_upfront_shutdown_script?&#xA;&gt;&#xA;&gt;     `splice_all_added` is checked for the following:&#xA;&gt;&#xA;&gt; -   average of `feerate_per_kw` by both sides (round down) is sufficient.&#xA;&gt;&#xA;&gt; -   average of `feerate_per_kw` by both sides not grossly excessive, if we&#39;re&#xA;&gt;     paying some of the fees (see below!)&#xA;&gt;&#xA;&gt; -   both sides can afford the fees from their post-splice funds (see&#xA;&gt;     Verification Changes below)&#xA;&gt;&#xA;&gt; -   maximum of the two `minimum_depth` is not grossly excessive.&#xA;&gt;&#xA;&gt; -   There is at least one splice_add_input or splice_add_output.&#xA;&gt;&#xA;&gt;     Splice negotiation, like closing negotiation, does not have persistent&#xA;&gt;     state. Reconnecting forgets previous negotiation.&#xA;&gt;&#xA;&gt;     Splice Signing&#xA;&gt;&#xA;&gt;&#xA;&gt; Once`splice_all_added` is both sent and received, we need to create and&#xA;&gt; sign both the splice tx itself, and the first commitment transaction&#xA;&gt; which spends it (but not in that order!).&#xA;&gt;&#xA;&gt; 1.  One input spends the current funding tx output.&#xA;&gt; 2.  There is one additional input for each splice_add_input.&#xA;&gt; 3.  One output creates the new funding tx.&#xA;&gt; 4.  There is one additional output for each splice_add_output.&#xA;&gt; 5.  The entire transaction is sorted into BIP69 order.&#xA;&gt; 6.  The feerate is the sum of the two `feerate_per_kw` divided by 2,&#xA;&gt;     rounded down.&#xA;&gt;&#xA;&gt; 7.  type: 43 (`splice_commitment_signature`) (`option_splice`)&#xA;&gt; 8.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`64`:`commitment_signature`]&#xA;&gt;     -   [`2`:`num_htlcs`]&#xA;&gt;     -   [`num_htlcs*64`:`htlc_signature`]&#xA;&gt; 9.  type: 44 (`splice_signature`) (`option_splice`)&#xA;&gt; 10.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`64`:`splice_signature`]&#xA;&gt; 11.  type: 45 (`splice_witness`) (`option_splice`)&#xA;&gt; 12.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`2`: `num_witness_elements`&#xA;&gt;     -   [`2`:`len`]&#xA;&gt;     -   [`len`:`witnesses`]&#xA;&gt;&#xA;&gt;         `witnesses` itself is serialized as `num_witness_elements` of:&#xA;&gt;&#xA;&gt;&#xA;&gt; -   `2`:`len`&#xA;&gt; -   `len`: `witness_element`&#xA;&gt;&#xA;&gt;     Each side sends `splice_commitment_signature` and waits to receive and&#xA;&gt;     verify the other side&#39;s `splice_commitment_signature` before sending&#xA;&gt;     `splice_signature` and `splice_witness` for each `splice_add_input` it&#xA;&gt;     proposed, in BIP69 input order.&#xA;&gt;&#xA;&gt;     Once a node has sent `splice_commitment_signature` it should remember&#xA;&gt;     the splice proposal across reconnects. Once it has both sent&#xA;&gt;     `splice_signature`, the splice is locked in.&#xA;&gt;&#xA;&gt;     Splice Announcement&#xA;&gt;&#xA;&gt;&#xA;&gt; We have to tell the network about the new channel, otherwise there will&#xA;&gt; be a distruption when it sees the old funding transaction spent. This&#xA;&gt; is inevitable for older nodes who won&#39;t understand splicing anyway.&#xA;&gt;&#xA;&gt; We can&#39;t send out a `channel_announcement` or `channel_update` for the&#xA;&gt; new channel until after the new funding transaction has 6 confirmations,&#xA;&gt; so we append to the existing `channel_update` for the original channel,&#xA;&gt; using a new `message_flags` field:&#xA;&gt;&#xA;&gt; Bit Position&#xA;&gt;&#xA;&gt; Name&#xA;&gt;&#xA;&gt; Field&#xA;&gt;&#xA;&gt; 0&#xA;&gt;&#xA;&gt; `option_channel_htlc_max`&#xA;&gt;&#xA;&gt; `htlc_maximum_msat`&#xA;&gt;&#xA;&gt; 1&#xA;&gt;&#xA;&gt; `option_channel_moving`&#xA;&gt;&#xA;&gt; `moving_txid&#xA;&gt;&#xA;&gt; The`channel_update` gains the following field:&#xA;&gt; * [`32`: moving_txid`] (option_channel_moving) If a current`channel_update`for a closing channel contains`option_channel_moving`a node SHOULD ignore the channel close for at least 100 blocks iff spent by`moving_txid`. A node SHOULD immediately forward a`channel_update`it sees containing`option_channel_moving`if neither previous`channel_update`for the channel contains`option_channel_moving`.&#xA;&gt;&#xA;&gt; Each side of the splice can send these unilaterally, and SHOULD allow a&#xA;&gt; few minutes for propagation (remember, average propagation from old&#xA;&gt; nodes is still 30 seconds) prior to broadcast of the splice transaction.&#xA;&gt;&#xA;&gt; Message Changes During Splicing&#xA;&gt;&#xA;&gt; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;&gt;&#xA;&gt; Once you&#39;ve sent `splice_commitment_signature` each commitment&#xA;&gt; transaction is duplicated: one spends the old funding transaction, one&#xA;&gt; spends the splice transaction:&#xA;&gt;&#xA;&gt; 1.  type: 39 (`closing_signed`)&#xA;&gt; 2.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`8`:`fee_satoshis`]&#xA;&gt;     -   [`64`:`signature`]&#xA;&gt;     -   [`64`:`splice_signature`] (`option_splice`)&#xA;&gt; 3.  type: 132 (`commitment_signed`)&#xA;&gt; 4.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`64`:`signature`]&#xA;&gt;     -   [`2`:`num_htlcs`]&#xA;&gt;     -   [`num_htlcs*64`:`htlc_signature`]&#xA;&gt;     -   [`num_htlcs*64`:`htlc_splice_signature`] (`option_splice`)&#xA;&gt;&#xA;&gt;         If a reconnection occurs between between sending and receiving&#xA;&gt;         `splice_commitment_signature`) the peer&#39;s status is uncertain (similarly&#xA;&gt;         for closing). This we have a new field in `channel_reestablish` to flag&#xA;&gt;         that we consider ourselves to be splicing:&#xA;&gt;&#xA;&gt; 5.  type: 136 (`channel_reestablish`)&#xA;&gt; 6.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;     -   [`8`:`next_local_commitment_number`]&#xA;&gt;     -   [`8`:`next_remote_revocation_number`]&#xA;&gt;     -   [`32`:`your_last_per_commitment_secret`] (`option_data_loss_protect`)&#xA;&gt;     -   [`33`:`my_current_per_commitment_point`] (`option_data_loss_protect`)&#xA;&gt;     -   [`32`:`splice_txid`] (`option_splice`)&#xA;&gt;&#xA;&gt;         The splice_txid field indicates that this side considers itself to be&#xA;&gt;         splicing.&#xA;&gt;&#xA;&gt;         The sender:&#xA;&gt;&#xA;&gt;&#xA;&gt; -   if it has sent `splice_commitment_signature` and not sent the corresponding&#xA;&gt;     `splice_closed`, MUST set `splice_txid` to the txid of the splice tx.&#xA;&gt;     -   Otherwise MUST NOT.&#xA;&gt;&#xA;&gt;         The recipient:&#xA;&gt;&#xA;&gt; -   if it has sent `splice_commitment_signature` and not sent the corresponding&#xA;&gt;     `splice_closed`:&#xA;&gt;     -   if `splice_txid` does not exist or does not match the current splice:&#xA;&gt;         -   SHOULD fail the channel&#xA;&gt;     -   otherwise:&#xA;&gt;         -   MUST retransmit `splice_signature`&#xA;&gt; -   otherwise:&#xA;&gt;     -   if `splice_txid` field exists and is not all zeroes:&#xA;&gt;         -   MUST send `splice_closed`&#xA;&gt;&#xA;&gt;             Validation Changes During Splicing&#xA;&gt;&#xA;&gt;&#xA;&gt; We track &#34;post-splice&#34; values as well as current values during&#xA;&gt; splicing.&#xA;&gt;&#xA;&gt; The post-splice reserve is 1% of post-splice capcacity (rounded down).&#xA;&gt;&#xA;&gt; The fees for the splicing transaction itself are divided into parts by&#xA;&gt; the number of `splice_add_input` plus `splice_add_output`, rounded up.&#xA;&gt; Each side pays as many parts as it proposed `splice_add_input` plus&#xA;&gt; `splice_add_output`.&#xA;&gt;&#xA;&gt; (So if Alice proposes two and Bob proposes one, and the total fee is 1000&#xA;&gt; satoshi, each part is 334 satoshi: Alice pays 668 and Bob pays 334.)&#xA;&gt;&#xA;&gt; Each side&#39;s post-splice funds are debited their `splice_add_output`&#xA;&gt; amounts, and credited their `splice_add_input` amounts, a debited the&#xA;&gt; splice tx fees. If any debiting occurs, the funds must be above the&#xA;&gt; post-splice reserve (ie. you can have below reserve, but you can&#39;t spend&#xA;&gt; if you&#39;re below reserve).&#xA;&gt;&#xA;&gt; All update_add_htlc must be valid for the both the current and&#xA;&gt; post-splice balances.&#xA;&gt;&#xA;&gt; Completing Splicing&#xA;&gt;&#xA;&gt; ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&#xA;&gt;&#xA;&gt; Once you&#39;ve seen both side&#39;s `minimum_depth` confirmations of the splice&#xA;&gt; transaction (ie. the maximum of the two `minimum_depth` values), you can&#xA;&gt; complete the splice by sending:&#xA;&gt;&#xA;&gt; 1.  type: 46 (`splice_closed`) (`option_splice`)&#xA;&gt; 2.  data:&#xA;&gt;     -   [`32`:`channel_id`]&#xA;&gt;&#xA;&gt;         Once you&#39;ve sent and received `splice_closed` you can send&#xA;&gt;         `announcement_signatures` for the new channel as per normal rules (ie. 6&#xA;&gt;         confirmations, `announce_channel` bit set).&#xA;&gt;&#xA;&gt;         In addition, you can forget everything about the old channel (including&#xA;&gt;         old HTLCs and revocation requirements).&#xA;&gt;&#xA;&gt;&#xA;&gt; Lightning-dev mailing list&#xA;&gt; Lightning-dev at lists.linuxfoundation.org&#xA;&gt; https://lists.linuxfoundation.org/mailman/listinfo/lightning-dev</html></oembed>