forked from LNP-WG/lnp-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopts.rs
57 lines (47 loc) · 1.67 KB
/
opts.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// LNP Node: node running lightning network protocol and generalized lightning
// channels.
// Written in 2020-2022 by
// Dr. Maxim Orlovsky <orlovsky@lnp-bp.org>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
//
// You should have received a copy of the MIT License along with this software.
// If not, see <https://opensource.org/licenses/MIT>.
use amplify::hex::FromHex;
use lnp::p2p::bolt::ChannelId;
use crate::opts::Options;
use crate::peerd::KeyOpts;
/// Lightning peer network channel daemon; part of LNP Node.
///
/// The daemon is controlled though RPC socket (see `rpc-socket`).
#[derive(Parser, Clone, PartialEq, Eq, Debug)]
#[clap(name = "channeld", bin_name = "channeld", author, version)]
pub struct Opts {
/// Node key configuration
#[clap(flatten)]
pub key_opts: KeyOpts,
/// Channel id
#[clap(parse(try_from_str = ChannelId::from_hex))]
pub channel_id: ChannelId,
/// Flag indicating that we are re-establishing a channel with the provided `channel_id`
#[clap(short, long)]
pub reestablish: bool,
/// These params can be read also from the configuration file, not just
/// command-line args or environment variables
#[clap(flatten)]
pub shared: crate::opts::Opts,
}
impl Options for Opts {
type Conf = ();
fn shared(&self) -> &crate::opts::Opts { &self.shared }
fn config(&self) -> Self::Conf { () }
}
impl Opts {
pub fn process(&mut self) {
self.shared.process();
self.key_opts.process(&self.shared);
}
}