Skip to content

Commit

Permalink
refactor: package structure (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackstar12 authored Jan 7, 2025
1 parent 84c6671 commit 2fac4e2
Show file tree
Hide file tree
Showing 166 changed files with 318 additions and 317 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ boltzcli
!cmd/boltzd
!cmd/boltzcli
bin/
onchain/wallet/lib/
internal/onchain/wallet/lib/
boltz-client-*.tar.gz
boltz-client-manifest-*.txt

Expand All @@ -26,9 +26,9 @@ vendor/

# Config, database, log, certificate and macaroon files
boltz.toml
!rpcserver/test/boltz.toml
rpcserver/test/wallet
rpcserver/test/autoswap.toml
!internal/rpcserver/test/boltz.toml
internal/rpcserver/test/wallet
internal/rpcserver/test/autoswap.toml
boltz.db
boltz.log
tls.key
Expand Down
9 changes: 5 additions & 4 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
with-expecter: True
filename: "{{ .InterfaceName }}_mock.go"
dir: ./internal/mocks/{{.PackageName}}
packages:
github.com/BoltzExchange/boltz-client/v2/onchain:
github.com/BoltzExchange/boltz-client/v2/internal/onchain:
interfaces:
Wallet:
TxProvider:
BlockProvider:
github.com/BoltzExchange/boltz-client/v2/autoswap:
github.com/BoltzExchange/boltz-client/v2/internal/autoswap:
config:
dir: autoswap
dir: ./internal/autoswap
inpackage: True
interfaces:
RpcProvider:
github.com/BoltzExchange/boltz-client/v2/lightning:
github.com/BoltzExchange/boltz-client/v2/internal/lightning:
interfaces:
LightningNode:
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ restart-regtest: download-regtest

build-bolt12:
@$(call print, "Building bolt12")
cd lightning/lib/bolt12 && cargo build --release
cd internal/lightning/lib/bolt12 && cargo build --release

build: download-gdk build-bolt12
@$(call print, "Building boltz-client")
Expand Down Expand Up @@ -117,10 +117,10 @@ deps: submodules
find secp256k1-zkp -type f -name "*.h" -print0 | xargs -0 sed -i '/include/!s/secp256k1/go_secp256k1/g'

download-gdk:
ifeq ("$(wildcard onchain/wallet/lib/libgreen_gdk.so)","")
ifeq ("$(wildcard internal/onchain/wallet/lib/libgreen_gdk.so)","")
@$(call print, "Downloading gdk library")
@container_id=$$(docker create "boltz/gdk-ubuntu:$(GDK_VERSION)" true); \
docker cp "$$container_id:/" onchain/wallet/lib/ && \
docker cp "$$container_id:/" internal/onchain/wallet/lib/ && \
docker rm "$$container_id";
endif

Expand Down
6 changes: 3 additions & 3 deletions cmd/boltzcli/boltzcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"path"
"strings"

"github.com/BoltzExchange/boltz-client/v2/boltzrpc/client"
"github.com/BoltzExchange/boltz-client/v2/build"
"github.com/BoltzExchange/boltz-client/v2/utils"
"github.com/BoltzExchange/boltz-client/v2/internal/build"
"github.com/BoltzExchange/boltz-client/v2/internal/utils"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/client"
"github.com/urfave/cli/v2"
"google.golang.org/grpc/status"
)
Expand Down
12 changes: 6 additions & 6 deletions cmd/boltzcli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/client"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/serializers"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/client"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/serializers"
"google.golang.org/protobuf/proto"
"io"
"os"
Expand All @@ -21,10 +21,10 @@ import (
"google.golang.org/protobuf/encoding/protojson"

"github.com/AlecAivazis/survey/v2"
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/utils"
"github.com/BoltzExchange/boltz-client/v2/internal/utils"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/autoswaprpc"
"github.com/BurntSushi/toml"
"github.com/briandowns/spinner"
"github.com/fatih/color"
Expand Down
6 changes: 3 additions & 3 deletions cmd/boltzcli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import (
"errors"
"fmt"
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/utils"
"github.com/BoltzExchange/boltz-client/v2/internal/utils"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"os"
"regexp"
"strconv"
Expand Down
10 changes: 5 additions & 5 deletions cmd/boltzd/boltzd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package main

import (
"fmt"
"github.com/BoltzExchange/boltz-client/v2/build"
"github.com/BoltzExchange/boltz-client/v2/config"
"github.com/BoltzExchange/boltz-client/v2/logger"
"github.com/BoltzExchange/boltz-client/v2/rpcserver"
"github.com/BoltzExchange/boltz-client/v2/utils"
"github.com/BoltzExchange/boltz-client/v2/internal/build"
"github.com/BoltzExchange/boltz-client/v2/internal/config"
"github.com/BoltzExchange/boltz-client/v2/internal/logger"
"github.com/BoltzExchange/boltz-client/v2/internal/rpcserver"
"github.com/BoltzExchange/boltz-client/v2/internal/utils"
"os"
"os/signal"
"runtime"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions autoswap/autoswap.go → internal/autoswap/autoswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/database"
"github.com/BoltzExchange/boltz-client/v2/lightning"
"github.com/BoltzExchange/boltz-client/v2/logger"
"github.com/BoltzExchange/boltz-client/v2/onchain"
"github.com/BoltzExchange/boltz-client/v2/utils"
"github.com/BoltzExchange/boltz-client/v2/internal/database"
"github.com/BoltzExchange/boltz-client/v2/internal/lightning"
"github.com/BoltzExchange/boltz-client/v2/internal/logger"
"github.com/BoltzExchange/boltz-client/v2/internal/onchain"
"github.com/BoltzExchange/boltz-client/v2/internal/utils"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/autoswaprpc"
"github.com/BurntSushi/toml"
"google.golang.org/protobuf/encoding/protojson"
"os"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package autoswap

import (
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/database"
"github.com/BoltzExchange/boltz-client/v2/onchain"
"github.com/BoltzExchange/boltz-client/v2/internal/database"
"github.com/BoltzExchange/boltz-client/v2/internal/onchain"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"os"
"testing"

Expand Down
4 changes: 2 additions & 2 deletions autoswap/balance.go → internal/autoswap/balance.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package autoswap

import (
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/utils"
"github.com/BoltzExchange/boltz-client/v2/internal/utils"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
)

type Balance struct {
Expand Down
6 changes: 3 additions & 3 deletions autoswap/budget.go → internal/autoswap/budget.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package autoswap

import (
"errors"
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"time"

"github.com/BoltzExchange/boltz-client/v2/database"
"github.com/BoltzExchange/boltz-client/v2/internal/database"
)

type Budget struct {
Expand Down
14 changes: 7 additions & 7 deletions autoswap/chain.go → internal/autoswap/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package autoswap
import (
"errors"
"fmt"
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/serializers"
"github.com/BoltzExchange/boltz-client/v2/database"
"github.com/BoltzExchange/boltz-client/v2/logger"
"github.com/BoltzExchange/boltz-client/v2/onchain"
"github.com/BoltzExchange/boltz-client/v2/internal/database"
"github.com/BoltzExchange/boltz-client/v2/internal/logger"
"github.com/BoltzExchange/boltz-client/v2/internal/onchain"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/serializers"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"sync"
Expand Down
14 changes: 7 additions & 7 deletions autoswap/chain_test.go → internal/autoswap/chain_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package autoswap

import (
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/database"
onchainmock "github.com/BoltzExchange/boltz-client/v2/mocks/github.com/BoltzExchange/boltz-client/v2/onchain"
"github.com/BoltzExchange/boltz-client/v2/onchain"
"github.com/BoltzExchange/boltz-client/v2/test"
"github.com/BoltzExchange/boltz-client/v2/internal/database"
onchainmock "github.com/BoltzExchange/boltz-client/v2/internal/mocks/onchain"
"github.com/BoltzExchange/boltz-client/v2/internal/onchain"
"github.com/BoltzExchange/boltz-client/v2/internal/test"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/autoswaprpc"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
Expand Down
8 changes: 4 additions & 4 deletions autoswap/config_test.go → internal/autoswap/config_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package autoswap

import (
"github.com/BoltzExchange/boltz-client/v2/database"
"github.com/BoltzExchange/boltz-client/v2/onchain"
"github.com/BoltzExchange/boltz-client/v2/internal/database"
"github.com/BoltzExchange/boltz-client/v2/internal/onchain"
"testing"

"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"github.com/stretchr/testify/require"
)

Expand Down
16 changes: 8 additions & 8 deletions autoswap/lightning.go → internal/autoswap/lightning.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package autoswap
import (
"errors"
"fmt"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/serializers"
"github.com/BoltzExchange/boltz-client/v2/database"
"github.com/BoltzExchange/boltz-client/v2/onchain"
"github.com/BoltzExchange/boltz-client/v2/internal/database"
"github.com/BoltzExchange/boltz-client/v2/internal/onchain"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/serializers"
"google.golang.org/protobuf/proto"
"slices"
"sync"
"time"

"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/lightning"
"github.com/BoltzExchange/boltz-client/v2/logger"
"github.com/BoltzExchange/boltz-client/v2/internal/lightning"
"github.com/BoltzExchange/boltz-client/v2/internal/logger"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
)

type LightningSwapper = swapper[*LightningConfig]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package autoswap

import (
"github.com/BoltzExchange/boltz-client/v2/onchain"
"github.com/BoltzExchange/boltz-client/v2/test"
"github.com/BoltzExchange/boltz-client/v2/internal/onchain"
"github.com/BoltzExchange/boltz-client/v2/internal/test"
"testing"
"time"

"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/database"
"github.com/BoltzExchange/boltz-client/v2/lightning"
"github.com/BoltzExchange/boltz-client/v2/internal/database"
"github.com/BoltzExchange/boltz-client/v2/internal/lightning"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/autoswaprpc"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/fieldmaskpb"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package autoswap

import (
"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"math"

"github.com/BoltzExchange/boltz-client/v2/utils"
"github.com/BoltzExchange/boltz-client/v2/internal/utils"
)

type checks struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package autoswap

import (
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"github.com/stretchr/testify/require"
"testing"
)
Expand Down
8 changes: 4 additions & 4 deletions autoswap/rpc.go → internal/autoswap/rpc.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package autoswap

import (
"github.com/BoltzExchange/boltz-client/v2/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/boltzrpc/serializers"
"github.com/BoltzExchange/boltz-client/v2/lightning"
"github.com/BoltzExchange/boltz-client/v2/internal/lightning"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/serializers"
)

func serializeLightningChannel(channel *lightning.LightningChannel) *boltzrpc.LightningChannel {
Expand Down
8 changes: 4 additions & 4 deletions autoswap/strategy.go → internal/autoswap/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package autoswap
import (
"math"

"github.com/BoltzExchange/boltz-client/v2/boltzrpc/autoswaprpc"
"github.com/BoltzExchange/boltz-client/v2/lightning"
"github.com/BoltzExchange/boltz-client/v2/logger"
"github.com/BoltzExchange/boltz-client/v2/internal/lightning"
"github.com/BoltzExchange/boltz-client/v2/internal/logger"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltzrpc/autoswaprpc"

"github.com/BoltzExchange/boltz-client/v2/boltz"
"github.com/BoltzExchange/boltz-client/v2/pkg/boltz"
)

type Strategy = func(channels []*lightning.LightningChannel) []*LightningRecommendation
Expand Down
Loading

0 comments on commit 2fac4e2

Please sign in to comment.