Skip to content

Commit 5ab4d48

Browse files
committed
lnnode: handle conf args instead of backends
1 parent 7f4e284 commit 5ab4d48

File tree

3 files changed

+27
-36
lines changed

3 files changed

+27
-36
lines changed

src/backends/compose/compose_backend.py

+2-19
Original file line numberDiff line numberDiff line change
@@ -421,28 +421,11 @@ def add_lnd_service(self, tank, compose):
421421
ln_cb_container_name = self.get_container_name(tank.index, ServiceType.CIRCUITBREAKER)
422422
bitcoin_container_name = self.get_container_name(tank.index, ServiceType.BITCOIN)
423423
# These args are appended to the Dockerfile `ENTRYPOINT ["lnd"]`
424-
args = [
425-
"--noseedbackup",
426-
"--norest",
427-
"--debuglevel=debug",
428-
"--accept-keysend",
429-
"--bitcoin.active",
430-
"--bitcoin.regtest",
431-
"--bitcoin.node=bitcoind",
432-
f"--bitcoind.rpcuser={tank.rpc_user}",
433-
f"--bitcoind.rpcpass={tank.rpc_password}",
434-
f"--bitcoind.rpchost={tank.ipv4}:{tank.rpc_port}",
435-
f"--bitcoind.zmqpubrawblock=tcp://{tank.ipv4}:{tank.zmqblockport}",
436-
f"--bitcoind.zmqpubrawtx=tcp://{tank.ipv4}:{tank.zmqtxport}",
437-
f"--externalip={tank.lnnode.ipv4}",
438-
f"--rpclisten=0.0.0.0:{tank.lnnode.rpc_port}",
439-
f"--alias={tank.index}",
440-
f"--tlsextradomain={ln_container_name}",
441-
]
424+
args = tank.lnnode.get_conf(ln_container_name, bitcoin_container_name)
442425
services[ln_container_name] = {
443426
"container_name": ln_container_name,
444427
"image": tank.lnnode.image,
445-
"command": " ".join(args),
428+
"command": args,
446429
"networks": {
447430
tank.network_name: {
448431
"ipv4_address": f"{tank.lnnode.ipv4}",

src/backends/kubernetes/kubernetes_backend.py

+1-17
Original file line numberDiff line numberDiff line change
@@ -442,23 +442,7 @@ def create_lnd_container(
442442
# These args are appended to the Dockerfile `ENTRYPOINT ["lnd"]`
443443
bitcoind_rpc_host = f"{bitcoind_service_name}.{self.namespace}"
444444
lightning_dns = f"lightning-{tank.index}.{self.namespace}"
445-
args = [
446-
"--noseedbackup",
447-
"--norest",
448-
"--debuglevel=debug",
449-
"--accept-keysend",
450-
"--bitcoin.active",
451-
"--bitcoin.regtest",
452-
"--bitcoin.node=bitcoind",
453-
f"--bitcoind.rpcuser={tank.rpc_user}",
454-
f"--bitcoind.rpcpass={tank.rpc_password}",
455-
f"--bitcoind.rpchost={bitcoind_rpc_host}:{tank.rpc_port}",
456-
f"--bitcoind.zmqpubrawblock={bitcoind_rpc_host}:{tank.zmqblockport}",
457-
f"--bitcoind.zmqpubrawtx={bitcoind_rpc_host}:{tank.zmqtxport}",
458-
f"--rpclisten=0.0.0.0:{tank.lnnode.rpc_port}",
459-
f"--externalhosts={lightning_dns}",
460-
f"--alias={tank.index}",
461-
]
445+
args = tank.lnnode.get_conf(lightning_dns, bitcoind_rpc_host)
462446
self.log.debug(f"Creating lightning container for tank {tank.index} using {args=:}")
463447
lightning_container = client.V1Container(
464448
name=LN_CONTAINER_NAME,

src/warnet/lnnode.py

+24
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55

66
from .status import RunningStatus
77

8+
LND_CONFIG_BASE = " ".join([
9+
"--noseedbackup",
10+
"--norest",
11+
"--debuglevel=debug",
12+
"--accept-keysend",
13+
"--bitcoin.active",
14+
"--bitcoin.regtest",
15+
"--bitcoin.node=bitcoind"
16+
])
817

918
class LNNode:
1019
def __init__(self, warnet, tank, impl, image, backend: BackendInterface, cb=None):
@@ -32,6 +41,21 @@ def cb_status(self) -> RunningStatus:
3241
self.tank.index, ServiceType.CIRCUITBREAKER
3342
)
3443

44+
def get_conf(self, ln_container_name, tank_container_name) -> str:
45+
if self.impl == "lnd":
46+
conf = LND_CONFIG_BASE
47+
conf += f" --bitcoind.rpcuser={self.tank.rpc_user}"
48+
conf += f" --bitcoind.rpcpass={self.tank.rpc_password}"
49+
conf += f" --bitcoind.rpchost={tank_container_name}:{self.tank.rpc_port}"
50+
conf += f" --bitcoind.zmqpubrawblock=tcp://{tank_container_name}:{self.tank.zmqblockport}"
51+
conf += f" --bitcoind.zmqpubrawtx=tcp://{tank_container_name}:{self.tank.zmqtxport}"
52+
conf += f" --rpclisten=0.0.0.0:{self.rpc_port}"
53+
conf += f" --alias={self.tank.index}"
54+
conf += f" --externalhosts={ln_container_name}"
55+
conf += f" --tlsextradomain={ln_container_name}"
56+
return conf
57+
return ""
58+
3559
@exponential_backoff(max_retries=20, max_delay=300)
3660
@handle_json
3761
def lncli(self, cmd) -> dict:

0 commit comments

Comments
 (0)