1use chik_streamable_macro::{streamable, Streamable};
2
3use crate::Coin;
4use crate::CoinState;
5use crate::FeeEstimateGroup;
6use crate::HeaderBlock;
7use crate::Program;
8use crate::SpendBundle;
9use crate::{Bytes, Bytes32};
10
11#[streamable(message)]
12pub struct RequestPuzzleSolution {
13 coin_name: Bytes32,
14 height: u32,
15}
16
17#[streamable]
18pub struct PuzzleSolutionResponse {
19 coin_name: Bytes32,
20 height: u32,
21 puzzle: Program,
22 solution: Program,
23}
24
25#[streamable(message)]
26pub struct RespondPuzzleSolution {
27 response: PuzzleSolutionResponse,
28}
29
30#[streamable(message)]
31pub struct RejectPuzzleSolution {
32 coin_name: Bytes32,
33 height: u32,
34}
35
36#[streamable(message)]
37pub struct SendTransaction {
38 transaction: SpendBundle,
39}
40
41#[streamable(message)]
42pub struct TransactionAck {
43 txid: Bytes32,
44 status: u8, error: Option<String>,
46}
47
48#[streamable(message)]
49pub struct NewPeakWallet {
50 header_hash: Bytes32,
51 height: u32,
52 weight: u128,
53 fork_point_with_previous_peak: u32,
54}
55
56#[streamable(message)]
57pub struct RequestBlockHeader {
58 height: u32,
59}
60
61#[streamable(message)]
62pub struct RespondBlockHeader {
63 header_block: HeaderBlock,
64}
65
66#[streamable(message)]
67pub struct RejectHeaderRequest {
68 height: u32,
69}
70
71#[streamable(message)]
72pub struct RequestRemovals {
73 height: u32,
74 header_hash: Bytes32,
75 coin_names: Option<Vec<Bytes32>>,
76}
77
78#[streamable(message)]
79pub struct RespondRemovals {
80 height: u32,
81 header_hash: Bytes32,
82 coins: Vec<(Bytes32, Option<Coin>)>,
83 proofs: Option<Vec<(Bytes32, Bytes)>>,
84}
85
86#[streamable(message)]
87pub struct RejectRemovalsRequest {
88 height: u32,
89 header_hash: Bytes32,
90}
91
92#[streamable(message)]
93pub struct RequestAdditions {
94 height: u32,
95 header_hash: Option<Bytes32>,
96 puzzle_hashes: Option<Vec<Bytes32>>,
97}
98
99#[streamable(message)]
100pub struct RespondAdditions {
101 height: u32,
102 header_hash: Bytes32,
103 coins: Vec<(Bytes32, Vec<Coin>)>,
104 proofs: Option<Vec<(Bytes32, Bytes, Option<Bytes>)>>,
105}
106
107#[streamable(message)]
108pub struct RejectAdditionsRequest {
109 height: u32,
110 header_hash: Bytes32,
111}
112
113#[streamable(message)]
114pub struct RespondBlockHeaders {
115 start_height: u32,
116 end_height: u32,
117 header_blocks: Vec<HeaderBlock>,
118}
119
120#[streamable(message)]
121pub struct RejectBlockHeaders {
122 start_height: u32,
123 end_height: u32,
124}
125
126#[streamable(message)]
127pub struct RequestBlockHeaders {
128 start_height: u32,
129 end_height: u32,
130 return_filter: bool,
131}
132
133#[streamable(message)]
134pub struct RequestHeaderBlocks {
135 start_height: u32,
136 end_height: u32,
137}
138
139#[streamable(message)]
140pub struct RejectHeaderBlocks {
141 start_height: u32,
142 end_height: u32,
143}
144
145#[streamable(message)]
146pub struct RespondHeaderBlocks {
147 start_height: u32,
148 end_height: u32,
149 header_blocks: Vec<HeaderBlock>,
150}
151
152#[streamable(message)]
153pub struct RegisterForPhUpdates {
154 puzzle_hashes: Vec<Bytes32>,
155 min_height: u32,
156}
157
158#[streamable(message)]
159pub struct RespondToPhUpdates {
160 puzzle_hashes: Vec<Bytes32>,
161 min_height: u32,
162 coin_states: Vec<CoinState>,
163}
164
165#[streamable(message)]
166pub struct RegisterForCoinUpdates {
167 coin_ids: Vec<Bytes32>,
168 min_height: u32,
169}
170
171#[streamable(message)]
172pub struct RespondToCoinUpdates {
173 coin_ids: Vec<Bytes32>,
174 min_height: u32,
175 coin_states: Vec<CoinState>,
176}
177
178#[streamable(message)]
179pub struct CoinStateUpdate {
180 height: u32,
181 fork_height: u32,
182 peak_hash: Bytes32,
183 items: Vec<CoinState>,
184}
185
186#[streamable(message)]
187pub struct RequestChildren {
188 coin_name: Bytes32,
189}
190
191#[streamable(message)]
192pub struct RespondChildren {
193 coin_states: Vec<CoinState>,
194}
195
196#[streamable(message)]
197pub struct RequestSesInfo {
198 start_height: u32,
199 end_height: u32,
200}
201
202#[streamable(message)]
203pub struct RespondSesInfo {
204 reward_chain_hash: Vec<Bytes32>,
205 heights: Vec<Vec<u32>>,
206}
207
208#[streamable(message)]
209pub struct RequestFeeEstimates {
210 time_targets: Vec<u64>,
211}
212
213#[streamable(message)]
214pub struct RespondFeeEstimates {
215 estimates: FeeEstimateGroup,
216}
217
218#[streamable(message)]
219pub struct RequestRemovePuzzleSubscriptions {
220 puzzle_hashes: Option<Vec<Bytes32>>,
221}
222
223#[streamable(message)]
224pub struct RespondRemovePuzzleSubscriptions {
225 puzzle_hashes: Vec<Bytes32>,
226}
227
228#[streamable(message)]
229pub struct RequestRemoveCoinSubscriptions {
230 coin_ids: Option<Vec<Bytes32>>,
231}
232
233#[streamable(message)]
234pub struct RespondRemoveCoinSubscriptions {
235 coin_ids: Vec<Bytes32>,
236}
237
238#[streamable]
239pub struct CoinStateFilters {
240 include_spent: bool,
241 include_unspent: bool,
242 include_hinted: bool,
243 min_amount: u64,
244}
245
246#[streamable(message)]
247pub struct RequestPuzzleState {
248 puzzle_hashes: Vec<Bytes32>,
249 previous_height: Option<u32>,
250 header_hash: Bytes32,
251 filters: CoinStateFilters,
252 subscribe_when_finished: bool,
253}
254
255#[streamable(message)]
256pub struct RespondPuzzleState {
257 puzzle_hashes: Vec<Bytes32>,
258 height: u32,
259 header_hash: Bytes32,
260 is_finished: bool,
261 coin_states: Vec<CoinState>,
262}
263
264#[streamable(message)]
265pub struct RejectPuzzleState {
266 reason: RejectStateReason,
267}
268
269#[streamable(message)]
270pub struct RequestCoinState {
271 coin_ids: Vec<Bytes32>,
272 previous_height: Option<u32>,
273 header_hash: Bytes32,
274 subscribe: bool,
275}
276
277#[streamable(message)]
278pub struct RespondCoinState {
279 coin_ids: Vec<Bytes32>,
280 coin_states: Vec<CoinState>,
281}
282
283#[streamable(message)]
284pub struct RejectCoinState {
285 reason: RejectStateReason,
286}
287
288#[cfg(feature = "py-bindings")]
289use chik_py_streamable_macro::{PyJsonDict, PyStreamable};
290
291#[repr(u8)]
292#[cfg_attr(feature = "py-bindings", derive(PyJsonDict, PyStreamable))]
293#[derive(Streamable, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
294#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
295pub enum RejectStateReason {
296 Reorg = 0,
297 ExceededSubscriptionLimit = 1,
298}
299
300#[cfg(feature = "py-bindings")]
301impl chik_traits::ChikToPython for RejectStateReason {
302 fn to_python<'a>(&self, py: pyo3::Python<'a>) -> pyo3::PyResult<pyo3::Bound<'a, pyo3::PyAny>> {
303 Ok(pyo3::IntoPyObject::into_pyobject(*self as u8, py)?
304 .clone()
305 .into_any())
306 }
307}
308
309#[repr(u8)]
310#[cfg_attr(feature = "py-bindings", derive(PyJsonDict, PyStreamable))]
311#[derive(Streamable, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
312#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
313pub enum MempoolRemoveReason {
314 Conflict = 1,
315 BlockInclusion = 2,
316 PoolFull = 3,
317 Expired = 4,
318}
319
320#[cfg(feature = "py-bindings")]
321impl chik_traits::ChikToPython for MempoolRemoveReason {
322 fn to_python<'a>(&self, py: pyo3::Python<'a>) -> pyo3::PyResult<pyo3::Bound<'a, pyo3::PyAny>> {
323 Ok(pyo3::IntoPyObject::into_pyobject(*self as u8, py)?
324 .clone()
325 .into_any())
326 }
327}
328
329#[streamable(no_serde)]
330pub struct RemovedMempoolItem {
331 transaction_id: Bytes32,
332 reason: MempoolRemoveReason,
333}
334
335#[streamable(message)]
336pub struct MempoolItemsAdded {
337 transaction_ids: Vec<Bytes32>,
338}
339
340#[streamable(message)]
341pub struct MempoolItemsRemoved {
342 removed_items: Vec<RemovedMempoolItem>,
343}
344
345#[streamable(message)]
346pub struct RequestCostInfo {}
347
348#[streamable(message)]
349pub struct RespondCostInfo {
350 max_transaction_cost: u64,
351 max_block_cost: u64,
352 max_mempool_cost: u64,
353 mempool_cost: u64,
354 mempool_fee: u64,
355 bump_fee_per_cost: u8,
356}