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

Function do_commit_signed_received

openingd/dualopend.c:1262–1340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1260}
1261
1262static char *do_commit_signed_received(const tal_t *ctx,
1263 const u8 *msg,
1264 struct state *state,
1265 struct tx_state *tx_state,
1266 struct bitcoin_tx **local_commit,
1267 struct bitcoin_signature *remote_sig)
1268{
1269 const u8 *wscript;
1270 char *error;
1271 struct channel_id cid;
1272 secp256k1_ecdsa_signature *htlc_sigs;
1273 struct tlv_commitment_signed_tlvs *cs_tlv
1274 = tlv_commitment_signed_tlvs_new(tmpctx);
1275
1276 if (!fromwire_commitment_signed(tmpctx, msg, &cid,
1277 &remote_sig->s,
1278 &htlc_sigs, &cs_tlv))
1279 open_err_fatal(state, "Parsing commitment signed %s",
1280 tal_hex(tmpctx, msg));
1281
1282 remote_sig->sighash_type = SIGHASH_ALL;
1283 check_channel_id(state, &cid, &state->channel_id);
1284
1285 if (htlc_sigs != NULL)
1286 open_err_fatal(state, "Must not send HTLCs with first"
1287 " commitment. %s", tal_hex(tmpctx, msg));
1288
1289 *local_commit = initial_channel_tx(ctx, &wscript, state->channel,
1290 &state->first_per_commitment_point[LOCAL],
1291 LOCAL, NULL, &error);
1292
1293 /* This shouldn't happen either, AFAICT. */
1294 if (!*local_commit)
1295 return tal_fmt(ctx, "Could not meet our fees"
1296 " and reserve: %s", error);
1297
1298 validate_initial_commitment_signature(HSM_FD, *local_commit, remote_sig);
1299
1300 /* BOLT #2:
1301 *
1302 * The recipient:
1303 * - if `signature` is incorrect OR non-compliant with LOW-S-standard
1304 * rule...:
1305 * - MUST send a `warning` and close the connection, or send an
1306 * `error` and fail the channel.
1307 */
1308 if (!check_tx_sig(*local_commit, 0, NULL, wscript,
1309 &state->their_funding_pubkey, remote_sig)) {
1310 /* BOLT #1:
1311 *
1312 * - when failure was caused by an invalid signature check:
1313 * - SHOULD include the raw, hex-encoded transaction in reply
1314 * to a `funding_created`, `funding_signed`,
1315 * `closing_signed`, or `commitment_signed` message.
1316 */
1317 /*~ This verbosity is not only useful for our own testing, but
1318 * a courtesy to other implementaters whose brains may be so
1319 * twisted by coding in Go, Scala and Rust that they can no

Callers 3

handle_commit_signedFunction · 0.85
accepter_commitsFunction · 0.85
opener_commitsFunction · 0.85

Calls 11

open_err_fatalFunction · 0.85
tal_hexFunction · 0.85
check_channel_idFunction · 0.85
initial_channel_txFunction · 0.85
check_tx_sigFunction · 0.85
fmt_bitcoin_signatureFunction · 0.85
fmt_bitcoin_txFunction · 0.85
fmt_pubkeyFunction · 0.85
fmt_bitcoin_txidFunction · 0.85
fmt_wally_psbtFunction · 0.85

Tested by

no test coverage detected