Skip to content

Commit 6df6c9a

Browse files
authored
Merge pull request #6 from ekzyis/recv-only
Add --invoice-macaroon-file option
2 parents a02fc9a + cdbf849 commit 6df6c9a

File tree

2 files changed

+304
-241
lines changed

2 files changed

+304
-241
lines changed

src/config.rs

+20-3
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,32 @@ pub struct Config {
3333
/// Path to admin.macaroon file for lnd
3434
macaroon_file: Option<String>,
3535
#[clap(long)]
36+
/// Path to invoice.macaroon file for lnd
37+
invoice_macaroon_file: Option<String>,
38+
#[clap(long)]
3639
/// Include route hints in invoices
3740
pub route_hints: bool,
3841
}
3942

4043
impl Config {
4144
pub fn macaroon_file(&self) -> String {
42-
self.macaroon_file
43-
.clone()
44-
.unwrap_or_else(|| default_macaroon_file(&self.network))
45+
if self.macaroon_file.is_some() && self.invoice_macaroon_file.is_some() {
46+
panic!("cannot set --macaroon-file and --invoice-macaroon-file at the same time")
47+
}
48+
match self.invoice_macaroon_file {
49+
Some(_) => self.invoice_macaroon_file.clone().unwrap(),
50+
None => self
51+
.macaroon_file
52+
.clone()
53+
.unwrap_or_else(|| default_macaroon_file(&self.network)),
54+
}
55+
}
56+
57+
pub fn recv_only(&self) -> bool {
58+
match self.invoice_macaroon_file {
59+
Some(_) => true,
60+
None => false,
61+
}
4562
}
4663

4764
pub fn cert_file(&self) -> String {

0 commit comments

Comments
 (0)