mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
34 lines
908 B
Rust
34 lines
908 B
Rust
use serde::Serialize;
|
|
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
|
|
|
use crate::{LoadedAddressData, Sats};
|
|
|
|
#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize)]
|
|
pub struct EmptyAddressData {
|
|
pub transfered: Sats,
|
|
}
|
|
|
|
impl From<LoadedAddressData> for EmptyAddressData {
|
|
fn from(value: LoadedAddressData) -> Self {
|
|
Self::from(&value)
|
|
}
|
|
}
|
|
|
|
impl From<&LoadedAddressData> for EmptyAddressData {
|
|
fn from(value: &LoadedAddressData) -> Self {
|
|
if value.sent != value.received {
|
|
dbg!(&value);
|
|
panic!("Trying to convert not empty wallet to empty !");
|
|
}
|
|
Self {
|
|
transfered: value.sent,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for EmptyAddressData {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "transfered: {}", self.transfered)
|
|
}
|
|
}
|