forked from LaurentMazare/btc-ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.mli
191 lines (165 loc) · 3.38 KB
/
message.mli
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
open Core.Std
module Version : sig
type t =
{ version : int
; services : Int64.t
; timestamp : Time.t
; addr_recv_services : Int64.t
; addr_recv_addr : Address.t
; addr_recv_port : int
; addr_trans_services : Int64.t
; addr_trans_addr : Address.t
; addr_trans_port : int
; nonce : Int64.t
; user_agent : string
; start_height : int
; relay : int
} with sexp, fields
end
module Ping : sig
type t =
{ nonce : Int64.t
} with sexp, fields
end
module Pong : sig
type t =
{ nonce : Int64.t
} with sexp, fields
end
module Addr : sig
type elem =
{ time : Time.t
; services : Int64.t
; ip_address : Address.t
; port : int
} with sexp, fields
type t = elem list with sexp
end
module Inv : sig
type type_identifier =
| Msg_tx
| Msg_block
| Msg_filtered_block
| Unknown of int
with sexp
type elem =
{ type_identifier : type_identifier
; hash : Hash.t
} with sexp, fields
type t = elem list with sexp
end
module Headers : sig
type t = Header.t list with sexp
end
module Reject : sig
module Code : sig
type t =
| Invalid_message
| Invalid_block
| Invalid_transaction
| Outdated_block_version
| Outdated_version
| Double_spend
| Multiple_version
| Non_standard_transaction
| Below_dust_threshold
| Not_enough_fee_or_priority
| Wrong_block_chain
with sexp
end
type t =
{ message : string
; code : Code.t
; reason : string
; extra_data : string
} with sexp, fields
end
module Getblocks : sig
type t =
{ version : int
; block_header_hashes : Hash.t list
; stop_hash : Hash.t option
} with sexp
end
module Notfound : sig
type t = Inv.t with sexp
end
module Getdata : sig
type t = Inv.t with sexp
end
module Getheaders : sig
type t = Getblocks.t with sexp
end
module Outpoint : sig
type t =
{ hash : Hash.t
; index : int
} with sexp
end
module Transaction_input : sig
type t =
{ previous_output : Outpoint.t
; signature_script : string
; sequence : int
} with sexp
end
module Transaction_output : sig
type t =
{ value : Int64.t
; pk_script : string
} with sexp
end
module Lock_time : sig
type t =
| Time of Time.t
| Block_height of int
end
module Raw_transaction : sig
type t =
{ tx_in : Transaction_input.t list
; tx_out : Transaction_output.t list
; lock_time : Lock_time.t
} with sexp
end
module Block : sig
type t =
{ block_header : Header.t
; txns : Raw_transaction.t list
} with sexp
end
module Merkleblock : sig
type t =
{ block_header : Header.t
; transaction_count : int
; hashes : Hash.t list
; flags : string
} with sexp
end
type t =
| Version of Version.t
| Verack
| Addr of Addr.t
| Getaddr
| Ping of Ping.t
| Pong of Pong.t
| Inv of Inv.t
| Notfound of Notfound.t
| Getheaders of Getheaders.t
| Getblocks of Getblocks.t
| Headers of Headers.t
| Reject of Reject.t
| Getdata of Getdata.t
| Tx of Raw_transaction.t
| Block of Block.t
| Mempool
| Merkleblock of Merkleblock.t
with sexp
val handle_chunk
: Bigstring.t
-> pos : int
-> len : int
-> f:((t, string) Result.t -> unit)
-> [ `Consumed of int ]
val version : unit -> t
val to_string : t -> string
val getheaders : from_hash:Hash.t -> stop_hash:Hash.t option -> t