mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-10 01:24:30 +01:00
plugins/offer: handle receiving an invoice in an onion_message.
And if we have a matching `send_invoice` offer, try to pay it! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <common/json_stream.h>
|
||||
#include <plugins/libplugin.h>
|
||||
#include <plugins/offers.h>
|
||||
#include <plugins/offers_inv_hook.h>
|
||||
#include <plugins/offers_invreq_hook.h>
|
||||
#include <plugins/offers_offer.h>
|
||||
|
||||
@@ -75,7 +76,7 @@ static struct command_result *onion_message_call(struct command *cmd,
|
||||
const char *buf,
|
||||
const jsmntok_t *params)
|
||||
{
|
||||
const jsmntok_t *om, *invreqtok;
|
||||
const jsmntok_t *om, *invreqtok, *invtok;
|
||||
|
||||
om = json_get_member(buf, params, "onion_message");
|
||||
|
||||
@@ -92,6 +93,14 @@ static struct command_result *onion_message_call(struct command *cmd,
|
||||
"invoice_request without reply_path");
|
||||
}
|
||||
|
||||
invtok = json_get_member(buf, om, "invoice");
|
||||
if (invtok) {
|
||||
const jsmntok_t *replytok;
|
||||
|
||||
replytok = json_get_member(buf, om, "reply_path");
|
||||
return handle_invoice(cmd, buf, invtok, replytok);
|
||||
}
|
||||
|
||||
return command_hook_success(cmd);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user