bright_lightning/lnd/models/
invoice_request.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct LndInvoiceRequest {
5 form: String,
6}
7impl LndInvoiceRequest {
8 #[must_use]
9 pub fn from_body(body: &LndInvoiceRequestBody) -> Self {
10 Self {
11 form: body.to_string(),
12 }
13 }
14 #[must_use]
15 pub fn new(amount: u64) -> Self {
16 let body = LndInvoiceRequestBody {
17 value: amount.to_string(),
18 memo: None,
19 };
20 Self {
21 form: body.to_string(),
22 }
23 }
24}
25impl std::fmt::Display for LndInvoiceRequest {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 write!(f, "{}", serde_json::to_string(self).unwrap_or_default())
28 }
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize, Default)]
32pub struct LndInvoiceRequestBody {
33 pub value: String,
34 pub memo: Option<String>,
35}
36impl std::fmt::Display for LndInvoiceRequestBody {
37 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38 write!(f, "{}", serde_json::to_string(self).unwrap_or_default())
39 }
40}
41impl LndInvoiceRequestBody {
42 #[must_use]
43 pub const fn new(value: String, memo: Option<String>) -> Self {
44 Self { value, memo }
45 }
46}