Skip to content

Commit cd3c99e

Browse files
t-bastniftynei
authored andcommitted
Store state when sending commitment_signed
If we only store state when sending `tx_signatures`, there are cases where we cannot reconcile states if a disconnection occurs during the signing steps: one side will have sent `tx_signatures` and thus must wait for the transaction to be spent or double-spent, while the other side has already forgotten that channel because they haven't sent `tx_signatures`. This is fixed by storing state when sending `commitment_signed`, and adding a `next_funding_txid` field to `channel_reestablish` to ask our peer to retransmit signatures that we haven't received.
1 parent a735468 commit cd3c99e

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

02-peer-protocol.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,7 @@ for [`commitment_signed`](#commiting-updates-so-far-commitment_signed) with the
13271327

13281328
The sending node:
13291329
- MUST send zero HTLCs.
1330+
- MUST remember the details of this funding transaction.
13301331

13311332
The receiving node:
13321333
- if the message has one or more HTLCs:
@@ -1341,6 +1342,10 @@ The receiving node:
13411342

13421343
The first commitment transaction has no HTLCs.
13431344

1345+
Once peers are ready to exchange commitment signatures, they must remember
1346+
the details of the funding transaction to allow resuming the signatures
1347+
exchange if a disconnection happens.
1348+
13441349
### Sharing funding signatures: `tx_signatures`
13451350

13461351
After a valid `commitment_signed` has been received
@@ -2244,6 +2249,12 @@ messages are), they are independent of requirements here.
22442249
* [`32*byte`:`your_last_per_commitment_secret`]
22452250
* [`point`:`my_current_per_commitment_point`]
22462251

2252+
1. `tlv_stream`: `channel_reestablish_tlvs`
2253+
2. types:
2254+
1. type: 0 (`next_funding`)
2255+
2. data:
2256+
* [`sha256`:`next_funding_txid`]
2257+
22472258
`next_commitment_number`: A commitment number is a 48-bit
22482259
incrementing counter for each commitment transaction; counters
22492260
are independent for each peer in the channel and start at 0.
@@ -2300,18 +2311,21 @@ The sending node:
23002311
- MUST set `your_last_per_commitment_secret` to all zeroes
23012312
- otherwise:
23022313
- MUST set `your_last_per_commitment_secret` to the last `per_commitment_secret` it received
2314+
- if it has sent `commitment_signed` for an interactive transaction construction but
2315+
it has not received `tx_signatures`:
2316+
- MUST set `next_funding_txid` to the txid of that interactive transaction.
2317+
- otherwise:
2318+
- MUST NOT set `next_funding_txid`.
23032319

23042320
A node:
23052321
- if `next_commitment_number` is 1 in both the `channel_reestablish` it
23062322
sent and received:
23072323
- MUST retransmit `channel_ready`.
2308-
- MUST retransmit `tx_signatures` if it is using channel establishment v2.
23092324
- otherwise:
23102325
- MUST NOT retransmit `channel_ready`, but MAY send `channel_ready` with
23112326
a different `short_channel_id` `alias` field.
23122327
- upon reconnection:
23132328
- MUST ignore any redundant `channel_ready` it receives.
2314-
- MUST ignore any redundant `tx_signatures` it receives.
23152329
- if `next_commitment_number` is equal to the commitment number of
23162330
the last `commitment_signed` message the receiving node has sent:
23172331
- MUST reuse the same commitment number for its next `commitment_signed`.
@@ -2361,6 +2375,20 @@ A node:
23612375
do not match the expected values):
23622376
- SHOULD send an `error` and fail the channel.
23632377

2378+
A receiving node:
2379+
- if `next_funding_txid` is set:
2380+
- if `next_funding_txid` matches the latest interactive funding transaction:
2381+
- if it has not received `tx_signatures` for that funding transaction:
2382+
- MUST retransmit its `commitment_signed` for that funding transaction.
2383+
- if it has already received `commitment_signed` and it should sign first,
2384+
as specified in the [`tx_signatures` requirements](#the-tx_signatures-message):
2385+
- MUST send its `tx_signatures` for that funding transaction.
2386+
- if it has already received `tx_signatures` for that funding transaction:
2387+
- MUST send its `tx_signatures` for that funding transaction.
2388+
- otherwise:
2389+
- MUST send `tx_abort` to let the sending node know that they can forget
2390+
this funding transaction.
2391+
23642392
A node:
23652393
- MUST NOT assume that previously-transmitted messages were lost,
23662394
- if it has sent a previous `commitment_signed` message:
@@ -2452,6 +2480,11 @@ fall-behind detection. An implementation can offer both, however, and
24522480
fall back to the `option_data_loss_protect` behavior if
24532481
`option_static_remotekey` is not negotiated.
24542482

2483+
`next_funding_txid` allows peers to finalize the signing steps of an
2484+
interactive transaction construction, or safely abort that transaction
2485+
if it was not signed by one of the peers, who has thus already removed
2486+
it from its state.
2487+
24552488
# Authors
24562489

24572490
[ FIXME: Insert Author List ]

0 commit comments

Comments
 (0)