|
| 1 | +# Contributing to PeerSwap |
| 2 | + |
| 3 | +Thanks for your interest in contributing to PeerSwap! |
| 4 | + |
| 5 | +PeerSwap is software that interacts with real funds (Lightning + on-chain). Even |
| 6 | +small changes can have safety, reliability, and security implications. Please |
| 7 | +keep changes focused, test them well, and prefer incremental PRs. |
| 8 | + |
| 9 | +## Quick Start (Dev Environment) |
| 10 | + |
| 11 | +PeerSwap supports multiple development setups: |
| 12 | + |
| 13 | +- **Nix (recommended):** `direnv allow` (or `nix develop`) |
| 14 | +- **Devcontainer:** open the repo in VS Code and “Reopen in Container” |
| 15 | + |
| 16 | +See `README.md` and `docs/setup-nix.md` for details. |
| 17 | + |
| 18 | +## Substantial contributions only |
| 19 | + |
| 20 | +We welcome contributions of all sizes, including small fixes. At the same time, |
| 21 | +review bandwidth is limited and we sometimes receive spam/trivial PRs. |
| 22 | + |
| 23 | +To keep review time focused on meaningful improvements: |
| 24 | + |
| 25 | +- **Please avoid PRs that only do mechanical churn** (whitespace-only changes, |
| 26 | + mass reformatting, renames without behavior change, “update year in LICENSE”, |
| 27 | + etc.) unless there is a clear technical reason. |
| 28 | +- **Small fixes are welcome when they matter** (wrong command in docs, broken |
| 29 | + link, misleading text, user-facing typo, flaky test fix, small bug fix). |
| 30 | + If possible, **bundle multiple small doc/typo fixes into a single PR**. |
| 31 | +- If you are unsure whether a change is worth a PR, **open an issue first** or |
| 32 | + ask in the community channels (see `README.md`). |
| 33 | + |
| 34 | +This isn’t meant to discourage newcomers — it’s only to reduce low-signal PRs |
| 35 | +that are expensive to review. |
| 36 | + |
| 37 | +## Before You Start |
| 38 | + |
| 39 | +- For **larger changes** (new features, protocol changes, DB migrations, major |
| 40 | + refactors), please **open an issue or start a discussion first**. This helps |
| 41 | + avoid duplicate work and ensures the approach matches the project direction. |
| 42 | +- Keep in mind PeerSwap has two main integration modes (**CLN plugin** and |
| 43 | + **LND daemon/CLI**). If your change affects one side, consider whether it also |
| 44 | + impacts the other. |
| 45 | + |
| 46 | +## Development Practices |
| 47 | + |
| 48 | +### Keep PRs Reviewable |
| 49 | + |
| 50 | +- Prefer **small, focused PRs** over sweeping changes. |
| 51 | +- Avoid mixing unrelated changes (e.g., refactor + behavior change + vendoring). |
| 52 | +- Add/adjust tests when fixing bugs or changing behavior. |
| 53 | + |
| 54 | +### Formatting |
| 55 | + |
| 56 | +- Go code should be `gofmt`’d: `make fmt` |
| 57 | + |
| 58 | +### Tests |
| 59 | + |
| 60 | +- Unit tests (fast, local): `make test` |
| 61 | +- Integration tests live under `./test` and can be run via the `test-matrix-*` |
| 62 | + targets in `Makefile` (these are heavier and may require external services). |
| 63 | + |
| 64 | +### Linting |
| 65 | + |
| 66 | +- Run: `make lint` |
| 67 | +- Auto-fix where possible: `make lint/fix` |
| 68 | + |
| 69 | +Note: `make lint` is configured to lint only changes vs the base branch when |
| 70 | +possible (see `Makefile` for details). |
| 71 | + |
| 72 | +### Protobuf / RPC Changes |
| 73 | + |
| 74 | +If you change `.proto` files or RPC interfaces: |
| 75 | + |
| 76 | +- Regenerate stubs: `make all-rpc` (uses `buf generate`) |
| 77 | +- Lint/format protos: `make buf-lint` / `make buf-format` |
| 78 | + |
| 79 | +### Documentation Diagrams |
| 80 | + |
| 81 | +Some state/sequence diagrams are generated (Mermaid): |
| 82 | + |
| 83 | +- Generate docs: `make all-docs` |
| 84 | + |
| 85 | +## Code Review Expectations |
| 86 | + |
| 87 | +- CI should be green, or the PR description should explain why not. |
| 88 | +- Reviewers may ask for changes; please be responsive and keep iterations small. |
| 89 | +- Maintainers may request splitting large PRs into smaller, independent pieces. |
| 90 | + |
| 91 | +## Security |
| 92 | + |
| 93 | +If you believe you found a **security vulnerability**, please **do not** open a |
| 94 | +public issue. Prefer responsible disclosure using GitHub Security Advisories |
| 95 | +for this repository. |
| 96 | + |
| 97 | +## Licensing |
| 98 | + |
| 99 | +Unless stated otherwise, contributions are accepted under the terms of the |
| 100 | +repository license (see `LICENSE`). |
0 commit comments