feat: use rust_util

This commit is contained in:
2021-01-01 19:03:40 +08:00
parent 54856504a2
commit 6fef958a70
6 changed files with 174 additions and 36 deletions

View File

@@ -1,32 +1,11 @@
use rand::rngs::OsRng;
use rust_util::XResult;
use serde::{Deserialize, Serialize};
use secp256k1::{Secp256k1, SecretKey, key::PublicKey};
use sha2::Sha256;
use ripemd160::Ripemd160;
use digest::{ Input, FixedOutput };
use std::{fmt::Display, str::FromStr};
use std::error::Error;
pub type XResult<T> = Result<T, Box<dyn Error>>;
#[derive(Debug)]
pub struct SimpleError {
pub message: String,
}
impl SimpleError {
pub fn new(message: String) -> Self {
Self { message }
}
}
impl Display for SimpleError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "SimpleErorr, message: {}", self.message)
}
}
impl Error for SimpleError {}
use std::str::FromStr;
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]