diff --git a/lightningd/pay.c b/lightningd/pay.c index c1f5ccaaf..db93876b7 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -632,6 +632,7 @@ send_payment(const tal_t *ctx, const struct sha256 *rhash, const struct route_hop *route, u64 msatoshi, + const char *description TAKES, void (*cb)(const struct sendpay_result *, void*), void *cbarg) { @@ -792,7 +793,10 @@ send_payment(const tal_t *ctx, payment->path_secrets = tal_steal(payment, path_secrets); payment->route_nodes = tal_steal(payment, ids); payment->route_channels = tal_steal(payment, channels); - payment->description = NULL; + if (description != NULL) + payment->description = tal_strdup(payment, description); + else + payment->description = NULL; /* We write this into db when HTLC is actually sent. */ wallet_payment_setup(ld->wallet, payment); @@ -1021,8 +1025,10 @@ static void json_sendpay(struct command *cmd, } } + /* FIXME(cdecker): Add a description parameter to sendpay */ if (send_payment(cmd, cmd->ld, &rhash, route, msatoshi ? *msatoshi : route[n_hops-1].amount, + NULL, &json_sendpay_on_resolve, cmd)) command_still_pending(cmd); } diff --git a/lightningd/pay.h b/lightningd/pay.h index 6895e0a1e..b6203550a 100644 --- a/lightningd/pay.h +++ b/lightningd/pay.h @@ -65,8 +65,10 @@ bool send_payment(const tal_t *ctx, const struct sha256 *rhash, const struct route_hop *route, u64 msatoshi, + const char *description TAKES, void (*cb)(const struct sendpay_result *, void*), void *cbarg); + /* Wait for a previous send_payment to complete in definite * success or failure. If the given context is freed before * the callback is called, then the callback will no longer diff --git a/lightningd/payalgo.c b/lightningd/payalgo.c index c89ede199..df5dd0a83 100644 --- a/lightningd/payalgo.c +++ b/lightningd/payalgo.c @@ -133,6 +133,9 @@ struct pay { * is mainly useful for tiny transfers for which the leveraged fee would * be dominated by the forwarding fee. */ u64 exemptfee; + + /* The description from the bolt11 string */ + const char *description; }; static struct routing_failure * @@ -502,6 +505,7 @@ static void json_pay_getroute_reply(struct subd *gossip UNUSED, send_payment(pay->try_parent, pay->cmd->ld, &pay->payment_hash, route, pay->msatoshi, + pay->description, &json_pay_sendpay_resume, pay); } @@ -691,6 +695,7 @@ static void json_pay(struct command *cmd, /* Start with no failures */ list_head_init(&pay->pay_failures); pay->in_sendpay = false; + pay->description = b11->description; /* Initiate payment */ if (json_pay_try(pay))