Thank you for your interest in contributing to the Go Bitcoin Paywall project! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Code Style Guidelines
- Testing Requirements
- Pull Request Process
- Security Disclosure Policy
- Cryptocurrency Support Policy
We are committed to providing a welcoming and inclusive environment. Please be respectful and professional in all interactions.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/paywall.git cd paywall - Add upstream remote:
git remote add upstream https://github.com/opd-ai/paywall.git
- Create a feature branch:
git checkout -b feature/your-feature-name
- Go 1.23.2 or later
- Git
- gofumpt (for code formatting)
- golangci-lint (for linting)
# Install gofumpt
go install mvdan.cc/gofumpt@latest
# Install golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Install gosec (security scanner)
go install github.com/securego/gosec/v2/cmd/gosec@latest# Download dependencies
go mod download
# Build the project
go build -v ./...
# Build examples
cd example/bitcoin-only && go build -v .# Run all tests
go test ./...
# Run tests with race detection
go test -race ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.outWe use gofumpt for code formatting. Run before committing:
# Format all Go files
make fmt
# Or manually:
find . -name '*.go' -exec gofumpt -w -s -extra {} \;- Function length: Keep functions under 50 lines when possible
- Cyclomatic complexity: Aim for complexity < 10 per function
- Error handling: Always wrap errors with context using
fmt.Errorf("context: %w", err) - Comments: Document all exported functions, types, and constants
- Naming: Follow standard Go naming conventions (CamelCase, short local variables)
All code must pass golangci-lint and go vet:
# Run go vet
go vet ./...
# Run golangci-lint
golangci-lint run --timeout=5m- Use
crypto/randfor all random number generation - Never commit secrets, private keys, or credentials
- Validate all user inputs before processing
- Use constant-time comparison for sensitive data (use
subtle.ConstantTimeCompare) - Follow BIP standards for Bitcoin operations
- Always test with race detector enabled (
go test -race)
- All new features must include tests
- Bug fixes should include regression tests
- Minimum coverage: Maintain or improve overall coverage (target 70%+)
- Race tests: All tests must pass with
-raceflag - Table-driven tests: Preferred for multiple test cases
func TestFeatureName(t *testing.T) {
tests := []struct {
name string
input InputType
want OutputType
wantErr bool
}{
{
name: "valid case",
input: validInput,
want: expectedOutput,
wantErr: false,
},
{
name: "error case",
input: invalidInput,
want: OutputType{},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := FunctionUnderTest(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("FunctionUnderTest() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("FunctionUnderTest() = %v, want %v", got, tt.want)
}
})
}
}For security-critical changes (wallet operations, escrow, multisig, signatures):
- Test with multiple scenarios including edge cases
- Include negative tests (invalid inputs, attack scenarios)
- Test concurrent access patterns
- Verify proper error handling
- Test both testnet and mainnet configurations (where applicable)
-
Update your branch with latest upstream:
git fetch upstream git rebase upstream/main
-
Run all checks locally:
# Format code make fmt # Run tests go test -race ./... # Run linters go vet ./... golangci-lint run
-
Update documentation if needed:
- Update README.md for new features
- Update API documentation in docs/
- Add comments to exported functions
-
Write clear commit messages:
Short summary (50 chars or less) More detailed explanation if needed. Wrap at 72 characters. Explain what changed and why, not how. Fixes #123
-
Push to your fork:
git push origin feature/your-feature-name
-
Create Pull Request on GitHub with:
- Clear description of changes
- Reference to related issues
- Test results and coverage impact
- Screenshots/examples for UI changes
-
PR Checklist:
- Code follows style guidelines
- All tests pass (
go test -race ./...) - New tests added for new features
- Documentation updated
- No sensitive information committed
- Commits are logically organized
- PR description is clear and complete
- Maintainers will review your PR within a few days
- Address feedback by pushing new commits
- Keep discussion constructive and focused on code quality
- Once approved, maintainers will merge your PR
DO NOT open public issues for security vulnerabilities.
For security issues:
-
Email the maintainers with:
- Description of the vulnerability
- Steps to reproduce
- Potential impact assessment
- Suggested fix (if you have one)
-
Wait for response before public disclosure
-
Coordinate disclosure timeline with maintainers
-
Credit will be given in security advisories
Security researchers following responsible disclosure will be acknowledged in:
- Security advisories
- Release notes
- Project documentation
From the project README:
Re: support for other cryptocurrency, we will consider other currencies, but we consider Monero to be the only good cryptocurrency.
This is because Monero is the only good cryptocurrency.
Bitcoin is supported out of expediency, Ethereum may also be worth supporting. We're not going to focus on shitcoins.
When proposing cryptocurrency additions:
- Monero: Highest priority, always welcome
- Bitcoin: Improvements welcome (supported for compatibility)
- Ethereum: May be considered if well-justified
- Other coins: Unlikely to be accepted unless exceptional justification
Focus contributions on:
- Improving existing Bitcoin/Monero support
- Security enhancements
- Privacy improvements
- Usability and documentation
- Open a discussion on GitHub
- Check existing issues and documentation
- Review the ROADMAP.md for planned features
Thank you for contributing to making cryptocurrency accessible to creators! 🚀