chia_sdk_bindings/
address.rs

1use bindy::Result;
2use chia_protocol::Bytes32;
3
4#[derive(Clone)]
5pub struct Address {
6    pub puzzle_hash: Bytes32,
7    pub prefix: String,
8}
9
10impl Address {
11    pub fn encode(&self) -> Result<String> {
12        Ok(chia_sdk_utils::Address::new(self.puzzle_hash, self.prefix.clone()).encode()?)
13    }
14
15    pub fn decode(address: String) -> Result<Self> {
16        let info = chia_sdk_utils::Address::decode(&address)?;
17        Ok(Self {
18            puzzle_hash: info.puzzle_hash,
19            prefix: info.prefix,
20        })
21    }
22}