Skip to content

Commit

Permalink
wallet: add derivations
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 30, 2023
1 parent 653c530 commit 2795f8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions std/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,19 +38,22 @@ 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,
Channel,
Unknown,
}

#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct TxInfo {
pub txid: Txid,
pub status: TxStatus,
Expand All @@ -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,
Expand All @@ -71,19 +76,22 @@ pub struct TxInInfo {
pub value: Option<Sats>,
}

#[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,
pub address: Address,
pub derivation: (NormalIndex, NormalIndex),
}

#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct AddrInfo {
pub derivation: (NormalIndex, NormalIndex),
pub used: u32,
Expand Down
3 changes: 3 additions & 0 deletions std/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl<D: DeriveSpk> Deref for WalletDescr<D> {
fn deref(&self) -> &Self::Target { &self.script_pubkey }
}

#[derive(Clone, Eq, PartialEq, Debug)]
pub struct WalletData {
pub name: String,
pub tx_annotations: BTreeMap<Txid, String>,
Expand All @@ -56,6 +57,7 @@ pub struct WalletData {
pub last_used: NormalIndex,
}

#[derive(Clone, Eq, PartialEq, Debug)]
pub struct WalletCache {
tip: u32,
headers: HashMap<NonZeroU32, BlockInfo>,
Expand All @@ -65,6 +67,7 @@ pub struct WalletCache {
max_known: HashMap<NormalIndex, NormalIndex>,
}

#[derive(Clone, Eq, PartialEq, Debug)]
pub struct Wallet<D: DeriveSpk, L2: Default = ()> {
descr: WalletDescr<D>,
data: WalletData,
Expand Down

0 comments on commit 2795f8a

Please sign in to comment.