Rusty Russell
8 years ago
3 changed files with 78 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||
#include <lightningd/channel_config.h> |
|||
#include <wire/wire.h> |
|||
|
|||
void towire_channel_config(u8 **pptr, const struct channel_config *config) |
|||
{ |
|||
towire_u64(pptr, config->dust_limit_satoshis); |
|||
towire_u64(pptr, config->max_htlc_value_in_flight_msat); |
|||
towire_u64(pptr, config->channel_reserve_satoshis); |
|||
towire_u32(pptr, config->minimum_depth); |
|||
towire_u32(pptr, config->htlc_minimum_msat); |
|||
towire_u16(pptr, config->to_self_delay); |
|||
towire_u16(pptr, config->max_accepted_htlcs); |
|||
} |
|||
|
|||
struct channel_config *fromwire_channel_config(const tal_t *ctx, |
|||
const u8 **ptr, size_t *max) |
|||
{ |
|||
struct channel_config *config = tal(ctx, struct channel_config); |
|||
|
|||
config->dust_limit_satoshis = fromwire_u64(ptr, max); |
|||
config->max_htlc_value_in_flight_msat = fromwire_u64(ptr, max); |
|||
config->channel_reserve_satoshis = fromwire_u64(ptr, max); |
|||
config->minimum_depth = fromwire_u32(ptr, max); |
|||
config->htlc_minimum_msat = fromwire_u32(ptr, max); |
|||
config->to_self_delay = fromwire_u16(ptr, max); |
|||
config->max_accepted_htlcs = fromwire_u16(ptr, max); |
|||
|
|||
if (!*ptr) |
|||
return tal_free(config); |
|||
return config; |
|||
} |
@ -0,0 +1,46 @@ |
|||
#ifndef LIGHTNING_LIGHTNINGD_CHANNEL_CONFIG_H |
|||
#define LIGHTNING_LIGHTNINGD_CHANNEL_CONFIG_H |
|||
#include "config.h" |
|||
#include <ccan/short_types/short_types.h> |
|||
#include <ccan/tal/tal.h> |
|||
|
|||
/* BOLT #2:
|
|||
* |
|||
* 1. type: 32 (`open_channel`) |
|||
* 2. data: |
|||
* * [8:temporary-channel-id] |
|||
* * [8:funding-satoshis] |
|||
* * [8:push-msat] |
|||
* * [8:dust-limit-satoshis] |
|||
* * [8:max-htlc-value-in-flight-msat] |
|||
* * [8:channel-reserve-satoshis] |
|||
* * [4:htlc-minimum-msat] |
|||
* * [4:feerate-per-kw] |
|||
* * [2:to-self-delay] |
|||
* * [2:max-accepted-htlcs] |
|||
*... |
|||
* 1. type: 33 (`accept_channel`) |
|||
* 2. data: |
|||
* * [8:temporary-channel-id] |
|||
* * [8:dust-limit-satoshis] |
|||
* * [8:max-htlc-value-in-flight-msat] |
|||
* * [8:channel-reserve-satoshis] |
|||
* * [4:minimum-depth] |
|||
* * [4:htlc-minimum-msat] |
|||
* * [2:to-self-delay] |
|||
* * [2:max-accepted-htlcs] |
|||
*/ |
|||
struct channel_config { |
|||
u64 dust_limit_satoshis; |
|||
u64 max_htlc_value_in_flight_msat; |
|||
u64 channel_reserve_satoshis; |
|||
u32 minimum_depth; |
|||
u32 htlc_minimum_msat; |
|||
u16 to_self_delay; |
|||
u16 max_accepted_htlcs; |
|||
}; |
|||
|
|||
void towire_channel_config(u8 **pptr, const struct channel_config *config); |
|||
struct channel_config *fromwire_channel_config(const tal_t *ctx, |
|||
const u8 **ptr, size_t *max); |
|||
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_CONFIG_H */ |
Loading…
Reference in new issue