mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
createinvoice: make a minimal blinded "path" in bolt12 invoice if none presented.
The "path" is just a message to ourselves. This meets the minimal requirement for bolt12 invoices: that there be a blinded path (at least so we can use the path_id inside in place of "payment_secret"). We expose the method to make this path_id to a common routine: offers will need this for generating more sophisticated paths. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
a5471a405b
commit
595fbd2a19
@@ -5,6 +5,7 @@
|
||||
#include <common/errcode.h>
|
||||
#include <common/hsm_encryption.h>
|
||||
#include <common/hsm_version.h>
|
||||
#include <common/invoice_path_id.h>
|
||||
#include <common/json_command.h>
|
||||
#include <common/json_param.h>
|
||||
#include <common/jsonrpc_errors.h>
|
||||
@@ -140,6 +141,17 @@ struct ext_key *hsm_init(struct lightningd *ld)
|
||||
"HSM gave invalid v1 bolt12_base");
|
||||
}
|
||||
|
||||
/* This is equivalent to makesecret("bolt12-invoice-base") */
|
||||
msg = towire_hsmd_derive_secret(NULL, tal_dup_arr(tmpctx, u8,
|
||||
(const u8 *)INVOICE_PATH_BASE_STRING,
|
||||
strlen(INVOICE_PATH_BASE_STRING), 0));
|
||||
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
||||
err(EXITCODE_HSM_GENERIC_ERROR, "Writing derive_secret msg to hsm");
|
||||
|
||||
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
||||
if (!fromwire_hsmd_derive_secret_reply(msg, &ld->invoicesecret_base))
|
||||
err(EXITCODE_HSM_GENERIC_ERROR, "Bad derive_secret_reply");
|
||||
|
||||
return bip32_base;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user