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
@@ -1665,120 +1665,6 @@ there are two forms in script: one which pushes up to 75 bytes, and a longer
1665
1665
one (`OP_PUSHDATA1`) which is needed for 76-80 bytes.
1666
1666
1667
1667
1668
-
### Closing Negotiation: `closing_signed`
1669
-
1670
-
Once shutdown is complete, the channel is empty of HTLCs, there are no commitments
1671
-
for which a revocation is owed, and all updates are included on both commitments,
1672
-
the final current commitment transactions will have no HTLCs, and closing fee
1673
-
negotiation begins. The funder chooses a fee it thinks is fair, and
1674
-
signs the closing transaction with the `scriptpubkey` fields from the
1675
-
`shutdown` messages (along with its chosen fee) and sends the signature;
1676
-
the other node then replies similarly, using a fee it thinks is fair. This
1677
-
exchange continues until both agree on the same fee or when one side fails
1678
-
the channel.
1679
-
1680
-
In the modern method, the funder sends its permissible fee range, and the
1681
-
non-funder has to pick a fee in this range. If the non-funder chooses the same
1682
-
value, negotiation is complete after two messages, otherwise the funder will
1683
-
reply with the same value (completing after three messages).
1684
-
1685
-
1. type: 39 (`closing_signed`)
1686
-
2. data:
1687
-
*[`channel_id`:`channel_id`]
1688
-
*[`u64`:`fee_satoshis`]
1689
-
*[`signature`:`signature`]
1690
-
*[`closing_signed_tlvs`:`tlvs`]
1691
-
1692
-
1.`tlv_stream`: `closing_signed_tlvs`
1693
-
2. types:
1694
-
1. type: 1 (`fee_range`)
1695
-
2. data:
1696
-
*[`u64`:`min_fee_satoshis`]
1697
-
*[`u64`:`max_fee_satoshis`]
1698
-
1699
-
#### Requirements
1700
-
1701
-
The funding node:
1702
-
- after `shutdown` has been received, AND no HTLCs remain in either commitment transaction:
1703
-
- SHOULD send a `closing_signed` message.
1704
-
1705
-
The sending node:
1706
-
- SHOULD set the initial `fee_satoshis` according to its estimate of cost of
1707
-
inclusion in a block.
1708
-
- SHOULD set `fee_range` according to the minimum and maximum fees it is
1709
-
prepared to pay for a close transaction.
1710
-
- if it doesn't receive a `closing_signed` response after a reasonable amount of time:
1711
-
- MUST fail the channel
1712
-
- if it is not the funder:
1713
-
- SHOULD set `max_fee_satoshis` to at least the `max_fee_satoshis` received
1714
-
- SHOULD set `min_fee_satoshis` to a fairly low value
1715
-
- MUST set `signature` to the Bitcoin signature of the close transaction,
1716
-
as specified in [BOLT #3](03-transactions.md#closing-transaction).
1717
-
1718
-
The receiving node:
1719
-
- if the `signature` is not valid for either variant of closing transaction
1720
-
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>:
1721
-
- MUST send a `warning` and close the connection, or send an
1722
-
`error` and fail the channel.
1723
-
- if `fee_satoshis` is equal to its previously sent `fee_satoshis`:
1724
-
- SHOULD sign and broadcast the final closing transaction.
1725
-
- MAY close the connection.
1726
-
- if `fee_satoshis` matches its previously sent `fee_range`:
1727
-
- SHOULD use `fee_satoshis` to sign and broadcast the final closing transaction
1728
-
- SHOULD reply with a `closing_signed` with the same `fee_satoshis` value if it is different from its previously sent `fee_satoshis`
1729
-
- MAY close the connection.
1730
-
- if the message contains a `fee_range`:
1731
-
- if there is no overlap between that and its own `fee_range`:
1732
-
- SHOULD send a warning
1733
-
- MUST fail the channel if it doesn't receive a satisfying `fee_range` after a reasonable amount of time
1734
-
- otherwise:
1735
-
- if it is the funder:
1736
-
- if `fee_satoshis` is not in the overlap between the sent and received `fee_range`:
1737
-
- MUST fail the channel
1738
-
- otherwise:
1739
-
- MUST reply with the same `fee_satoshis`.
1740
-
- otherwise (it is not the funder):
1741
-
- if it has already sent a `closing_signed`:
1742
-
- if `fee_satoshis` is not the same as the value it sent:
1743
-
- MUST fail the channel
1744
-
- otherwise:
1745
-
- MUST propose a `fee_satoshis` in the overlap between received and (about-to-be) sent `fee_range`.
1746
-
- otherwise, if `fee_satoshis` is not strictly between its last-sent `fee_satoshis`
1747
-
and its previously-received `fee_satoshis`, UNLESS it has since reconnected:
1748
-
- SHOULD send a `warning` and close the connection, or send an
1749
-
`error` and fail the channel.
1750
-
- otherwise, if the receiver agrees with the fee:
1751
-
- SHOULD reply with a `closing_signed` with the same `fee_satoshis` value.
1752
-
- otherwise:
1753
-
- MUST propose a value "strictly between" the received `fee_satoshis`
1754
-
and its previously-sent `fee_satoshis`.
1755
-
1756
-
The receiving node:
1757
-
- 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)):
1758
-
- MUST fail the channel
1759
-
1760
-
#### Rationale
1761
-
1762
-
When `fee_range` is not provided, the "strictly between" requirement ensures
1763
-
that forward progress is made, even if only by a single satoshi at a time.
1764
-
To avoid keeping state and to handle the corner case, where fees have shifted
1765
-
between disconnection and reconnection, negotiation restarts on reconnection.
1766
-
1767
-
Note there is limited risk if the closing transaction is
1768
-
delayed, but it will be broadcast very soon; so there is usually no
1769
-
reason to pay a premium for rapid processing.
1770
-
1771
-
Note that the non-funder is not paying the fee, so there is no reason for it
1772
-
to have a maximum feerate. It may want a minimum feerate, however, to ensure
1773
-
that the transaction propagates. It can always use CPFP later to speed up
1774
-
confirmation if necessary, so that minimum should be low.
1775
-
1776
-
It may happen that the closing transaction doesn't meet bitcoin's default relay
1777
-
policies (e.g. when using a non-segwit shutdown script for an output below 546
1778
-
satoshis, which is possible if `dust_limit_satoshis` is below 546 satoshis).
1779
-
No funds are at risk when that happens, but the channel must be force-closed as
1780
-
the closing transaction will likely never reach miners.
1781
-
1782
1668
### Closing Negotiation: `closing_complete` and `closing_sig`
1783
1669
1784
1670
Once shutdown is complete, the channel is empty of HTLCs, there are no commitments
@@ -1958,6 +1844,120 @@ or the final commitment transaction can be spent. In practice, the opener has an
1958
1844
offer a reasonable closing fee, as they would pay the fee for the commitment transaction, which
1959
1845
also costs more to spend.
1960
1846
1847
+
### Legacy Closing Negotiation: `closing_signed`
1848
+
1849
+
Once shutdown is complete, the channel is empty of HTLCs, there are no commitments
1850
+
for which a revocation is owed, and all updates are included on both commitments,
1851
+
the final current commitment transactions will have no HTLCs, and closing fee
1852
+
negotiation begins. The funder chooses a fee it thinks is fair, and
1853
+
signs the closing transaction with the `scriptpubkey` fields from the
1854
+
`shutdown` messages (along with its chosen fee) and sends the signature;
1855
+
the other node then replies similarly, using a fee it thinks is fair. This
1856
+
exchange continues until both agree on the same fee or when one side fails
1857
+
the channel.
1858
+
1859
+
In the modern method, the funder sends its permissible fee range, and the
1860
+
non-funder has to pick a fee in this range. If the non-funder chooses the same
1861
+
value, negotiation is complete after two messages, otherwise the funder will
1862
+
reply with the same value (completing after three messages).
1863
+
1864
+
1. type: 39 (`closing_signed`)
1865
+
2. data:
1866
+
*[`channel_id`:`channel_id`]
1867
+
*[`u64`:`fee_satoshis`]
1868
+
*[`signature`:`signature`]
1869
+
*[`closing_signed_tlvs`:`tlvs`]
1870
+
1871
+
1.`tlv_stream`: `closing_signed_tlvs`
1872
+
2. types:
1873
+
1. type: 1 (`fee_range`)
1874
+
2. data:
1875
+
*[`u64`:`min_fee_satoshis`]
1876
+
*[`u64`:`max_fee_satoshis`]
1877
+
1878
+
#### Requirements
1879
+
1880
+
The funding node:
1881
+
- after `shutdown` has been received, AND no HTLCs remain in either commitment transaction:
1882
+
- SHOULD send a `closing_signed` message.
1883
+
1884
+
The sending node:
1885
+
- SHOULD set the initial `fee_satoshis` according to its estimate of cost of
1886
+
inclusion in a block.
1887
+
- SHOULD set `fee_range` according to the minimum and maximum fees it is
1888
+
prepared to pay for a close transaction.
1889
+
- if it doesn't receive a `closing_signed` response after a reasonable amount of time:
1890
+
- MUST fail the channel
1891
+
- if it is not the funder:
1892
+
- SHOULD set `max_fee_satoshis` to at least the `max_fee_satoshis` received
1893
+
- SHOULD set `min_fee_satoshis` to a fairly low value
1894
+
- MUST set `signature` to the Bitcoin signature of the close transaction,
1895
+
as specified in [BOLT #3](03-transactions.md#closing-transaction).
1896
+
1897
+
The receiving node:
1898
+
- if the `signature` is not valid for either variant of closing transaction
1899
+
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>:
1900
+
- MUST send a `warning` and close the connection, or send an
1901
+
`error` and fail the channel.
1902
+
- if `fee_satoshis` is equal to its previously sent `fee_satoshis`:
1903
+
- SHOULD sign and broadcast the final closing transaction.
1904
+
- MAY close the connection.
1905
+
- if `fee_satoshis` matches its previously sent `fee_range`:
1906
+
- SHOULD use `fee_satoshis` to sign and broadcast the final closing transaction
1907
+
- SHOULD reply with a `closing_signed` with the same `fee_satoshis` value if it is different from its previously sent `fee_satoshis`
1908
+
- MAY close the connection.
1909
+
- if the message contains a `fee_range`:
1910
+
- if there is no overlap between that and its own `fee_range`:
1911
+
- SHOULD send a warning
1912
+
- MUST fail the channel if it doesn't receive a satisfying `fee_range` after a reasonable amount of time
1913
+
- otherwise:
1914
+
- if it is the funder:
1915
+
- if `fee_satoshis` is not in the overlap between the sent and received `fee_range`:
1916
+
- MUST fail the channel
1917
+
- otherwise:
1918
+
- MUST reply with the same `fee_satoshis`.
1919
+
- otherwise (it is not the funder):
1920
+
- if it has already sent a `closing_signed`:
1921
+
- if `fee_satoshis` is not the same as the value it sent:
1922
+
- MUST fail the channel
1923
+
- otherwise:
1924
+
- MUST propose a `fee_satoshis` in the overlap between received and (about-to-be) sent `fee_range`.
1925
+
- otherwise, if `fee_satoshis` is not strictly between its last-sent `fee_satoshis`
1926
+
and its previously-received `fee_satoshis`, UNLESS it has since reconnected:
1927
+
- SHOULD send a `warning` and close the connection, or send an
1928
+
`error` and fail the channel.
1929
+
- otherwise, if the receiver agrees with the fee:
1930
+
- SHOULD reply with a `closing_signed` with the same `fee_satoshis` value.
1931
+
- otherwise:
1932
+
- MUST propose a value "strictly between" the received `fee_satoshis`
1933
+
and its previously-sent `fee_satoshis`.
1934
+
1935
+
The receiving node:
1936
+
- 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)):
1937
+
- MUST fail the channel
1938
+
1939
+
#### Rationale
1940
+
1941
+
When `fee_range` is not provided, the "strictly between" requirement ensures
1942
+
that forward progress is made, even if only by a single satoshi at a time.
1943
+
To avoid keeping state and to handle the corner case, where fees have shifted
1944
+
between disconnection and reconnection, negotiation restarts on reconnection.
1945
+
1946
+
Note there is limited risk if the closing transaction is
1947
+
delayed, but it will be broadcast very soon; so there is usually no
1948
+
reason to pay a premium for rapid processing.
1949
+
1950
+
Note that the non-funder is not paying the fee, so there is no reason for it
1951
+
to have a maximum feerate. It may want a minimum feerate, however, to ensure
1952
+
that the transaction propagates. It can always use CPFP later to speed up
1953
+
confirmation if necessary, so that minimum should be low.
1954
+
1955
+
It may happen that the closing transaction doesn't meet bitcoin's default relay
1956
+
policies (e.g. when using a non-segwit shutdown script for an output below 546
1957
+
satoshis, which is possible if `dust_limit_satoshis` is below 546 satoshis).
1958
+
No funds are at risk when that happens, but the channel must be force-closed as
1959
+
the closing transaction will likely never reach miners.
1960
+
1961
1961
## Normal Operation
1962
1962
1963
1963
Once both nodes have exchanged `channel_ready` (and optionally [`announcement_signatures`](07-routing-gossip.md#the-announcement_signatures-message)), the channel can be used to make payments via Hashed Time Locked Contracts.
0 commit comments