bc

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2025 License: ISC Imports: 16 Imported by: 0

README ¶

🚀 go-bc

The go-to Bitcoin Block Chain (BC) GoLang library (Forked from libsv/go-bc)

CI / CD Quality & Security Docs & Meta Community
Latest Release
Build Status
CodeQL
SonarCloud
Go Report Card
Code Coverage
OpenSSF Scorecard
Security policy
Go version
Go docs
AGENTS.md rules
Makefile Supported
Dependabot
Contributors
Last commit
Sponsor

🗂️ Table of Contents


đź§© What's Inside

  • Block header building
  • Coinbase transaction building (cb1 + cb2 in stratum protocol)
  • Bitcoin block hash difficulty and hashrate functions
  • Merkle proof/root/branch functions

📦 Installation

go-bc requires a supported release of Go.

go get -u github.com/bsv-blockchain/go-bc

📚 Documentation

For more information around the technical aspects of Bitcoin, please see the updated Bitcoin Wiki


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 Make 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 Compliance Playbook – machine‑readable guidelines (AGENTS.md, CLAUDE.md, .cursorrules, sweep.yaml) keep ChatGPT, Claude, Cursor & Sweep aligned with your repo’s rules.
  • Pre-commit Hooks for Consistency powered by pre-commit and the .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 current via a weekly workflow.
  • 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.

To generate a snapshot (non-versioned) release for testing purposes, run:

make release-snap

Then create and push a new Git tag using:

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

make help

List of all current commands:

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
fumpt                 ## Run fumpt to format Go code
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               ## 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 Automatically merges PRs after approval and all required checks, following strict rules.
check-for-leaks.yml Runs gitleaks to detect secrets on a daily schedule.
clean-runner-cache.yml Removes GitHub Actions caches tied to closed pull requests.
codeql.yml Analyzes code for security vulnerabilities using GitHub CodeQL.
delete-merged-branches.yml Deletes feature branches after their pull requests are merged.
dependabot-auto-merge.yml Automatically merges Dependabot PRs that meet all requirements.
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 Builds and publishes releases via GoReleaser when a semver tag is pushed.
run-tests.yml Runs linter, Go tests and dependency checks on every push and pull request.
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.
update-pre-commit-hooks.yml Automatically update versions for pre-commit hooks
update-pip-requirements.yml Updates Python requirements for pre-commit hooks to the latest versions.
Updating Dependencies

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

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 hooks to run the same formatting, linting, and tests defined in AGENTS.md before every commit:

pip install pre-commit
pre-commit install

The hooks are configured in .pre-commit-config.yaml and mirror the CI pipeline.


đź§Ş 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:

make test

⚡ Benchmarks

Run the Go benchmarks:

make bench

Benchmark Results
Benchmark Iterations ns/op B/op allocs/op
NewBUMPFromMerkleTreeAndIndex 1,000,000,000 0.2684 0 0
ExpandTargetFrom 7,822,695 154.3 264 7

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.


🤖 AI Compliance

This project documents expectations for AI assistants using a few dedicated files:

  • AGENTS.md — canonical rules for coding style, workflows, and pull requests used by Codex.
  • CLAUDE.md — quick checklist for the Claude agent.
  • .cursorrules — machine-readable subset of the policies for Cursor and similar tools.
  • sweep.yaml — rules for 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

Siggi
Siggi

🤝 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 💬. You can also support this project by becoming a sponsor on GitHub 👏

Stars


📝 License

License

Documentation ¶

Overview ¶

Package bc is a bitcoin blockchain library bc = block chain.

Index ¶

Constants ¶

This section is empty.

Variables ¶

View Source
var (
	// ErrHeaderNotFound can be returned if the blockHash isn't found on the network.
	ErrHeaderNotFound = errors.New("header with not found")

	// ErrNotOnLongestChain indicates the blockhash is present but isn't on the longest current chain.
	ErrNotOnLongestChain = errors.New("header exists but is not on the longest chain")
)

Functions ¶

func BuildCoinbase ¶

func BuildCoinbase(c1 []byte, c2 []byte, extraNonce1 string, extraNonce2 string) []byte

