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

Function print_secret

tools/lightning-hsmtool.c:272–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272static void print_secret(const char *hsm_secret_path, const char *id, bool must_be_oldstyle)
273{
274 struct secret hsm_secret;
275 char *bip93;
276 const char *err;
277 struct hsm_secret *hsms = load_hsm_secret(tmpctx, hsm_secret_path);
278
279 switch (hsms->type) {
280 case HSM_SECRET_ENCRYPTED:
281 errx(ERROR_USAGE, "Encrypted hsm_secret");
282 case HSM_SECRET_MNEMONIC_NO_PASS:
283 if (must_be_oldstyle)
284 errx(ERROR_USAGE, "Cannot use getcodexsecret with modern nodes: use getsecret");
285 printf("%s\n", hsms->mnemonic);
286 return;
287 case HSM_SECRET_MNEMONIC_WITH_PASS:
288 errx(ERROR_USAGE, "hsm_secret with passphrase");
289 case HSM_SECRET_PLAIN:
290 if (id == NULL)
291 errx(ERROR_USAGE, "Must set 'id' for a codex32 secret");
292 /* Extract first 32 bytes for legacy compatibility */
293 memcpy(hsm_secret.data, hsms->secret_data, 32);
294
295 err = codex32_secret_encode(tmpctx, "cl", id, 0, hsm_secret.data, 32, &bip93);
296 if (err)
297 errx(ERROR_USAGE, "%s", err);
298
299 printf("%s\n", bip93);
300 return;
301 case HSM_SECRET_INVALID:
302 break;
303 }
304 /* Never happens. */
305 abort();
306}
307
308static void print_emergencyrecover(const char *emer_rec_path)
309{

Callers 1

mainFunction · 0.85

Calls 4

load_hsm_secretFunction · 0.85
errxFunction · 0.85
codex32_secret_encodeFunction · 0.85
abortFunction · 0.85

Tested by

no test coverage detected