core-lightning/common/sciddir_or_pubkey.h
Rusty Russell e30c835f72 common: add sciddir_or_pubkey type.
This is proposed to be added to bolt 12, so we need a type to
represent it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-12 19:11:43 -05:00

31 lines
1.1 KiB
C

#ifndef LIGHTNING_COMMON_SCIDDIR_OR_PUBKEY_H
#define LIGHTNING_COMMON_SCIDDIR_OR_PUBKEY_H
#include "config.h"
#include <bitcoin/pubkey.h>
#include <bitcoin/short_channel_id.h>
struct node_id;
struct sciddir_or_pubkey {
bool is_pubkey;
/* Only valid if is_pubkey is true */
struct pubkey pubkey;
/* Only valid if is_pubkey is false */
struct short_channel_id_dir scidd;
};
void towire_sciddir_or_pubkey(u8 **pptr,
const struct sciddir_or_pubkey *sciddpk);
void fromwire_sciddir_or_pubkey(const u8 **cursor, size_t *max,
struct sciddir_or_pubkey *sciddpk);
void sciddir_or_pubkey_from_pubkey(struct sciddir_or_pubkey *sciddpk,
const struct pubkey *pubkey);
WARN_UNUSED_RESULT
bool sciddir_or_pubkey_from_node_id(struct sciddir_or_pubkey *sciddpk,
const struct node_id *node_id);
void sciddir_or_pubkey_from_scidd(struct sciddir_or_pubkey *sciddpk,
const struct short_channel_id_dir *scidd);
const char *fmt_sciddir_or_pubkey(const tal_t *ctx,
const struct sciddir_or_pubkey *sciddpk);
#endif /* LIGHTNING_COMMON_SCIDDIR_OR_PUBKEY_H */