MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_future_dataloss_fields

Function check_future_dataloss_fields

openingd/dualopend.c:4044–4087  ·  view source on GitHub ↗

BOLT #2: * * A receiving node: * - MUST ignore `my_current_per_commitment_point`, but MAY require it to be * a valid point. * - if `next_revocation_number` is greater than expected above, AND * `your_last_per_commitment_secret` is correct for that * `next_revocation_number` minus 1: * - MUST NOT broadcast its commitment transaction. * - SHOULD send an `error` to

Source from the content-addressed store, hash-verified

4042 * - SHOULD send an `error` to request the peer to fail the channel.
4043 */
4044static void
4045check_future_dataloss_fields(struct state *state,
4046 u64 next_revocation_number,
4047 const struct secret *last_local_per_commit_secret)
4048{
4049 const u8 *msg;
4050 bool correct;
4051
4052 /* We're always at zero in dualopend */
4053 assert(next_revocation_number > 0);
4054
4055 msg = towire_hsmd_check_future_secret(NULL,
4056 next_revocation_number - 1,
4057 last_local_per_commit_secret);
4058 wire_sync_write(HSM_FD, take(msg));
4059 msg = wire_sync_read(tmpctx, HSM_FD);
4060
4061 if (!fromwire_hsmd_check_future_secret_reply(msg, &correct))
4062 status_failed(STATUS_FAIL_HSM_IO,
4063 "Bad hsm_check_future_secret_reply: %s",
4064 tal_hex(tmpctx, msg));
4065
4066 if (!correct)
4067 open_err_fatal(state,
4068 "Bad future last_local_per_commit_secret:"
4069 " %"PRIu64" vs %d",
4070 next_revocation_number, 0);
4071
4072 /* Oh shit, they really are from the future! */
4073 peer_billboard(true, "They have future commitment number %"PRIu64
4074 " vs our %d. We must wait for them to close!",
4075 next_revocation_number, 0);
4076
4077
4078 /* BOLT #2:
4079 * - MUST NOT broadcast its commitment transaction.
4080 * - SHOULD send an `error` to request the peer to fail the channel.
4081 */
4082 wire_sync_write(REQ_FD,
4083 take(towire_dualopend_fail_fallen_behind(NULL)));
4084
4085 /* We have to send them an error to trigger dropping to chain. */
4086 open_err_fatal(state, "%s", "Awaiting unilateral close");
4087}
4088
4089
4090static void do_reconnect_dance(struct state *state)

Callers 1

do_reconnect_danceFunction · 0.70

Calls 6

tal_hexFunction · 0.85
open_err_fatalFunction · 0.85
wire_sync_writeFunction · 0.50
wire_sync_readFunction · 0.50
status_failedFunction · 0.50
peer_billboardFunction · 0.50

Tested by

no test coverage detected