From 2795f8a97a1a6f6807c75c655280d90a78ecd9ce Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 30 Jul 2023 13:09:41 +0200 Subject: [PATCH] wallet: add derivations --- Cargo.lock | 2 +- std/src/chain.rs | 8 ++++++++ std/src/wallet.rs | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 7d14677..db3d1f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "bp-primitives" version = "0.10.6" -source = "git+https://github.com/BP-WG/bp-core?branch=primitives#73483b4d553dd7150e09cfaff00072e8e097e959" +source = "git+https://github.com/BP-WG/bp-core?branch=primitives#e13eb2897f6a53d5815c6542b2c5c5c9a1d5d424" dependencies = [ "amplify", "commit_verify", diff --git a/std/src/chain.rs b/std/src/chain.rs index 360a1f9..af58d2d 100644 --- a/std/src/chain.rs +++ b/std/src/chain.rs @@ -28,6 +28,7 @@ use crate::{Address, NormalIndex}; pub type BlockHeight = NonZeroU32; +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct BlockInfo { pub header: BlockHeader, pub difficulty: u8, @@ -37,12 +38,14 @@ pub struct BlockInfo { pub mediantime: u32, } +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct MiningInfo { pub height: BlockHeight, pub time: u64, pub block_hash: BlockHash, } +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub enum TxStatus { Mined(MiningInfo), Mempool, @@ -50,6 +53,7 @@ pub enum TxStatus { Unknown, } +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct TxInfo { pub txid: Txid, pub status: TxStatus, @@ -62,6 +66,7 @@ pub struct TxInfo { pub locktime: LockTime, } +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct TxInInfo { pub outpoint: Outpoint, pub sequence: SeqNo, @@ -71,12 +76,14 @@ pub struct TxInInfo { pub value: Option, } +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct TxOutInfo { pub outpoint: Outpoint, pub value: Sats, pub derivation: Option<(NormalIndex, NormalIndex)>, } +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct UtxoInfo { pub outpoint: Outpoint, pub value: Sats, @@ -84,6 +91,7 @@ pub struct UtxoInfo { pub derivation: (NormalIndex, NormalIndex), } +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct AddrInfo { pub derivation: (NormalIndex, NormalIndex), pub used: u32, diff --git a/std/src/wallet.rs b/std/src/wallet.rs index 219f244..ace468d 100644 --- a/std/src/wallet.rs +++ b/std/src/wallet.rs @@ -47,6 +47,7 @@ impl Deref for WalletDescr { fn deref(&self) -> &Self::Target { &self.script_pubkey } } +#[derive(Clone, Eq, PartialEq, Debug)] pub struct WalletData { pub name: String, pub tx_annotations: BTreeMap, @@ -56,6 +57,7 @@ pub struct WalletData { pub last_used: NormalIndex, } +#[derive(Clone, Eq, PartialEq, Debug)] pub struct WalletCache { tip: u32, headers: HashMap, @@ -65,6 +67,7 @@ pub struct WalletCache { max_known: HashMap, } +#[derive(Clone, Eq, PartialEq, Debug)] pub struct Wallet { descr: WalletDescr, data: WalletData,