Skip to content

Commit 0891bb3

Browse files
committed
WIP on connection initialization
1 parent a54c690 commit 0891bb3

22 files changed

+553
-241
lines changed

Cargo.lock

+21-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ required-features = ["cli"]
2323

2424
[dependencies]
2525
# Rust language
26-
amplify = "~2.0.6"
27-
amplify_derive = "~2.0.6"
28-
lnpbp = { version = "0.2.0-alpha.3", features = ["lnp", "url", "websockets"] }
29-
lnpbp_derive = { version = "0.2.0-alpha.3" }
30-
lnpbp_services = { version = "0.2.0-alpha.3" }
26+
amplify = "~2.1.2"
27+
amplify_derive = "~2.1.1"
28+
lnpbp = { git = "git://github.com/LNP-BP/rust-lnpbp", features = ["lnp", "url", "websockets"] }
29+
lnpbp_derive = { git = "git://github.com/LNP-BP/rust-lnpbp" }
30+
lnpbp_services = { git = "git://github.com/LNP-BP/rust-lnpbp" }
3131
lazy_static = "~1.4.0"
3232
nix = { version = "~0.19.0", optional = true }
3333
# Bitcoin
@@ -57,10 +57,10 @@ tokio = { version = "~0.2.21", features = ["full"], optional = true }
5757
zmq = { version = "~0.9.2", optional = true }
5858

5959
[build-dependencies]
60-
amplify = "~1.2.0"
61-
amplify_derive = "~2.0.6"
62-
lnpbp = { version = "0.2.0-alpha.3", features = ["lnp", "url", "websockets"] }
63-
lnpbp_services = { version = "0.2.0-alpha.3" }
60+
amplify = "~2.1.2"
61+
amplify_derive = "~2.1.1"
62+
lnpbp = { git = "git://github.com/LNP-BP/rust-lnpbp", features = ["lnp", "url", "websockets"] }
63+
lnpbp_services = { git = "git://github.com/LNP-BP/rust-lnpbp" }
6464
clap = "=3.0.0-beta.2"
6565
clap_generate = "=3.0.0-beta.2"
6666
log = { version = "~0.4.8", features = ["max_level_trace", "release_max_level_debug"] }

README.md

+5-22
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ The overall architecture of LNP Node is the following:
127127

128128
![Node architacture](doc/lnp_node_arch.jpeg)
129129

130+
More information on the service buses used in the node:
131+
132+
![Node architacture](doc/node_esb.jpeg)
133+
134+
130135
## Project organization & architecture
131136

132137
* [`src/bin/`](src/bin/) – binaries for daemons & CLI launching main process
@@ -165,25 +170,3 @@ organization concept for module/file names:
165170
* dr_orlovsky: my account on IRC
166171
* Lightning Hackdays Mattermost channel:
167172
<https://mm.fulmo.org/fulmo/channels/x-rust-ln-node>
168-
169-
## Previous (mostly independent/unrelated) work
170-
171-
* `rust-lightning` architecture explanation:
172-
<https://github.com/rust-bitcoin/rust-lightning/blob/master/ARCH.md>
173-
* Antoine Riard's explanation on possible LN daemon architecture:
174-
<https://github.com/ariard/hacking-rust-lightning>
175-
* PR in rust-lightning removing storage of private keys from the memory:
176-
<https://github.com/rust-bitcoin/rust-lightning/pull/562/files>
177-
* Matt Corallo's sample implementation of rust-lightning based daemon,
178-
showcasing its API: <https://github.com/TheBlueMatt/rust-lightning-bitcoinrpc>
179-
* Antoine Riard's set of separate lightning daemons based on standard Rust
180-
multithreading/async (no tokio): <https://github.com/ariard/orage>
181-
* Forks of Matt Corallo's daemon developed much further towards full-flegged
182-
Lightning daemoin:
183-
* by @YaaMe: <https://github.com/YaaMe/rust-lightning-bitcoinrpc>
184-
* further development by @knarfytrebil:
185-
<https://github.com/knarfytrebil/rust-lightning-bitcoinrpc>
186-
* Sample of Rust multithreaded server architecture:
187-
<https://github.com/LNP-BP/txserv>
188-
* SquareCrypto Development Kit based on `rust-lightning` library:
189-
<http://lightningdevkit.org/>

