mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
d8c06dccac
We have various functions to convert to a string, rename them all so we can count on fmt_X being the formatter for struct X, and make them all return `char *`. Sometimes they existed but were private, sometimes they had a different name. Most take a pointer, but simple types pass by copy: short_channel_id, amount_msat and amount_sat. The following public functions changed: 1. psbt_to_b64 -> fmt_wally_psbt. 2. pubkey_to_hexstr -> fmt_pubkey. 3. short_channel_id_to_str -> fmt_short_channel_id (scid by copy now!) 4. fmt_signature -> fmt_secp256k1_ecdsa_signature 5. fmt_amount_sat/fmt_amount_msat pass copy not pointer, return non-const char *. 6. node_id_to_hexstr -> fmt_node_id Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
47 lines
1.5 KiB
C
47 lines
1.5 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>
|
|
#include <ccan/tal/tal.h>
|
|
|
|
struct bitcoin_outpoint;
|
|
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);
|
|
|
|
/* For v1 channel establishment */
|
|
void derive_channel_id(struct channel_id *channel_id,
|
|
const struct bitcoin_outpoint *outpoint);
|
|
|
|
/* For v1 channel establishment */
|
|
void temporary_channel_id(struct channel_id *channel_id);
|
|
|
|
/* For v2 channel establishment */
|
|
void derive_channel_id_v2(struct channel_id *channel_id,
|
|
const struct pubkey *basepoint_1,
|
|
const struct pubkey *basepoint_2);
|
|
|
|
/* For v2 channel establishment */
|
|
void derive_tmp_channel_id(struct channel_id *channel_id,
|
|
const struct pubkey *opener_basepoint);
|
|
|
|
char *fmt_channel_id(const tal_t *ctx, const struct channel_id *channel_id);
|
|
|
|
/* Marshalling/unmarshalling functions */
|
|
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id);
|
|
bool fromwire_channel_id(const u8 **cursor, size_t *max,
|
|
struct channel_id *channel_id);
|
|
#endif /* LIGHTNING_COMMON_CHANNEL_ID_H */
|