mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 15:04:19 +01:00
plugins/fetchinvoice: remove obsolete string-based API.
Generate the payload in the callers. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -639,8 +639,7 @@ static struct pubkey *path_to_node(const tal_t *ctx,
|
||||
/* Marshal arguments for sending onion messages */
|
||||
struct sending {
|
||||
struct sent *sent;
|
||||
const char *msgfield;
|
||||
const u8 *msgval;
|
||||
struct tlv_onionmsg_payload *payload;
|
||||
struct command_result *(*done)(struct command *cmd,
|
||||
const char *buf UNUSED,
|
||||
const jsmntok_t *result UNUSED,
|
||||
@@ -684,7 +683,7 @@ send_modern_message(struct command *cmd,
|
||||
&node_alias[i]);
|
||||
}
|
||||
/* Final payload contains the actual data. */
|
||||
payloads[nhops-1] = tlv_onionmsg_payload_new(payloads);
|
||||
payloads[nhops-1] = sending->payload;
|
||||
|
||||
/* We don't include enctlv in final, but it gives us final alias */
|
||||
if (!create_final_enctlv(tmpctx, &blinding_iter, &sent->path[nhops-1],
|
||||
@@ -696,15 +695,6 @@ send_modern_message(struct command *cmd,
|
||||
"Could create final enctlv");
|
||||
}
|
||||
|
||||
/* FIXME: This interface is a string for sendobsonionmessage! */
|
||||
if (streq(sending->msgfield, "invoice_request")) {
|
||||
payloads[nhops-1]->invoice_request
|
||||
= cast_const(u8 *, sending->msgval);
|
||||
} else {
|
||||
assert(streq(sending->msgfield, "invoice"));
|
||||
payloads[nhops-1]->invoice
|
||||
= cast_const(u8 *, sending->msgval);
|
||||
}
|
||||
payloads[nhops-1]->reply_path = reply_path;
|
||||
|
||||
req = jsonrpc_request_start(cmd->plugin, cmd, "sendonionmessage",
|
||||
@@ -779,8 +769,7 @@ static struct command_result *make_reply_path(struct command *cmd,
|
||||
|
||||
static struct command_result *send_message(struct command *cmd,
|
||||
struct sent *sent,
|
||||
const char *msgfield TAKES,
|
||||
const u8 *msgval TAKES,
|
||||
struct tlv_onionmsg_payload *payload STEALS,
|
||||
struct command_result *(*done)
|
||||
(struct command *cmd,
|
||||
const char *buf UNUSED,
|
||||
@@ -789,8 +778,7 @@ static struct command_result *send_message(struct command *cmd,
|
||||
{
|
||||
struct sending *sending = tal(cmd, struct sending);
|
||||
sending->sent = sent;
|
||||
sending->msgfield = tal_strdup(sending, msgfield);
|
||||
sending->msgval = tal_dup_talarr(sending, u8, msgval);
|
||||
sending->payload = tal_steal(sending, payload);
|
||||
sending->done = done;
|
||||
|
||||
return make_reply_path(cmd, sending);
|
||||
@@ -829,11 +817,12 @@ sendinvreq_after_connect(struct command *cmd,
|
||||
const jsmntok_t *result UNUSED,
|
||||
struct sent *sent)
|
||||
{
|
||||
u8 *rawinvreq = tal_arr(tmpctx, u8, 0);
|
||||
towire_tlv_invoice_request(&rawinvreq, sent->invreq);
|
||||
struct tlv_onionmsg_payload *payload = tlv_onionmsg_payload_new(sent);
|
||||
|
||||
return send_message(cmd, sent, "invoice_request", rawinvreq,
|
||||
sendonionmsg_done);
|
||||
payload->invoice_request = tal_arr(payload, u8, 0);
|
||||
towire_tlv_invoice_request(&payload->invoice_request, sent->invreq);
|
||||
|
||||
return send_message(cmd, sent, payload, sendonionmsg_done);
|
||||
}
|
||||
|
||||
struct connect_attempt {
|
||||
@@ -1378,9 +1367,12 @@ sendinvoice_after_connect(struct command *cmd,
|
||||
const jsmntok_t *result UNUSED,
|
||||
struct sent *sent)
|
||||
{
|
||||
u8 *rawinv = tal_arr(tmpctx, u8, 0);
|
||||
towire_tlv_invoice(&rawinv, sent->inv);
|
||||
return send_message(cmd, sent, "invoice", rawinv, prepare_inv_timeout);
|
||||
struct tlv_onionmsg_payload *payload = tlv_onionmsg_payload_new(sent);
|
||||
|
||||
payload->invoice = tal_arr(payload, u8, 0);
|
||||
towire_tlv_invoice(&payload->invoice, sent->inv);
|
||||
|
||||
return send_message(cmd, sent, payload, prepare_inv_timeout);
|
||||
}
|
||||
|
||||
static struct command_result *createinvoice_done(struct command *cmd,
|
||||
|
||||
Reference in New Issue
Block a user