2021-06-10 22:30:19 +02:00
|
|
|
#ifndef LIGHTNING_COMMON_LEASE_RATES_H
|
|
|
|
#define LIGHTNING_COMMON_LEASE_RATES_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdbool.h>
|
2021-07-11 08:59:42 +02:00
|
|
|
#include <wire/peer_wire.h>
|
2021-06-10 22:30:19 +02:00
|
|
|
|
2021-06-08 23:42:45 +02:00
|
|
|
struct amount_msat;
|
|
|
|
struct amount_sat;
|
2021-06-10 22:30:19 +02:00
|
|
|
struct lease_rates;
|
2021-06-14 21:22:46 +02:00
|
|
|
struct pubkey;
|
|
|
|
struct sha256;
|
|
|
|
|
|
|
|
#define LEASE_RATE_DURATION 4032
|
2021-06-10 22:30:19 +02:00
|
|
|
|
2021-07-11 08:59:42 +02:00
|
|
|
bool lease_rates_empty(const struct lease_rates *rates);
|
2021-06-08 23:42:45 +02:00
|
|
|
|
2021-07-11 08:59:42 +02:00
|
|
|
void lease_rates_get_commitment(const struct pubkey *pubkey,
|
2021-06-14 21:22:46 +02:00
|
|
|
u32 lease_expiry,
|
|
|
|
u32 chan_fee_msat,
|
|
|
|
u16 chan_fee_ppt,
|
|
|
|
struct sha256 *sha);
|
|
|
|
|
2021-07-11 08:59:42 +02:00
|
|
|
/* lease_rates_eq: has 2 padding bytes after third field */
|
|
|
|
STRUCTEQ_DEF(lease_rates, 2,
|
|
|
|
funding_weight,
|
|
|
|
lease_fee_basis,
|
|
|
|
channel_fee_max_proportional_thousandths,
|
|
|
|
lease_fee_base_sat,
|
|
|
|
channel_fee_max_base_msat);
|
2021-07-02 23:00:17 +02:00
|
|
|
|
2021-07-11 08:59:42 +02:00
|
|
|
bool lease_rates_calc_fee(const struct lease_rates *rates,
|
2021-06-15 00:49:57 +02:00
|
|
|
struct amount_sat accept_funding_sats,
|
|
|
|
struct amount_sat requested_sats,
|
|
|
|
u32 onchain_feerate,
|
|
|
|
struct amount_sat *fee);
|
|
|
|
|
2021-06-08 23:42:45 +02:00
|
|
|
WARN_UNUSED_RESULT bool lease_rates_set_chan_fee_base_msat(struct lease_rates *rates, struct amount_msat amt);
|
|
|
|
|
|
|
|
WARN_UNUSED_RESULT bool lease_rates_set_lease_fee_sat(struct lease_rates *rates, struct amount_sat amt);
|
2021-07-02 23:00:17 +02:00
|
|
|
|
|
|
|
/* Convert 'lease_rates' into a hexstring */
|
|
|
|
char *lease_rates_tohex(const tal_t *ctx, const struct lease_rates *rates);
|
|
|
|
|
|
|
|
/* Convert 'lease_rates' from a hexstring */
|
2021-07-11 08:59:42 +02:00
|
|
|
struct lease_rates *lease_rates_fromhex(const tal_t *ctx,
|
|
|
|
const char *hexdata, size_t len);
|
2021-07-02 23:00:17 +02:00
|
|
|
|
|
|
|
/* Format a string describing the passed in lease_rates */
|
|
|
|
char *lease_rates_fmt(const tal_t *ctx, const struct lease_rates *rates);
|
2021-06-10 22:30:19 +02:00
|
|
|
#endif /* LIGHTNING_COMMON_LEASE_RATES_H */
|