https://github.com/bsv-blockchain/go-chaincfg
BSV network and genesis settings for blockchain initialization and consensus
https://github.com/bsv-blockchain/go-chaincfg
bitcoin bitcoinsv bsv genesis
Last synced: 4 months ago
JSON representation
BSV network and genesis settings for blockchain initialization and consensus
- Host: GitHub
- URL: https://github.com/bsv-blockchain/go-chaincfg
- Owner: bsv-blockchain
- License: isc
- Created: 2025-07-01T01:22:05.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2025-07-01T14:07:36.000Z (4 months ago)
- Last Synced: 2025-07-01T14:28:10.019Z (4 months ago)
- Topics: bitcoin, bitcoinsv, bsv, genesis
- Language: Go
- Homepage:
- Size: 154 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
- Support: .github/SUPPORT.md
Awesome Lists containing this project
README
# 🚀 go-chaincfg
> Defines BSV network parameters and genesis blocks to initialize and configure blockchain state and consensus behavior.
CIÂ /Â CD
Quality & Security
Docs & Meta
Community
## 🗂️ Table of Contents
* [Installation](#-installation)
* [Documentation](#-documentation)
* [Examples & Tests](#-examples--tests)
* [Benchmarks](#-benchmarks)
* [Code Standards](#-code-standards)
* [AI Compliance](#-ai-compliance)
* [Maintainers](#-maintainers)
* [Contributing](#-contributing)
* [License](#-license)
## 📦 Installation
**go-chaincfg** requires a [supported release of Go](https://golang.org/doc/devel/release.html#policy).
```shell script
go get -u github.com/bsv-blockchain/go-chaincfg
```
## 📚 Documentation
- **API Reference** – Dive into the godocs at [pkg.go.dev/github.com/bsv-blockchain/go-chaincfg](https://pkg.go.dev/github.com/bsv-blockchain/go-chaincfg)
- **Usage Examples** – Browse practical patterns either the [examples directory](examples)
- **Benchmarks** – Check the latest numbers in the [benchmark results](#benchmark-results)
- **Test Suite** – Review both the [unit tests](genesis_test.go) and [fuzz tests](chaincfg_fuzz_test.go) (powered by [`testify`](https://github.com/stretchr/testify))
> **Good to know:** `go-chaincfg` ships with *zero* runtime dependencies.
> The only external package we use is `testify`—and that's strictly for tests.
Repository Features
* **Continuous Integration on Autopilot** with [GitHub Actions](https://github.com/features/actions) – every push is built, tested, and reported in minutes.
* **Pull‑Request Flow That Merges Itself** thanks to [auto‑merge](.github/workflows/auto-merge-on-approval.yml) and hands‑free [Dependabot auto‑merge](.github/workflows/dependabot-auto-merge.yml).
* **One‑Command Builds** powered by battle‑tested [Make](https://www.gnu.org/software/make) targets for linting, testing, releases, and more.
* **First‑Class Dependency Management** using native [Go Modules](https://github.com/golang/go/wiki/Modules).
* **Uniform Code Style** via [gofumpt](https://github.com/mvdan/gofumpt) plus zero‑noise linting with [golangci‑lint](https://github.com/golangci/golangci-lint).
* **Confidence‑Boosting Tests** with [testify](https://github.com/stretchr/testify), the Go [race detector](https://blog.golang.org/race-detector), crystal‑clear [HTML coverage](https://blog.golang.org/cover) snapshots, and automatic uploads to [Codecov](https://codecov.io/).
* **Hands‑Free Releases** delivered by [GoReleaser](https://github.com/goreleaser/goreleaser) whenever you create a [new Tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging).
* **Relentless Dependency & Vulnerability Scans** via [Dependabot](https://dependabot.com), [Nancy](https://github.com/sonatype-nexus-community/nancy), and [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck).
* **Security Posture by Default** with [CodeQL](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning), [OpenSSF Scorecard](https://openssf.org), and secret‑leak detection via [gitleaks](https://github.com/gitleaks/gitleaks).
* **Automatic Syndication** to [pkg.go.dev](https://pkg.go.dev/) on every release for instant godoc visibility.
* **Polished Community Experience** using rich templates for [Issues & PRs](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository).
* **All the Right Meta Files** (`LICENSE`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `SUPPORT.md`, `SECURITY.md`) pre‑filled and ready.
* **Code Ownership** clarified through a [CODEOWNERS](.github/CODEOWNERS) file, keeping reviews fast and focused.
* **Zero‑Noise Dev Environments** with tuned editor settings (`.editorconfig`) plus curated *ignore* files for [VS Code](.editorconfig), [Docker](.dockerignore), and [Git](.gitignore).
* **Label Sync Magic**: your repo labels stay in lock‑step with [.github/labels.yml](.github/labels.yml).
* **Friendly First PR Workflow** – newcomers get a warm welcome thanks to a dedicated [workflow](.github/workflows/pull-request-management.yml).
* **Standards‑Compliant Docs** adhering to the [standard‑readme](https://github.com/RichardLitt/standard-readme/blob/master/spec.md) spec.
* **Instant Cloud Workspaces** via [Gitpod](https://gitpod.io/) – spin up a fully configured dev environment with automatic linting and tests.
* **Out‑of‑the‑Box VS Code Happiness** with a preconfigured [Go](https://code.visualstudio.com/docs/languages/go) workspace and [`.vscode`](.vscode) folder with all the right settings.
* **Optional Release Broadcasts** to your community via [Slack](https://slack.com), [Discord](https://discord.com), or [Twitter](https://twitter.com) – plug in your webhook.
* **AI Compliance Playbook** – machine‑readable guidelines ([AGENTS.md](.github/AGENTS.md), [CLAUDE.md](.github/CLAUDE.md), [.cursorrules](.cursorrules), [sweep.yaml](.github/sweep.yaml)) keep ChatGPT, Claude, Cursor & Sweep aligned with your repo’s rules.
* **Pre-commit Hooks for Consistency** powered by [pre-commit](https://pre-commit.com) and the [.pre-commit-config.yaml](.pre-commit-config.yaml) file—run the same formatting, linting, and tests before every commit, just like CI.
* **Automated Hook Updates** keep the [.pre-commit-config.yaml](.pre-commit-config.yaml) current via a weekly [workflow](.github/workflows/update-pre-commit-hooks.yml).
* **DevContainers for Instant Onboarding** – Launch a ready-to-code environment in seconds with [VS Code DevContainers](https://containers.dev/) and the included [.devcontainer/devcontainer.json](.devcontainer/devcontainer.json) config.
Library Deployment
This project uses [goreleaser](https://github.com/goreleaser/goreleaser) for streamlined binary and library deployment to GitHub. To get started, install it via:
```bash
brew install goreleaser
```
The release process is defined in the [.goreleaser.yml](.goreleaser.yml) configuration file.
To generate a snapshot (non-versioned) release for testing purposes, run:
```bash
make release-snap
```
Then create and push a new Git tag using:
```bash
make tag version=x.y.z
```
This process ensures consistent, repeatable releases with properly versioned artifacts and citation metadata.
Makefile Commands
View all `makefile` commands
```bash script
make help
```
List of all current commands:
```text
bench ## Run all benchmarks in the Go application
build-go ## Build the Go application (locally)
citation ## Update version in CITATION.cff (use version=X.Y.Z)
clean-mods ## Remove all the Go mod cache
coverage ## Show test coverage
diff ## Show git diff and fail if uncommitted changes exist
generate ## Run go generate in the base of the repo
godocs ## Trigger GoDocs tag sync
govulncheck-install ## Install govulncheck
help ## Display this help message
install-go ## Install using go install with specific version
install-releaser ## Install GoReleaser
install-template ## Kick-start a fresh copy of go-chaincfg (run once!)
install ## Install the application binary
lint ## Run the golangci-lint application (install if not found)
release-snap ## Build snapshot binaries
release-test ## Run release dry-run (no publish)
release ## Run production release (requires github_token)
run-fuzz-tests ## Run fuzz tests for all packages
tag-remove ## Remove local and remote tag (use version=X.Y.Z)
tag-update ## Force-update tag to current commit (use version=X.Y.Z)
tag ## Create and push a new tag (use version=X.Y.Z)
test-ci-no-race ## CI test suite without race detector
test-ci-short ## CI unit-only short tests
test-ci ## CI full test suite with coverage
test-no-lint ## Run only tests (no lint)
test-short ## Run tests excluding integration
test-unit ## Runs tests and outputs coverage
test ## Run lint and all tests
uninstall ## Uninstall the Go binary
update-linter ## Upgrade golangci-lint (macOS only)
update-releaser ## Reinstall GoReleaser
update ## Update dependencies
vet ## Run go vet
```
GitHub Workflows
| Workflow Name | Description |
|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| [auto-merge-on-approval.yml](.github/workflows/auto-merge-on-approval.yml) | Automatically merges PRs after approval and all required checks, following strict rules. |
| [check-for-leaks.yml](.github/workflows/check-for-leaks.yml) | Runs [gitleaks](https://github.com/gitleaks/gitleaks) to detect secrets on a daily schedule. |
| [clean-runner-cache.yml](.github/workflows/clean-runner-cache.yml) | Removes GitHub Actions caches tied to closed pull requests. |
| [codeql-analysis.yml](.github/workflows/codeql-analysis.yml) | Analyzes code for security vulnerabilities using [GitHub CodeQL](https://codeql.github.com/). |
| [delete-merged-branches.yml](.github/workflows/delete-merged-branches.yml) | Deletes feature branches after their pull requests are merged. |
| [dependabot-auto-merge.yml](.github/workflows/dependabot-auto-merge.yml) | Automatically merges [Dependabot](https://github.com/dependabot) PRs that meet all requirements. |
| [pull-request-management.yml](.github/workflows/pull-request-management.yml) | Labels PRs by branch prefix, assigns a default user if none is assigned, and welcomes new contributors with a comment. |
| [release.yml](.github/workflows/release.yml) | Builds and publishes releases via [GoReleaser](https://goreleaser.com/intro/) when a semver tag is pushed. |
| [run-tests.yml](.github/workflows/run-tests.yml) | Runs linter, Go tests and dependency checks on every push and pull request. |
| [scorecard.yml](.github/workflows/scorecard.yml) | Runs [OpenSSF](https://openssf.org/) Scorecard to assess supply chain security. |
| [stale.yml](.github/workflows/stale.yml) | Warns about (and optionally closes) inactive issues and PRs on a schedule or manual trigger. |
| [sync-labels.yml](.github/workflows/sync-labels.yml) | Keeps GitHub labels in sync with the declarative manifest at [`.github/labels.yml`](./.github/labels.yml). |
| [update-pre-commit-hooks.yml](.github/workflows/update-pre-commit-hooks.yml) | Automatically update versions for [pre-commit](https://pre-commit.com/) hooks |
| [update-pip-requirements.yml](.github/workflows/update-pip-requirements.yml) | Updates Python [requirements](./.github/workflows/update-pip-requirements.yml) for pre-commit hooks to the latest versions. |
Updating Dependencies
To update all dependencies (Go modules, linters, and related tools), run:
```bash
make update
```
This command ensures all dependencies are brought up to date in a single step, including Go modules and any tools managed by the Makefile. It is the recommended way to keep your development environment and CI in sync with the latest versions.
Pre-commit Hooks
Set up the optional [pre-commit](https://pre-commit.com) hooks to run the same formatting, linting, and tests defined in [AGENTS.md](.github/AGENTS.md) before every commit:
```bash
pip install pre-commit
pre-commit install
```
The hooks are configured in [.pre-commit-config.yaml](.pre-commit-config.yaml) and mirror the CI pipeline.
## đź§Ş Examples & Tests
All unit tests and [examples](examples) run via [GitHub Actions](https://github.com/bsv-blockchain/go-chaincfg/actions) and use [Go version 1.24.x](https://go.dev/doc/go1.24). View the [configuration file](.github/workflows/run-tests.yml).
Run all tests:
```bash script
make test
```
## ⚡ Benchmarks
Run the Go [benchmarks](chaincfg_benchmark_test.go):
```bash script
make bench
```
### Benchmark Results
| Benchmark | Iterations | ns/op | B/op | allocs/op |
|-------------------------------------|------------|------:|-----:|----------:|
| | | | | |
> These benchmarks reflect fast, allocation-free lookups for most retrieval functions, ensuring optimal performance in production environments.
> Performance benchmarks for the core functions in this library, executed on an Apple M1 Max (ARM64).
## 🛠️ Code Standards
Read more about this Go project's [code standards](.github/CODE_STANDARDS.md).
## 🤖 AI Compliance
This project documents expectations for AI assistants using a few dedicated files:
- [AGENTS.md](.github/AGENTS.md) — canonical rules for coding style, workflows, and pull requests used by [Codex](https://chatgpt.com/codex).
- [CLAUDE.md](.github/CLAUDE.md) — quick checklist for the [Claude](https://www.anthropic.com/product) agent.
- [.cursorrules](.cursorrules) — machine-readable subset of the policies for [Cursor](https://www.cursor.so/) and similar tools.
- [sweep.yaml](.github/sweep.yaml) — rules for [Sweep](https://github.com/sweepai/sweep), a tool for code review and pull request management.
Edit `AGENTS.md` first when adjusting these policies, and keep the other files in sync within the same pull request.
## 👥 Maintainers
| [
](https://github.com/icellan) |
|:--------------------------------------------------------------------------------------------------:|
| [Siggi](https://github.com/icellan) |
## 🤝 Contributing
View the [contributing guidelines](.github/CONTRIBUTING.md) and please follow the [code of conduct](.github/CODE_OF_CONDUCT.md).
### How can I help?
All kinds of contributions are welcome :raised_hands:!
The most basic way to show your support is to star :star2: the project, or to raise issues :speech_balloon:.
You can also support this project by [becoming a sponsor on GitHub](https://github.com/sponsors/bsv-blockchain) :clap:
[](https://github.com/bsv-blockchain/go-chaincfg/stargazers)
## 📝 License
[](LICENSE)