BuildCoinbase recombines the different parts of the coinbase transaction. See https://arxiv.org/pdf/1703.06545.pdf section 2.2 for more info.

func BuildMerkleRoot ¶

func BuildMerkleRoot(txids []string) (string, error)

BuildMerkleRoot builds the Merkle Root from a list of transactions.

func BuildMerkleRootFromCoinbase ¶

func BuildMerkleRootFromCoinbase(coinbaseHash []byte, merkleBranches []string) []byte

BuildMerkleRootFromCoinbase builds the merkle root of the block from the coinbase transaction hash (txid) and the merkle branches needed to work up the merkle tree and returns the merkle root byte array.

func BuildMerkleTreeStore ¶

func BuildMerkleTreeStore(txids []string) ([]string, error)

BuildMerkleTreeStore creates a merkle tree from a slice of transaction IDs, stores it using a linear array, and returns a slice of the backing array. A linear array was chosen as opposed to an actual tree structure since it uses about half as much memory. The following describes a merkle tree and how it is stored in a linear array.

A merkle tree is a tree in which every non-leaf node is the hash of its children nodes. A diagram depicting how this works for bitcoin transactions where h(x) is a double sha256 follows:

         root = h1234 = h(h12 + h34)
        /                           \
  h12 = h(h1 + h2)            h34 = h(h3 + h4)
   /            \              /            \
h1 = h(tx1)  h2 = h(tx2)    h3 = h(tx3)  h4 = h(tx4)

The above stored as a linear array is as follows:

[h1 h2 h3 h4 h12 h34 root]

As the above shows, the merkle root is always the last element in the array.

The number of inputs is not always a power of two which results in a balanced tree structure as above. In that case, parent nodes with no children are also zero and parent nodes with only a single left node are calculated by concatenating the left node with itself before hashing. Since this function uses nodes that are pointers to the hashes, empty nodes will be nil.

The additional bool parameter indicates if we are generating the merkle tree using witness transaction id's rather than regular transaction id's. This also presents an additional case wherein the wtxid of the coinbase transaction is the zeroHash.

based off of bsvd: https://github.com/bitcoinsv/bsvd/blob/4c29707f717300d3eb92352081c3b0fec556881b/blockchain/merkle.go#L74

func BuildMerkleTreeStoreChainHash ¶

func BuildMerkleTreeStoreChainHash(txids []*chainhash.Hash) []*chainhash.Hash

BuildMerkleTreeStoreChainHash has the same functionality as BuildMerkleTreeStore but uses chainhash as a type to avoid string conversions.

func BytesFromStringReverse ¶

func BytesFromStringReverse(s string) []byte

BytesFromStringReverse decodes a hex string into a byte slice and reverses it.

func Decode32Byte ¶

func Decode32Byte(hexStr string) ([32]byte, error)

Decode32Byte decodes a hex string into a 32-byte array.

func DifficultyFromBits ¶

func DifficultyFromBits(bits []byte) (float64, error)

DifficultyFromBits returns the mining difficulty from the nBits field in the block header.

func DifficultyToHashrate ¶

func DifficultyToHashrate(coin string, diff uint64, targetSeconds float64) float64

DifficultyToHashrate takes a specific coin ticker, it's difficulty, and target and computes the estimated hashrate on that specific coin (or chain).

func Equals ¶

func Equals(b1 []byte, b2 []byte) bool

Equals checks if two byte arrays are equal.

func ExpandTargetFrom ¶

func ExpandTargetFrom(bits string) (string, error)

ExpandTargetFrom comment.

func ExpandTargetFromAsInt ¶

func ExpandTargetFromAsInt(bits string) (*big.Int, error)

ExpandTargetFromAsInt comment.

func ExtractMerkleRootFromBlockHeader ¶

func ExtractMerkleRootFromBlockHeader(header string) (string, error)

ExtractMerkleRootFromBlockHeader will take an 80 byte Bitcoin block header hex string and return the Merkle Root from it.

func GetCoinbaseParts ¶

