Skip to content

bsv-blockchain/spv-wallet-go-client

🧰  spv-wallet-go-client

Lightweight Go client library for interacting with the SPV Wallet


Release Go Version License


CI / CD    Build Last Commit      Quality    Go Report Coverage
Security    Scorecard Security      Community    Contributors Sponsor


Project Navigation

📦 Installation 🧪 Examples & Tests 📚 Documentation
🤝 Contributing 🛠️ Code Standards ⚡ Benchmarks
🤖 AI Usage 📝 License 👥 Maintainers

📦 Installation

spv-wallet-go-client requires a supported release of Go.

go get -u github.com/bsv-blockchain/spv-wallet-go-client

📚 Documentation


Quick Start Guide

Quick Start Guide

The implementation enforces separation of concerns by isolating admin and non-admin APIs, requiring separate initialization for their respective clients. This ensures clarity and modularity when utilizing the exposed functionality.

UserAPI Initialization Methods:

  • Description: Initializes a UserAPI instance using an access key for authentication.
  • Note: Requests made with this instance will be securely signed, ensuring integrity and authenticity.
  • Description: Initializes a UserAPI instance using an extended private key (xPriv) for authentication.
  • Note: Requests made with this instance will also be securely signed.
  • Recommendation: This option offers a high level of security, making it a preferred choice alongside the access key option.
  • Description: Initializes a UserAPI instance using an extended public key (xPub).
  • Note: Requests made with this instance will not be signed.
  • Security Advisory: For enhanced security, it is strongly recommended to use either NewUserAPIWithAccessKey or NewUserAPIWithXPriv instead, as unsigned requests may be less secure.

AdminAPI Initialization Methods:

  • Description: Initializes a AdminAPI instance using an extended private key (xPriv) for authentication.
  • Note: Requests made with this instance will be securely signed, ensuring integrity and authenticity.
  • Description: Initializes a AdminAPI instance using an extended public key (xPub).
  • Note: Requests made with this instance will not be signed.
  • Security Advisory: For enhanced security, it is strongly recommended to use either NewAdminAPIWithXPrivinstead, as unsigned requests may be less secure.

Code snippets:

Compatibility & Support

Compatibility and Support

Deprecation Notice

The client does not support the following:

  • Admin and non-admin old endpoints of the SPV Wallet API based on the /v1/ prefix.
  • Deprecated methods for building query parameters for HTTP requests.

Current Compatibility

The client is designed for full compatibility with the newer /api/v1/ endpoints exposed by the SPV Wallet API. It focuses on aligning with the latest standards and structure provided by the API.

API Endpoints Compatibility

API Admin Endpoints Compatibility

Access Keys API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/users/keys Search access keys API

Contacts API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/contacts Search contacts API
POST /api/v1/admin/contacts/confirmations Confirm contact API
PUT /api/v1/admin/contacts/{id} Update contact API
DELETE /api/v1/admin/contacts/{id} Delete contact API
POST /api/v1/admin/contacts/{paymail} Create contact API

Invitations API

HTTP Method Endpoint Action Support Status API Code Pagination
POST /api/v1/admin/invitations/{id} Accept invitation API
DELETE /api/v1/admin/invitations/{id} Reject invitation API

Paymails API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/paymails Search paymails API
POST /api/v1/admin/paymails Create paymail API
GET /api/v1/admin/paymails/{id} Retrieve paymail API
DELETE /api/v1/admin/paymails/{id} Delete paymail API

Stats API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/stats Retrieve stats API

Status API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/status Retrieve status API

Transactions API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/transactions Search transactions API
GET /api/v1/admin/transactions/{id} Retrieve transaction API

UTXOs API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/utxos Search UTXOs API

Webhooks API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/webhooks/subscriptions Subscribe to webhook API
DELETE /api/v1/admin/webhooks/subscriptions Unsubscribe webhook API

XPubs API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/admin/users Search XPubs API
POST /api/v1/admin/users Create XPub API
API Non-Admin Endpoints Compatibility

API Non-Admin Endpoints Compatibility

Access Keys API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/users/current/keys Search access keys API
POST /api/v1/users/current/keys Create access key API
GET /api/v1/users/current/keys/{id} Retrieve access key API
DELETE /api/v1/users/current/keys/{id} Revoke access key API

Contacts API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/contacts Search contacts API
GET /api/v1/contacts/{paymail} Retrieve contact API
PUT /api/v1/contacts/{paymail} Upsert contact API
DELETE /api/v1/contacts/{paymail} Remove contact API
POST /api/v1/contacts/{paymail} Confirm contact API
DELETE /api/v1/contacts/{paymail} Unconfirm contact API

Invitations API

HTTP Method Endpoint Action Support Status API Code Pagination
POST /api/v1/invitations/{paymail}/contacts Accept invitation API
DELETE /api/v1/invitations/{paymail} Reject invitation API

Merkle Roots API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/merkleroots Search Merkle roots API

Paymails API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/paymails Search paymails API

Transactions API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/transactions Search transactions API
POST /api/v1/transactions Record transaction API
POST /api/v1/transactions/drafts Draft transaction API
GET /api/v1/transactions/{id} Retrieve transaction API
PATCH /api/v1/transactions/{id} Update transaction API

UTXOs API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/utxos Search UTXOs API

XPubs API

HTTP Method Endpoint Action Support Status API Code Pagination
GET /api/v1/users/current Retrieve current user info API
PATCH /api/v1/users/current Update current user info API
Development Build Commands

Get the MAGE-X build tool for development:

go install github.com/mrz1836/mage-x/cmd/magex@latest

View all build commands

