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

Function handle_validate_commitment_tx

hsmd/libhsmd.c:1368–1414  ·  view source on GitHub ↗

~This stub implementation is overriden by fully validating signers * that need to independently verify the peer's signatures. */

Source from the content-addressed store, hash-verified

1366/* ~This stub implementation is overriden by fully validating signers
1367 * that need to independently verify the peer's signatures. */
1368static u8 *handle_validate_commitment_tx(struct hsmd_client *c, const u8 *msg_in)
1369{
1370 struct bitcoin_tx *tx;
1371 struct simple_htlc **htlc;
1372 u64 commit_num;
1373 u32 feerate;
1374 struct bitcoin_signature sig;
1375 struct bitcoin_signature *htlc_sigs;
1376 struct secret channel_seed;
1377 struct sha256 shaseed;
1378 struct secret *old_secret;
1379 struct pubkey next_per_commitment_point;
1380
1381 if (!fromwire_hsmd_validate_commitment_tx(tmpctx, msg_in,
1382 &tx, &htlc,
1383 &commit_num, &feerate,
1384 &sig, &htlc_sigs))
1385 return hsmd_status_malformed_request(c, msg_in);
1386
1387 /* Stub implementation */
1388
1389 /* The signatures are not checked in this stub because they
1390 * are already checked by the caller. However, the returned
1391 * old_secret and next_per_commitment_point are used.
1392 */
1393
1394 get_channel_seed(&c->id, c->dbid, &channel_seed);
1395 if (!derive_shaseed(&channel_seed, &shaseed))
1396 return hsmd_status_bad_request(c, msg_in, "bad derive_shaseed");
1397
1398 if (!per_commit_point(&shaseed, &next_per_commitment_point, commit_num + 1))
1399 return hsmd_status_bad_request_fmt(
1400 c, msg_in, "bad per_commit_point %" PRIu64, commit_num + 1);
1401
1402 if (commit_num >= 1) {
1403 old_secret = tal(tmpctx, struct secret);
1404 if (!per_commit_secret(&shaseed, old_secret, commit_num - 1)) {
1405 return hsmd_status_bad_request_fmt(
1406 c, msg_in, "Cannot derive secret %" PRIu64, commit_num - 1);
1407 }
1408 } else {
1409 old_secret = NULL;
1410 }
1411
1412 return towire_hsmd_validate_commitment_tx_reply(
1413 NULL, old_secret, &next_per_commitment_point);
1414}
1415
1416/* This stub implementation is overriden by fully validating signers
1417 * that need to independently verify that the latest state is

Callers 1

Calls 7

derive_shaseedFunction · 0.85
per_commit_pointFunction · 0.85
per_commit_secretFunction · 0.85
get_channel_seedFunction · 0.70
hsmd_status_bad_requestFunction · 0.70

Tested by

no test coverage detected