openfare_lib/lock/payee/
mod.rs

1pub type Label = String;
2pub type Payees = std::collections::BTreeMap<Label, Payee>;
3pub type PaymentMethodName = String;
4
5#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
6pub struct Payee {
7    pub url: Option<String>,
8    #[serde(flatten)]
9    pub profile: crate::profile::Profile,
10}
11
12pub fn get_lock_payee(
13    profile: &crate::profile::Profile,
14    all_lock_payees: &std::collections::BTreeMap<Label, Payee>,
15) -> Option<(Label, Payee)> {
16    for (name, existing_payee) in all_lock_payees {
17        if profile.unique_id == existing_payee.profile.unique_id {
18            return Some((name.clone(), existing_payee.clone()));
19        }
20    }
21    None
22}
23
24pub fn unique_label(payee_label: &Label, payee: &Payee) -> Label {
25    let unique_id = payee.profile.unique_id.to_string()[..13].to_string();
26    format!(
27        "{payee_label}___{unique_id}",
28        payee_label = payee_label,
29        unique_id = unique_id
30    )
31}