waves_rust/model/
proof.rs1use crate::error::Result;
2use crate::model::ByteString;
3use crate::util::Base58;
4use std::fmt;
5
6#[derive(Clone, Eq, PartialEq, Hash)]
7pub struct Proof {
8 bytes: Vec<u8>,
9}
10
11impl fmt::Debug for Proof {
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 write!(f, "Proof {{ {} }}", self.encoded())
14 }
15}
16
17impl Proof {
18 pub fn new(bytes: Vec<u8>) -> Self {
19 Self { bytes }
20 }
21
22 pub fn from_string(base58str: &str) -> Result<Self> {
23 Ok(Self {
24 bytes: Base58::decode(base58str)?,
25 })
26 }
27}
28
29impl ByteString for Proof {
30 fn bytes(&self) -> Vec<u8> {
31 self.bytes.clone()
32 }
33
34 fn encoded(&self) -> String {
35 Base58::encode(&self.bytes, false)
36 }
37
38 fn encoded_with_prefix(&self) -> String {
39 Base58::encode(&self.bytes, true)
40 }
41}