From 7e4c818b0b802687b0ed3ab953214d64d4b32309 Mon Sep 17 00:00:00 2001 From: git-nostr <4387895+git-nostr@users.noreply.github.com> Date: Thu, 23 Jul 2026 15:32:03 +0000 Subject: [PATCH 1/2] wallet: fix context leak from discarded WithTimeout cancel funcs RelayFee and EstimateFee discarded the cancel function returned by context.WithTimeout (flagged by go vet's lostcancel check). Deferring cancel releases the timer as soon as the function returns instead of leaking it until the 10s timeout fires on its own. --- wallet/service.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wallet/service.go b/wallet/service.go index 03fe35b..e61c03e 100644 --- a/wallet/service.go +++ b/wallet/service.go @@ -226,7 +226,8 @@ func (ws *WalletService) RelayFee() (float32, error) { return 0, electrum.ErrServerShutdown } - ctx, _ := context.WithTimeout(context.Background(), time.Second*10) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() return ws.electrumClient.GetRelayFee(ctx) } @@ -239,7 +240,8 @@ func (ws *WalletService) EstimateFee(target uint32) (float32, error) { return 0, electrum.ErrServerShutdown } - ctx, _ := context.WithTimeout(context.Background(), time.Second*10) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() return ws.electrumClient.GetFee(ctx, target) } From b2a1a8cde5870810c500995aa6b4bf808637b861 Mon Sep 17 00:00:00 2001 From: git-nostr <4387895+git-nostr@users.noreply.github.com> Date: Thu, 23 Jul 2026 15:34:07 +0000 Subject: [PATCH 2/2] ci: add GitHub Actions workflow for build, vet, and test Runs on push to main and on pull requests: go build ./..., go vet ./..., go test ./.... Uses go-version-file so the toolchain always tracks go.mod instead of being hardcoded. --- .github/workflows/ci.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..cd79448 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + build-and-test: + name: Build, Vet & Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Build + run: go build ./... + + - name: Vet + run: go vet ./... + + - name: Test + run: go test -timeout 20m ./...