You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Closing Negotiation: `closing_complete` and `closing_sig`](#closing-negotiation-closing_complete-and-closing_sig)
20
19
*[Normal Operation](#normal-operation)
21
20
*[Forwarding HTLCs](#forwarding-htlcs)
@@ -571,20 +570,6 @@ Closing happens in two stages:
571
570
1. one side indicates it wants to clear the channel (and thus will accept no new HTLCs)
572
571
2. once all HTLCs are resolved, the final channel close negotiation begins.
573
572
574
-
+-------+ +-------+
575
-
| |--(1)----- shutdown ------->| |
576
-
| |<-(2)----- shutdown --------| |
577
-
| | | |
578
-
| | <complete all pending HTLCs> | |
579
-
| A | ... | B |
580
-
| | | |
581
-
| |--(3)-- closing_signed F1--->| |
582
-
| |<-(4)-- closing_signed F2----| |
583
-
| | ... | |
584
-
| |--(?)-- closing_signed Fn--->| |
585
-
| |<-(?)-- closing_signed Fn----| |
586
-
+-------+ +-------+
587
-
588
573
+-------+ +-------+
589
574
| |--(1)----- shutdown ------->| |
590
575
| |<-(2)----- shutdown --------| |
@@ -673,120 +658,6 @@ of the receiving node to change the `scriptpubkey`.
673
658
674
659
The `shutdown` response requirement implies that the node sends `commitment_signed` to commit any outstanding changes before replying; however, it could theoretically reconnect instead, which would simply erase all outstanding uncommitted changes.
675
660
676
-
### Closing Negotiation: `closing_signed`
677
-
678
-
Once shutdown is complete, the channel is empty of HTLCs, there are no commitments
679
-
for which a revocation is owed, and all updates are included on both commitments,
680
-
the final current commitment transactions will have no HTLCs, and closing fee
681
-
negotiation begins. The funder chooses a fee it thinks is fair, and
682
-
signs the closing transaction with the `scriptpubkey` fields from the
683
-
`shutdown` messages (along with its chosen fee) and sends the signature;
684
-
the other node then replies similarly, using a fee it thinks is fair. This
685
-
exchange continues until both agree on the same fee or when one side fails
686
-
the channel.
687
-
688
-
In the modern method, the funder sends its permissible fee range, and the
689
-
non-funder has to pick a fee in this range. If the non-funder chooses the same
690
-
value, negotiation is complete after two messages, otherwise the funder will
691
-
reply with the same value (completing after three messages).
692
-
693
-
1. type: 39 (`closing_signed`)
694
-
2. data:
695
-
*[`channel_id`:`channel_id`]
696
-
*[`u64`:`fee_satoshis`]
697
-
*[`signature`:`signature`]
698
-
*[`closing_signed_tlvs`:`tlvs`]
699
-
700
-
1.`tlv_stream`: `closing_signed_tlvs`
701
-
2. types:
702
-
1. type: 1 (`fee_range`)
703
-
2. data:
704
-
*[`u64`:`min_fee_satoshis`]
705
-
*[`u64`:`max_fee_satoshis`]
706
-
707
-
#### Requirements
708
-
709
-
The funding node:
710
-
- after `shutdown` has been received, AND no HTLCs remain in either commitment transaction:
711
-
- SHOULD send a `closing_signed` message.
712
-
713
-
The sending node:
714
-
- SHOULD set the initial `fee_satoshis` according to its estimate of cost of
715
-
inclusion in a block.
716
-
- SHOULD set `fee_range` according to the minimum and maximum fees it is
717
-
prepared to pay for a close transaction.
718
-
- if it doesn't receive a `closing_signed` response after a reasonable amount of time:
719
-
- MUST fail the channel
720
-
- if it is not the funder:
721
-
- SHOULD set `max_fee_satoshis` to at least the `max_fee_satoshis` received
722
-
- SHOULD set `min_fee_satoshis` to a fairly low value
723
-
- MUST set `signature` to the Bitcoin signature of the close transaction,
724
-
as specified in [BOLT #3](03-transactions.md#closing-transaction).
725
-
726
-
The receiving node:
727
-
- if the `signature` is not valid for either variant of closing transaction
728
-
specified in [BOLT #3](03-transactions.md#closing-transaction) OR non-compliant with LOW-S-standard rule<sup>[LOWS](https://github.com/bitcoin/bitcoin/pull/6769)</sup>:
729
-
- MUST send a `warning` and close the connection, or send an
730
-
`error` and fail the channel.
731
-
- if `fee_satoshis` is equal to its previously sent `fee_satoshis`:
732
-
- SHOULD sign and broadcast the final closing transaction.
733
-
- MAY close the connection.
734
-
- if `fee_satoshis` matches its previously sent `fee_range`:
735
-
- SHOULD use `fee_satoshis` to sign and broadcast the final closing transaction
736
-
- SHOULD reply with a `closing_signed` with the same `fee_satoshis` value if it is different from its previously sent `fee_satoshis`
737
-
- MAY close the connection.
738
-
- if the message contains a `fee_range`:
739
-
- if there is no overlap between that and its own `fee_range`:
740
-
- SHOULD send a warning
741
-
- MUST fail the channel if it doesn't receive a satisfying `fee_range` after a reasonable amount of time
742
-
- otherwise:
743
-
- if it is the funder:
744
-
- if `fee_satoshis` is not in the overlap between the sent and received `fee_range`:
745
-
- MUST fail the channel
746
-
- otherwise:
747
-
- MUST reply with the same `fee_satoshis`.
748
-
- otherwise (it is not the funder):
749
-
- if it has already sent a `closing_signed`:
750
-
- if `fee_satoshis` is not the same as the value it sent:
751
-
- MUST fail the channel
752
-
- otherwise:
753
-
- MUST propose a `fee_satoshis` in the overlap between received and (about-to-be) sent `fee_range`.
754
-
- otherwise, if `fee_satoshis` is not strictly between its last-sent `fee_satoshis`
755
-
and its previously-received `fee_satoshis`, UNLESS it has since reconnected:
756
-
- SHOULD send a `warning` and close the connection, or send an
757
-
`error` and fail the channel.
758
-
- otherwise, if the receiver agrees with the fee:
759
-
- SHOULD reply with a `closing_signed` with the same `fee_satoshis` value.
760
-
- otherwise:
761
-
- MUST propose a value "strictly between" the received `fee_satoshis`
762
-
and its previously-sent `fee_satoshis`.
763
-
764
-
The receiving node:
765
-
- if one of the outputs in the closing transaction is below the dust limit for its `scriptpubkey` (see [BOLT 3](03-transactions.md#dust-limits)):
766
-
- MUST fail the channel
767
-
768
-
#### Rationale
769
-
770
-
When `fee_range` is not provided, the "strictly between" requirement ensures
771
-
that forward progress is made, even if only by a single satoshi at a time.
772
-
To avoid keeping state and to handle the corner case, where fees have shifted
773
-
between disconnection and reconnection, negotiation restarts on reconnection.
774
-
775
-
Note there is limited risk if the closing transaction is
776
-
delayed, but it will be broadcast very soon; so there is usually no
777
-
reason to pay a premium for rapid processing.
778
-
779
-
Note that the non-funder is not paying the fee, so there is no reason for it
780
-
to have a maximum feerate. It may want a minimum feerate, however, to ensure
781
-
that the transaction propagates. It can always use CPFP later to speed up
782
-
confirmation if necessary, so that minimum should be low.
783
-
784
-
It may happen that the closing transaction doesn't meet bitcoin's default relay
785
-
policies (e.g. when using a non-segwit shutdown script for an output below 546
786
-
satoshis, which is possible if `dust_limit_satoshis` is below 546 satoshis).
787
-
No funds are at risk when that happens, but the channel must be force-closed as
788
-
the closing transaction will likely never reach miners.
789
-
790
661
### Closing Negotiation: `closing_complete` and `closing_sig`
791
662
792
663
Once shutdown is complete, the channel is empty of HTLCs, there are no commitments
Copy file name to clipboardExpand all lines: 03-transactions.md
-45Lines changed: 0 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -347,53 +347,8 @@ The witness script for the output is:
347
347
348
348
To spend this via penalty, the remote node uses a witness stack `<revocationsig> 1`, and to collect the output, the local node uses an input with nSequence `to_self_delay` and a witness stack `<local_delayedsig> 0`.
349
349
350
-
## Classic Closing Transaction
351
-
352
-
This variant is used for `closing_signed` messages (i.e. where `option_simple_close` is not negotiated).
353
-
354
-
Note that there are two possible variants for each node.
355
-
356
-
* version: 2
357
-
* locktime: 0
358
-
* txin count: 1
359
-
*`txin[0]` outpoint: `txid` and `output_index` from `funding_created` message
*`txout` amount: final balance to be paid to one node (minus `fee_satoshis` from `closing_signed`, if this peer funded the channel)
365
-
*`txout` script: as specified in that node's `scriptpubkey` in its `shutdown` message
366
-
367
-
### Requirements
368
-
369
-
Each node offering a signature:
370
-
- MUST round each output down to whole satoshis.
371
-
- MUST subtract the fee given by `fee_satoshis` from the output to the funder.
372
-
- MUST remove any output below its own `dust_limit_satoshis`.
373
-
- MAY eliminate its own output.
374
-
375
-
### Rationale
376
-
377
-
There is a possibility of irreparable differences on closing if one
378
-
node considers the other's output too small to allow propagation on
379
-
the Bitcoin network (a.k.a. "dust"), and that other node instead
380
-
considers that output too valuable to discard. This is why each
381
-
side uses its own `dust_limit_satoshis`, and the result can be a
382
-
signature validation failure, if they disagree on what the closing
383
-
transaction should look like.
384
-
385
-
However, if one side chooses to eliminate its own output, there's no
386
-
reason for the other side to fail the closing protocol; so this is
387
-
explicitly allowed. The signature indicates which variant
388
-
has been used.
389
-
390
-
There will be at least one output, if the funding amount is greater
391
-
than twice `dust_limit_satoshis`.
392
-
393
350
## Closing Transaction
394
351
395
-
This variant is used for `closing_complete` and `closing_sig` messages (i.e. where `option_simple_close` is negotiated).
396
-
397
352
In this case, the node sending `closing_complete` ("the closer") pays the fees, and the sequence is set to 0xFFFFFFFD to allow RBF. The outputs are ordered as detailed in [Transaction Output Ordering](#transaction-output-ordering).
398
353
399
354
Two closing transactions are always produced: one `with_closee_output` one `without_closee_output` (the non-closer chooses which to accept). `closing_complete` contains `has_closer_output` to indicate whether the closer's output is in the transactions.
0 commit comments