Browse Source

pay: Pass description to send_payment

Extract the description from the bolt11 string and store it in the database.
ppa-0.6.1
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
ab223c2ade
  1. 8
      lightningd/pay.c
  2. 2
      lightningd/pay.h
  3. 5
      lightningd/payalgo.c

8
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);
}

2
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

5
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))

Loading…
Cancel
Save