btctxformatter

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 7

Documentation

Index

Constants

View Source
const (
	TagLength = 4

	CurrentVersion FormatVersion = 0

	LastCommitHashLength = 32

	BitMapLength = 13

	AddressLength = 20

	// Each checkpoint is composed of two parts
	NumberOfParts = 2

	BlsSigLength = 48

	// 8 bytes are for 64bit unsigned epoch number
	EpochLength = 8

	RawBTCCheckpointLength = EpochLength + LastCommitHashLength + BitMapLength + BlsSigLength + AddressLength
)

Variables

This section is empty.

Functions

func ConnectParts

func ConnectParts(version FormatVersion, f []byte, s []byte) ([]byte, error)

ConnectParts composes raw checkpoint data by connecting two parts of checkpoint data and stripping off data that is not relevant to a raw checkpoint

func EncodeCheckpointData

func EncodeCheckpointData(
	tag BabylonTag,
	version FormatVersion,
	rawBTCCheckpoint *RawBtcCheckpoint,
) ([]byte, []byte, error)

func GetCheckpointData

func GetCheckpointData(
	tag BabylonTag,
	version FormatVersion,
	partIndex uint8,
	data []byte,
) ([]byte, error)

func MustEncodeCheckpointData

func MustEncodeCheckpointData(
	tag BabylonTag,
	version FormatVersion,
	rawBTCCheckpoint *RawBtcCheckpoint,
) ([]byte, []byte)

func U64ToBEBytes

func U64ToBEBytes(u uint64) []byte

Types

type BabylonData

type BabylonData struct {
	Data  []byte
	Index uint8
}

func IsBabylonCheckpointData

func IsBabylonCheckpointData(
	tag BabylonTag,
	version FormatVersion,
	data []byte,
) (*BabylonData, error)

IsBabylonCheckpointData Checks if given bytearray is potential babylon data, if it is then returns index of data along side with data itself

type BabylonTag

type BabylonTag []byte

type FormatVersion

type FormatVersion uint8

type RawBtcCheckpoint

type RawBtcCheckpoint struct {
	Epoch            uint64
	LastCommitHash   []byte
	BitMap           []byte
	SubmitterAddress []byte
	BlsSig           []byte
}

func DecodeRawCheckpoint

func DecodeRawCheckpoint(version FormatVersion, btcCkptBytes []byte) (*RawBtcCheckpoint, error)

DecodeRawCheckpoint extracts epoch, lastCommitHash, bitmap, and blsSig from a flat byte array and compose them into a RawCheckpoint struct

Jump to

Keyboard shortcuts

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