bright_lightning/lnd/models/
invoice_request.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LndInvoiceRequest {
    form: String,
}
impl LndInvoiceRequest {
    pub fn new(amount: u64) -> Self {
        let body = LndInvoiceRequestBody {
            value: amount.to_string(),
        };
        Self {
            form: body.to_string(),
        }
    }
}
impl ToString for LndInvoiceRequest {
    fn to_string(&self) -> String {
        serde_json::to_string(self).unwrap()
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LndInvoiceRequestBody {
    value: String,
}
impl ToString for LndInvoiceRequestBody {
    fn to_string(&self) -> String {
        serde_json::to_string(self).unwrap()
    }
}
impl LndInvoiceRequestBody {
    pub fn new(value: String) -> Self {
        Self { value }
    }
}