From 8138ef136faf9243addbea7077b04279ac42fcd3 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 25 Apr 2020 15:04:03 +0200 Subject: [PATCH] plugin: Add a data backend for the new payment state-machine --- plugins/Makefile | 4 +-- plugins/libplugin-pay.c | 0 plugins/libplugin-pay.h | 68 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 plugins/libplugin-pay.c create mode 100644 plugins/libplugin-pay.h diff --git a/plugins/Makefile b/plugins/Makefile index ca51322e2..df23b4f36 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -13,8 +13,8 @@ PLUGIN_BCLI_OBJS := $(PLUGIN_BCLI_SRC:.c=.o) PLUGIN_KEYSEND_SRC := plugins/keysend.c PLUGIN_KEYSEND_OBJS := $(PLUGIN_KEYSEND_SRC:.c=.o) -PLUGIN_LIB_SRC := plugins/libplugin.c -PLUGIN_LIB_HEADER := plugins/libplugin.h +PLUGIN_LIB_SRC := plugins/libplugin.c plugins/libplugin-pay.c +PLUGIN_LIB_HEADER := plugins/libplugin.h plugins/libplugin-pay.h PLUGIN_LIB_OBJS := $(PLUGIN_LIB_SRC:.c=.o) PLUGIN_COMMON_OBJS := \ diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/libplugin-pay.h b/plugins/libplugin-pay.h new file mode 100644 index 000000000..7dcf7a38d --- /dev/null +++ b/plugins/libplugin-pay.h @@ -0,0 +1,68 @@ +#ifndef LIGHTNING_PLUGINS_LIBPLUGIN_PAY_H +#define LIGHTNING_PLUGINS_LIBPLUGIN_PAY_H +#include "config.h" + +#include + +enum route_hop_style { + ROUTE_HOP_LEGACY = 1, + ROUTE_HOP_TLV = 2, +}; + +struct route_hop { + struct short_channel_id channel_id; + int direction; + struct node_id nodeid; + struct amount_msat amount; + u32 delay; + struct pubkey *blinding; + enum route_hop_style style; +}; + +/* A parsed version of the possible outcomes that a sendpay / payment may + * result in. */ +struct payment_result { +}; + +/* Relevant information about a local channel so we can exclude them early. */ +struct channel_status { +}; + +struct payment { + + /* Real destination we want to route to */ + struct node_id *destination; + + /* Payment hash extracted from the invoice if any. */ + struct sha256 *payment_hash; + + u32 partid; + + /* Destination we should ask `getroute` for. This might differ from + * the above destination if we use rendez-vous routing of blinded + * paths to amend the route later in a mixin. */ + struct node_id *getroute_destination; + + /* Target amount to be delivered at the destination */ + struct amount_msat amount; + + /* tal_arr of route_hops we decoded from the `getroute` call. Exposed + * here so it can be amended by mixins. */ + struct route_hop *route; + + struct channel_status *peer_channels; + + /* The blockheight at which the payment attempt was + * started. */ + u32 start_block; + + struct timeabs start_time, end_time; + struct timeabs deadline; + + struct amount_msat extra_budget; + + struct short_channel_id *exclusions; + +}; + +#endif /* LIGHTNING_PLUGINS_LIBPLUGIN_PAY_H */