func GetCoinbaseParts(height uint32, coinbaseValue uint64, defaultWitnessCommitment string, coinbaseText string,
	walletAddress string, minerIDBytes []byte,
) (coinbase1 []byte, coinbase2 []byte, err error)

GetCoinbaseParts returns the two split coinbase parts from coinbase metadata. See https://arxiv.org/pdf/1703.06545.pdf section 2.2 for more info.

func GetMerkleBranches ¶

func GetMerkleBranches(template []string) []string

GetMerkleBranches comment.

func HumanHash ¶

func HumanHash(val float64) string

HumanHash returns a human-readable hash/second value from a very large number.

func MerkleRootFromBranches ¶

func MerkleRootFromBranches(txHash string, txIndex int, branches []string) (string, error)

MerkleRootFromBranches returns a Merkle root given a transaction hash (txid), the index in which it is positioned in the Merkle tree, and the branches needed along the way (a Merkle path).

func MerkleTreeParent ¶

func MerkleTreeParent(leftNode, rightNode []byte) []byte

MerkleTreeParent returns the Merkle Tree parent of two Merkle Tree children.

func MerkleTreeParentBytes ¶

func MerkleTreeParentBytes(l *chainhash.Hash, r *chainhash.Hash) *chainhash.Hash

MerkleTreeParentBytes returns the Merkle Tree parent of two Merkle Tree children. The expectation is that the bytes are not reversed.

func MerkleTreeParentStr ¶

func MerkleTreeParentStr(leftNode, rightNode string) (string, error)

MerkleTreeParentStr returns the Merkle Tree parent of two Merkle Tree children using hex strings instead of just bytes.

func ReverseHexString ¶

func ReverseHexString(hex string) string

ReverseHexString reverses the hex string (little endian/big endian). This is used when computing merkle trees in Bitcoin, for example.

func Sha256Sha256 ¶

func Sha256Sha256(digest []byte) []byte

Sha256Sha256 calculates the double sha256 hash of a byte slice.

func SortByteArrays ¶

func SortByteArrays(src [][]byte) [][]byte

SortByteArrays comment.

func StringFromBytesReverse ¶

func StringFromBytesReverse(h []byte) string

StringFromBytesReverse reverses a byte slice and encodes it as a hex string.

func TxsToTxIDs ¶

func TxsToTxIDs(txs []string) ([]string, error)

TxsToTxIDs takes an array of transactions and returns instead an array of their corresponding transaction IDs.

func UInt32ToBytes ¶

func UInt32ToBytes(num uint32) []byte

UInt32ToBytes converts an uint32 into an array of bytes.

Types ¶

type BUMP ¶

type BUMP struct {
	BlockHeight uint64   `json:"blockHeight"`
	Path        [][]leaf `json:"path"`
}

BUMP data model json format according to BRC-74.

func NewBUMPFromBytes ¶

func NewBUMPFromBytes(bytes []byte) (*BUMP, error)

NewBUMPFromBytes creates a new BUMP from a byte slice.

func NewBUMPFromJSON ¶

func NewBUMPFromJSON(jsonStr string) (*BUMP, error)

NewBUMPFromJSON creates a BUMP from a JSON string.

func NewBUMPFromMerkleTreeAndIndex ¶

func NewBUMPFromMerkleTreeAndIndex(blockHeight uint64, merkleTree []*chainhash.Hash, txIndex uint64) (*BUMP, error)

NewBUMPFromMerkleTreeAndIndex with a merkle tree we calculate the merkle path for a given transaction.

func NewBUMPFromStr ¶

func NewBUMPFromStr(str string) (*BUMP, error)

NewBUMPFromStr creates a BUMP from hex string.

func NewBUMPFromStream ¶

func NewBUMPFromStream(bytes []byte) (*BUMP, int, error)

NewBUMPFromStream takes an array of bytes and contracts a BUMP from it, returning the BUMP and the bytes used. Despite the name, this is not reading a stream in the true sense: it is a byte slice that contains many BUMPs one after another.

func (*BUMP) Bytes ¶

func (bump *BUMP) Bytes() ([]byte, error)

Bytes encodes a BUMP as a slice of bytes. BUMP Binary Format according to BRC-74 https://brc.dev/74

