mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
7056018b15
The probability for a success forward of x amount on a channel is now computed as: P_success(x) = b * P_rene(x) where P_rene(x) is the probability distribution proposed by Rene Pickhardt with a uniform distribution on the known liquidity of the channel and 'b' is a new parameter we add in this PR, by the name of "base probability". The "base probability" represents the probability for a channel in the network choosen at random to be able to forward at least 1msat, ie. of being alive, non-depleted and with at least one HTLC slot. We don't know the value of 'b', but for the moment we assume that it is 0.98 and use that as default. As a consequence the probability cost becomes non-linear and non-convex because of the additional constant term: Cost(x) = - log P_success(x) = - log b - - log P_rene(x) = - log b + Cost_rene(x) We currently don't handle well base fees and neither this additional "base probability" but we can as a first approximation linearize the cost function in this way: Cost_linear(x) = (- log b)*x + Cost_rene_linear(x) Changelog-Added: renepay: Add a dev parameter to renepay that represents a constant probability of availability for all channels in the network. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
87 lines
2.0 KiB
C
87 lines
2.0 KiB
C
#ifndef LIGHTNING_PLUGINS_RENEPAY_PAYMENT_INFO_H
|
|
#define LIGHTNING_PLUGINS_RENEPAY_PAYMENT_INFO_H
|
|
|
|
/* Plain data payment information. */
|
|
|
|
#include "config.h"
|
|
#include <ccan/crypto/sha256/sha256.h>
|
|
#include <ccan/time/time.h>
|
|
#include <common/amount.h>
|
|
#include <common/node_id.h>
|
|
|
|
struct payment_info {
|
|
/* payment_hash is unique */
|
|
struct sha256 payment_hash;
|
|
|
|
/* invstring (bolt11 or bolt12) */
|
|
const char *invstr;
|
|
|
|
/* Description and labels, if any. */
|
|
const char *description, *label;
|
|
|
|
/* payment_secret, if specified by invoice. */
|
|
struct secret *payment_secret;
|
|
|
|
/* Payment metadata, if specified by invoice. */
|
|
const u8 *payment_metadata;
|
|
|
|
/* Extracted routehints */
|
|
const struct route_info **routehints;
|
|
|
|
/* How much, what, where */
|
|
struct node_id destination;
|
|
struct amount_msat amount;
|
|
|
|
/* === Payment attempt parameters === */
|
|
|
|
/* Limits on what routes we'll accept. */
|
|
struct amount_msat maxspend;
|
|
|
|
/* Max accepted HTLC delay.*/
|
|
unsigned int maxdelay;
|
|
|
|
/* TODO new feature: Maximum number of hops */
|
|
// see common/gossip_constants.h:8:#define ROUTING_MAX_HOPS 20
|
|
// int max_num_hops;
|
|
|
|
/* We promised this in pay() output */
|
|
struct timeabs start_time;
|
|
|
|
/* We stop trying after this time is reached. */
|
|
struct timeabs stop_time;
|
|
|
|
u32 final_cltv;
|
|
|
|
/* === Developer options === */
|
|
|
|
/* Penalty for base fee */
|
|
double base_fee_penalty;
|
|
|
|
/* Conversion from prob. cost to millionths */
|
|
double prob_cost_factor;
|
|
/* prob. cost = - prob_cost_factor * log prob. */
|
|
|
|
/* The probability for a channel to be able to forward an amount
|
|
* greater than zero. */
|
|
double base_prob_success;
|
|
|
|
/* Penalty for CLTV delays */
|
|
double delay_feefactor;
|
|
|
|
/* With these the effective linear fee cost is computed as
|
|
*
|
|
* linear fee cost =
|
|
* millionths
|
|
* + base_fee* base_fee_penalty
|
|
* +delay*delay_feefactor;
|
|
* */
|
|
|
|
/* The minimum acceptable prob. of success */
|
|
double min_prob_success;
|
|
|
|
/* --developer allows disabling shadow route */
|
|
bool use_shadow;
|
|
};
|
|
|
|
#endif /* LIGHTNING_PLUGINS_RENEPAY_PAYMENT_INFO_H */
|