2016-11-29 20:51:50 +01:00
|
|
|
#ifndef LIGHTNING_WIRE_WIRE_H
|
|
|
|
#define LIGHTNING_WIRE_WIRE_H
|
|
|
|
#include "config.h"
|
2017-02-21 05:45:28 +01:00
|
|
|
#include <bitcoin/privkey.h>
|
2016-11-29 20:51:50 +01:00
|
|
|
#include <bitcoin/pubkey.h>
|
2017-02-21 05:45:28 +01:00
|
|
|
#include <bitcoin/shadouble.h>
|
2016-11-29 20:51:50 +01:00
|
|
|
#include <bitcoin/signature.h>
|
|
|
|
#include <ccan/crypto/sha256/sha256.h>
|
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2017-03-02 13:21:49 +01:00
|
|
|
struct short_channel_id {
|
2016-11-29 20:51:50 +01:00
|
|
|
u32 blocknum;
|
|
|
|
u32 txnum : 24;
|
|
|
|
u8 outnum : 8;
|
|
|
|
};
|
2017-03-02 13:21:49 +01:00
|
|
|
struct channel_id {
|
|
|
|
u8 id[32];
|
|
|
|
};
|
2016-11-29 20:51:50 +01:00
|
|
|
struct ipv6 {
|
|
|
|
u8 addr[16];
|
|
|
|
};
|
2017-03-29 12:56:15 +02:00
|
|
|
struct preimage;
|
2016-11-29 20:51:50 +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);
|
|
|
|
|
2016-11-29 20:51:50 +01:00
|
|
|
void towire(u8 **pptr, const void *data, size_t len);
|
2016-12-02 08:41:06 +01:00
|
|
|
void towire_pubkey(u8 **pptr, const struct pubkey *pubkey);
|
2017-02-21 05:45:28 +01:00
|
|
|
void towire_privkey(u8 **pptr, const struct privkey *privkey);
|
2017-01-25 00:33:42 +01:00
|
|
|
void towire_secp256k1_ecdsa_signature(u8 **pptr,
|
|
|
|
const secp256k1_ecdsa_signature *signature);
|
2016-11-29 20:51:50 +01:00
|
|
|
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id);
|
2017-03-02 13:21:49 +01:00
|
|
|
void towire_short_channel_id(u8 **pptr,
|
|
|
|
const struct short_channel_id *short_channel_id);
|
2016-11-29 20:51:50 +01:00
|
|
|
void towire_sha256(u8 **pptr, const struct sha256 *sha256);
|
2017-02-21 05:45:28 +01:00
|
|
|
void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d);
|
2017-03-29 12:56:15 +02:00
|
|
|
void towire_preimage(u8 **pptr, const struct preimage *preimage);
|
2016-11-29 20:51:50 +01:00
|
|
|
void towire_ipv6(u8 **pptr, const struct ipv6 *ipv6);
|
|
|
|
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);
|
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);
|
2016-11-29 20:51:50 +01:00
|
|
|
|
|
|
|
void towire_u8_array(u8 **pptr, const u8 *arr, size_t num);
|
|
|
|
|
|
|
|
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);
|
2017-01-04 04:39:21 +01:00
|
|
|
bool fromwire_bool(const u8 **cursor, size_t *max);
|
2017-02-21 05:45:28 +01:00
|
|
|
void fromwire_privkey(const u8 **cursor, size_t *max, struct privkey *privkey);
|
2016-12-02 08:41:06 +01:00
|
|
|
void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey);
|
2017-01-25 00:33:42 +01:00
|
|
|
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor, size_t *max,
|
|
|
|
secp256k1_ecdsa_signature *signature);
|
2016-11-29 20:51:50 +01:00
|
|
|
void fromwire_channel_id(const u8 **cursor, size_t *max,
|
|
|
|
struct channel_id *channel_id);
|
2017-03-02 13:21:49 +01:00
|
|
|
void fromwire_short_channel_id(const u8 **cursor, size_t *max,
|
|
|
|
struct short_channel_id *short_channel_id);
|
2016-11-29 20:51:50 +01:00
|
|
|
void fromwire_sha256(const u8 **cursor, size_t *max, struct sha256 *sha256);
|
2017-02-21 05:45:28 +01:00
|
|
|
void fromwire_sha256_double(const u8 **cursor, size_t *max,
|
|
|
|
struct sha256_double *sha256d);
|
2017-03-29 12:56:15 +02:00
|
|
|
void fromwire_preimage(const u8 **cursor, size_t *max, struct preimage *preimage);
|
2016-11-29 20:51:50 +01:00
|
|
|
void fromwire_ipv6(const u8 **cursor, size_t *max, struct ipv6 *ipv6);
|
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);
|
2016-11-29 20:51:50 +01:00
|
|
|
#endif /* LIGHTNING_WIRE_WIRE_H */
|