2016-11-29 20:51:50 +01:00
|
|
|
#ifndef LIGHTNING_WIRE_WIRE_H
|
|
|
|
#define LIGHTNING_WIRE_WIRE_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <ccan/short_types/short_types.h>
|
2020-05-16 03:29:05 +02:00
|
|
|
#include <ccan/tal/tal.h>
|
2022-09-18 02:20:50 +02:00
|
|
|
#include <common/jsonrpc_errors.h>
|
2021-10-12 13:16:37 +02:00
|
|
|
#include <common/wireaddr.h>
|
2017-10-26 05:01:19 +02:00
|
|
|
#include <secp256k1_recovery.h>
|
2016-11-29 20:51:50 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2017-08-18 06:43:52 +02:00
|
|
|
struct ripemd160;
|
2020-05-16 03:29:05 +02:00
|
|
|
struct sha256;
|
2018-02-26 03:32:58 +01:00
|
|
|
struct siphash_seed;
|
2016-11-29 20:51:50 +01:00
|
|
|
|
2018-02-08 02:25:12 +01:00
|
|
|
/* Makes generate-wire.py work */
|
|
|
|
typedef char wirestring;
|
2020-12-05 03:19:54 +01:00
|
|
|
typedef char utf8;
|
2018-02-08 02:25:12 +01:00
|
|
|
|
2017-01-04 04:39:21 +01:00
|
|
|
/* Read the type; returns -1 if not long enough. cursor is a tal ptr. */
|
|
|
|
int fromwire_peektype(const u8 *cursor);
|
2020-05-19 03:05:40 +02:00
|
|
|
void *fromwire_fail(const u8 **cursor, size_t *max);
|
2017-01-04 04:39:21 +01:00
|
|
|
|
2016-11-29 20:51:50 +01:00
|
|
|
void towire(u8 **pptr, const void *data, size_t len);
|
2017-01-25 00:33:42 +01:00
|
|
|
void towire_secp256k1_ecdsa_signature(u8 **pptr,
|
|
|
|
const secp256k1_ecdsa_signature *signature);
|
2017-10-26 05:01:19 +02:00
|
|
|
void towire_secp256k1_ecdsa_recoverable_signature(u8 **pptr,
|
|
|
|
const secp256k1_ecdsa_recoverable_signature *rsig);
|
2016-11-29 20:51:50 +01:00
|
|
|
void towire_sha256(u8 **pptr, const struct sha256 *sha256);
|
2017-08-18 06:43:52 +02:00
|
|
|
void towire_ripemd160(u8 **pptr, const struct ripemd160 *ripemd);
|
2016-11-29 20:51:50 +01:00
|
|
|
void towire_u8(u8 **pptr, u8 v);
|
|
|
|
void towire_u16(u8 **pptr, u16 v);
|
|
|
|
void towire_u32(u8 **pptr, u32 v);
|
|
|
|
void towire_u64(u8 **pptr, u64 v);
|
2023-05-05 21:10:53 +02:00
|
|
|
void towire_s8(u8 **pptr, s8 v);
|
|
|
|
void towire_s16(u8 **pptr, s16 v);
|
|
|
|
void towire_s32(u8 **pptr, s32 v);
|
|
|
|
void towire_s64(u8 **pptr, s64 v);
|
2019-07-18 07:17:16 +02:00
|
|
|
void towire_tu16(u8 **pptr, u16 v);
|
|
|
|
void towire_tu32(u8 **pptr, u32 v);
|
|
|
|
void towire_tu64(u8 **pptr, u64 v);
|
2017-01-04 04:39:20 +01:00
|
|
|
void towire_pad(u8 **pptr, size_t num);
|
2017-01-04 04:39:21 +01:00
|
|
|
void towire_bool(u8 **pptr, bool v);
|
2022-09-18 02:20:50 +02:00
|
|
|
void towire_jsonrpc_errcode(u8 **pptr, enum jsonrpc_errcode v);
|
2016-11-29 20:51:50 +01:00
|
|
|
|
|
|
|
void towire_u8_array(u8 **pptr, const u8 *arr, size_t num);
|
2020-12-05 03:19:54 +01:00
|
|
|
void towire_utf8_array(u8 **pptr, const char *arr, size_t num);
|
2016-11-29 20:51:50 +01:00
|
|
|
|
2018-02-08 02:25:12 +01:00
|
|
|
void towire_wirestring(u8 **pptr, const char *str);
|
2018-02-26 03:32:58 +01:00
|
|
|
void towire_siphash_seed(u8 **cursor, const struct siphash_seed *seed);
|
2018-01-04 18:19:02 +01:00
|
|
|
|
2016-11-29 20:51:50 +01:00
|
|
|
const u8 *fromwire(const u8 **cursor, size_t *max, void *copy, size_t n);
|
|
|
|
u8 fromwire_u8(const u8 **cursor, size_t *max);
|
|
|
|
u16 fromwire_u16(const u8 **cursor, size_t *max);
|
|
|
|
u32 fromwire_u32(const u8 **cursor, size_t *max);
|
|
|
|
u64 fromwire_u64(const u8 **cursor, size_t *max);
|
2023-05-05 21:10:53 +02:00
|
|
|
s8 fromwire_s8(const u8 **cursor, size_t *max);
|
|
|
|
s16 fromwire_s16(const u8 **cursor, size_t *max);
|
|
|
|
s32 fromwire_s32(const u8 **cursor, size_t *max);
|
|
|
|
s64 fromwire_s64(const u8 **cursor, size_t *max);
|
2019-07-18 07:17:16 +02:00
|
|
|
u16 fromwire_tu16(const u8 **cursor, size_t *max);
|
|
|
|
u32 fromwire_tu32(const u8 **cursor, size_t *max);
|
|
|
|
u64 fromwire_tu64(const u8 **cursor, size_t *max);
|
2017-01-04 04:39:21 +01:00
|
|
|
bool fromwire_bool(const u8 **cursor, size_t *max);
|
2022-09-18 02:20:50 +02:00
|
|
|
enum jsonrpc_errcode fromwire_jsonrpc_errcode(const u8 **cursor, size_t *max);
|
2017-01-25 00:33:42 +01:00
|
|
|
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor, size_t *max,
|
|
|
|
secp256k1_ecdsa_signature *signature);
|
2017-10-26 05:01:19 +02:00
|
|
|
void fromwire_secp256k1_ecdsa_recoverable_signature(const u8 **cursor,
|
|
|
|
size_t *max,
|
|
|
|
secp256k1_ecdsa_recoverable_signature *rsig);
|
2016-11-29 20:51:50 +01:00
|
|
|
void fromwire_sha256(const u8 **cursor, size_t *max, struct sha256 *sha256);
|
2017-08-18 06:43:52 +02:00
|
|
|
void fromwire_ripemd160(const u8 **cursor, size_t *max, struct ripemd160 *ripemd);
|
2017-01-04 04:39:20 +01:00
|
|
|
void fromwire_pad(const u8 **cursor, size_t *max, size_t num);
|
2016-11-29 20:51:50 +01:00
|
|
|
|
2017-02-21 05:45:28 +01:00
|
|
|
void fromwire_u8_array(const u8 **cursor, size_t *max, u8 *arr, size_t num);
|
2020-12-05 03:19:54 +01:00
|
|
|
void fromwire_utf8_array(const u8 **cursor, size_t *max, char *arr, size_t num);
|
2020-03-04 05:13:00 +01:00
|
|
|
u8 *fromwire_tal_arrn(const tal_t *ctx,
|
|
|
|
const u8 **cursor, size_t *max, size_t num);
|
2018-02-08 02:25:12 +01:00
|
|
|
char *fromwire_wirestring(const tal_t *ctx, const u8 **cursor, size_t *max);
|
2018-02-26 03:32:58 +01:00
|
|
|
void fromwire_siphash_seed(const u8 **cursor, size_t *max,
|
|
|
|
struct siphash_seed *seed);
|
2016-11-29 20:51:50 +01:00
|
|
|
#endif /* LIGHTNING_WIRE_WIRE_H */
|