mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
pay: Add notification for pay_success
This commit is contained in:
committed by
Rusty Russell
parent
98aa3c3da7
commit
c6fd849aa3
@@ -377,6 +377,10 @@ static const struct plugin_hook hooks[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const char *notification_topics[] = {
|
||||
"pay_success",
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct feature_set features;
|
||||
@@ -388,5 +392,5 @@ int main(int argc, char *argv[])
|
||||
|
||||
plugin_main(argv, init, PLUGIN_STATIC, true, &features, commands,
|
||||
ARRAY_SIZE(commands), NULL, 0, hooks, ARRAY_SIZE(hooks),
|
||||
NULL, 0, NULL);
|
||||
notification_topics, ARRAY_SIZE(notification_topics), NULL);
|
||||
}
|
||||
|
||||
@@ -1844,6 +1844,8 @@ static void payment_finished(struct payment *p)
|
||||
struct json_stream *ret;
|
||||
struct command *cmd = p->cmd;
|
||||
const char *msg;
|
||||
struct json_stream *n;
|
||||
struct payment *root = payment_root(p);
|
||||
|
||||
/* Either none of the leaf attempts succeeded yet, or we have a
|
||||
* preimage. */
|
||||
@@ -1885,6 +1887,12 @@ static void payment_finished(struct payment *p)
|
||||
|
||||
json_add_string(ret, "status", "complete");
|
||||
|
||||
n = plugin_notification_start(p->plugin, "pay_success");
|
||||
json_add_sha256(n, "payment_hash", p->payment_hash);
|
||||
if (root->invstring != NULL)
|
||||
json_add_string(n, "bolt11", root->invstring);
|
||||
plugin_notification_end(p->plugin, n);
|
||||
|
||||
if (command_finished(cmd, ret)) {/* Ignore result. */}
|
||||
return;
|
||||
} else if (p->aborterror != NULL) {
|
||||
|
||||
@@ -2193,12 +2193,17 @@ static const struct plugin_command commands[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const char *notification_topics[] = {
|
||||
"pay_success",
|
||||
"pay_failure",
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
setup_locale();
|
||||
plugin_main(argv, init, PLUGIN_RESTARTABLE, true, NULL, commands,
|
||||
ARRAY_SIZE(commands), NULL, 0, NULL, 0,
|
||||
NULL, 0,
|
||||
notification_topics, ARRAY_SIZE(notification_topics),
|
||||
plugin_option("disable-mpp", "flag",
|
||||
"Disable multi-part payments.",
|
||||
flag_option, &disablempp),
|
||||
|
||||
Reference in New Issue
Block a user