From ded4ddc6f9a968dce6a756d2854ac4dfc01f410d Mon Sep 17 00:00:00 2001 From: Impa10r Date: Tue, 14 Jan 2025 22:11:05 +0100 Subject: [PATCH] Add timout dialing lnd --- .vscode/launch.json | 2 +- CHANGELOG.md | 2 ++ cmd/psweb/ln/lnd.go | 8 +++++--- cmd/psweb/main.go | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e9eb78d..11f003d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,7 @@ "program": "${workspaceFolder}/cmd/psweb/", "showLog": false, //"envFile": "${workspaceFolder}/.env", - "args": ["-datadir", "/home/vlad/.peerswap_t4"] + //"args": ["-datadir", "/home/vlad/.peerswap_t4"] //"args": ["-datadir", "/home/vlad/.peerswap2"] }, // sudo bash -c 'echo 0 > /proc/sys/kernel/yama/ptrace_scope' diff --git a/CHANGELOG.md b/CHANGELOG.md index 387a8f6..f779774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Fix BTC to sats rounding bug preventing claim init or join - Fix external funding peg-in num of confirmations not registered +- Fix ClaimJoin OP_RETURN string +- Add timout dialing lnd - Wait for lightning to sync before subscribing ## 1.7.5 diff --git a/cmd/psweb/ln/lnd.go b/cmd/psweb/ln/lnd.go index d7036ad..00f0e6d 100644 --- a/cmd/psweb/ln/lnd.go +++ b/cmd/psweb/ln/lnd.go @@ -133,9 +133,11 @@ func lndConnection() (*grpc.ClientConn, error) { grpc.WithPerRPCCredentials(macCred), } - conn, err := grpc.Dial(host, opts...) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + conn, err := grpc.DialContext(ctx, host, opts...) if err != nil { - fmt.Println("lndConnection dial:", err) return nil, err } @@ -1185,7 +1187,7 @@ func DownloadAll() bool { ctx := context.Background() if MyNodeId == "" { - res, err := client.GetInfo(context.Background(), &lnrpc.GetInfoRequest{}) + res, err := client.GetInfo(ctx, &lnrpc.GetInfoRequest{}) if err != nil { // lnd not ready return false diff --git a/cmd/psweb/main.go b/cmd/psweb/main.go index 794c1c4..f5e208c 100644 --- a/cmd/psweb/main.go +++ b/cmd/psweb/main.go @@ -281,7 +281,7 @@ func startTimer() { onTimer() // then every minute - for range time.Tick(60 * time.Second) { + for range time.Tick(time.Minute) { onTimer() } } @@ -457,7 +457,7 @@ func setLogging(logFileName string) (func(), error) { } // add new line after start up - log.Println("------------------START-----------------") + log.Printf("------------------START %s-----------------", VERSION) return cleanup, nil }