mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
pay: generalize payment_succeeded().
We'll want this without an htlc_out, for self-pay. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
07e00d50c6
commit
c377edfbd1
4 changed files with 15 additions and 9 deletions
|
@ -326,23 +326,25 @@ static void tell_waiters_success(struct lightningd *ld,
|
|||
notify_sendpay_success(ld, payment);
|
||||
}
|
||||
|
||||
void payment_succeeded(struct lightningd *ld, struct htlc_out *hout,
|
||||
void payment_succeeded(struct lightningd *ld,
|
||||
const struct sha256 *payment_hash,
|
||||
u64 partid, u64 groupid,
|
||||
const struct preimage *rval)
|
||||
{
|
||||
struct wallet_payment *payment;
|
||||
|
||||
wallet_payment_set_status(ld->wallet, &hout->payment_hash,
|
||||
hout->partid, hout->groupid,
|
||||
wallet_payment_set_status(ld->wallet, payment_hash,
|
||||
partid, groupid,
|
||||
PAYMENT_COMPLETE, rval);
|
||||
payment = wallet_payment_by_hash(tmpctx, ld->wallet,
|
||||
&hout->payment_hash,
|
||||
hout->partid, hout->groupid);
|
||||
payment_hash,
|
||||
partid, groupid);
|
||||
assert(payment);
|
||||
|
||||
if (payment->local_invreq_id)
|
||||
wallet_invoice_request_mark_used(ld->wallet->db,
|
||||
payment->local_invreq_id);
|
||||
tell_waiters_success(ld, &hout->payment_hash, payment);
|
||||
tell_waiters_success(ld, payment_hash, payment);
|
||||
}
|
||||
|
||||
/* Return a struct routing_failure for an immediate failure
|
||||
|
|
|
@ -12,7 +12,9 @@ struct json_stream;
|
|||
struct wallet_payment;
|
||||
struct routing_failure;
|
||||
|
||||
void payment_succeeded(struct lightningd *ld, struct htlc_out *hout,
|
||||
void payment_succeeded(struct lightningd *ld,
|
||||
const struct sha256 *payment_hash,
|
||||
u64 partid, u64 groupid,
|
||||
const struct preimage *rval);
|
||||
|
||||
/* hout->failmsg or hout->failonion must be set. */
|
||||
|
|
|
@ -1462,7 +1462,7 @@ static void fulfill_our_htlc_out(struct channel *channel, struct htlc_out *hout,
|
|||
hout->msat);
|
||||
|
||||
if (hout->am_origin)
|
||||
payment_succeeded(ld, hout, preimage);
|
||||
payment_succeeded(ld, &hout->payment_hash, hout->partid, hout->groupid, preimage);
|
||||
else if (hout->in) {
|
||||
fulfill_htlc(hout->in, preimage);
|
||||
wallet_forwarded_payment_add(ld->wallet, hout->in,
|
||||
|
|
|
@ -621,7 +621,9 @@ void payment_failed(struct lightningd *ld UNNEEDED, const struct htlc_out *hout
|
|||
void payment_store(struct lightningd *ld UNNEEDED, struct wallet_payment *payment UNNEEDED)
|
||||
{ fprintf(stderr, "payment_store called!\n"); abort(); }
|
||||
/* Generated stub for payment_succeeded */
|
||||
void payment_succeeded(struct lightningd *ld UNNEEDED, struct htlc_out *hout UNNEEDED,
|
||||
void payment_succeeded(struct lightningd *ld UNNEEDED,
|
||||
const struct sha256 *payment_hash UNNEEDED,
|
||||
u64 partid UNNEEDED, u64 groupid UNNEEDED,
|
||||
const struct preimage *rval UNNEEDED)
|
||||
{ fprintf(stderr, "payment_succeeded called!\n"); abort(); }
|
||||
/* Generated stub for peer_restart_dualopend */
|
||||
|
|
Loading…
Add table
Reference in a new issue