mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
renepay: payment state machine (mods)
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.
This commit is contained in:
parent
4b9fe23293
commit
6766acbcdf
1048
plugins/renepay/mods.c
Normal file
1048
plugins/renepay/mods.c
Normal file
File diff suppressed because it is too large
Load Diff
36
plugins/renepay/mods.h
Normal file
36
plugins/renepay/mods.h
Normal file
@ -0,0 +1,36 @@
|
||||
#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 */
|
Loading…
Reference in New Issue
Block a user