tranche 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tranche-0.2.2 → tranche-0.2.4}/PKG-INFO +3 -3
- {tranche-0.2.2 → tranche-0.2.4}/README.md +2 -2
- {tranche-0.2.2 → tranche-0.2.4}/core.py +3 -3
- {tranche-0.2.2 → tranche-0.2.4}/pyproject.toml +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/__init__.py +4 -4
- {tranche-0.2.2 → tranche-0.2.4}/src/commands/__init__.py +3 -3
- {tranche-0.2.2 → tranche-0.2.4}/src/commands/clean.py +1 -1
- tranche-0.2.2/src/commands/cluster.py → tranche-0.2.4/src/commands/deploy.py +11 -6
- {tranche-0.2.2 → tranche-0.2.4}/src/commands/flush.py +5 -3
- {tranche-0.2.2 → tranche-0.2.4}/src/commands/mine.py +1 -1
- tranche-0.2.4/src/commands/nodekeys.py +54 -0
- tranche-0.2.4/src/commands/ping_pong.py +135 -0
- {tranche-0.2.2 → tranche-0.2.4}/src/commands/setup.py +6 -4
- {tranche-0.2.2 → tranche-0.2.4}/src/configs.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/__init__.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/blockchain_info.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/cluster_enum.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/image_alias.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/lnd_info.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/mutex_option.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/new_address.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/open_channel.py +1 -1
- {tranche-0.2.2 → tranche-0.2.4}/src/schemas/service.py +1 -1
- tranche-0.2.2/src/commands/nodekeys.py +0 -47
- tranche-0.2.2/src/commands/ping_pong.py +0 -100
- {tranche-0.2.2 → tranche-0.2.4}/LICENSE +0 -0
- {tranche-0.2.2 → tranche-0.2.4}/src/constants.yaml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tranche
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Command line interface used for generating local Lightning test environment
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Sitt Guruvanich
|
|
@@ -44,8 +44,8 @@ You can use `tranche` simply by installing via `pip` on your Terminal.
|
|
|
44
44
|
$ pip install tranche
|
|
45
45
|
> ...
|
|
46
46
|
> Installing collected packages: tranche
|
|
47
|
-
> Successfully installed tranche-0.2.
|
|
48
|
-
$ tranche
|
|
47
|
+
> Successfully installed tranche-0.2.4
|
|
48
|
+
$ tranche deploy
|
|
49
49
|
> Deploy specified local cluster: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:01
|
|
50
50
|
> Generate addresses: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
|
|
51
51
|
> Mine initial capital for parties: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
|
|
@@ -20,8 +20,8 @@ You can use `tranche` simply by installing via `pip` on your Terminal.
|
|
|
20
20
|
$ pip install tranche
|
|
21
21
|
> ...
|
|
22
22
|
> Installing collected packages: tranche
|
|
23
|
-
> Successfully installed tranche-0.2.
|
|
24
|
-
$ tranche
|
|
23
|
+
> Successfully installed tranche-0.2.4
|
|
24
|
+
$ tranche deploy
|
|
25
25
|
> Deploy specified local cluster: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:01
|
|
26
26
|
> Generate addresses: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
|
|
27
27
|
> Mine initial capital for parties: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# coding:utf-8
|
|
3
3
|
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
4
|
# FILENAME: tranche.py
|
|
5
|
-
# VERSION: 0.2.
|
|
5
|
+
# VERSION: 0.2.4
|
|
6
6
|
# CREATED: 2023-12-01 02:20
|
|
7
7
|
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
8
|
# DESCRIPTION:
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
from click import group
|
|
15
15
|
|
|
16
16
|
### Local modules ###
|
|
17
|
-
from src.commands import clean,
|
|
17
|
+
from src.commands import clean, deploy, flush, mine, nodekeys, ping_pong, setup
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
@group
|
|
@@ -23,7 +23,7 @@ def cli() -> None:
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
cli.add_command(clean, "clean")
|
|
26
|
-
cli.add_command(
|
|
26
|
+
cli.add_command(deploy, "deploy")
|
|
27
27
|
cli.add_command(flush, "flush")
|
|
28
28
|
cli.add_command(mine, "mine")
|
|
29
29
|
cli.add_command(nodekeys, "nodekeys")
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# coding:utf-8
|
|
3
3
|
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
4
|
# FILENAME: ~~/src/__init__.py
|
|
5
|
-
# VERSION: 0.2.
|
|
5
|
+
# VERSION: 0.2.4
|
|
6
6
|
# CREATED: 2023-12-01 05:31
|
|
7
7
|
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
8
|
# DESCRIPTION:
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# *************************************************************
|
|
12
12
|
|
|
13
13
|
### Local modules ###
|
|
14
|
-
from src.commands import clean,
|
|
14
|
+
from src.commands import clean, deploy, flush, mine, nodekeys, ping_pong, setup
|
|
15
15
|
from src.schemas import (
|
|
16
16
|
BlockchainInfo,
|
|
17
17
|
ClusterEnum,
|
|
@@ -36,7 +36,7 @@ __all__ = [
|
|
|
36
36
|
"Service",
|
|
37
37
|
"ServiceName",
|
|
38
38
|
"clean",
|
|
39
|
-
"
|
|
39
|
+
"deploy",
|
|
40
40
|
"flush",
|
|
41
41
|
"mine",
|
|
42
42
|
"nodekeys",
|
|
@@ -44,4 +44,4 @@ __all__ = [
|
|
|
44
44
|
"setup",
|
|
45
45
|
]
|
|
46
46
|
|
|
47
|
-
__version__ = "0.2.
|
|
47
|
+
__version__ = "0.2.4"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# coding:utf-8
|
|
3
3
|
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
4
|
# FILENAME: ~~/src/commands/__init__.py
|
|
5
|
-
# VERSION: 0.2.
|
|
5
|
+
# VERSION: 0.2.4
|
|
6
6
|
# CREATED: 2023-12-01 05:31
|
|
7
7
|
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
8
|
# DESCRIPTION:
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
### Local modules ###
|
|
14
14
|
from src.commands.clean import clean
|
|
15
|
-
from src.commands.
|
|
15
|
+
from src.commands.deploy import deploy
|
|
16
16
|
from src.commands.flush import flush
|
|
17
17
|
from src.commands.mine import mine
|
|
18
18
|
from src.commands.nodekeys import nodekeys
|
|
19
19
|
from src.commands.ping_pong import ping_pong
|
|
20
20
|
from src.commands.setup import setup
|
|
21
21
|
|
|
22
|
-
__all__ = ["clean", "
|
|
22
|
+
__all__ = ["clean", "deploy", "flush", "mine", "nodekeys", "ping_pong", "setup"]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env python3.8
|
|
2
2
|
# coding:utf-8
|
|
3
3
|
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
|
-
# FILENAME: ~~/src/commands/
|
|
5
|
-
# VERSION: 0.2.
|
|
4
|
+
# FILENAME: ~~/src/commands/deploy.py
|
|
5
|
+
# VERSION: 0.2.4
|
|
6
6
|
# CREATED: 2023-12-01 05:31
|
|
7
7
|
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
8
|
# DESCRIPTION:
|
|
@@ -18,7 +18,7 @@ from typing import Dict, List
|
|
|
18
18
|
### Third-party packages ###
|
|
19
19
|
from click import command, option
|
|
20
20
|
from docker import DockerClient, from_env
|
|
21
|
-
from docker.errors import APIError
|
|
21
|
+
from docker.errors import APIError, NotFound
|
|
22
22
|
from docker.models.containers import Container
|
|
23
23
|
from pydantic import TypeAdapter
|
|
24
24
|
from rich.progress import track
|
|
@@ -31,7 +31,7 @@ from src.schemas import MutexOption, NewAddress, Service, ServiceName
|
|
|
31
31
|
@command
|
|
32
32
|
@option("--duo", alternatives=["uno"], cls=MutexOption, is_flag=True, type=bool)
|
|
33
33
|
@option("--uno", alternatives=["duo"], cls=MutexOption, is_flag=True, type=bool)
|
|
34
|
-
def
|
|
34
|
+
def deploy(duo: bool, uno: bool) -> None:
|
|
35
35
|
"""Deploy cluster, either with one or two LND nodes."""
|
|
36
36
|
duo = duo or (not duo and not uno) # defaults to duo network
|
|
37
37
|
cluster: Dict[ServiceName, Service] = (CLUSTERS["duo"], CLUSTERS["uno"])[uno]
|
|
@@ -71,7 +71,12 @@ def cluster(duo: bool, uno: bool) -> None:
|
|
|
71
71
|
).output
|
|
72
72
|
)
|
|
73
73
|
mining_targets.append(new_address.address)
|
|
74
|
-
bitcoind: Container
|
|
74
|
+
bitcoind: Container
|
|
75
|
+
try:
|
|
76
|
+
bitcoind = client.containers.get("tranche-bitcoind")
|
|
77
|
+
except NotFound:
|
|
78
|
+
print('!! Unable to find "tranche-bitcoind" container.')
|
|
79
|
+
return
|
|
75
80
|
for address in track(mining_targets, "Mine initial capital for parties:".ljust(42)):
|
|
76
81
|
bitcoind.exec_run(
|
|
77
82
|
"""
|
|
@@ -81,4 +86,4 @@ def cluster(duo: bool, uno: bool) -> None:
|
|
|
81
86
|
)
|
|
82
87
|
|
|
83
88
|
|
|
84
|
-
__all__ = ["
|
|
89
|
+
__all__ = ["deploy"]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# coding:utf-8
|
|
3
3
|
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
4
|
# FILENAME: ~~/src/commands/flush.py
|
|
5
|
-
# VERSION: 0.2.
|
|
5
|
+
# VERSION: 0.2.4
|
|
6
6
|
# CREATED: 2023-12-01 06:24
|
|
7
7
|
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
8
|
# DESCRIPTION:
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# *************************************************************
|
|
12
12
|
|
|
13
13
|
### Standard packages ###
|
|
14
|
-
from typing import Set
|
|
14
|
+
from typing import List, Set
|
|
15
15
|
|
|
16
16
|
### Third-party packages ###
|
|
17
17
|
from click import command
|
|
@@ -27,11 +27,13 @@ def flush() -> None:
|
|
|
27
27
|
"""Remove images deprecated by workspace."""
|
|
28
28
|
client: DockerClient = from_env()
|
|
29
29
|
if client.ping():
|
|
30
|
+
outputs: List[str] = []
|
|
30
31
|
docker_images: Set[str] = {image.tags[0] for image in client.images.list()}
|
|
31
32
|
for registry_id in track(DEPRECATED, "Remove deprecated images:".ljust(42)):
|
|
32
33
|
if registry_id in docker_images:
|
|
33
34
|
client.images.remove(registry_id)
|
|
34
|
-
|
|
35
|
+
outputs.append(f"<Image: '{ registry_id }'> removed.")
|
|
36
|
+
list(map(print, outputs))
|
|
35
37
|
else:
|
|
36
38
|
print("!! Unable to connect to docker daemon.")
|
|
37
39
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env python3.8
|
|
2
|
+
# coding:utf-8
|
|
3
|
+
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
|
+
# FILENAME: ~~/src/commands/nodekeys.py
|
|
5
|
+
# VERSION: 0.2.4
|
|
6
|
+
# CREATED: 2023-12-01 05:31
|
|
7
|
+
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
|
+
# DESCRIPTION:
|
|
9
|
+
#
|
|
10
|
+
# HISTORY:
|
|
11
|
+
# *************************************************************
|
|
12
|
+
|
|
13
|
+
### Standard packages ###
|
|
14
|
+
from re import match
|
|
15
|
+
from typing import List
|
|
16
|
+
|
|
17
|
+
### Third-party packages ###
|
|
18
|
+
from click import command
|
|
19
|
+
from docker import DockerClient, from_env
|
|
20
|
+
from docker.models.containers import Container
|
|
21
|
+
from pydantic import TypeAdapter
|
|
22
|
+
from rich.progress import track
|
|
23
|
+
|
|
24
|
+
### Local modules ###
|
|
25
|
+
from src.schemas import LNDInfo
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@command
|
|
29
|
+
def nodekeys() -> None:
|
|
30
|
+
"""Fetch nodekeys from active LND containers."""
|
|
31
|
+
client: DockerClient = from_env()
|
|
32
|
+
if client.ping():
|
|
33
|
+
containers: List[Container] = reversed(client.containers.list()) # type: ignore[assignment]
|
|
34
|
+
lnds: List[Container] = list(
|
|
35
|
+
filter(lambda c: match(r"tranche-lnd|tranche-ping|tranche-pong", c.name), containers)
|
|
36
|
+
)
|
|
37
|
+
outputs: List[str] = []
|
|
38
|
+
for container in track(lnds, "Fetch LND nodekeys:".ljust(42)):
|
|
39
|
+
lnd_info: LNDInfo = TypeAdapter(LNDInfo).validate_json(
|
|
40
|
+
container.exec_run(
|
|
41
|
+
"""
|
|
42
|
+
lncli
|
|
43
|
+
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
44
|
+
--rpcserver=localhost:10001
|
|
45
|
+
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
46
|
+
getinfo
|
|
47
|
+
"""
|
|
48
|
+
).output
|
|
49
|
+
)
|
|
50
|
+
outputs.append(f"<Nodekey: '{container.name}', '{lnd_info.identity_pubkey}'>")
|
|
51
|
+
list(map(print, outputs))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
__all__ = ["nodekeys"]
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#!/usr/bin/env python3.8
|
|
2
|
+
# coding:utf-8
|
|
3
|
+
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
|
+
# FILENAME: ~~/src/commands/ping_pong.py
|
|
5
|
+
# VERSION: 0.2.4
|
|
6
|
+
# CREATED: 2023-12-01 06:18
|
|
7
|
+
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
|
+
# DESCRIPTION:
|
|
9
|
+
#
|
|
10
|
+
# HISTORY:
|
|
11
|
+
# *************************************************************
|
|
12
|
+
|
|
13
|
+
### Standard packages ###
|
|
14
|
+
from re import match
|
|
15
|
+
from typing import Dict, List
|
|
16
|
+
|
|
17
|
+
### Third-party packages ###
|
|
18
|
+
from click import argument, command
|
|
19
|
+
from docker import DockerClient, from_env
|
|
20
|
+
from docker.errors import NotFound
|
|
21
|
+
from docker.models.containers import Container
|
|
22
|
+
from pydantic import TypeAdapter, ValidationError
|
|
23
|
+
from rich.progress import track
|
|
24
|
+
|
|
25
|
+
### Local modules ###
|
|
26
|
+
from src.schemas import LNDInfo, NewAddress, OpenChannel
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@command
|
|
30
|
+
@argument("channel_size", default=16777215)
|
|
31
|
+
def ping_pong(channel_size: int) -> None:
|
|
32
|
+
"""For "duo" cluster, create channels between LND nodes."""
|
|
33
|
+
client: DockerClient = from_env()
|
|
34
|
+
if client.ping():
|
|
35
|
+
bitcoind: Container
|
|
36
|
+
try:
|
|
37
|
+
bitcoind = client.containers.get("tranche-bitcoind")
|
|
38
|
+
except NotFound:
|
|
39
|
+
print('!! Unable to find "tranche-bitcoind" container.')
|
|
40
|
+
return
|
|
41
|
+
containers: List[Container] = list(reversed(client.containers.list()))
|
|
42
|
+
paddles: List[Container] = list(
|
|
43
|
+
filter(lambda c: match(r"tranche-ping|tranche-pong", c.name), containers)
|
|
44
|
+
)
|
|
45
|
+
mining_targets: Dict[str, str] = {}
|
|
46
|
+
nodekeys: Dict[str, str] = {}
|
|
47
|
+
|
|
48
|
+
### Fetch nodekeys ###
|
|
49
|
+
for container in track(paddles, "Fetch LND nodekeys:".ljust(42)):
|
|
50
|
+
lnd_info: LNDInfo = TypeAdapter(LNDInfo).validate_json(
|
|
51
|
+
container.exec_run(
|
|
52
|
+
"""
|
|
53
|
+
lncli
|
|
54
|
+
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
55
|
+
--rpcserver=localhost:10001
|
|
56
|
+
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
57
|
+
getinfo
|
|
58
|
+
"""
|
|
59
|
+
).output
|
|
60
|
+
)
|
|
61
|
+
nodekeys[container.name] = lnd_info.identity_pubkey
|
|
62
|
+
new_address: NewAddress = TypeAdapter(NewAddress).validate_json(
|
|
63
|
+
container.exec_run(
|
|
64
|
+
"""
|
|
65
|
+
lncli
|
|
66
|
+
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
67
|
+
--rpcserver=localhost:10001
|
|
68
|
+
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
69
|
+
newaddress p2wkh
|
|
70
|
+
"""
|
|
71
|
+
).output
|
|
72
|
+
)
|
|
73
|
+
mining_targets[container.name] = new_address.address
|
|
74
|
+
|
|
75
|
+
### Open channels ###
|
|
76
|
+
outputs: List[str] = []
|
|
77
|
+
for container in track(paddles, "Open channels:".ljust(42)):
|
|
78
|
+
if container.name == "tranche-ping":
|
|
79
|
+
try:
|
|
80
|
+
open_channel: OpenChannel = TypeAdapter(OpenChannel).validate_json(
|
|
81
|
+
container.exec_run(
|
|
82
|
+
"""
|
|
83
|
+
lncli
|
|
84
|
+
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
85
|
+
--rpcserver=localhost:10001
|
|
86
|
+
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
87
|
+
openchannel %d
|
|
88
|
+
--node_key %s
|
|
89
|
+
--connect tranche-pong:9735
|
|
90
|
+
"""
|
|
91
|
+
% (channel_size, nodekeys.get("tranche-pong", ""))
|
|
92
|
+
).output
|
|
93
|
+
)
|
|
94
|
+
outputs.append(
|
|
95
|
+
f"<Channel 'tranche-ping --> tranche-pong' : { open_channel.funding_txid }>"
|
|
96
|
+
)
|
|
97
|
+
bitcoind.exec_run(
|
|
98
|
+
"""
|
|
99
|
+
bitcoin-cli -regtest -rpcuser=tranche -rpcpassword=tranche generatetoaddress %d %s
|
|
100
|
+
"""
|
|
101
|
+
% (6, mining_targets.get("tranche-ping", ""))
|
|
102
|
+
)
|
|
103
|
+
except ValidationError:
|
|
104
|
+
outputs.append("!! Channel 'tranche-ping --> tranche-pong' already opened.")
|
|
105
|
+
elif container.name == "tranche-pong":
|
|
106
|
+
try:
|
|
107
|
+
open_channel: OpenChannel = TypeAdapter(OpenChannel).validate_json( # type: ignore[no-redef]
|
|
108
|
+
container.exec_run(
|
|
109
|
+
"""
|
|
110
|
+
lncli
|
|
111
|
+
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
112
|
+
--rpcserver=localhost:10001
|
|
113
|
+
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
114
|
+
openchannel %d
|
|
115
|
+
--node_key %s
|
|
116
|
+
--connect tranche-ping:9735
|
|
117
|
+
"""
|
|
118
|
+
% (channel_size, nodekeys.get("tranche-ping", ""))
|
|
119
|
+
).output
|
|
120
|
+
)
|
|
121
|
+
outputs.append(
|
|
122
|
+
f"<Channel 'tranche-pong --> tranche-ping' : { open_channel.funding_txid }>"
|
|
123
|
+
)
|
|
124
|
+
bitcoind.exec_run(
|
|
125
|
+
"""
|
|
126
|
+
bitcoin-cli -regtest -rpcuser=tranche -rpcpassword=tranche generatetoaddress %d %s
|
|
127
|
+
"""
|
|
128
|
+
% (6, mining_targets.get("tranche-pong", ""))
|
|
129
|
+
)
|
|
130
|
+
except ValidationError:
|
|
131
|
+
outputs.append("!! Channel 'tranche-pong --> tranche-ping' already opened.")
|
|
132
|
+
list(map(print, outputs))
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
__all__ = ["ping_pong"]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# coding:utf-8
|
|
3
3
|
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
4
|
# FILENAME: ~~/src/commands/setup.py
|
|
5
|
-
# VERSION: 0.2.
|
|
5
|
+
# VERSION: 0.2.4
|
|
6
6
|
# CREATED: 2023-12-01 06:18
|
|
7
7
|
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
8
|
# DESCRIPTION:
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# *************************************************************
|
|
12
12
|
|
|
13
13
|
### Standard packages ###
|
|
14
|
-
from typing import Set
|
|
14
|
+
from typing import List, Set
|
|
15
15
|
|
|
16
16
|
### Third-party packages ###
|
|
17
17
|
from click import command
|
|
@@ -27,14 +27,16 @@ def setup() -> None:
|
|
|
27
27
|
"""Download docker images used by command-line interface."""
|
|
28
28
|
client: DockerClient = from_env()
|
|
29
29
|
if client.ping():
|
|
30
|
+
outputs: List[str] = []
|
|
30
31
|
docker_images: Set[str] = {image.tags[0] for image in client.images.list()}
|
|
31
32
|
for registry_id in track(IMAGES.values(), "Download required images:".ljust(42)):
|
|
32
33
|
if registry_id in docker_images:
|
|
33
|
-
|
|
34
|
+
outputs.append(f"<Image: '{ registry_id }'> already exists in local docker images.")
|
|
34
35
|
else:
|
|
35
36
|
repository, tag = registry_id.split(":")
|
|
36
37
|
client.images.pull(repository=repository, tag=tag)
|
|
37
|
-
|
|
38
|
+
outputs.append(f"<Image: '{ registry_id }'> downloaded.")
|
|
39
|
+
list(map(print, outputs))
|
|
38
40
|
else:
|
|
39
41
|
print("!! Unable to connect to docker daemon.")
|
|
40
42
|
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3.8
|
|
2
|
-
# coding:utf-8
|
|
3
|
-
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
|
-
# FILENAME: ~~/src/commands/nodekeys.py
|
|
5
|
-
# VERSION: 0.2.2
|
|
6
|
-
# CREATED: 2023-12-01 05:31
|
|
7
|
-
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
|
-
# DESCRIPTION:
|
|
9
|
-
#
|
|
10
|
-
# HISTORY:
|
|
11
|
-
# *************************************************************
|
|
12
|
-
|
|
13
|
-
### Standard packages ###
|
|
14
|
-
from re import match
|
|
15
|
-
|
|
16
|
-
### Third-party packages ###
|
|
17
|
-
from click import command
|
|
18
|
-
from docker import DockerClient, from_env
|
|
19
|
-
from pydantic import TypeAdapter
|
|
20
|
-
from rich.progress import track
|
|
21
|
-
|
|
22
|
-
### Local modules ###
|
|
23
|
-
from src.schemas import LNDInfo
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@command
|
|
27
|
-
def nodekeys() -> None:
|
|
28
|
-
"""Fetch nodekeys from active LND containers."""
|
|
29
|
-
client: DockerClient = from_env()
|
|
30
|
-
if client.ping():
|
|
31
|
-
for container in track(client.containers.list(), "Fetch LND nodekeys:".ljust(42)):
|
|
32
|
-
if match(r"tranche-lnd|tranche-ping|tranche-pong", container.name) is not None:
|
|
33
|
-
lnd_info: LNDInfo = TypeAdapter(LNDInfo).validate_json(
|
|
34
|
-
container.exec_run(
|
|
35
|
-
"""
|
|
36
|
-
lncli
|
|
37
|
-
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
38
|
-
--rpcserver=localhost:10001
|
|
39
|
-
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
40
|
-
getinfo
|
|
41
|
-
"""
|
|
42
|
-
).output
|
|
43
|
-
)
|
|
44
|
-
print(f"<Nodekey: '{container.name}', '{lnd_info.identity_pubkey}'>")
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
__all__ = ["nodekeys"]
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3.8
|
|
2
|
-
# coding:utf-8
|
|
3
|
-
# Copyright (C) 2022-2023 All rights reserved.
|
|
4
|
-
# FILENAME: ~~/src/commands/ping_pong.py
|
|
5
|
-
# VERSION: 0.2.2
|
|
6
|
-
# CREATED: 2023-12-01 06:18
|
|
7
|
-
# AUTHOR: Sitt Guruvanich <aekasitt.g+github@siamintech.co.th>
|
|
8
|
-
# DESCRIPTION:
|
|
9
|
-
#
|
|
10
|
-
# HISTORY:
|
|
11
|
-
# *************************************************************
|
|
12
|
-
|
|
13
|
-
### Standard packages ###
|
|
14
|
-
from re import match
|
|
15
|
-
from typing import Dict, List
|
|
16
|
-
|
|
17
|
-
### Third-party packages ###
|
|
18
|
-
from click import argument, command
|
|
19
|
-
from docker import DockerClient, from_env
|
|
20
|
-
from docker.models.containers import Container
|
|
21
|
-
from pydantic import TypeAdapter, ValidationError
|
|
22
|
-
from rich.progress import track
|
|
23
|
-
|
|
24
|
-
### Local modules ###
|
|
25
|
-
from src.schemas import LNDInfo, OpenChannel
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@command
|
|
29
|
-
@argument("channel_size", default=16777215)
|
|
30
|
-
def ping_pong(channel_size: int) -> None:
|
|
31
|
-
"""For "duo" cluster, create channels between LND nodes."""
|
|
32
|
-
client: DockerClient = from_env()
|
|
33
|
-
if client.ping():
|
|
34
|
-
nodekeys: Dict[str, str] = {}
|
|
35
|
-
containers: List[Container] = client.containers.list()
|
|
36
|
-
|
|
37
|
-
### Fetch nodekeys ###
|
|
38
|
-
for container in track(containers, "Fetch LND nodekeys:".ljust(42)):
|
|
39
|
-
if match(r"tranche-ping|tranche-pong", container.name) is not None:
|
|
40
|
-
lnd_info: LNDInfo = TypeAdapter(LNDInfo).validate_json(
|
|
41
|
-
container.exec_run(
|
|
42
|
-
"""
|
|
43
|
-
lncli
|
|
44
|
-
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
45
|
-
--rpcserver=localhost:10001
|
|
46
|
-
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
47
|
-
getinfo
|
|
48
|
-
"""
|
|
49
|
-
).output
|
|
50
|
-
)
|
|
51
|
-
nodekeys[container.name] = lnd_info.identity_pubkey
|
|
52
|
-
|
|
53
|
-
### Open channels ###
|
|
54
|
-
errors: List[str] = []
|
|
55
|
-
funding_txids: List[str] = []
|
|
56
|
-
for container in track(containers, "Open channels:".ljust(42)):
|
|
57
|
-
if container.name == "tranche-ping":
|
|
58
|
-
try:
|
|
59
|
-
open_channel: OpenChannel = TypeAdapter(OpenChannel).validate_json(
|
|
60
|
-
container.exec_run(
|
|
61
|
-
"""
|
|
62
|
-
lncli
|
|
63
|
-
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
64
|
-
--rpcserver=localhost:10001
|
|
65
|
-
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
66
|
-
openchannel %d
|
|
67
|
-
--node_key %s
|
|
68
|
-
--connect tranche-pong:9735
|
|
69
|
-
"""
|
|
70
|
-
% (channel_size, nodekeys.get("tranche-pong", ""))
|
|
71
|
-
).output
|
|
72
|
-
)
|
|
73
|
-
funding_txids.append(open_channel.funding_txid)
|
|
74
|
-
except ValidationError:
|
|
75
|
-
errors.append("!! Channel between tranche-ping to tranche-pong already opened.")
|
|
76
|
-
elif container.name == "tranche-pong":
|
|
77
|
-
try:
|
|
78
|
-
open_channel: OpenChannel = TypeAdapter(OpenChannel).validate_json(
|
|
79
|
-
container.exec_run(
|
|
80
|
-
"""
|
|
81
|
-
lncli
|
|
82
|
-
--macaroonpath=/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon
|
|
83
|
-
--rpcserver=localhost:10001
|
|
84
|
-
--tlscertpath=/home/lnd/.lnd/tls.cert
|
|
85
|
-
openchannel %d
|
|
86
|
-
--node_key %s
|
|
87
|
-
--connect tranche-ping:9735
|
|
88
|
-
"""
|
|
89
|
-
% (channel_size, nodekeys.get("tranche-ping", ""))
|
|
90
|
-
).output
|
|
91
|
-
)
|
|
92
|
-
funding_txids.append(open_channel.funding_txid)
|
|
93
|
-
except ValidationError:
|
|
94
|
-
errors.append("!! Channel between tranche-pong to tranche-ping already opened.")
|
|
95
|
-
print(f"Funding transactions: { funding_txids }")
|
|
96
|
-
for error in errors:
|
|
97
|
-
print(error)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
__all__ = ["ping_pong"]
|
|
File without changes
|
|
File without changes
|