forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protobuf_convert.h
52 lines (45 loc) · 1.83 KB
/
protobuf_convert.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef LIGHTNING_PROTOBUF_CONVERT_H
#define LIGHTNING_PROTOBUF_CONVERT_H
#include "config.h"
#include "lightning.pb-c.h"
#include <ccan/tal/tal.h>
#include <secp256k1.h>
#include <stdbool.h>
/* Convert to-from protobuf to internal representation. */
struct signature;
Signature *signature_to_proto(const tal_t *ctx,
secp256k1_context *secpctx,
const struct signature *sig);
bool proto_to_signature(secp256k1_context *secpctx,
const Signature *pb,
struct signature *sig);
/* Convert to-from protobuf to internal representation. */
struct pubkey;
BitcoinPubkey *pubkey_to_proto(const tal_t *ctx,
secp256k1_context *secpctx,
const struct pubkey *key);
bool proto_to_pubkey(secp256k1_context *secpctx,
const BitcoinPubkey *pb, struct pubkey *key);
/* Useful helper for allocating & populating a protobuf Sha256Hash */
struct sha256;
Sha256Hash *sha256_to_proto(const tal_t *ctx, const struct sha256 *hash);
void proto_to_sha256(const Sha256Hash *pb, struct sha256 *hash);
struct rval {
u8 r[32];
};
Rval *rval_to_proto(const tal_t *ctx, const struct rval *r);
void proto_to_rval(const Rval *pb, struct rval *r);
struct rel_locktime;
struct abs_locktime;
bool proto_to_rel_locktime(const Locktime *l, struct rel_locktime *locktime);
bool proto_to_abs_locktime(const Locktime *l, struct abs_locktime *locktime);
Locktime *rel_locktime_to_proto(const tal_t *ctx,
const struct rel_locktime *locktime);
Locktime *abs_locktime_to_proto(const tal_t *ctx,
const struct abs_locktime *locktime);
/* Get allocator so decoded protobuf will be tal off it. */
struct ProtobufCAllocator *make_prototal(const tal_t *ctx);
/* Now steal object off of allocator (and free prototal) */
void steal_from_prototal(const tal_t *ctx, struct ProtobufCAllocator *prototal,
const void *pb);
#endif /* LIGHTNING_PROTOBUF_CONVERT_H */