~This stub implementation is overriden by fully validating signers * that need to independently verify the peer's signatures. */
| 1366 | /* ~This stub implementation is overriden by fully validating signers |
| 1367 | * that need to independently verify the peer's signatures. */ |
| 1368 | static 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 |
no test coverage detected