Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tleekkul committed Jan 26, 2022
2 parents f1a0424 + 9388185 commit 9e97267
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 3,555 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ config.json
venv/
docker-compose.yml
.vscode/
/configs/slpdb-config.sh
48 changes: 40 additions & 8 deletions bch-devsuite
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import json
import os
import random
import shutil
import string
import subprocess
import sys
import time
from dataclasses import asdict, dataclass
from enum import Enum
from pathlib import Path
from typing import List, Optional
from urllib.parse import urlparse

import inquirer
import typer
Expand All @@ -25,6 +28,7 @@ BCH_GENERATE_ADDRESS = "bchreg:qzerfrqkvsclmrlx3hzl0j2ac2eh0k88wqa0efygtm"
BCH_WIF = "cUDjy47QLpAUyv1beivDPoYCHjCRVqwRMwCuSnkdF4teVFBDD1ip"



def subprocess_run(command):
typer.echo(f"DEBUG:subprocess_run:command: {command}")
output = subprocess.run(
Expand Down Expand Up @@ -63,9 +67,14 @@ class SLPMongoConf:

@dataclass
class RPCConf:
host: str
port: str
username: str
password: str

def host_without_protocol(self):
return urlparse(self.host).netloc


@dataclass
class LocalNode:
Expand All @@ -88,6 +97,7 @@ class InitConfig:
rest_service: Optional[RestService] = None
slp: Optional[SLPMongoConf] = None
smartbch: Optional[SmartBCHConf] = None
bch_rpc_conf: Optional[RPCConf] = None
exposed_ports: bool = True
docker_network: str = DEFAULT_DOCKER_NETWORK

Expand Down Expand Up @@ -155,12 +165,6 @@ def handle_local_node():
node = inquirer.list_input(
message="Local node?", choices=LOCAL_NODES, default=LOCAL_NODES[0]
)
username = inquirer.text(
message="Please enter a username for the node RPC connection"
)
password = inquirer.text(
message="Please enter a password for the node RPC connection"
)
regtest_blocks = None
if config.network == Network.REGTEST:
regtest_blocks = inquirer.text(
Expand All @@ -169,7 +173,6 @@ def handle_local_node():
)
config.local_node = LocalNode(
node=node,
rpc_conf=RPCConf(username=username, password=password),
regtest_blocks=regtest_blocks,
)

Expand Down Expand Up @@ -200,6 +203,17 @@ def handle_smartbch():
elif config.network in (Network.TESTNET, Network.MAINNET):
config.smartbch = SmartBCHConf(enabled=True)

def handle_bch_rpc_conf():
host = inquirer.text(message="BCH RPC host", default="http://bch-node")
port = inquirer.text(message="BCH RPC port", default=config.rpc_port())
username = inquirer.text(message="BCH RPC username", default="actorforth")
password = inquirer.text(message="BCH RPC password (randomly generated by default)", default=''.join(random.choices(string.ascii_letters + string.digits, k=32)))
config.bch_rpc_conf = RPCConf(
host=host,
port=port,
username=username,
password=password
)

component_handlers = {
"local_node": handle_local_node,
Expand All @@ -224,7 +238,7 @@ def build_config():
)
for component in components:
component_handlers[component]()

handle_bch_rpc_conf()
docker_network = inquirer.text(
message="docker network", default=DEFAULT_DOCKER_NETWORK
)
Expand Down Expand Up @@ -365,6 +379,22 @@ def setup_smartbch():
"""
pass

def make_executable(path):
mode = os.stat(path).st_mode
mode |= (mode & 0o444) >> 2 # copy R bits to X
os.chmod(path, mode)

def setup_slpdb():
if config.slp:
typer.echo(f"Setting up SLPDB...", nl=False)
with open("./configs/slpdb-config.sh", "w") as config_file:
config_file.write(
templates.get_template("slpdb-config.sh").render(
config=config, rpc_port=config.rpc_port()
)
)
make_executable('./configs/slpdb-config.sh')
typer.echo(success)

def pull_images():
"""
Expand Down Expand Up @@ -507,6 +537,7 @@ def init(
typer.echo("##############")
create_docker_network_if_not_exist()
setup_local_node()
setup_slpdb()
setup_rest_service()
setup_smartbch()
setup_docker_compose()
Expand Down Expand Up @@ -538,6 +569,7 @@ def clean():
remove("config file", "./config.json")
remove("config file", "./configs/bitcoin-unlimited.conf")
remove("config file", "./configs/bitcoincashnode.conf")
remove("config file", "./configs/slpdb-config.sh")
remove("config file", "./configs/temp-fulcrum-config.conf")
remove("docker-compose", "./docker-compose.yml")
remove("lock", "./.lock")
Expand Down
62 changes: 0 additions & 62 deletions docs/index.js

This file was deleted.

Loading

0 comments on commit 9e97267

Please sign in to comment.