{"type":"rich","version":"1.0","title":"lisa neigut [ARCHIVE] wrote","author_name":"lisa neigut [ARCHIVE] (npub1sp…s64t2)","author_url":"https://yabu.me/npub1sprhp66c693av0c0n9had046hcdcckp2th25fnmphwstc5e4wg9qxs64t2","provider_name":"njump","provider_url":"https://yabu.me","html":"📅 Original date posted:2020-01-27\n📝 Original message:\nSome of the feedback I received from the check-in for the dual-funding\nproposal this past Monday was along the lines that we look at simplifying\nfor breaking it into smaller, more manageable chunks.\n\nThe biggest piece of the dual-funding protocol update is definitely the\nmove from a single peer constructing a transaction to two participants.\nWe're also going to likely want to reuse this portion of the protocol for\nbatched closings and splicing. To that extent, it seemed useful to\nhighlight it in a separate email.\n\nThis is a change from the existing proposal in the dual-funding PR #524\n\u003chttps://github.com/lightningnetwork/lightning-rfc/pull/524\u003e -- it allows\nfor the removal of inputs and outputs.\n\nThe set of messages are as follows.\n\n\nNote that the 'initiation' of this protocol will be different depending on\nthe case of the transaction (open, close or splice):\n\n1. type:   440 `tx_add_input`\n\n2. data:\n\n    * [`32*byte`:`channel_identifier`]\n\n    * [`u64`:`sats`]\n\n    * [`sha256`:`prevtx_txid`]\n\n    * [`u32`:`prevtx_vout`]\n\n    * [`u16`:`prevtx_scriptpubkey_len`]\n\n    * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`]\n\n    * [`u16`:`max_witness_len`]\n\n    * [`u16`:`scriptlen`]\n\n    * [`scriptlen*byte`:`script`]\n\n    * [`byte`:`signal_rbf`]\n\n1. type: 442 `tx_add_output`\n\n2. data:\n\n    * [`32*byte`:`channel_identifier`]\n\n    * [`u64`:`sats`]\n\n    * [`u16`:`scriptlen`]\n\n    * [`scriptlen*byte`:`script`]\n\n1. type: 444 `tx_remove_input`\n\n2. data:\n\n    * [`32*byte`:`channel_identifier`]\n\n    * [`sha256`:`prevtx_txid`]\n\n    * [`u32`:`prevtx_vout`]\n\n1. type: 446 `tx_remove_output`\n\n2. data:\n\n    * [`32*byte`:`channel_identifier`]\n\n    * [`u64`:`sats`]\n\n    * [`u16`:`scriptlen`]\n\n    * [`scriptlen*byte`:`script`]\n\n1. type: 448 `tx_complete`\n\n2. data:\n\n    * [`32*byte`:`channel_identifier`]\n\n    * [`u16`:`num_inputs`]\n\n    * [`u16`:`num_outputs`]\n\n1. type:  448 `tx_sigs`\n\n2. data:\n\n    * [`channel_id`:`channel_identifier`]\n\n    * [`u16`:`num_witnesses`]\n\n    * [`num_witnesses*witness_stack`:`witness_stack`]\n\n1. subtype: `witness_stack`\n\n2. data:\n\n    * [`sha256`:`prevtx_txid`]\n\n    * [`u32`:`prevtx_vout`]\n\n    * [`u16`:`num_input_witness`]\n\n    * [`num_input_witness*witness_element`:`witness_element`]\n\n1. subtype: `witness_element`\n\n2. data:\n\n    * [`u16`:`len`]\n\n    * [`len*byte`:`witness`]\n\n\n\n## General Notes\n\n- Validity of inputs/outputs is not checked until both peers have sent\nconsecutive `tx_complete`  messages.\n\n- Duplicate inputs or outputs is a protocol error.\n\n- Feerate is set by the initiator, or in the case of a closing transaction,\nnegotiated before the transaction construction is initiated.\n\n- Every peer pays fees for the inputs + outputs they contribute, plus\nenough to cover the maximum estimate of their witnesses. Overpayment of\nfees is permissible.\n\n- Initiator is responsible for contributing the output/input in question,\ni.e. the\n\n  funding output in the case of an opening, or the funding input in the\ncase of a close.\n\n  (This means that the opener will pay for the opening output). In the case\nof a splice,\n\n  the initiator of the splice pays for the funding tx's inclusion as an\ninput and the\n\n  new 'funding tx' output.\n\n- Any contributor may signal that their input is RBF'able. The nSequence\nfor this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise.\n\n- The initiating peer is understood to be paying the fee for the shared\ntransaction fields (nVersion [4], segwit marker + flag [2], input + output\ncounts [2-18], witness count [1-9], nLocktime [4]; total [13-40bytes])\n\n- Inputs MUST be segwit compatible (PW* or P2SH-PW*)\n\n- All output scripts must be standard\n\n- nLocktime is always set to 0x00000000.\n\n- The `num_inputs` and `num_outputs` in `tx_complete` is a count of that\npeer’s final input and output contributions, net any removals.\n\n- Either peer may add or remove inputs and outputs until both peers have\nsuccessfully\n\n  exchanged a `tx_complete` message in succession.\n\n- Either peer may only add or remove their own input or output.\n\n- In the case that a `tx_complete` agreement cannot be reached, either peer\nmay\n\n  fail the channel or open protocol (whatever is reasonable for the\nparticular case)\n\n  - In the case of a splice, this would be a soft error (channel returns to\nnormal operation until\n\n    otherwise failed or closed.)\n\n  - In the case of an open, this would be a failure to open the channel.\n\n  - In the case of a close, a failed collaborative close would result in an\nerror and a unilateral close.\n\n### Considering the Simple Open case (2 parties)\n\n- Both peers signal `opt_dual_fund`\n\n- Opener initiates a channel open with `open_channel2` message, indicating\nthe feerate for the opening transaction\n\n- Accepter signals acceptance of channel open as proposed, including\nproposed feerate, via `accept_channel2`\n\n- Opener sends `tx_add_output`, with the funding output for the sum of both\npeer’s funding_amount\n\n- Opener sends `tx_add_input` for each input the wish to add to the funding\ntransaction\n\n- Opener sends `tx_add_output` for their change\n\n- Opener sends `tx_complete`\n\n- Accepter sends `tx_add_input` for each input they wish to add to the\nfunding transaction\n\n- Accepter sends `tx_add_output` for their change.\n\n- Accepter sends `tx_complete`\n\n- Opener sends `tx_complete`\n\n- Opener and accepter exchange commitment signatures; etc.\n\n### Considering the Splice case:\n\n- Both peers signal `opt_splice_ok`\n\n- One peer initiates a splice, also signaling the feerate for the\ntransaction. Exact protocol unspecified herein.\n\n- Initiator sends `tx_add_input` with the original funding output\n\n- Initiator sends `tx_add_output` with the new, post-splice funding output\n\n- Initiator sends `tx_add_input/output` as needed to add all desired inputs\n+ outputs\n\n- Initiator sends `tx_complete`\n\n- Peer sends `tx_add_input/output` as needed to add all desired inputs +\noutputs\n\n- Initiator sends `tx_complete`\n\n- Peer sends `tx_complete`\n\n- Initiator + peer exchange commitment signatures, etc.\n\n### Considering the Close case:\n\n- Both peers signal `opt_collaborative_close` in their `node_announcement`.\n\n- A peer initiates a close sending a `shutdown`, as per usual.\n\n- A feerate is negotiated. Out of band for this particular portion of the\nprotocol.\n\n-The closing initiator (peer which first sent `shutdown`), sends\n`tx_add_input` to spend the funding output and `tx_add_output` to add their\noutput for the channel closure.\n\n- The peer responds with `tx_add_output`, adding their output to the close\ntransaction.\n\n- If `option_upfront_shutdown_script` is flagged but no such output with a\nvalue at or within a reasonable feerate gap of the peer's funding output is\npresent, then the peer must fail the channel.\n\n\n## Updating a collaborative transaction with RBF:\n\n- If any input is flagged as RBF’able, then the transaction is considered\neligible for RBF\n\n- RBF can be initiated by either party, and serves as an initiation for\nanother round of transaction composition, as outlined above.\n\n- Note that this section has been cribbed and re-purposed from the original\nRBF proposal for splicing, see\nhttps://lists.linuxfoundation.org/pipermail/lightning-dev/2018-November/001621.html\n\n1. type: 45 (`init_rbf`) (`option_collaborative_rbf`)\n\n2. data:\n\n   * [`32`:`channel_id`]\n\n   * [`4`:`fee_step`]\n\nEach `fee_step` adds 1/4 (rounded down) to the initial\n\ntransaction feerate. eg. if the initial feerate was 512 satoshis per\nkiloweight, `fee_step` 1\n\nis  512 + 512 / 4 = 640, `fee_step` 2 is 640 + 640 / 4 = 800.\n\nThe sender:\n\n  - MUST set `fee_step` greater than zero and greater than any prior\n`fee_step`.\n\nThe recipient:\n\n  - if the new fee exceeds the sender's current balance minus reserve\n\n    after it is applied to the splice transaction:\n\n    - MUST error.\n\n\n\nNOTES:\n\n1. 1/4 is a reasonable minimal RBF, but as each one requires more\n\n   tracking by the recipient, serves to limit the number you can create.\n\n2. Rule 4 of BIP125 requires a feerate increase to at least surpass the\nminimum transaction relay setting. Ratcheting by 25% should satisfy this\nrequirement\n\n3. An additional rule will be added to the checks of an RBF transaction\nthat it must include at least one identical, replaceable input as the\noriginal transaction.\n-------------- next part --------------\nAn HTML attachment was scrubbed...\nURL: \u003chttp://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20200127/ca2e504d/attachment-0001.html\u003e"}
