pay: Add notification for pay_success

This commit is contained in:
Christian Decker
2021-04-28 18:36:56 +02:00
committed by Rusty Russell
parent 98aa3c3da7
commit c6fd849aa3
5 changed files with 35 additions and 3 deletions

View File

@@ -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) {