mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
6766acbcdf
Add a new implementation of the payment state machine. This is based in the `pay` plugin concept of payment modifiers, but here we take it to the next level. The payment goes through a virtual machine that includes calling functions and evaluating conditions.
37 lines
1.2 KiB
C
37 lines
1.2 KiB
C
#ifndef LIGHTNING_PLUGINS_RENEPAY_MODS_H
|
|
#define LIGHTNING_PLUGINS_RENEPAY_MODS_H
|
|
|
|
#include "config.h"
|
|
|
|
struct payment;
|
|
struct command_result;
|
|
|
|
struct payment_modifier {
|
|
const char *name;
|
|
struct command_result *(*step_cb)(struct payment *p);
|
|
};
|
|
|
|
struct payment_condition {
|
|
const char *name;
|
|
bool (*condition_cb)(const struct payment *p);
|
|
};
|
|
|
|
struct command_result *payment_continue(struct payment *p);
|
|
|
|
#define REGISTER_PAYMENT_MODIFIER(name, step_cb) \
|
|
struct payment_modifier name##_pay_mod = { \
|
|
stringify(name), \
|
|
typesafe_cb_cast(struct command_result * (*)(struct payment *), \
|
|
struct command_result * (*)(struct payment *), \
|
|
step_cb), \
|
|
};
|
|
|
|
#define REGISTER_PAYMENT_CONDITION(name, condition_cb) \
|
|
struct payment_condition name##_pay_cond = { \
|
|
stringify(name), \
|
|
typesafe_cb_cast(bool (*)(const struct payment *), \
|
|
bool (*)(const struct payment *), condition_cb), \
|
|
};
|
|
|
|
#endif /* LIGHTNING_PLUGINS_RENEPAY_MODS_H */
|