core-lightning/common/channel_id.h
niftynei 42a38b9808 channel_id: add v2 channel_id derivtion helper
v2 of channel open uses the channel revocation basepoints to calculate
the channel_id, instead of the funding_txid + outnum

Moving away from the funding_txid opens the way for splicing + rbf
2020-09-09 19:54:20 +09:30

34 lines
1.1 KiB
C

#ifndef LIGHTNING_COMMON_CHANNEL_ID_H
#define LIGHTNING_COMMON_CHANNEL_ID_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <ccan/structeq/structeq.h>
struct bitcoin_txid;
struct pubkey;
/* BOLT #2:
*
* This message introduces the `channel_id` to identify the channel. It's
* derived from the funding transaction by combining the `funding_txid` and
* the `funding_output_index`, using big-endian exclusive-OR
* (i.e. `funding_output_index` alters the last 2 bytes).
*/
struct channel_id {
u8 id[32];
};
/* Define channel_id_eq (no padding) */
STRUCTEQ_DEF(channel_id, 0, id);
void derive_channel_id(struct channel_id *channel_id,
const struct bitcoin_txid *txid, u16 txout);
void derive_channel_id_v2(struct channel_id *channel_id,
const struct pubkey *basepoint_1,
const struct pubkey *basepoint_2);
/* Marshalling/unmarshalling functions */
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id);
void fromwire_channel_id(const u8 **cursor, size_t *max,
struct channel_id *channel_id);
#endif /* LIGHTNING_COMMON_CHANNEL_ID_H */