core-lightning/lightningd/pay.h
Rusty Russell 6bfebf4307 lightningd: refactor payment failed.
Don't assume we have an outgoing HTLC at this level.

Note that previously we didn't save the failed onion unless it was
unparsable: we keep that both for space savings and because our
`waitsendpay` logic assumes that when it fetches from the db if
there's a failonion it was unparsable!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-27 13:57:50 +11:00

58 lines
1.7 KiB
C

#ifndef LIGHTNING_LIGHTNINGD_PAY_H
#define LIGHTNING_LIGHTNINGD_PAY_H
#include "config.h"
#include <common/errcode.h>
#include <wallet/wallet.h>
struct htlc_out;
struct lightningd;
struct onionreply;
struct preimage;
struct sha256;
struct json_stream;
struct wallet_payment;
struct routing_failure;
void payment_succeeded(struct lightningd *ld,
const struct sha256 *payment_hash,
u64 partid, u64 groupid,
const struct preimage *rval);
/* failmsg or failonion must be set. */
void payment_failed(struct lightningd *ld,
struct logger *log,
const struct sha256 *payment_hash,
u64 partid, u64 groupid,
const struct onionreply *failonion,
const u8 *failmsg,
const char *localfail);
/* This json will be also used in 'sendpay_success' notifictaion. */
void json_add_payment_fields(struct json_stream *response,
const struct wallet_payment *t);
/* This json will be also used in 'sendpay_failure' notifictaion. */
void json_sendpay_fail_fields(struct json_stream *js,
const struct wallet_payment *t,
enum jsonrpc_errcode pay_errcode,
const struct onionreply *onionreply,
const struct routing_failure *fail);
/* wait() hooks in here */
void sendpay_index_deleted(struct lightningd *ld,
const struct sha256 *payment_hash,
u64 partid,
u64 groupid,
enum payment_status status);
u64 sendpay_index_created(struct lightningd *ld,
const struct sha256 *payment_hash,
u64 partid,
u64 groupid,
enum payment_status status);
u64 sendpay_index_update_status(struct lightningd *ld,
const struct sha256 *payment_hash,
u64 partid,
u64 groupid,
enum payment_status status);
#endif /* LIGHTNING_LIGHTNINGD_PAY_H */