-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRLP.h
95 lines (79 loc) · 3.22 KB
/
RLP.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Copyright (c) 2016-2018 . All Rights Reserved.
*/
#ifndef RLP_RLP_H
#define RLP_RLP_H
#include <stdbool.h>
#include <stdint.h>
#include "utils.h"
#define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; pb_byte_t bytes[n]; }
typedef PB_BYTES_ARRAY_T(32) EthereumSignTx_nonce_t;
typedef PB_BYTES_ARRAY_T(32) EthereumSignTx_gas_price_t;
typedef PB_BYTES_ARRAY_T(32) EthereumSignTx_gas_limit_t;
typedef PB_BYTES_ARRAY_T(20) EthereumSignTx_to_t;
typedef PB_BYTES_ARRAY_T(32) EthereumSignTx_value_t;
typedef PB_BYTES_ARRAY_T(1024) EthereumSignTx_data_initial_chunk_t;
typedef struct _EthereumSignTx {
EthereumSignTx_nonce_t nonce;
EthereumSignTx_gas_price_t gas_price;
EthereumSignTx_gas_limit_t gas_limit;
EthereumSignTx_to_t to;
EthereumSignTx_value_t value;
EthereumSignTx_data_initial_chunk_t data_initial_chunk;
} EthereumSignTx;
typedef PB_BYTES_ARRAY_T(64) EthereumTxRequest_signature_r_t;
typedef PB_BYTES_ARRAY_T(64) EthereumTxRequest_signature_s_t;
typedef struct _EthereumTxRequest {
uint32_t data_length;
uint32_t signature_v;
EthereumTxRequest_signature_r_t signature_r;
EthereumTxRequest_signature_s_t signature_s;
} EthereumSig;
typedef PB_BYTES_ARRAY_T(33) EncodeEthereumSignTx_nonce_t;
typedef PB_BYTES_ARRAY_T(33) EncodeEthereumSignTx_gas_price_t;
typedef PB_BYTES_ARRAY_T(33) EncodeEthereumSignTx_gas_limit_t;
typedef PB_BYTES_ARRAY_T(21) EncodeEthereumSignTx_to_t;
typedef PB_BYTES_ARRAY_T(33) EncodeEthereumSignTx_value_t;
typedef PB_BYTES_ARRAY_T(1025) EncodeEthereumSignTx_data_initial_chunk_t;
typedef struct _EncodeEthereumSignTx {
pb_size_t address_n_count;
uint32_t address_n[8];
bool has_nonce;
EncodeEthereumSignTx_nonce_t nonce;
bool has_gas_price;
EncodeEthereumSignTx_gas_price_t gas_price;
bool has_gas_limit;
EncodeEthereumSignTx_gas_limit_t gas_limit;
bool has_to;
EncodeEthereumSignTx_to_t to;
bool has_value;
EncodeEthereumSignTx_value_t value;
bool has_data_initial_chunk;
EncodeEthereumSignTx_data_initial_chunk_t data_initial_chunk;
bool has_data_length;
uint32_t data_length;
bool has_chain_id;
uint32_t chain_id;
/* @@protoc_insertion_point(struct:EthereumSignTx) */
} EncodeEthereumSignTx;
typedef PB_BYTES_ARRAY_T(33) EncodeEthereumTxRequest_signature_r_t;
typedef PB_BYTES_ARRAY_T(33) EncodeEthereumTxRequest_signature_s_t;
typedef struct _EncodeEthereumTxRequest {
bool has_data_length;
uint32_t data_length;
bool has_signature_v;
uint32_t signature_v;
bool has_signature_r;
EncodeEthereumTxRequest_signature_r_t signature_r;
bool has_signature_s;
EncodeEthereumTxRequest_signature_s_t signature_s;
/* @@protoc_insertion_point(struct:EthereumTxRequest) */
} EncodeEthereumTxRequest;
void wallet_encode_byte(pb_byte_t singleByte, pb_byte_t *new_bytes);
void wallet_encode_short(uint16_t singleShort, pb_byte_t *new_bytes);
int wallet_encode_list(EncodeEthereumSignTx *new_msg, EncodeEthereumTxRequest *new_tx,
uint64_t *rawTx);
void wallet_encode_element(pb_byte_t *bytes, pb_size_t size,
pb_byte_t *new_bytes, pb_size_t *new_size, bool remove_leading_zeros);
void wallet_encode_int(uint32_t singleInt, pb_byte_t *new_bytes);
#endif //RLP_RLP_H