Skip to main content

datalayer_driver/
types.rs

1pub use crate::xch_server_coin::XchServerCoin;
2use crate::DataStore;
3use chia_bls::{PublicKey, SecretKey};
4pub use chia_protocol::*;
5pub use chia_puzzle_types::{EveProof, LineageProof, Proof};
6
7pub struct SimulatorPuzzle {
8    pub puzzle_hash: Bytes32,
9    pub puzzle_reveal: Program,
10}
11
12pub struct BlsPair {
13    pub sk: SecretKey,
14    pub pk: PublicKey,
15    pub puzzle_hash: Bytes32,
16}
17
18#[derive(Clone, Debug)]
19pub struct SuccessResponse {
20    pub coin_spends: Vec<CoinSpend>,
21    pub new_datastore: DataStore,
22}
23
24pub struct UnspentCoinsResponse {
25    pub coins: Vec<Coin>,
26    pub last_height: u32,
27    pub last_header_hash: Bytes32,
28}
29
30impl From<UnspentCoinStates> for UnspentCoinsResponse {
31    fn from(unspent_coin_states: UnspentCoinStates) -> Self {
32        Self {
33            coins: unspent_coin_states
34                .coin_states
35                .into_iter()
36                .map(|cs| cs.coin)
37                .collect(),
38            last_height: unspent_coin_states.last_height,
39            last_header_hash: unspent_coin_states.last_header_hash,
40        }
41    }
42}
43
44pub struct UnspentCoinStates {
45    pub coin_states: Vec<CoinState>,
46    pub last_height: u32,
47    pub last_header_hash: Bytes32,
48}
49pub fn coin_records_to_states(
50    coin_records: Vec<chia_wallet_sdk::coinset::CoinRecord>,
51) -> Vec<CoinState> {
52    coin_records
53        .into_iter()
54        .map(|coin_record| CoinState {
55            coin: coin_record.coin,
56            spent_height: Some(coin_record.spent_block_index),
57            created_height: Some(coin_record.confirmed_block_index),
58        })
59        .collect()
60}