magex help
Repository Features
  • Continuous Integration on Autopilot with GitHub Actions – every push is built, tested, and reported in minutes.
  • Pull‑Request Flow That Merges Itself thanks to auto‑merge and hands‑free Dependabot auto‑merge.
  • One‑Command Builds powered by battle‑tested MAGE-X targets for linting, testing, releases, and more.
  • First‑Class Dependency Management using native Go Modules.
  • Uniform Code Style via gofumpt plus zero‑noise linting with golangci‑lint.
  • Confidence‑Boosting Tests with testify, the Go race detector, crystal‑clear HTML coverage snapshots, and automatic uploads to Codecov.
  • Hands‑Free Releases delivered by GoReleaser whenever you create a new Tag.
  • Relentless Dependency & Vulnerability Scans via Dependabot, Nancy and govulncheck.
  • Security Posture by Default with CodeQL, OpenSSF Scorecard and secret‑leak detection via gitleaks.
  • Automatic Syndication to pkg.go.dev on every release for instant godoc visibility.
  • Polished Community Experience using rich templates for Issues & PRs.
  • 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 file, keeping reviews fast and focused.
  • Zero‑Noise Dev Environments with tuned editor settings (.editorconfig) plus curated ignore files for VS Code, Docker, and Git.
  • Label Sync Magic: your repo labels stay in lock‑step with .github/labels.yml.
  • Friendly First PR Workflow – newcomers get a warm welcome thanks to a dedicated workflow.
  • Standards‑Compliant Docs adhering to the standard‑readme spec.
  • Instant Cloud Workspaces via Gitpod – spin up a fully configured dev environment with automatic linting and tests.
  • Out‑of‑the‑Box VS Code Happiness with a preconfigured Go workspace and .vscode folder with all the right settings.
  • Optional Release Broadcasts to your community via Slack, Discord, or Twitter – plug in your webhook.
  • AI Playbook – machine‑readable guidelines in tech conventions.
  • Go-Pre-commit System - High-performance Go-native pre-commit hooks with 17x faster execution—run the same formatting, linting, and tests before every commit, just like CI.
  • Zero Python Dependencies - Pure Go implementation with environment-based configuration via .env.base.
  • DevContainers for Instant Onboarding – Launch a ready-to-code environment in seconds with VS Code DevContainers and the included .devcontainer.json config.
Library Deployment

This project uses goreleaser for streamlined binary and library deployment to GitHub. To get started, install it via:

brew install goreleaser

The release process is defined in the .goreleaser.yml configuration file.

Then create and push a new Git tag using:

magex version:bump push=true bump=patch branch=main

This process ensures consistent, repeatable releases with properly versioned artifacts and citation metadata.

Pre-commit Hooks

Set up the Go-Pre-commit System to run the same formatting, linting, and tests defined in AGENTS.md before every commit:

go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
go-pre-commit install

The system is configured via .env.base and can be customized using also using .env.custom and provides 17x faster execution than traditional Python-based pre-commit hooks. See the complete documentation for details.

GitHub Workflows

🎛️ The Workflow Control Center

All GitHub Actions workflows in this repository are powered by a single configuration files – your one-stop shop for tweaking CI/CD behavior without touching a single YAML file! 🎯

Configuration Files:

  • .env.base – Default configuration that works for most Go projects
  • .env.custom – Optional project-specific overrides

This magical file controls everything from:

  • ⚙️ Go version matrix (test on multiple versions or just one)
  • 🏃 Runner selection (Ubuntu or macOS, your wallet decides)
  • 🔬 Feature toggles (coverage, fuzzing, linting, race detection, benchmarks)
  • 🛡️ Security tool versions (gitleaks, nancy, govulncheck)
  • 🤖 Auto-merge behaviors (how aggressive should the bots be?)
  • 🏷️ PR management rules (size labels, auto-assignment, welcome messages)

Workflow Name Description
auto-merge-on-approval.yml Automatically merges PRs after approval and all required checks, following strict rules.
codeql-analysis.yml Analyzes code for security vulnerabilities using GitHub CodeQL.
dependabot-auto-merge.yml Automatically merges Dependabot PRs that meet all requirements.
fortress.yml Runs the GoFortress security and testing workflow, including linting, testing, releasing, and vulnerability checks.
pull-request-management.yml Labels PRs by branch prefix, assigns a default user if none is assigned, and welcomes new contributors with a comment.
scorecard.yml Runs OpenSSF Scorecard to assess supply chain security.
stale.yml Warns about (and optionally closes) inactive issues and PRs on a schedule or manual trigger.
sync-labels.yml Keeps GitHub labels in sync with the declarative manifest at .github/labels.yml.
Updating Dependencies

To update all dependencies (Go modules, linters, and related tools), run:

magex deps:update

This command ensures all dependencies are brought up to date in a single step, including Go modules and any tools managed by MAGE-X. It is the recommended way to keep your development environment and CI in sync with the latest versions.


🧪 Examples & Tests

All unit tests and examples run via GitHub Actions and use Go version 1.24.x. View the configuration file.

Run all tests (fast):

magex test

Run all tests with race detector (slower):

magex test:race

⚡ Benchmarks

Run the Go benchmarks:

magex bench

🛠️ Code Standards

Read more about this Go project's code standards.


🤖 AI Usage & Assistant Guidelines

Read the AI Usage & Assistant Guidelines for details on how AI is used in this project and how to interact with AI assistants.


👥 Maintainers

Siggi Galt MrZ
Siggi Dylan MrZ

🤝 Contributing

View the contributing guidelines and please follow the code of conduct.

How can I help?

All kinds of contributions are welcome 🙌! The most basic way to show your support is to star 🌟 the project, or to raise issues 💬.

Stars


📝 License

License