bitcoin

package
v0.0.0-...-1329066 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 11 Imported by: 0

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"`
}

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