bitcoin

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const BitcoinBlockHeaderLen = 80

Variables

View Source
var (
	ErrInvalidLengthBitcoin        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowBitcoin          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupBitcoin = fmt.Errorf("proto: unexpected end of group")
)

Functions

func Prove

func Prove(txid Hash256Digest, merkleRoot Hash256Digest, intermediateNodes []byte, index uint) bool

Prove checks the validity of a merkle proof

func VerifyHash256Merkle

func VerifyHash256Merkle(proof []byte, index uint) bool

VerifyHash256Merkle checks a merkle inclusion proof's validity. Note that `index` is not a reliable indicator of location within a block.

Types

type Hash256Digest

type Hash256Digest = chainhash.Hash

func Hash256

func Hash256(in []byte) Hash256Digest

Hash256 implements bitcoin's hash256 (double sha2)

func Hash256MerkleStep

func Hash256MerkleStep(a []byte, b []byte) Hash256Digest

Hash256MerkleStep concatenates and hashes two inputs for merkle proving

type Merkle

type Merkle struct {
	// contains filtered or unexported fields
}

Merkle is a wrapper around "github.com/btcsuite/btcd/blockchain" merkle tree. Additionally, it provides a method to generate a merkle proof for a given transaction.

func NewMerkle

func NewMerkle(txns []*btcutil.Tx) *Merkle

func (*Merkle) BuildMerkleProof

func (m *Merkle) BuildMerkleProof(txIndex int) ([]byte, uint, error)

BuildMerkleProof builds merkle proof for a given transaction index in block.

type Proof

type Proof struct {
	TxBytes []byte `protobuf:"bytes,1,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"`
	Path    []byte `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
	Index   uint32 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"`
}

Proof represents the proof of a bitcoin transaction

func (*Proof) Descriptor

func (*Proof) Descriptor() ([]byte, []int)

func (*Proof) GetIndex

func (m *Proof) GetIndex() uint32

func (*Proof) GetPath

func (m *Proof) GetPath() []byte

func (*Proof) GetTxBytes

func (m *Proof) GetTxBytes() []byte

func (*Proof) Marshal

func (m *Proof) Marshal() (dAtA []byte, err error)

func (*Proof) MarshalTo

func (m *Proof) MarshalTo(dAtA []byte) (int, error)

func (*Proof) MarshalToSizedBuffer

func (m *Proof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Proof) ProtoMessage

func (*Proof) ProtoMessage()

func (*Proof) Reset

func (m *Proof) Reset()

func (*Proof) Size

func (m *Proof) Size() (n int)

func (*Proof) String

func (m *Proof) String() string

func (*Proof) Unmarshal

func (m *Proof) Unmarshal(dAtA []byte) error

func (*Proof) XXX_DiscardUnknown

func (m *Proof) XXX_DiscardUnknown()

func (*Proof) XXX_Marshal

func (m *Proof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Proof) XXX_Merge

func (m *Proof) XXX_Merge(src proto.Message)

func (*Proof) XXX_Size

func (m *Proof) XXX_Size() int

func (*Proof) XXX_Unmarshal

func (m *Proof) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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