func (*BUMP) CalculateRootGivenTxid ¶

func (bump *BUMP) CalculateRootGivenTxid(txid string) (string, error)

CalculateRootGivenTxid calculates the root of the Merkle tree given a txid.

func (*BUMP) String ¶

func (bump *BUMP) String() (string, error)

String encodes a BUMP as a hex string.

func (*BUMP) Txids ¶

func (bump *BUMP) Txids() []string

Txids returns the txids within the BUMP which the client is expecting. This allows a client to receive one BUMP for a whole block and it will know which txids it should update.

type Block ¶

type Block struct {
	BlockHeader *BlockHeader
	Txs         []*bt.Tx
}

A Block in the Bitcoin blockchain.

func NewBlockFromBytes ¶

func NewBlockFromBytes(b []byte) (*Block, error)

NewBlockFromBytes will encode a block header byte slice into the bitcoin block header structure.

See https://btcinformation.org/en/developer-reference#serialized-blocks

func NewBlockFromStr ¶

func NewBlockFromStr(blockStr string) (*Block, error)

NewBlockFromStr will encode a block header hash into the bitcoin block header structure.

See https://btcinformation.org/en/developer-reference#serialized-blocks

func (*Block) Bytes ¶

func (b *Block) Bytes() []byte

Bytes will decode a bitcoin block struct into a byte slice.

See https://btcinformation.org/en/developer-reference#serialized-blocks

func (*Block) String ¶

func (b *Block) String() string

String returns the Block Header encoded as hex string.

type BlockHeader ¶

type BlockHeader struct {
	Version        uint32 `json:"version"`
	Time           uint32 `json:"time"`
	Nonce          uint32 `json:"nonce"`
	HashPrevBlock  []byte `json:"hashPrevBlock"`
	HashMerkleRoot []byte `json:"merkleRoot"`
	Bits           []byte `json:"bits"`
}

A BlockHeader in the Bitcoin blockchain.

func NewBlockHeaderFromBytes ¶

func NewBlockHeaderFromBytes(headerBytes []byte) (*BlockHeader, error)

NewBlockHeaderFromBytes will encode a block header byte slice into the bitcoin block header structure.

See https://en.bitcoin.it/wiki/Block_hashing_algorithm

func NewBlockHeaderFromStr ¶

func NewBlockHeaderFromStr(headerStr string) (*BlockHeader, error)

NewBlockHeaderFromStr will encode a block header hash into the bitcoin block header structure.

See https://en.bitcoin.it/wiki/Block_hashing_algorithm

func (*BlockHeader) BitsStr ¶

func (bh *BlockHeader) BitsStr() string

BitsStr returns the Block Header encoded as hex string.

func (*BlockHeader) Bytes ¶

func (bh *BlockHeader) Bytes() []byte

Bytes will decode a bitcoin block header struct into a byte slice.

See https://en.bitcoin.it/wiki/Block_hashing_algorithm

func (*BlockHeader) HashMerkleRootStr ¶

func (bh *BlockHeader) HashMerkleRootStr() string

HashMerkleRootStr returns the Block Header encoded as hex string.

func (*BlockHeader) HashPrevBlockStr ¶

func (bh *BlockHeader) HashPrevBlockStr() string

HashPrevBlockStr returns the Block Header encoded as hex string.

func (*BlockHeader) MarshalJSON ¶

func (bh *BlockHeader) MarshalJSON() ([]byte, error)

MarshalJSON marshals the receiving bc.BlockHeader into a JSON []byte.

func (*BlockHeader) String ¶

func (bh *BlockHeader) String() string

String returns the Block Header encoded as hex string.

func (*BlockHeader) UnmarshalJSON ¶

func (bh *BlockHeader) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a JSON []byte into the receiving bc.BlockHeader.

func (*BlockHeader) Valid ¶

func (bh *BlockHeader) Valid() bool

Valid checks whether a blockheader satisfies the proof-of-work claimed in Bits. Wwe check whether its Hash256 read as a little endian number is less than the Bits written in expanded form.

type BlockHeaderChain ¶

