mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
pay: Pass description to send_payment
Extract the description from the bolt11 string and store it in the database.
This commit is contained in:
committed by
Rusty Russell
parent
60e0eec967
commit
ab223c2ade
@@ -632,6 +632,7 @@ send_payment(const tal_t *ctx,
|
|||||||
const struct sha256 *rhash,
|
const struct sha256 *rhash,
|
||||||
const struct route_hop *route,
|
const struct route_hop *route,
|
||||||
u64 msatoshi,
|
u64 msatoshi,
|
||||||
|
const char *description TAKES,
|
||||||
void (*cb)(const struct sendpay_result *, void*),
|
void (*cb)(const struct sendpay_result *, void*),
|
||||||
void *cbarg)
|
void *cbarg)
|
||||||
{
|
{
|
||||||
@@ -792,6 +793,9 @@ send_payment(const tal_t *ctx,
|
|||||||
payment->path_secrets = tal_steal(payment, path_secrets);
|
payment->path_secrets = tal_steal(payment, path_secrets);
|
||||||
payment->route_nodes = tal_steal(payment, ids);
|
payment->route_nodes = tal_steal(payment, ids);
|
||||||
payment->route_channels = tal_steal(payment, channels);
|
payment->route_channels = tal_steal(payment, channels);
|
||||||
|
if (description != NULL)
|
||||||
|
payment->description = tal_strdup(payment, description);
|
||||||
|
else
|
||||||
payment->description = NULL;
|
payment->description = NULL;
|
||||||
|
|
||||||
/* We write this into db when HTLC is actually sent. */
|
/* We write this into db when HTLC is actually sent. */
|
||||||
@@ -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,
|
if (send_payment(cmd, cmd->ld, &rhash, route,
|
||||||
msatoshi ? *msatoshi : route[n_hops-1].amount,
|
msatoshi ? *msatoshi : route[n_hops-1].amount,
|
||||||
|
NULL,
|
||||||
&json_sendpay_on_resolve, cmd))
|
&json_sendpay_on_resolve, cmd))
|
||||||
command_still_pending(cmd);
|
command_still_pending(cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,10 @@ bool send_payment(const tal_t *ctx,
|
|||||||
const struct sha256 *rhash,
|
const struct sha256 *rhash,
|
||||||
const struct route_hop *route,
|
const struct route_hop *route,
|
||||||
u64 msatoshi,
|
u64 msatoshi,
|
||||||
|
const char *description TAKES,
|
||||||
void (*cb)(const struct sendpay_result *, void*),
|
void (*cb)(const struct sendpay_result *, void*),
|
||||||
void *cbarg);
|
void *cbarg);
|
||||||
|
|
||||||
/* Wait for a previous send_payment to complete in definite
|
/* Wait for a previous send_payment to complete in definite
|
||||||
* success or failure. If the given context is freed before
|
* success or failure. If the given context is freed before
|
||||||
* the callback is called, then the callback will no longer
|
* the callback is called, then the callback will no longer
|
||||||
|
|||||||
@@ -133,6 +133,9 @@ struct pay {
|
|||||||
* is mainly useful for tiny transfers for which the leveraged fee would
|
* is mainly useful for tiny transfers for which the leveraged fee would
|
||||||
* be dominated by the forwarding fee. */
|
* be dominated by the forwarding fee. */
|
||||||
u64 exemptfee;
|
u64 exemptfee;
|
||||||
|
|
||||||
|
/* The description from the bolt11 string */
|
||||||
|
const char *description;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct routing_failure *
|
static struct routing_failure *
|
||||||
@@ -502,6 +505,7 @@ static void json_pay_getroute_reply(struct subd *gossip UNUSED,
|
|||||||
send_payment(pay->try_parent,
|
send_payment(pay->try_parent,
|
||||||
pay->cmd->ld, &pay->payment_hash, route,
|
pay->cmd->ld, &pay->payment_hash, route,
|
||||||
pay->msatoshi,
|
pay->msatoshi,
|
||||||
|
pay->description,
|
||||||
&json_pay_sendpay_resume, pay);
|
&json_pay_sendpay_resume, pay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,6 +695,7 @@ static void json_pay(struct command *cmd,
|
|||||||
/* Start with no failures */
|
/* Start with no failures */
|
||||||
list_head_init(&pay->pay_failures);
|
list_head_init(&pay->pay_failures);
|
||||||
pay->in_sendpay = false;
|
pay->in_sendpay = false;
|
||||||
|
pay->description = b11->description;
|
||||||
|
|
||||||
/* Initiate payment */
|
/* Initiate payment */
|
||||||
if (json_pay_try(pay))
|
if (json_pay_try(pay))
|
||||||
|
|||||||
Reference in New Issue
Block a user