| 452 | } |
| 453 | |
| 454 | static void derive_to_remote(const struct unilateral_close_info *info, const char *hsm_secret_path) |
| 455 | { |
| 456 | struct secret hsm_secret, channel_seed, basepoint_secret; |
| 457 | struct pubkey basepoint; |
| 458 | struct privkey privkey; |
| 459 | |
| 460 | secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY |
| 461 | | SECP256K1_CONTEXT_SIGN); |
| 462 | |
| 463 | struct hsm_secret *hsms = load_hsm_secret(tmpctx, hsm_secret_path); |
| 464 | /* Copy first 32 bytes of secret_data to the local secret struct */ |
| 465 | memcpy(hsm_secret.data, hsms->secret_data, sizeof(hsm_secret.data)); |
| 466 | get_channel_seed(&channel_seed, &info->peer_id, info->channel_id, &hsm_secret); |
| 467 | if (!derive_payment_basepoint(&channel_seed, &basepoint, &basepoint_secret)) |
| 468 | errx(ERROR_KEYDERIV, "Could not derive basepoints for dbid %"PRIu64 |
| 469 | " and channel seed %s.", info->channel_id, |
| 470 | fmt_secret(tmpctx, &channel_seed)); |
| 471 | if (!info->commitment_point) |
| 472 | privkey.secret = basepoint_secret; |
| 473 | else if (!derive_simple_privkey(&basepoint_secret, &basepoint, info->commitment_point, &privkey)) |
| 474 | errx(ERROR_KEYDERIV, "Could not derive simple privkey for dbid %"PRIu64 |
| 475 | ", channel seed %s, and commitment point %s.", info->channel_id, |
| 476 | fmt_secret(tmpctx, &channel_seed), |
| 477 | fmt_pubkey(tmpctx, info->commitment_point)); |
| 478 | printf("privkey : %s\n", fmt_secret(tmpctx, &privkey.secret)); |
| 479 | } |
| 480 | |
| 481 | static void dumponchaindescriptors(const char *hsm_secret_path, |
| 482 | const u32 version, bool show_secrets) |
no test coverage detected