Skip to content

Commit

Permalink
Merge pull request #363 from BoltzExchange/cln-hold-invoices
Browse files Browse the repository at this point in the history
CLN hold invoices
  • Loading branch information
michael1011 authored Aug 12, 2023
2 parents 2285372 + e652ce3 commit 483d6a6
Show file tree
Hide file tree
Showing 29 changed files with 2,518 additions and 272 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
matrix:
platform: [ubuntu-latest]
node-version: [18, 20]
python-version: ['3.10']

runs-on: ${{ matrix.platform }}

Expand All @@ -21,18 +22,33 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Use Poetry
uses: abatilo/actions-poetry@v2

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install dependencies
- name: Install Node.js dependencies
run: npm ci

- name: Install Python dependencies
run: poetry config virtualenvs.in-project true && npm run python:install

- name: Start containers
run: npm run docker:regtest && npm run docker:solidity

- name: Deploy Ethereum contracts
run: npm run docker:solidity:deploy

- name: Set Python symlink in regtest container
run: docker exec regtest mkdir -p $pythonLocation/bin &&
docker exec regtest ln -s /usr/bin/python3 $pythonLocation/bin/python

- name: Compile
run: npm run compile

Expand All @@ -42,8 +58,14 @@ jobs:
- name: Lint
run: npm run lint

- name: Python lint
run: npm run python:lint

- name: Unit tests
run: npm run test:unit

- name: Integration tests
run: node run-int.js

- name: Python plugin tests
run: npm run python:test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ typedoc/
# Built API documentation
site/

# Python cache
**/__pycache__

# Virtual Python environment
.venv
.ruff_cache
Expand Down
49 changes: 29 additions & 20 deletions docker/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class BuildArgument:
name: str
value: str


@dataclass
class Image:

Expand All @@ -23,6 +24,7 @@ class Image:
tags: list[str]
arguments: list[BuildArgument]


UBUNTU_VERSION = BuildArgument(
name="UBUNTU_VERSION",
value="22.04",
Expand All @@ -35,13 +37,13 @@ class Image:

GOLANG_VERSION = BuildArgument(
name="GOLANG_VERSION",
value="1.20.5-buster",
value="1.20.7-bullseye",
)

BITCOIN_VERSION = "25.0"
LITECOIN_VERSION = "0.21.2.2"
ELEMENTS_VERSION = "22.1.1"
GETH_VERSION = "1.12.0"
GETH_VERSION = "1.12.2"

C_LIGHTNING_VERSION = "23.05.2"
ECLAIR_VERSION = "0.9.0"
Expand Down Expand Up @@ -99,35 +101,43 @@ class Image:
],
),
"regtest": Image(
tags=["3.5.3"],
tags=["4.0.0"],
arguments=[
UBUNTU_VERSION,
BITCOIN_BUILD_ARG,
BuildArgument(
BuildArgument(
name="ELEMENTS_VERSION",
value=ELEMENTS_VERSION,
),
BuildArgument(
name="LND_VERSION",
value=LND_VERSION,
),
BuildArgument(
name="C_LIGHTNING_VERSION",
value=C_LIGHTNING_VERSION,
),
],
),
}


def print_step(message: str) -> None:
"""Print green text and is used to log the step of a process."""
print(f"\033[0;32m{message}\033[0;0m")


def print_error(message: str) -> None:
"""Print red text and is used to report errors."""
print(f"\033[1;31m{message}\033[0;0m")


def change_working_directory() -> None:
"""Change the working directory to the one this script is located in."""
directory = Path(__file__).parent
chdir(directory)


def get_build_details(image: str) -> Image:
"""Get the build details of an image or exits the script if they can't be found."""
build_details = IMAGES.get(image)
Expand All @@ -138,6 +148,7 @@ def get_build_details(image: str) -> Image:

return build_details


def list_images(to_list: list[str]) -> None:
"""List the version and build arguments of either one or all images."""
print("Images:")
Expand All @@ -156,13 +167,11 @@ def list_images(to_list: list[str]) -> None:
if build_details.arguments:
print(" Build arguments:")
for argument in build_details.arguments:
print(" - {name}:{value}".format(
name=argument.name,
value=argument.value,
))
print(f" - {argument.name}:{argument.value}")

print()


