mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
tx_roles: allow to be serialized btw processes
We're going to use this in a bit to pass role type btw dualopend/lightningd
This commit is contained in:
parent
739d3c7b47
commit
3eecbaee4d
@ -87,6 +87,7 @@ COMMON_SRC_NOGEN := \
|
||||
common/status_wire.c \
|
||||
common/subdaemon.c \
|
||||
common/timeout.c \
|
||||
common/tx_roles.c \
|
||||
common/type_to_string.c \
|
||||
common/utils.c \
|
||||
common/utxo.c \
|
||||
@ -108,8 +109,7 @@ COMMON_HEADERS_NOGEN := $(COMMON_SRC_NOGEN:.c=.h) \
|
||||
common/htlc.h \
|
||||
common/json_command.h \
|
||||
common/jsonrpc_errors.h \
|
||||
common/overflows.h \
|
||||
common/tx_roles.h
|
||||
common/overflows.h
|
||||
|
||||
COMMON_HEADERS_GEN := common/htlc_state_names_gen.h common/status_wiregen.h common/peer_status_wiregen.h common/scb_wiregen.h
|
||||
|
||||
|
18
common/tx_roles.c
Normal file
18
common/tx_roles.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include "config.h"
|
||||
#include <common/tx_roles.h>
|
||||
#include <wire/wire.h>
|
||||
|
||||
void towire_tx_role(u8 **pptr, const enum tx_role tx_role)
|
||||
{
|
||||
towire_u8(pptr, tx_role);
|
||||
}
|
||||
|
||||
enum tx_role fromwire_tx_role(const u8 **cursor, size_t *max)
|
||||
{
|
||||
u8 tx_role = fromwire_u8(cursor, max);
|
||||
if (tx_role >= NUM_TX_ROLES) {
|
||||
tx_role = TX_INITIATOR;
|
||||
fromwire_fail(cursor, max);
|
||||
}
|
||||
return tx_role;
|
||||
}
|
@ -2,6 +2,8 @@
|
||||
#define LIGHTNING_COMMON_TX_ROLES_H
|
||||
|
||||
#include "config.h"
|
||||
#include <ccan/short_types/short_types.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define NUM_TX_ROLES (TX_ACCEPTER + 1)
|
||||
enum tx_role {
|
||||
@ -9,4 +11,7 @@ enum tx_role {
|
||||
TX_ACCEPTER,
|
||||
};
|
||||
|
||||
|
||||
void towire_tx_role(u8 **pptr, const enum tx_role tx_role);
|
||||
enum tx_role fromwire_tx_role(const u8 **cursor, size_t *max);
|
||||
#endif /* LIGHTNING_COMMON_TX_ROLES_H */
|
||||
|
@ -126,6 +126,7 @@ LIGHTNINGD_COMMON_OBJS := \
|
||||
common/sphinx.o \
|
||||
common/status_wire.o \
|
||||
common/timeout.o \
|
||||
common/tx_roles.o \
|
||||
common/type_to_string.o \
|
||||
common/utils.o \
|
||||
common/utxo.o \
|
||||
|
@ -77,6 +77,7 @@ OPENINGD_COMMON_OBJS := \
|
||||
common/status_wire.o \
|
||||
common/status_wiregen.o \
|
||||
common/subdaemon.o \
|
||||
common/tx_roles.o \
|
||||
common/type_to_string.o \
|
||||
common/utils.o \
|
||||
common/utxo.o \
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <common/fee_states.h>
|
||||
#include <common/htlc_wire.h>
|
||||
#include <common/penalty_base.h>
|
||||
#include <common/tx_roles.h>
|
||||
#include <secp256k1.h>
|
||||
#include <wire/peer_wire.h>
|
||||
|
||||
|
Can't render this file because it has a wrong number of fields in line 16.
|
Loading…
Reference in New Issue
Block a user