mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 02:27:51 +01:00
46cc7c281e
As we add more features, the current code is insufficient. 1. Keep an array of single feature bits, for easy switching on and off. 2. Create feature_offered() which checks for both compulsory and optional variants. 3. Invert requires_unsupported_features() and unsupported_features() which tend to be double-negative, all_supported_features() and features_supported(). 4. Move single feature definition from wire/peer_wire.h to common/features.h. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
34 lines
1.0 KiB
C
34 lines
1.0 KiB
C
#ifndef LIGHTNING_COMMON_FEATURES_H
|
|
#define LIGHTNING_COMMON_FEATURES_H
|
|
#include "config.h"
|
|
#include <ccan/short_types/short_types.h>
|
|
#include <ccan/tal/tal.h>
|
|
|
|
/* Returns true if we're OK with all these offered features. */
|
|
bool features_supported(const u8 *gfeatures, const u8 *lfeatures);
|
|
|
|
/* For sending our features: tal_len() returns length. */
|
|
u8 *get_offered_global_features(const tal_t *ctx);
|
|
u8 *get_offered_local_features(const tal_t *ctx);
|
|
|
|
/* Is this feature bit requested? (Either compulsory or optional) */
|
|
bool feature_offered(const u8 *features, size_t f);
|
|
|
|
#define COMPULSORY_FEATURE(x) (x)
|
|
#define OPTIONAL_FEATURE(x) ((x)+1)
|
|
|
|
/* BOLT #9:
|
|
*
|
|
* ## Assigned `localfeatures` flags
|
|
*...
|
|
* | Bits | Name |...
|
|
* | 0/1 | `option-data-loss-protect` |...
|
|
* | 3 | `initial_routing_sync` |...
|
|
* | 4/5 | `option_upfront_shutdown_script` |...
|
|
*/
|
|
#define LOCAL_DATA_LOSS_PROTECT 0
|
|
#define LOCAL_INITIAL_ROUTING_SYNC 2
|
|
#define LOCAL_UPFRONT_SHUTDOWN_SCRIPT 4
|
|
|
|
#endif /* LIGHTNING_COMMON_FEATURES_H */
|