Welcome to the BSV Blockchain Libraries Project, the comprehensive Go SDK designed to provide an updated and unified layer for developing scalable applications on the BSV Blockchain. This SDK addresses the limitations of previous tools by offering a fresh, peer-to-peer approach, adhering to SPV, and ensuring privacy and scalability.
The BSV Blockchain Libraries Project aims to structure and maintain a middleware layer of the BSV Blockchain technology stack. By facilitating the development and maintenance of core libraries, it serves as an essential toolkit for developers looking to build on the BSV Blockchain.
To install the SDK, run:
go install github.com/bitcoin-sv/go-sdk
Here's a simple example of using the SDK to create and sign a transaction:
package main
import (
"context"
"log"
wif "github.com/bitcoin-sv/go-sdk/compat/wif"
"github.com/bitcoin-sv/go-sdk/transaction"
"github.com/bitcoin-sv/go-sdk/transaction/unlocker"
)
func main() {
tx := transaction.NewTransaction()
unlockingScriptTemplate, _ := p2pkh.Unlock(priv, nil)
if err := tx.AddInputFrom(
"11b476ad8e0a48fcd40807a111a050af51114877e09283bfa7f3505081a1819d",
0,
"76a9144bca0c466925b875875a8e1355698bdcc0b2d45d88ac",
1500,
unlockingScriptTemplate,
); err!= nil {
log.Fatal(err.Error())
}
_ = tx.PayToAddress("1AdZmoAQUw4XCsCihukoHMvNWXcsd8jDN6", 1000)
priv, _ := ec.PrivateKeyFromWif("KznvCNc6Yf4iztSThoMH6oHWzH9EgjfodKxmeuUGPq5DEX5maspS")
if err := tx.Sign(); err != nil {
log.Fatal(err.Error())
}
log.Printf("tx: %s\n", tx)
}
See the Go Doc for a complete list of available modules and functions.
Our examples are organized by category to help you find what you need. Each example is self-contained and includes detailed comments.
- Creating a Simple Transaction - Basic transaction creation and signing
- Adding OP_RETURN Data - How to embed data in transactions
- Creating Inscriptions - Working with inscriptions
- Transaction Verification - How to verify transactions
- Fee Modeling - Understanding and calculating transaction fees
- Broadcasting Transactions - How to broadcast transactions to the network
- HD Key Generation - Creating hierarchical deterministic keys
- HD Key from Extended Public Key - Working with xPubs
- Child Key Derivation - Deriving child keys
- Address from WIF - Converting WIF to addresses
- AES Encryption - Symmetric encryption examples
- ECIES Single Key - Elliptic Curve Integrated Encryption Scheme
- ECIES Shared Keys - Working with shared ECIES keys
- ECIES Electrum Binary - Electrum-compatible ECIES
- Encrypted Messages - Working with encrypted messages
- Key Shares to Backup - Backing up private keys using Shamir's Secret Sharing
- Key Shares from Backup - Recovering private keys from shares
- Headers Client - Working with blockchain headers
- BEEF Verification - Verifying BEEF proofs
- Converting from go-bt - Guide for migrating from go-bt
Check out the examples folder for more examples.
- Performance Oriented: Designed to deliver performant functionality for large scale / high demand systems.
- Cryptographic Primitives: Secure key management, signature computations, and encryption protocols.
- Script Level Constructs: Network-compliant script interpreter with support for custom scripts and serialization formats.
- Transaction Construction and Signing: Comprehensive transaction builder API, ensuring versatile and secure transaction creation.
- Transaction Broadcast Management: Mechanisms to send transactions to both miners and overlays, ensuring extensibility and future-proofing.
- Merkle Proof Verification: Tools for representing and verifying merkle proofs, adhering to various serialization standards.
- Serializable SPV Structures: Structures and interfaces for full SPV verification.
- Secure Encryption and Signed Messages: Enhanced mechanisms for encryption and digital signatures, replacing outdated methods.
- Shamir Key Splitting & Recombining: Allows private keys to be split into N shares, and recombined by providing M of N shares.
- Compatability Packages: Supports additional / deprecated features like ECIES, Bitcoin Signed Message, and BIP32 style key derivation.
This SDK is supported by multiple layers of documentation:
- Examples - Common usage examples and code samples
- Concepts - High-level concepts and architectural decisions
- Low-Level Details - Implementation details and technical specifications
- Go Doc - Complete API reference
- Script Interpreter - Comprehensive documentation of the Bitcoin script interpreter
- Includes extensive test suite
- Based on the Bitcoin Script specification
- Transaction Management
- Basic transaction creation and signing
- Converting transactions from go-bt
- Cryptographic Operations
- Standard Pay-to-pubkey-hash operations
- Key management and derivation
- Script Operations
- Custom script creation
- Script interpretation and validation
For hands-on examples, visit our examples directory.
We're always looking for contributors to help us improve the SDK. Whether it's bug reports, feature requests, or pull requests - all contributions are welcome.
- Fork & Clone: Fork this repository and clone it to your local machine.
- Set Up: Run
go get github.com/bitcoin-sv/go-sdk
to get all the modules. - Make Changes: Create a new branch and make your changes.
- Test: Ensure all tests pass by running
go test ./...
. - Commit: Commit your changes and push to your fork.
- Pull Request: Open a pull request from your fork to this repository.
For more details, check the contribution guidelines.
For information on past releases, check out the changelog. For future plans, check the roadmap!
Project Owners: Thomas Giacomo and Darren Kellenschwiler
Development Team Lead: Luke Rohenaz
For questions, bug reports, or feature requests, please open an issue on GitHub or contact us directly.
The license for the code in this repository is the Open BSV License. Refer to LICENSE.txt for the license text.
Thank you for being a part of the BSV Blockchain Libraries Project. Let's build the future of BSV Blockchain together!