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

Function derive_to_remote

tools/lightning-hsmtool.c:454–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454static 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
481static void dumponchaindescriptors(const char *hsm_secret_path,
482 const u32 version, bool show_secrets)

Callers 1

mainFunction · 0.85

Calls 7

load_hsm_secretFunction · 0.85
derive_payment_basepointFunction · 0.85
errxFunction · 0.85
fmt_secretFunction · 0.85
derive_simple_privkeyFunction · 0.85
fmt_pubkeyFunction · 0.85
get_channel_seedFunction · 0.70

Tested by

no test coverage detected