| 299 | } |
| 300 | |
| 301 | static int dump_commitments_infos(struct node_id *node_id, u64 channel_id, |
| 302 | u64 depth, char *hsm_secret_path) |
| 303 | { |
| 304 | struct sha256 shaseed; |
| 305 | struct secret hsm_secret, channel_seed, per_commitment_secret; |
| 306 | struct pubkey per_commitment_point; |
| 307 | char *passwd, *err; |
| 308 | int exit_code = 0; |
| 309 | |
| 310 | secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY |
| 311 | | SECP256K1_CONTEXT_SIGN); |
| 312 | |
| 313 | /* This checks the file existence, too. */ |
| 314 | if (hsm_secret_is_encrypted(hsm_secret_path)) { |
| 315 | printf("Enter hsm_secret password:\n"); |
| 316 | fflush(stdout); |
| 317 | passwd = read_stdin_pass_with_exit_code(&err, &exit_code); |
| 318 | if (!passwd) |
| 319 | errx(exit_code, "%s", err); |
| 320 | get_encrypted_hsm_secret(&hsm_secret, hsm_secret_path, passwd); |
| 321 | free(passwd); |
| 322 | } else |
| 323 | get_hsm_secret(&hsm_secret, hsm_secret_path); |
| 324 | |
| 325 | get_channel_seed(&channel_seed, node_id, channel_id, &hsm_secret); |
| 326 | |
| 327 | derive_shaseed(&channel_seed, &shaseed); |
| 328 | printf("shaseed: %s\n", type_to_string(tmpctx, struct sha256, &shaseed)); |
| 329 | for (u64 i = 0; i < depth; i++) { |
| 330 | if (!per_commit_secret(&shaseed, &per_commitment_secret, i)) |
| 331 | errx(ERROR_KEYDERIV, "Could not derive secret #%"PRIu64, i); |
| 332 | printf("commit secret #%"PRIu64": %s\n", |
| 333 | i, tal_hexstr(tmpctx, per_commitment_secret.data, |
| 334 | sizeof(per_commitment_secret.data))); |
| 335 | if (!per_commit_point(&shaseed, &per_commitment_point, i)) |
| 336 | errx(ERROR_KEYDERIV, "Could not derive point #%"PRIu64, i); |
| 337 | printf("commit point #%"PRIu64": %s\n", |
| 338 | i, type_to_string(tmpctx, struct pubkey, &per_commitment_point)); |
| 339 | } |
| 340 | |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | /* In case of an unilateral close from the remote side while we suffered a |
| 345 | * loss of data, this tries to recover the private key from the `to_remote` |
no test coverage detected