fedimint_walletv2_client/
db.rs1use fedimint_core::core::Account;
2use fedimint_core::encoding::{Decodable, Encodable};
3use fedimint_core::{impl_db_lookup, impl_db_record};
4use serde::Serialize;
5use strum_macros::EnumIter;
6
7#[repr(u8)]
8#[derive(Clone, Debug, EnumIter)]
9pub enum DbKeyPrefix {
10 NextOutputIndex = 0x31,
11 ValidAddressIndex = 0x32,
12}
13
14impl std::fmt::Display for DbKeyPrefix {
15 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16 write!(f, "{self:?}")
17 }
18}
19
20#[derive(Clone, Debug, Encodable, Decodable, Serialize)]
24pub struct NextOutputIndexKey;
25
26impl_db_record!(
27 key = NextOutputIndexKey,
28 value = u64,
29 db_prefix = DbKeyPrefix::NextOutputIndex
30);
31
32#[derive(Clone, Debug, Encodable, Decodable, Serialize)]
36pub struct ValidAddressIndexKey(pub Account, pub u64);
37
38impl_db_record!(
39 key = ValidAddressIndexKey,
40 value = (),
41 db_prefix = DbKeyPrefix::ValidAddressIndex
42);
43
44#[derive(Clone, Debug, Encodable, Decodable, Serialize)]
46pub struct ValidAddressIndexPrefix;
47
48impl_db_lookup!(
49 key = ValidAddressIndexKey,
50 query_prefix = ValidAddressIndexPrefix
51);
52
53#[derive(Clone, Debug, Encodable, Decodable, Serialize)]
54pub struct ValidAddressIndexAccountPrefix(pub Account);
55
56impl_db_lookup!(
57 key = ValidAddressIndexKey,
58 query_prefix = ValidAddressIndexAccountPrefix
59);