doc/node_esb.jpeg

84.8 KB
Loading

shell/_lnp-cli

+33-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ _lnp-cli() {
4242
(( CURRENT += 1 ))
4343
curcontext="${curcontext%:*:*}:lnp-cli-command-$line[1]:"
4444
case $line[1] in
45-
(ping)
45+
(connect)
4646
_arguments "${_arguments_options[@]}" \
4747
'-d+[Data directory path]: :_files -/' \
4848
'--data-dir=[Data directory path]: :_files -/' \
@@ -60,6 +60,28 @@ _arguments "${_arguments_options[@]}" \
6060
'--help[Prints help information]' \
6161
'-V[Prints version information]' \
6262
'--version[Prints version information]' \
63+
':node-locator -- Address of the remote node, in '<public_key>@<ipv4>|<ipv6>|<onionv2>|<onionv3>\[\:<port>\]' format:' \
64+
&& ret=0
65+
;;
66+
(ping)
67+
_arguments "${_arguments_options[@]}" \
68+
'-d+[Data directory path]: :_files -/' \
69+
'--data-dir=[Data directory path]: :_files -/' \
70+
'-c+[Path to the configuration file]: :_files' \
71+
'--config=[Path to the configuration file]: :_files' \
72+
'*-T+[Use Tor]: :_hosts' \
73+
'*--tor-proxy=[Use Tor]: :_hosts' \
74+
'-m+[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \
75+
'--msg-socket=[ZMQ socket name/address to forward all incoming lightning messages]: :_files' \
76+
'-x+[ZMQ socket name/address for daemon control interface]: :_files' \
77+
'--ctl-socket=[ZMQ socket name/address for daemon control interface]: :_files' \
78+
'*-v[Set verbosity level]' \
79+
'*--verbose[Set verbosity level]' \
80+
'-h[Prints help information]' \
81+
'--help[Prints help information]' \
82+
'-V[Prints version information]' \
83+
'--version[Prints version information]' \
84+
':node-locator -- Address of the remote node, in '<public_key>@<ipv4>|<ipv6>|<onionv2>|<onionv3>\[\:<port>\]' format:' \
6385
&& ret=0
6486
;;
6587
(create-channel)
@@ -80,7 +102,7 @@ _arguments "${_arguments_options[@]}" \
80102
'--help[Prints help information]' \
81103
'-V[Prints version information]' \
82104
'--version[Prints version information]' \
83-
':node-addr -- Address of the remote node, in '<public_key>@<ipv4>|<ipv6>|<onionv2>|<onionv3>\[\:<port>\]' format:' \
105+
':node-locator -- Address of the remote node, in '<public_key>@<ipv4>|<ipv6>|<onionv2>|<onionv3>\[\:<port>\]' format:' \
84106
&& ret=0
85107
;;
86108
(help)
@@ -99,12 +121,20 @@ esac
99121
(( $+functions[_lnp-cli_commands] )) ||
100122
_lnp-cli_commands() {
101123
local commands; commands=(
102-
"ping:Ping remote peer" \
124+
"connect:Connect to the peer" \
125+
"ping:Ping remote peer" \
103126
"create-channel:Establishes new channel" \
104127
"help:Prints this message or the help of the given subcommand(s)" \
105128
)
106129
_describe -t commands 'lnp-cli commands' commands "$@"
107130
}
131+
(( $+functions[_lnp-cli__connect_commands] )) ||
132+
_lnp-cli__connect_commands() {
133+
local commands; commands=(
134+
135+
)
136+
_describe -t commands 'lnp-cli connect commands' commands "$@"
137+
}
108138
(( $+functions[_lnp-cli__create-channel_commands] )) ||
109139
_lnp-cli__create-channel_commands() {
110140
local commands; commands=(

shell/_lnp-cli.ps1

+20
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,31 @@ Register-ArgumentCompleter -Native -CommandName 'lnp-cli' -ScriptBlock {
3838
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
3939
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
4040
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
41+
[CompletionResult]::new('connect', 'connect', [CompletionResultType]::ParameterValue, 'Connect to the peer')
4142
[CompletionResult]::new('ping', 'ping', [CompletionResultType]::ParameterValue, 'Ping remote peer')
4243
[CompletionResult]::new('create-channel', 'create-channel', [CompletionResultType]::ParameterValue, 'Establishes new channel')
4344
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Prints this message or the help of the given subcommand(s)')
4445
break
4546
}
47+
'lnp-cli;connect' {
48+
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path')
49+
[CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path')
50+
[CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to the configuration file')
51+
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to the configuration file')
52+
[CompletionResult]::new('-T', 'T', [CompletionResultType]::ParameterName, 'Use Tor')
53+
[CompletionResult]::new('--tor-proxy', 'tor-proxy', [CompletionResultType]::ParameterName, 'Use Tor')
54+
[CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages')
55+
[CompletionResult]::new('--msg-socket', 'msg-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address to forward all incoming lightning messages')
56+
[CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface')
57+
[CompletionResult]::new('--ctl-socket', 'ctl-socket', [CompletionResultType]::ParameterName, 'ZMQ socket name/address for daemon control interface')
58+
[CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Set verbosity level')
59+
[CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Set verbosity level')
60+
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
61+
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
62+
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
63+
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
64+
break
65+
}
4666
'lnp-cli;ping' {
4767
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Data directory path')
4868
[CompletionResult]::new('--data-dir', 'data-dir', [CompletionResultType]::ParameterName, 'Data directory path')

shell/lnp-cli.bash

+61-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ _lnp-cli() {
1313
cmd="lnp__cli"
1414
;;
1515

16+
connect)
17+
cmd+="__connect"
18+
;;
1619
create-channel)
1720
cmd+="__create__channel"
1821
;;
@@ -29,7 +32,7 @@ _lnp-cli() {
2932

3033
case "${cmd}" in
3134
lnp__cli)
32-
opts=" -d -c -v -T -m -x -n -h -V --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --help --version ping create-channel help"
35+
opts=" -d -c -v -T -m -x -n -h -V --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --chain --help --version connect ping create-channel help"
3336
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
3437
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
3538
return 0
@@ -92,8 +95,63 @@ _lnp-cli() {
9295
return 0
9396
;;
9497

98+
lnp__cli__connect)
99+
opts=" -d -c -v -T -m -x -h -V --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --help --version <node-locator> "
100+
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
101+
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
102+
return 0
103+
fi
104+
case "${prev}" in
105+
106+
--data-dir)
107+
COMPREPLY=($(compgen -f "${cur}"))
108+
return 0
109+
;;
110+
-d)
111+
COMPREPLY=($(compgen -f "${cur}"))
112+
return 0
113+
;;
114+
--config)
115+
COMPREPLY=($(compgen -f "${cur}"))
116+
return 0
117+
;;
118+
-c)
119+
COMPREPLY=($(compgen -f "${cur}"))
120+
return 0
121+
;;
122+
--tor-proxy)
123+
COMPREPLY=($(compgen -f "${cur}"))
124+
return 0
125+
;;
126+
-T)
127+
COMPREPLY=($(compgen -f "${cur}"))
128+
return 0
129+
;;
130+
--msg-socket)
131+
COMPREPLY=($(compgen -f "${cur}"))
132+
return 0
133+
;;
134+
-m)
135+
COMPREPLY=($(compgen -f "${cur}"))
136+
return 0
137+
;;
138+
--ctl-socket)
139+
COMPREPLY=($(compgen -f "${cur}"))
140+
return 0
141+
;;
142+
-x)
143+
COMPREPLY=($(compgen -f "${cur}"))
144+
return 0
145+
;;
146+
*)
147+
COMPREPLY=()
148+
;;
149+
esac
150+
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
151+
return 0
152+
;;
95153
lnp__cli__create__channel)
96-
opts=" -d -c -v -T -m -x -h -V --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --help --version <node-addr> "
154+
opts=" -d -c -v -T -m -x -h -V --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --help --version <node-locator> "
97155
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
98156
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
99157
return 0
@@ -163,7 +221,7 @@ _lnp-cli() {
163221
return 0
164222
;;
165223
lnp__cli__ping)
166-
opts=" -d -c -v -T -m -x -h -V --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --help --version "
224+
opts=" -d -c -v -T -m -x -h -V --data-dir --config --verbose --tor-proxy --msg-socket --ctl-socket --help --version <node-locator> "
167225
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
168226
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
169227
return 0

0 commit comments

Comments
 (0)