Skip to content

Commit 3f86844

Browse files
authored
Merge pull request #103 from Impa10r/premium
v5 with premiums
2 parents 7a3492f + 94b6dcc commit 3f86844

28 files changed

Lines changed: 1249 additions & 1120 deletions

.github/workflows/docker-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
run: |
3535
docker buildx build \
3636
--platform linux/arm64,linux/amd64 \
37+
--build-arg COMMIT=8f670390ff9277f02bd6d422d518de757ce2faf8 \
3738
--tag ghcr.io/impa10r/peerswap-web:${GITHUB_REF#refs/tags/} \
3839
--tag ghcr.io/impa10r/peerswap-web:latest \
3940
--output "type=registry" \

.github/workflows/manual-docker-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
run: |
3737
docker buildx build \
3838
--platform linux/arm64,linux/amd64 \
39+
--build-arg COMMIT=8f670390ff9277f02bd6d422d518de757ce2faf8 \
3940
--tag ghcr.io/impa10r/peerswap-web:${{ github.event.inputs.version }} \
4041
--tag ghcr.io/impa10r/peerswap-web:latest \
4142
--output "type=registry" \

.vscode/launch.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
"version": "0.2.0",
66
"configurations": [
77
{
8-
"name": "Launch Package",
8+
"name": "Launch LND version",
99
"type": "go",
1010
"request": "launch",
1111
"mode": "auto",
1212
"buildFlags": "-tags lnd",
1313
"program": "${workspaceFolder}/cmd/psweb/",
1414
"showLog": false,
1515
//"envFile": "${workspaceFolder}/.env",
16-
//"args": ["-datadir", "/home/vlad/.peerswap2_t4"]
17-
"args": ["-datadir", "/home/vlad/.peerswap2"]
16+
//"args": ["-datadir", "/home/vlad/.peerswap2"]
17+
//"args": ["-datadir", "/home/vlad/.peerswap_mac"]
1818
},
1919
// sudo bash -c 'echo 0 > /proc/sys/kernel/yama/ptrace_scope'
2020
// go install -tags cln -gcflags 'all=-N -l' ./cmd/psweb
2121
// lcli -k plugin subcommand=stop plugin=/home/vlad/go/bin/psweb
2222
// lcli -k plugin subcommand=start plugin=/home/vlad/go/bin/psweb
2323
{
24-
"name": "Attach to Package",
24+
"name": "Attach to CLN version",
2525
"type": "go",
2626
"request": "attach",
2727
"mode": "local",

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Versions
22

3+
## 1.8.0
4+
5+
- Breaking: requires peerswap v5 with premium feature
6+
- Enable setting premium rates and display those of peers
7+
- Add premium PPM limit for new swaps, blank by default
8+
- Remove words "Liquid balance" from telegram backups for privacy
9+
- Reduce L-BTC dust reserve to 170 sats for Elements v23.2.7+
10+
- CLN: fetch peers' aliases from gossip
11+
312
## 1.7.8
413

514
- Respect spendable and receivable limits for max swap calculation

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Build PeerSwap and PeerSwap Web UI in a joint container
33
###
44

5-
FROM golang:1.22.2-bookworm AS builder
5+
FROM golang:1.23.8-bookworm AS builder
66

77
#ENV CGO_ENABLED=1
88

cmd/psweb/config/cln.go

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,65 @@ import (
1010
"strings"
1111
)
1212

13+
var DatabaseFile string
14+
1315
// Config defaults for CLN
14-
func loadDefaults(home, dataDir string) {
16+
func loadDefaults(home, dataDir, network string) {
1517
if dataDir == "" {
1618
Config.LightningDir = filepath.Join(home, ".lightning")
1719
} else {
1820
// Drop the last folder
1921
Config.LightningDir = dataDir
2022
}
2123

22-
Config.RpcHost = filepath.Join(Config.LightningDir, "bitcoin")
23-
if Config.Chain == "testnet" {
24-
Config.RpcHost = filepath.Join(Config.LightningDir, "testnet")
24+
if network == "bitcoin" {
25+
Config.Chain = "mainnet"
26+
} else {
27+
Config.Chain = network
2528
}
29+
30+
Config.RpcHost = filepath.Join(Config.LightningDir, network)
2631
Config.DataDir = filepath.Join(Config.RpcHost, "peerswap")
32+
33+
// only sqlite3 supported for now
34+
DatabaseFile = filepath.Join(Config.RpcHost, "lightningd.sqlite3")
35+
36+
// check if the sqlite3 database is in a different location
37+
filePath := filepath.Join(Config.LightningDir, "config")
38+
39+
// Read the entire content of the file
40+
content, err := os.ReadFile(filePath)
41+
if err != nil {
42+
log.Println("Unable to read CLN config file")
43+
return
44+
}
45+
// Convert the content to a string
46+
fileContent := string(content)
47+
48+
// Search lines
49+
lines := strings.Split(fileContent, "\n")
50+
for _, line := range lines {
51+
l := strings.TrimSpace(line)
52+
if strings.HasPrefix(l, "#") {
53+
// ignore commented out lines
54+
continue
55+
}
56+
if parts := strings.Split(l, "="); len(parts) > 1 {
57+
if parts[0] == "wallet" {
58+
// ignore inline comments
59+
value := strings.TrimSpace(strings.Split(parts[1], "#")[0])
60+
// sqlite3:///home/user/.lightning/bitcoin/lightningd.sqlite3:/backup/lightningd.sqlite3
61+
// identify scheme and location
62+
p := strings.Split(value, ":")
63+
if p[0] != "sqlite3" {
64+
log.Fatalf("Only sqlite3 database is supported")
65+
}
66+
67+
DatabaseFile = p[1][2:]
68+
break
69+
}
70+
}
71+
}
2772
}
2873

2974
// CLN-specific load from Peerswap config

cmd/psweb/config/common.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type Configuration struct {
4848
AutoSwapMaxAmount uint64
4949
AutoSwapThresholdPPM uint64
5050
AutoSwapTargetPct uint64
51+
AutoSwapPremiumLimit int64
5152
SecureConnection bool
5253
ServerIPs string
5354
SecurePort string
@@ -78,7 +79,7 @@ func Load(dataDir string, network string) {
7879
Config.ElementsHost = "http://127.0.0.1"
7980
Config.ElementsPort = "18884"
8081

81-
Config.Chain = "mainnet"
82+
Config.Chain = network
8283
Config.NodeApi = "https://amboss.space/node"
8384
Config.BitcoinApi = "https://mempool.space"
8485
Config.LiquidApi = "https://liquid.network"
@@ -89,10 +90,9 @@ func Load(dataDir string, network string) {
8990
Config.SecureConnection = false
9091
Config.SecurePort = "1985"
9192

92-
if network == "testnet" {
93-
Config.Chain = "testnet"
94-
Config.NodeApi = "https://mempool.space/testnet/lightning/node"
95-
Config.BitcoinApi = "https://mempool.space/testnet"
93+
if network != "mainnet" {
94+
Config.NodeApi = "https://mempool.space/" + network + "/lightning/node"
95+
Config.BitcoinApi = "https://mempool.space/" + network
9696
Config.LiquidApi = "https://liquid.network/testnet"
9797
Config.ElementsPort = "7039"
9898
}
@@ -115,7 +115,7 @@ func Load(dataDir string, network string) {
115115
}
116116

117117
// different defaults for LND and CLN
118-
loadDefaults(currentUser.HomeDir, dataDir)
118+
loadDefaults(currentUser.HomeDir, dataDir, network)
119119

120120
// load config from peerswap.conf
121121
LoadPS()
@@ -176,10 +176,10 @@ func Save() error {
176176

177177
// fallback for Bitcoin Core API if local is unreachable
178178
func GetBlockIoHost() string {
179-
if Config.Chain == "testnet" {
180-
return "https://go.getblock.io/77cfc97c83e0454fb35557331188e7d6"
179+
if Config.Chain == "mainnet" {
180+
return "https://go.getblock.io/6f4b1867b4324698936d8d18ea99a245"
181181
} else {
182-
return "https://go.getblock.io/62af44fe83f540539ed0a1b52a80d41e"
182+
return "https://go.getblock.io/6bf5fea3b5344c43a061fd295f613be4"
183183
}
184184
}
185185

@@ -188,6 +188,7 @@ func GetHostname() string {
188188
// Get the hostname of the machine
189189
hostname, _ := os.Hostname()
190190

191+
// Env takes priority
191192
if os.Getenv("HOSTNAME") != "" {
192193
hostname = os.Getenv("HOSTNAME")
193194
}

cmd/psweb/config/lnd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
// Config defaults for LND
14-
func loadDefaults(home, dataDir string) {
14+
func loadDefaults(home, dataDir, _ string) {
1515
Config.LightningDir = filepath.Join(home, ".lnd")
1616
Config.RpcHost = "localhost:42069"
1717

0 commit comments

Comments
 (0)