def build_images(
to_build: list[str],
organisation: str,
Expand All @@ -177,33 +186,30 @@ def build_images(
build_details = get_build_details(image)

for tag in build_details.tags:
build_args: list[str] = []
build_args = [f"{arg.name}={arg.value}" for arg in build_details.arguments]

# The regtest image doesn't need the version as a build flag
if image != "regtest":
build_args.append(f"VERSION={tag}")

for argument in build_details.arguments:
build_args.append("{name}={value}".format(
name=argument.name,
value=argument.value,
))

# Add the prefix "--build-arg " to every entry and
# join the array to a string
build_args = " ".join(["--build-arg " + entry for entry in build_args])
args = " ".join(["--build-arg " + entry for entry in build_args])

if buildx:
command = "docker buildx build --push {args} --platform " + \
platform + " --file {dockerfile} --tag {name}:{tag} ."
command = (
"docker buildx build --push {args} --platform "
+ platform
+ " --file {dockerfile} --tag {name}:{tag} ."
)
else:
command = "docker build -t {name}:{tag} -f {dockerfile} {args} ."

command = command.format(
tag=tag,
args=args,
name=f"{organisation}/{image}",
dockerfile=f"{image}/Dockerfile",
args=build_args,
)

if no_cache:
Expand All @@ -222,13 +228,15 @@ def build_images(
print()
print_step("Built images: {}".format(", ".join(to_build)))


def parse_images(to_parse: list[str]) -> list[str]:
"""Return all available images if none was specified."""
if not to_parse:
return list(IMAGES.keys())

return to_parse


if __name__ == "__main__":
PARSER = ArgumentParser(description="Build or push Docker images")

Expand All @@ -253,7 +261,8 @@ def parse_images(to_parse: list[str]) -> list[str]:

BUILDX_PARSER.add_argument("images", type=str, nargs="*")
BUILDX_PARSER.add_argument("--no-cache", dest="no_cache", action="store_true")
BUILDX_PARSER.add_argument("--platform",
BUILDX_PARSER.add_argument(
"--platform",
action="store_true",
default="linux/amd64,linux/arm64",
help="The platforms to build for",
Expand Down
2 changes: 1 addition & 1 deletion docker/c-lightning/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ WORKDIR /lightning
RUN git checkout v${VERSION}
RUN git submodule init && git submodule update

RUN ./configure
RUN ./configure --enable-developer
RUN make -j$(nproc)
RUN make install

Expand Down
10 changes: 10 additions & 0 deletions docker/regtest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ ARG BITCOIN_VERSION
ARG ELEMENTS_VERSION

ARG LND_VERSION
ARG C_LIGHTNING_VERSION

FROM boltz/bitcoin-core:${BITCOIN_VERSION} AS bitcoin-core
FROM ghcr.io/vulpemventures/elements:${ELEMENTS_VERSION} AS elements-core

FROM boltz/lnd:${LND_VERSION} as lnd
FROM boltz/c-lightning:${C_LIGHTNING_VERSION} as cln

FROM ubuntu:${UBUNTU_VERSION}

Expand All @@ -18,6 +20,7 @@ RUN apt-get -y install \
jq \
psmisc \
openssl \
python3 \
libdb-dev \
libdb++-dev \
libzmq3-dev \
Expand All @@ -41,13 +44,20 @@ COPY --from=elements-core /usr/local/bin/elements-cli /bin/
COPY --from=lnd /bin/lnd /bin/
COPY --from=lnd /bin/lncli /bin/

# Copy the Core Lightning executables
COPY --from=cln /bin/lightningd /bin/
COPY --from=cln /bin/lightning-cli /bin/
COPY --from=cln /usr/libexec /usr/libexec

# Copy configuration files
COPY regtest/data/core/config.conf /root/.bitcoin/bitcoin.conf
COPY regtest/data/elements/elements.conf /root/.elements/elements.conf

COPY regtest/data/lnd/lnd.conf /root/.lnd-btc/
COPY regtest/data/lnd/lnd.conf /root/.lnd-btc2/

COPY regtest/data/cln/config /root/.lightning/config

# Copy certificates for the LNDs
COPY regtest/data/lnd/certificates /root/.lnd-btc/
COPY regtest/data/lnd/certificates /root/.lnd-btc2/
Expand Down
10 changes: 10 additions & 0 deletions docker/regtest/data/cln/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
network=regtest
bind-addr=127.0.0.1:9737

log-file=/root/.lightning/cln.log

fee-base=0
fee-per-satoshi=1
large-channels

dev-fast-gossip
3 changes: 2 additions & 1 deletion docker/regtest/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ startNodes

bitcoin-cli loadwallet $DEFAULT_WALLET_NAME > /dev/null
elements-cli loadwallet $DEFAULT_WALLET_NAME > /dev/null
elements-cli-sim rescanblockchain 0 > /dev/null
elements-cli rescanblockchain 0 > /dev/null

startCln
startLnds

mkdir -p /cookies
Expand Down
Loading

0 comments on commit 483d6a6

Please sign in to comment.