Skip to content

Commit 1739746

Browse files
committed
Anchor outputs
This commit extends the specification with a new commitment format that adds two anchor outputs to the commitment transaction. Anchor outputs are a safety feature that allows a channel party to unilaterally increase the fee of the commitment transaction using CPFP and ensure timely confirmation on the chain. There is no cooperation required from the remote party.
1 parent bfc66e5 commit 1739746

File tree

5 files changed

+480
-49
lines changed

5 files changed

+480
-49
lines changed

.aspell.en.pws

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,12 @@ bitmasks
376376
CSPRNG
377377
lexicographically
378378
MINIMALIF
379+
SIGHASH
380+
ANYONECANPAY
381+
cpfp
382+
utxo
383+
txes
384+
csv
385+
CHECKSIGVERIFY
386+
IFDUP
387+
sats

02-peer-protocol.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ This message introduces the `channel_id` to identify the channel. It's derived f
378378
#### Requirements
379379

380380
Both peers:
381-
- if `option_static_remotekey` was negotiated:
382-
- `option_static_remotekey` applies to all commitment transactions
381+
- if `option_static_remotekey` or `option_anchor_outputs` was negotiated:
382+
- `option_static_remotekey` or `option_anchor_outputs` applies to all commitment transactions
383383
- otherwise:
384-
- `option_static_remotekey` does not apply to any commitment transactions
384+
- `option_static_remotekey` or `option_anchor_outputs` does not apply to any commitment transactions
385385

386386
The sender MUST set:
387387
- `channel_id` by exclusive-OR of the `funding_txid` and the `funding_output_index` from the `funding_created` message.
@@ -396,9 +396,10 @@ The recipient:
396396

397397
#### Rationale
398398

399-
We decide on `option_static_remotekey` at this point when we first have to generate the commitment
400-
transaction. Even if a later reconnection does not negotiate this parameter, this channel will continue to use `option_static_remotekey`; we don't support "downgrading".
401-
This simplifies channel state, particularly penalty transaction handling.
399+
We decide on `option_static_remotekey` or `option_anchor_outputs` at this point when we first have to generate the commitment
400+
transaction. The feature bits that were communicated in the `init` message exchange for the current connection determine
401+
the channel commitment format for the total lifetime of the channel. Even if a later reconnection does not negotiate this parameter,
402+
this channel will continue to use `option_static_remotekey` or `option_anchor_outputs`; we don't support "downgrading".
402403

403404
### The `funding_locked` Message
404405

@@ -811,6 +812,10 @@ A sending node:
811812
transaction, it cannot pay the fee for either the local or remote commitment
812813
transaction at the current `feerate_per_kw` while maintaining its channel
813814
reserve (see [Updating Fees](#updating-fees-update_fee)).
815+
- if `option_anchor_outputs` applies to this commitment transaction and the sending
816+
node is the funder:
817+
- MUST be able to additionally pay for `to_local_anchor` and
818+
`to_remote_anchor` above its reserve.
814819
- SHOULD NOT offer `amount_msat` if, after adding that HTLC to its commitment
815820
transaction, its remaining balance doesn't allow it to pay the commitment
816821
transaction fee when receiving or sending a future additional non-dust HTLC
@@ -843,7 +848,7 @@ been received). It MUST continue incrementing instead.
843848
A receiving node:
844849
- receiving an `amount_msat` equal to 0, OR less than its own `htlc_minimum_msat`:
845850
- SHOULD fail the channel.
846-
- receiving an `amount_msat` that the sending node cannot afford at the current `feerate_per_kw` (while maintaining its channel reserve):
851+
- receiving an `amount_msat` that the sending node cannot afford at the current `feerate_per_kw` (while maintaining its channel reserve and any `to_local_anchor` and `to_remote_anchor` costs):
847852
- SHOULD fail the channel.
848853
- if a sending node adds more than receiver `max_accepted_htlcs` HTLCs to
849854
its local commitment transaction, OR adds more than receiver `max_htlc_value_in_flight_msat` worth of offered HTLCs to its local commitment transaction:
@@ -1034,6 +1039,8 @@ output HTLCs are fully resolved.
10341039

10351040
Note that the `htlc_signature` implicitly enforces the time-lock mechanism in the case of offered HTLCs being timed out or received HTLCs being spent. This is done to reduce fees by creating smaller scripts compared to explicitly stating time-locks on HTLC outputs.
10361041

1042+
The `option_anchor_outputs` allows HTLC transactions to "bring their own fees" by attaching other inputs and outputs, hence the modified signature flags.
1043+
10371044
### Completing the Transition to the Updated State: `revoke_and_ack`
10381045

10391046
Once the recipient of `commitment_signed` checks the signature and knows
@@ -1118,13 +1125,18 @@ A receiving node:
11181125

11191126
#### Rationale
11201127

1121-
Bitcoin fees are required for unilateral closes to be effective —
1122-
particularly since there is no general method for the broadcasting node to use
1123-
child-pays-for-parent to increase its effective fee.
1128+
Bitcoin fees are required for unilateral closes to be effective.
1129+
With `option_anchor_outputs`, `feerate_per_kw` is not as critical anymore to
1130+
guarantee confirmation as it was in the legacy commitment format, but it still
1131+
needs to be enough to be able to enter the mempool (satisfy min relay fee and
1132+
mempool min fee).
1133+
1134+
For the legacy commitment format, there is no general method for the
1135+
broadcasting node to use child-pays-for-parent to increase its effective fee.
11241136

11251137
Given the variance in fees, and the fact that the transaction may be
11261138
spent in the future, it's a good idea for the fee payer to keep a good
1127-
margin (say 5x the expected fee requirement); but, due to differing methods of
1139+
margin (say 5x the expected fee requirement) for legacy commitment txes; but, due to differing methods of
11281140
fee estimation, an exact value is not specified.
11291141

11301142
Since the fees are currently one-sided (the party which requested the

0 commit comments

Comments
 (0)