Skip to content

Commit

Permalink
wip: autoswap (#2)
Browse files Browse the repository at this point in the history
* feat: initial swap recommendations

* feat: swap recommendation command

* feat: `ChanId` in db and grpc

* experiment with wallet seed phrases

* feat: create swaps inside channel watcher

channel watcher was moved to rpc server to avoid cyclic imports

* feat: `Pair` type in boltz

* feat: liquid reverse swaps (#3)

* test liquid deposit

* feat: `BlindingKey` in db and grpc

* initial liquid experimenting

* liquid testing

* fix findVout

* add real claim tx in test

* feat: `Transaction` abstraction

* feat: `Network` abstraction

* cleanup test

* deps

* feat: use `Transaction`

* refactor: rename Size to VSize on Transaction

* fix cgo issues

* start implementing liquid tx building

* chore: fix dependency issue

* implement psetv2 for liquid

* fix lockup address for liquid

* fix signature in liquid tx construction

* refactor: more consistent naming, cleanup

* refactor: require instead of assert in tests

* cleanup

remove old tests and unnecessary submodule

* cleanup

* refactor: simplify address config

* feat: autoswap through `LocalBalanceThreshhold`

* feat: `SwapType` constants in boltz

* feat: pair parameter for service info

* refactor: remove `Pair` from config

* refactor: exclude in-use channels before recommendations

this helps avoid a situation where a strategy operating on the total channel balance picks a channel which is in-use

* feat: `Percentage` util

* feat: min local reserve, fee checks

* chore: add tools installation command in makefile

* feat: auto swap integration tests

* feat: use fresh db in test

* feat: channel specific swaps

currently reverse only

* refactor: move core autoswap functionality into module

* feat: regtest in workflow

* fix: channel balance denomination in sat instead of msat

* uncomment mempool test for now

* feat: `CheckInvoicePaid` function for lightning interface

reduce reliance on lnd - only chain listener is left now

* fix: add test config to repo

* fix: use `RetryFor` instead of `Maxdelay`

* fix: check all returned invoices in `CheckInvoicePaid`

* fix: handle error handling in lnd

* Update boltz/network.go

Co-authored-by: michael1011 <[email protected]>

* refactor: rename `NewBtcTx`

* Update boltzrpc/boltzrpc.proto

Co-authored-by: michael1011 <[email protected]>

* feat: budget config values

* feat: add `createdAt` and fee fields to db

* feat: error handling and claim tx fee from reverse nursery

* feat: QueryFees function

* feat: initial `Budget` implementation

* refactor: use `rawRecommendation` internally to distinguish between checked and unchecked

* feat: `IsAuto` param in fee calculation

* feat: initial failure backoff

* feat: reasons for channel exclusion

* fix: get btc asset id from network object

* refactor: rename `BlindingKey` to `OurOutputBlindingKey`

* cleanup

* refactor: use `QueryRow` in fee query

* comment

* refactor: rename `Dismissed` to `DismissedReason`

* refactor: use last budget end date as current start date and potentially move forward

* fix: coalesce in fee query so it doesnt disappear when no rows are present

* refactor: cleanup migrations

* refactor: make `DismissedReasons` an array

* feat: abstract onchain (#13)

* initial onchain interfaces

* feat: swap type check in imbalance strategy

* feat: swap init logs

* minor test improvements

* feat: abstract mempool and add mempool liquid support

* refactor: still use mempool for btc and liquid due to lacking cln support

* refactor: move address checking logic into autoswap package

* remove dead file

* feat: cln block listener through polling

* test: refund normal swaps

* fix: add different transaction output types back

* feat: lightning node configuration

* fix: minimum fee

* refactor: make strategy config more explicit

* feat: fee fallback to wallet

* refactor: use struct for parsing json in mempool

* feat: minimum fee in estimations

* fix: error if lightning cant connect at all

* feat: cln polling interval depending on network

* chore: cleanup

* refactor: remove pair param from swaprecommendations rpc

* update protos

* cleanup

* fix: merging errors

* add missing onchain to server

* fix: correct expiry in cln invoice creation

* feat: autostatus command

* feat: more default values for autoswap config

* feat: format dates properly

* feat: test autostats

* refactor: make stats sql more readable

* feat: total balance strategy with % threshhold

* refactor: dont provide a specific channel in local balance strat

* refactor: make autobduget uint64 in grpc

* refactor: return pointer to swaptype

* doc: proper description for new commands

* feat: correctly store onchain and service fees for all swaps (#17)

* feat: onchain transaction fee provider

* feat: save normal swap fees to database

* fix: production endpoint in mempool test

* fix: check script length of liquid outputs when finding fee

* feat: cache input transaction in btc tx fee calculation

* feat: add reverse swap fees to grpc and check them in tests

* feat: accurate representation of boltz service fee

* cleanup

* refactor: only store normal swap lockup fees if paid by internal wallet

other payments might come from exchanges that batch a lot of transactions together which would mess with our fee

* refactor: remove unnecessary network call

* feat: make sure onchain amount of normal swap is always stored

* refactor: make fee fields optional in grpc

* fix: merging errors

* fix: regtest (#19)

* fix: disable lnd channel specific payments for now

* change regtest branch for now

* test: run get info on cln instead of lnd (lnd causes issues?)

* update workflow

* fix permissions

* ci: only push on master

* refactor: remove unnecessary install step

* refactor: move onchain test to mempool to avoid import cycle

* fix old test

* refactor: rename all boltz-lnd occurences to boltz-client

* make tests more robust

* skip per channel autoswap tests

* bump go version

* fix: mempool fee test

* fix: adjust minfee for btc

* fix: linting issues

* fix: checkout code before installing go

* refactor: improve logging (#29)

* feat: new logger

* refactor: rename `logger.Warning` to `logger.Warn`

* chore: improve logging messages

* refactor: log level in config, remove logprefix

* fix: use new logger in tests aswell

* refactor: return no error in logger init

* refactor: move test logger to test pkg

* feat: grpc swap info streaming (#30)

* feat: swapinfo streaming rpc

* fix: make behaviour of `PayInvoice` identical across lnd and cln

* fix: make sure the swap listener isnt closed too early

* feat: intial streaming integraion in cli

* fix: wrong log placement in `PayReverseSwap`

* feat: channelforwarder

* fix: use new logger

* test: pay deposits via cli and use mempool api directly

* fix: explicitly close stop handler

* feat: log status of swap updates

* doc: add `ArgsUsage` to swapinfo commands

* doc: adjust `GetSwapInfoStream` comment

* feat: detect outdated macaroons

* fix: remove unnecessary buffers and properly close receiver channels

* fix: `SetSwapLockupTransactionId` sql parameters

* feat: initial gdk experimentation

* feat: mnemonic import / backup

* feat: liquid wallet cli commands

* feat: cleanup and test liquid wallet

* fix: use correct payment script in liquid transactions

* refactor: make chain used in transaction explicit

* feat: group liquid commands together

* fix: linting errors and cleanup

* refactor: unify channel ids (#31)

* refactor: unify channel ids and make naming more consistent

* revert unwanted changes

* fix: weird indentation

* test: more cases for channel id

* refactor: log message in cln

* refactor: better naming for `ChannelId` proto

* refactor: log both formats in chanId `String` function

* fix: allow parsing of empty string as zero-channel id

* test: poll balance on init for more reliability

* feat: liquid wallet grpc

* feat: include gdk details in eror message

* refactor: parse gdk results into proper structs for better safety

* feat: estimate fee

* refactor: properly free all GA_json objects

* feat: allow wallet creation through grpc

* fix: add missing macaroon permissions

* refactor: make sure free calls dont collide

* refactor: remove balance log on startup

* feat: support unconfidential addresses in reverse swaps

* refactor: dont return wallet info on import rpc

* feat: allow specifying subaccount to use

* doc: add comments to new rpc commands

* cleanup

* fix: eof for .gitignore

* feat: forbid p2pk claim addresses (#35)

* refactor: remove unnecessary secp lib

* fix: use correct subaccount in liquid `NewAddress`

* feat: normal liquid swaps (#36)

* feat: liquid swaps

* refactor: use createswap for deposit internally

* fix: minor fee issues and better tests

* fix: endpoint hell

* chore: improved error handling

* lint

* Update nursery/reverse.go

Co-authored-by: michael1011 <[email protected]>

---------

Co-authored-by: michael1011 <[email protected]>

* fix: dont send raw pairId to boltz

* fix: make sure right node is chosen

* refactor: better naming for autoswap config values

* test: dont use memory db

seems to cause some weird errors

* feat: static liquid linking (#37)

* fix: use correct subaccount in liquid `NewAddress`

* feat: static liquid linking

* cleanup

* use cross plattform builder

* refactor: remove --parallel 1 in favor of build arg

* feat: prettify cli (#38)

* feat: prettify listswaps

* refactor: timestamps in grpc and prettify in cli

* feat: highlight swap status

* feat: prettify autostatus command

* feat: allow yes/no to be y/n

* feat: prettify liquid commands

* fix: wait until liquid subaccounts are synced before fetching balances

* feat: loading spinner

* fix: proper errors

* feat: use survey lib for prompts

* cleanup

* feat: prettify swap stream and use it for deposit and withdraw

* refactor: take client instead of ctx as an argument  in commands that are reused

* fix: stop ticker in subaccount sync

* fix: default to btc when parsing pairId

* chore: deprecate old fields

* fix: add newline on end of swap stream

* fix: use actual fee estimate when paying normal swap internally

* docs: clarify config (#41)

* refactor: remove channel creation internally (#39)

* refactor: remove channel creation

* fix: connect to current lightning node instead of lnd

* feat: set mempool endpoint based on network (#49)

* fix: correct network check for setting boltz endpoint (#51)

* feat: unconfirmed liquid balances (#46)

* refactor: use native segwit accounts by default

* feat: return unconfirmed balance and type in subaccount grpc

* feat: parse liquid account type in cli

* fix: wrong error message

* refactor: add `Balance` message to `LiquidSubaccount` proto

* fix: correct account types

* feat: detect which node to use based on config (#57)

* refactor: move autoswap execution logic into AutoSwapper struct (#64)

* cleanup

* fix: ping mempool ws to avoid disconnect (#60)

* chore: better error messages for block listener

* fix: ping mempool websocket regulary to avoid disconnect

* fix: set node param in test AutoSwap test

* feat: show help commands when required args are missing (#56)

* feat: show help commands when required args are missing

* refactor: use decorator

* fix: no silly logs in test and better sqlite dsn

* refactor: rename datadir to .boltz and support old .boltz-lnd aswell (#61)

* fix: tests (#67)

* feat: cli improvements (#65)

* refactor: merge deposit and createswap commands

* refactor: merge withdraw and createreverserswap commands

* refactor: rename `Manual` category to `Swaps`

* refactor: improve command descriptions

* chore: update cli package

* feat: cli example usage

* feat: no-zero-conf flag on withdraw

* feat: shell completions setup command

* log

* fix: error if trying to autosend with 0 amount

eof

* refactor: remove aliases

* fix: newline

* feat: properly parse pair in createswap rpc to allow using L-BTC as a pair

* feat: --any-amount flag for createswap

* feat: --liquid flag

* fix: handle error

* feat: global description

* feat: liquid block listener (#71)

* feat: implement `BlockListener` for liquid wallet through gdk notifications

* feat: implement `GetBlockHeight` for `Wallet` interface

* feat: `GetBlockHeight` for mempool

* feat: make sure liquid wallet isnt used if not logged in

* feat: add `Notification` enum

* fix: check if lnd / cln are connected in `Ready` function

* fix: only fetch lockup tx fee once its confirmed (#68)

* fix: retry getting tx fee made by wallet

* fix: make sure lock up tx is set on recovery aswell

* feat: return custom Error if boltz returns error message in api

* fix: ignore boltz api error when querying lockup transaction

* fix: error message

* feat: allow external refund address for normal swaps (#69)

* feat: allow external refund address for normal swaps

* refactor: make `RefundAddress` optional in grpc

* fix: correct refunaddress comparison

* feat: stop command (#70)

* feat: stop command

* feat: nursery shutdown

* feat: add timeout to http shutdown

* feat: include `auto_send` in grpc

* test: refactor swap fee checking

* feat: allow sending unconfirmed transactions in liquid wallet

* fix: dont autosend in recovery test

* fix: only close swapListener once

* fix: lint

* refactor: combine external and internal refund tests

* feat: proper autoswap cli (#66)

* feat: show whether autoswapper is running in cli

* feat: autoswap rpc and cli

* feat: show strategy name in status

* feat: account for edge case where local balance threshhold is too low

* feat: restart swapper when liquid wallet has been changed

* feat: store and show errors happening on autoswapper startup

* fix: correct swap type on absolute balance strategy with relative threshhold

* refactor: remove autoswap daemon cli parameters

* feat: only add dismissed reason once

* refactor: threshhold -> threshold

* improve command description

Co-authored-by: Kilian <[email protected]>

* refactor: autoswap status

* feat: do not crash on startup if configuration is invalid

* feat: show config before enabling autoswap

* feat: allow excluding dismissed recommendations

* doc: basic autoswap description in cli

* refactor: rename

* fix: proper permissions for autoswap

* chore: cleanup boltzrpc

* chore: cleanup boltz rpc

* feat: autoswap macaroon entity

* cleanup

* refactor: make `no_dismissed` field optional

* fix(liquid): only remove mnemonic backup file instead of entire directory

seems to cause issues with gdk

---------

Co-authored-by: Kilian <[email protected]>

* fix(test): poll swap state on startup instead of trying to stream

* refactor: remove unnecessary `done` chan from swap streams

---------

Co-authored-by: michael1011 <[email protected]>
Co-authored-by: Kilian <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2023
1 parent cc0007c commit 9a5ed37
Show file tree
Hide file tree
Showing 118 changed files with 13,992 additions and 2,748 deletions.
2 changes: 1 addition & 1 deletion .chglog/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/BoltzExchange/boltz-lnd
repository_url: https://github.com/BoltzExchange/boltz-client
options:
commits:
filters:
Expand Down
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.so
*.a
vendor
bin
79 changes: 8 additions & 71 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,87 +15,24 @@ jobs:
strategy:
matrix:
platform: [ ubuntu-latest ]
go-version: [ 1.20.x ]

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

steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Install C cross compilers
run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi gcc-mingw-w64 gcc-mingw-w64-i686

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Fetch dependencies
run: go mod vendor
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build
- name: Build dockerfile
run: make docker

- name: Build binaries
run: make binaries

- name: Upload Linux AMD64 artifact
uses: actions/upload-artifact@v3
with:
name: boltz-lnd-linux-amd64
path: binaries/linux-amd64/

- name: Upload Linux ARM64 artifact
uses: actions/upload-artifact@v3
with:
name: boltz-lnd-linux-arm64
path: binaries/linux-arm64/

- name: Upload Linux ARM artifact
uses: actions/upload-artifact@v3
with:
name: boltz-lnd-linux-arm
path: binaries/linux-arm/

- name: Upload Windows AMD64 artifact
uses: actions/upload-artifact@v3
with:
name: boltz-lnd-windows-amd64
path: binaries/windows-amd64/

- name: Upload Windows 386 artifact
uses: actions/upload-artifact@v3
with:
name: boltz-lnd-windows-386
path: binaries/windows-386/

darwin:
name: Build binaries for Darwin

strategy:
matrix:
platform: [ macos-latest ]
go-version: [ 1.19.x ]

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

steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Fetch dependencies
run: go mod vendor

- name: Build
run: make build

- name: Upload Darwin AMD64 artifact
uses: actions/upload-artifact@v3
with:
name: boltz-lnd-darwin-amd64
path: |
boltzd
boltzcli
name: boltz-client-linux-amd64
path: bin
35 changes: 24 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
name: CI

on: [ push, pull_request ]
on:
push:
branches:
- master
pull_request:

jobs:
build:
name: CI

strategy:
matrix:
platform: [ ubuntu-latest ]
go-version: [ 1.20.x ]
platform: [ubuntu-latest]
go-version: [1.21.x]

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

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Fetch dependencies
run: go mod vendor

- name: Build
run: make build

- name: Test
- name: Setup Regtest
run: |
git clone https://github.com/BoltzExchange/legend-regtest-enviroment.git ~/regtest -b electrum
sudo chmod -R 777 ~/regtest
cd ~/regtest
chmod +x ./regtest
./regtest
sudo chmod -R a+rwx .
- name: Unit Tests
run: make unit

- name: Integration Tests
run: make integration

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: 'latest'
version: "latest"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.exe~
*.dll
*.so
*.a
*.dylib

boltzd
Expand All @@ -22,6 +23,8 @@ vendor/

# Config, database, log, certificate and macaroon files
boltz.toml
!cmd/boltzd/test/boltz.toml
cmd/boltzd/test/autoswap.toml
boltz.db
boltz.log
tls.key
Expand All @@ -30,3 +33,5 @@ tls.cert

# Goland
.idea/

liquid-wallet
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "go-secp256k1-zkp"]
path = go-secp256k1-zkp
url = https://github.com/vulpemventures/go-secp256k1-zkp
branch = v1.1.6
40 changes: 23 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
FROM golang:1.20.2-alpine3.17 as builder
FROM golang:1.21-alpine as go
FROM michael1011/gdk-ubuntu-builder:0.68.2 as builder

# Install dependencies.
RUN apk add --no-cache --update \
alpine-sdk \
git \
make \
gcc
ARG GDK_ARGS
RUN git clone https://github.com/Blockstream/gdk --depth 1 --branch release_0.68.2
RUN export PATH="/root/.cargo/bin:$PATH" && cd gdk && ./tools/build.sh --gcc --buildtype release --no-deps-rebuild --external-deps-dir /prebuild/gcc ${GDK_ARGS}

# Shallow clone project.
RUN git clone --depth=1 https://github.com/BoltzExchange/boltz-lnd /go/src/github.com/BoltzExchange/boltz-lnd
COPY --from=go /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:$PATH"

WORKDIR /boltz-client

COPY . ./
RUN cp /root/gdk/gdk/build-gcc/libgreenaddress_full.a /boltz-client/onchain/liquid/lib/

# Build the binaries.
RUN cd /go/src/github.com/BoltzExchange/boltz-lnd \
&& go mod vendor \
&& make build
RUN make deps static

FROM scratch AS binaries

COPY --from=builder /boltz-client/boltzd /
COPY --from=builder /boltz-client/boltzcli /

# Start a new, final image.
FROM alpine:3.17 as final
FROM ubuntu:jammy as final

# Root volume for data persistence.
VOLUME /root/.boltz-lnd
VOLUME /root/.boltz-client

# Copy binaries.
COPY --from=builder /go/src/github.com/BoltzExchange/boltz-lnd/boltzd /bin/
COPY --from=builder /go/src/github.com/BoltzExchange/boltz-lnd/boltzcli /bin/
COPY --from=builder /boltz-client/boltzd /bin/
COPY --from=builder /boltz-client/boltzcli /bin/

# gRPC and REST ports
EXPOSE 9002 9003

ENTRYPOINT ["boltzd"]
CMD ["boltzd"]
63 changes: 48 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
PKG := github.com/BoltzExchange/boltz-lnd
PKG := github.com/BoltzExchange/boltz-client

PKG_BOLTZD := github.com/BoltzExchange/boltz-lnd/cmd/boltzd
PKG_BOLTZ_CLI := github.com/BoltzExchange/boltz-lnd/cmd/boltzcli
PKG_BOLTZD := github.com/BoltzExchange/boltz-client/cmd/boltzd
PKG_BOLTZ_CLI := github.com/BoltzExchange/boltz-client/cmd/boltzcli

GO_BIN := ${GOPATH}/bin

GOTEST := CGO_ENABLED=1 GO111MODULE=on go test -v
GOBUILD := CGO_ENABLED=1 GO111MODULE=on go build -v
GORUN := CGO_ENABLED=1 GO111MODULE=on go run -v
GOINSTALL := CGO_ENABLED=1 GO111MODULE=on go install -v
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/' | grep -v '/cmd/'

COMMIT := $(shell git log --pretty=format:'%h' -n 1)
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT) -w -s"

LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
LINT_VERSION := v1.50.1
LINT_VERSION := v1.55.0

LINT_BIN := $(GO_BIN)/golangci-lint
LINT_BIN := golangci-lint
LINT = $(LINT_BIN) run -v --timeout 5m

CHANGELOG_PKG := github.com/git-chglog/git-chglog/cmd/git-chglog
Expand Down Expand Up @@ -47,7 +47,19 @@ $(CHANGELOG_BIN):
@$(call print, "Fetching git-chglog")
go get -u $(CHANGELOG_PKG)

proto:
$(TOOLS_PATH):
eval export PATH="$PATH:$(go env GOPATH)/bin"


tools: $(TOOLS_PATH)
@$(call print, "Installing tools")
go install \
"github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway" \
"github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc" \
"google.golang.org/grpc/cmd/protoc-gen-go-grpc" \
"google.golang.org/protobuf/cmd/protoc-gen-go" \

proto: $(TOOLS_PATH)
@$(call print, "Generating protosbufs")
eval cd boltzrpc && ./gen_protos.sh && cd ..

Expand All @@ -59,15 +71,26 @@ unit:
@$(call print, "Running unit tests")
$(GOLIST) | $(XARGS) env $(GOTEST)

integration:
@$(call print, "Running integration tests")
$(GOTEST) -v $(PKG)/cmd/boltzd -skip TestAutoSwap/BTC/PerChannel


#
# Building
#

build:
@$(call print, "Building boltz-lnd")
$(GOBUILD) -o boltzd $(LDFLAGS) $(PKG_BOLTZD)
@$(call print, "Building boltz-client")
$(GOBUILD) $(ARGS) -o boltzd $(LDFLAGS) $(PKG_BOLTZD)
$(GOBUILD) $(ARGS) -o boltzcli $(LDFLAGS) $(PKG_BOLTZ_CLI)

static:
@$(call print, "Building static boltz-client")
$(GOBUILD) -tags static -o boltzd $(LDFLAGS) $(PKG_BOLTZD)
$(GOBUILD) -o boltzcli $(LDFLAGS) $(PKG_BOLTZ_CLI)


daemon:
@$(call print, "running boltzd")
$(GORUN) $(LDFLAGS) $(PKG_BOLTZD)
Expand All @@ -77,14 +100,18 @@ cli:
$(GORUN) $(LDFLAGS) $(PKG_BOLTZ_CLI)

install:
@$(call print, "Installing boltz-lnd")
@$(call print, "Installing boltz-client")
$(GOINSTALL) $(LDFLAGS) $(PKG_BOLTZD)
$(GOINSTALL) $(LDFLAGS) $(PKG_BOLTZ_CLI)

binaries:
@$(call print, "Compiling binaries")
eval ./binaries.sh linux-amd64 linux-arm64 linux-arm windows-amd64 windows-386

deps:
go mod vendor
cp -r ./go-secp256k1-zkp/secp256k1-zkp ./vendor/github.com/vulpemventures/go-secp256k1-zkp
# exclude the package and any lines including a # (#cgo, #include, etc.)
cd ./vendor/github.com/vulpemventures/go-secp256k1-zkp && \
sed -i '/#\|package/!s/secp256k1/go_secp256k1/g' *.go && \
find secp256k1-zkp -type f -name "*.c" -print0 | xargs -0 sed -i '/include/!s/secp256k1/go_secp256k1/g' && \
find secp256k1-zkp -type f -name "*.h" -print0 | xargs -0 sed -i '/include/!s/secp256k1/go_secp256k1/g'
#
# Utils
#
Expand All @@ -101,8 +128,14 @@ changelog:
@$(call print, "Updating changelog")
$(CHANGELOG)

PLATFORMS := linux/amd64

docker:
@$(call print, "Building docker image")
docker buildx build --push --platform linux/amd64 --platform linux/arm64 --platform linux/arm/v7 -t boltz/boltz-lnd:$(version) -t boltz/boltz-lnd:latest .
docker buildx build --push --platform $(PLATFORMS) -t boltz/boltz-client:$(version) -t boltz/boltz-client:latest .

binaries:
@$(call print, "Building binaries")
docker buildx build --output bin --platform $(PLATFORMS) --target binaries .

.PHONY: build binaries
Loading

0 comments on commit 9a5ed37

Please sign in to comment.