type BlockHeaderChain interface {
	BlockHeader(ctx context.Context, blockHash string) (*BlockHeader, error)
}

A BlockHeaderChain is a generic interface used to map things in the block header chain (chain of block headers). For example, it is used to get a block Header from a bitcoin block hash if it exists in the longest block header chain.

Errors can be returned if the header isn't found or is on a stale chain, you may also use the ErrHeaderNotFound & ErrNotOnLongestChain sentinel errors when implementing the interface.

type MapiCallback ¶

type MapiCallback struct {
	CallbackPayload string `json:"callbackPayload"`
	APIVersion      string `json:"apiVersion"`
	Timestamp       string `json:"timestamp"`
	MinerID         string `json:"minerId"`
	BlockHash       string `json:"blockHash"`
	BlockHeight     uint64 `json:"blockHeight"`
	CallbackTxID    string `json:"callbackTxId"`
	CallbackReason  string `json:"callbackReason"`
}

MapiCallback is the body contents posted to the provided callback url from Merchant API.

func NewMapiCallbackFromBytes ¶

func NewMapiCallbackFromBytes(b []byte) (*MapiCallback, error)

NewMapiCallbackFromBytes is a glorified JSON unmarshaller, but might be more sophisticated in the future.

func (*MapiCallback) Bytes ¶

func (mcb *MapiCallback) Bytes() ([]byte, error)

Bytes convert the MapiCallback struct into a binary format. We are not going to parse anything out but rather take the whole JSON object as a binary blob. The reason behind this approach is that the mapi server signs the whole callback, so if a single byte is out of place, the signature will be invalid.

type MerklePath ¶

type MerklePath struct {
	Index uint64   `json:"index"`
	Path  []string `json:"path"`
}

MerklePath data model json format according to BRC-58.

func GetTxMerklePath ¶

func GetTxMerklePath(txIndex int, merkleTree []string) *MerklePath

GetTxMerklePath with a merkle tree we calculate the merkle path for a given transaction.

func NewMerklePathFromBytes ¶

func NewMerklePathFromBytes(bytes []byte) (*MerklePath, error)

NewMerklePathFromBytes creates a new MerklePath from a byte slice.

func NewMerklePathFromStr ¶

func NewMerklePathFromStr(str string) (*MerklePath, error)

NewMerklePathFromStr creates a MerklePath from hex string.

func (*MerklePath) Bytes ¶

func (mp *MerklePath) Bytes() ([]byte, error)

Bytes encodes a MerklePath as a slice of bytes. MerklePath Binary Format according to BRC-71 https://brc.dev/71

func (*MerklePath) CalculateRoot ¶

func (mp *MerklePath) CalculateRoot(txid string) (string, error)

CalculateRoot calculates the merkle root from a transaction ID and a MerklePath.

func (*MerklePath) String ¶

func (mp *MerklePath) String() (string, error)

String encodes a MerklePath as a hex string.

type MerkleProof ¶

type MerkleProof struct {
	Index      uint64   `json:"index"`
	TxOrID     string   `json:"txOrId"`
	Target     string   `json:"target"`
	Nodes      []string `json:"nodes"`
	TargetType string   `json:"targetType,omitempty"`
	ProofType  string   `json:"proofType,omitempty"`
	Composite  bool     `json:"composite,omitempty"`
}

A MerkleProof is a structure that proves the inclusion of a Bitcoin transaction in a block.

func (*MerkleProof) Bytes ¶

func (mp *MerkleProof) Bytes() ([]byte, error)

Bytes convert the JSON Merkle Proof into byte encoding.

Check the following encoding:

flags: byte, index: varint, txLength: varint, //omitted if flag bit 0 == 0 as it's a fixed length transaction ID txOrId: byte[32 or variable length], target: byte[32 or 80], //determined by flag bits 1 and 2 nodeCount: varint, nodes: node[]

Directories ¶

Path Synopsis
Package main is the main package for the examples
Package main is the main package for the examples
Package spv is a simple payment verification library for Bitcoin SV.
Package spv is a simple payment verification library for Bitcoin SV.
testing
data
Package data contains test data for the spv package.
Package data contains test data for the spv package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL