mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pay: Rename some sendpay functions and fields to waitsendpay
Nearer to their actual purposes at this point. Also in preparation for next change.
This commit is contained in:
@@ -67,7 +67,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
|||||||
ld->alias = NULL;
|
ld->alias = NULL;
|
||||||
ld->rgb = NULL;
|
ld->rgb = NULL;
|
||||||
list_head_init(&ld->connects);
|
list_head_init(&ld->connects);
|
||||||
list_head_init(&ld->sendpay_commands);
|
list_head_init(&ld->waitsendpay_commands);
|
||||||
ld->wireaddrs = tal_arr(ld, struct wireaddr, 0);
|
ld->wireaddrs = tal_arr(ld, struct wireaddr, 0);
|
||||||
ld->portnum = DEFAULT_PORT;
|
ld->portnum = DEFAULT_PORT;
|
||||||
timers_init(&ld->timers, time_mono());
|
timers_init(&ld->timers, time_mono());
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ struct lightningd {
|
|||||||
|
|
||||||
struct wallet *wallet;
|
struct wallet *wallet;
|
||||||
|
|
||||||
/* Outstanding sendpay commands. */
|
/* Outstanding waitsendpay commands. */
|
||||||
struct list_head sendpay_commands;
|
struct list_head waitsendpay_commands;
|
||||||
|
|
||||||
/* Maintained by invoices.c */
|
/* Maintained by invoices.c */
|
||||||
struct invoices *invoices;
|
struct invoices *invoices;
|
||||||
|
|||||||
@@ -50,19 +50,19 @@ add_payment_waiter(const tal_t *cxt,
|
|||||||
pc->payment_hash = *payment_hash;
|
pc->payment_hash = *payment_hash;
|
||||||
pc->cb = cb;
|
pc->cb = cb;
|
||||||
pc->cbarg = cbarg;
|
pc->cbarg = cbarg;
|
||||||
list_add(&ld->sendpay_commands, &pc->list);
|
list_add(&ld->waitsendpay_commands, &pc->list);
|
||||||
tal_add_destructor(pc, destroy_sendpay_command);
|
tal_add_destructor(pc, destroy_sendpay_command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Caller responsible for freeing ctx. */
|
/* Caller responsible for freeing ctx. */
|
||||||
static void sendpay_resolve(const tal_t *ctx,
|
static void waitsendpay_resolve(const tal_t *ctx,
|
||||||
struct lightningd *ld,
|
struct lightningd *ld,
|
||||||
const struct sha256 *payment_hash,
|
const struct sha256 *payment_hash,
|
||||||
const struct sendpay_result *result)
|
const struct sendpay_result *result)
|
||||||
{
|
{
|
||||||
struct sendpay_command *pc;
|
struct sendpay_command *pc;
|
||||||
struct sendpay_command *next;
|
struct sendpay_command *next;
|
||||||
list_for_each_safe(&ld->sendpay_commands, pc, next, list) {
|
list_for_each_safe(&ld->waitsendpay_commands, pc, next, list) {
|
||||||
if (!structeq(payment_hash, &pc->payment_hash))
|
if (!structeq(payment_hash, &pc->payment_hash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ sendpay_result_success(const tal_t *ctx,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendpay_success(struct lightningd *ld,
|
static void payment_trigger_success(struct lightningd *ld,
|
||||||
const struct sha256 *payment_hash,
|
const struct sha256 *payment_hash,
|
||||||
const struct preimage *payment_preimage)
|
const struct preimage *payment_preimage)
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ static void sendpay_success(struct lightningd *ld,
|
|||||||
|
|
||||||
result = sendpay_result_success(tmpctx, payment_preimage);
|
result = sendpay_result_success(tmpctx, payment_preimage);
|
||||||
|
|
||||||
sendpay_resolve(tmpctx, ld, payment_hash, result);
|
waitsendpay_resolve(tmpctx, ld, payment_hash, result);
|
||||||
|
|
||||||
tal_free(tmpctx);
|
tal_free(tmpctx);
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ sendpay_result_route_failure(const tal_t *ctx,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendpay_route_failure(struct lightningd *ld,
|
static void payment_route_failure(struct lightningd *ld,
|
||||||
const struct sha256 *payment_hash,
|
const struct sha256 *payment_hash,
|
||||||
bool retry_plausible,
|
bool retry_plausible,
|
||||||
struct routing_failure *fail,
|
struct routing_failure *fail,
|
||||||
@@ -132,7 +132,7 @@ static void sendpay_route_failure(struct lightningd *ld,
|
|||||||
onionreply,
|
onionreply,
|
||||||
details);
|
details);
|
||||||
|
|
||||||
sendpay_resolve(tmpctx, ld, payment_hash, result);
|
waitsendpay_resolve(tmpctx, ld, payment_hash, result);
|
||||||
|
|
||||||
tal_free(tmpctx);
|
tal_free(tmpctx);
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ void payment_succeeded(struct lightningd *ld, struct htlc_out *hout,
|
|||||||
{
|
{
|
||||||
wallet_payment_set_status(ld->wallet, &hout->payment_hash,
|
wallet_payment_set_status(ld->wallet, &hout->payment_hash,
|
||||||
PAYMENT_COMPLETE, rval);
|
PAYMENT_COMPLETE, rval);
|
||||||
sendpay_success(ld, &hout->payment_hash, rval);
|
payment_trigger_success(ld, &hout->payment_hash, rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return NULL if the wrapped onion error message has no
|
/* Return NULL if the wrapped onion error message has no
|
||||||
@@ -474,7 +474,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
|
|||||||
|
|
||||||
|
|
||||||
/* Report to client. */
|
/* Report to client. */
|
||||||
sendpay_route_failure(ld, &hout->payment_hash,
|
payment_route_failure(ld, &hout->payment_hash,
|
||||||
retry_plausible, fail, hout->failuremsg,
|
retry_plausible, fail, hout->failuremsg,
|
||||||
failmsg);
|
failmsg);
|
||||||
tal_free(tmpctx);
|
tal_free(tmpctx);
|
||||||
@@ -752,7 +752,7 @@ json_sendpay_success(struct command *cmd,
|
|||||||
command_success(cmd, response);
|
command_success(cmd, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void json_sendpay_on_resolve(const struct sendpay_result *r,
|
static void json_waitsendpay_on_resolve(const struct sendpay_result *r,
|
||||||
void *vcmd)
|
void *vcmd)
|
||||||
{
|
{
|
||||||
struct command *cmd = (struct command*) vcmd;
|
struct command *cmd = (struct command*) vcmd;
|
||||||
@@ -823,6 +823,13 @@ static void json_sendpay_on_resolve(const struct sendpay_result *r,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void json_sendpay_on_resolve(const struct sendpay_result* r,
|
||||||
|
void *vcmd)
|
||||||
|
{
|
||||||
|
struct command *cmd = (struct command*) vcmd;
|
||||||
|
json_waitsendpay_on_resolve(r, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
static void json_sendpay(struct command *cmd,
|
static void json_sendpay(struct command *cmd,
|
||||||
const char *buffer, const jsmntok_t *params)
|
const char *buffer, const jsmntok_t *params)
|
||||||
{
|
{
|
||||||
@@ -968,7 +975,7 @@ static void json_waitsendpay(struct command *cmd, const char *buffer,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wait_payment(cmd, cmd->ld, &rhash, &json_sendpay_on_resolve, cmd))
|
if (!wait_payment(cmd, cmd->ld, &rhash, &json_waitsendpay_on_resolve, cmd))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (timeouttok)
|
if (timeouttok)
|
||||||
|
|||||||
Reference in New Issue
Block a user