utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: ISC Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const ChainIDCount = 4096

ChainIDCount = 2^12

View Source
const CoinbaseFlags = "/P2SH/jaxnet/"

CoinbaseFlags is added to the coinbase script of a generated block and is used to monitor BIP16 support as well as blocks that are generated via btcd.

Variables

This section is empty.

Functions

func BitcoinBlockCopy added in v0.2.0

func BitcoinBlockCopy(msg *btcdwire.MsgBlock) *btcdwire.MsgBlock

BitcoinBlockCopy creates a deep copy of a MsgBlock so that the original does not get modified when the copy is manipulated.

func Bits2Difficulty added in v0.2.0

func Bits2Difficulty(bits uint32) (float *big.Float)

TODO: unused function

func BtcBlockToBlockAux added in v0.2.0

func BtcBlockToBlockAux(btcBlock *btcdwire.MsgBlock) wire.BTCBlockAux

func BtcTxToJaxTx added in v0.2.0

func BtcTxToJaxTx(tx *btcdwire.MsgTx) wire.MsgTx

func CalculateSteps added in v0.2.0

func CalculateSteps(data [][]byte) [][]byte

func Difficulty2Target added in v0.2.0

func Difficulty2Target(bigDiff *big.Float) *big.Int

func ExtractOptionsFromPassword added in v0.2.0

func ExtractOptionsFromPassword(password string) (map[string]float64, error)

func GetMerkleHashes added in v0.2.0

func GetMerkleHashes(steps [][]byte) []string

func HashSortingLastBits added in v0.2.0

func HashSortingLastBits(diff *big.Int, chainIDCount uint32) uint32

func JaxCoinbaseScript added in v0.2.0

func JaxCoinbaseScript(nextBlockHeight int64, chainID uint32, extraNonce uint64) ([]byte, error)

JaxCoinbaseScript returns a standard script suitable for use as the signature script of the coinbase transaction of a new block. In particular, it starts with the block height that is required by version 2 blocks and adds the extra nonce as well as additional coinbase flags.

func JaxTxToBtcTx added in v0.2.0

func JaxTxToBtcTx(tx *wire.MsgTx) btcdwire.MsgTx

func MerkleJoin added in v0.2.0

func MerkleJoin(h1, h2 []byte) []byte

func MerkleTreeBranch added in v0.2.0

func MerkleTreeBranch(merkles []*btcdchainhash.Hash) (path []*btcdchainhash.Hash)

func MerkleTreeBranchString added in v0.2.0

func MerkleTreeBranchString(merkles []string) (path []string)

func PackInt32BE added in v0.2.0

func PackInt32BE(n int32) []byte

func PackInt32LE added in v0.2.0

func PackInt32LE(n int32) []byte

func PackUint16LE added in v0.2.0

func PackUint16LE(n uint16) []byte

func PackUint32BE added in v0.2.0

func PackUint32BE(n uint32) []byte

func PackUint32LE added in v0.2.0

func PackUint32LE(n uint32) []byte

func PackUint64LE added in v0.2.0

func PackUint64LE(n uint64) []byte

func RandHexUint64 added in v0.2.0

func RandHexUint64() string

func RandUint32 added in v0.2.0

func RandUint32() uint32

func RandUint64 added in v0.2.0

func RandUint64() uint64

func Range added in v0.2.0

func Range(start, stop, step int) []int

Range steps between [start, end]

func ReverseByteOrder added in v0.2.0

func ReverseByteOrder(b []byte) []byte

ReverseByteOrder converts bytes in Little endian from/to Big endian

func ReverseBytes added in v0.2.0

func ReverseBytes(b []byte) []byte

func SerializeNumber added in v0.2.0

func SerializeNumber(n uint64) []byte

func SerializeString added in v0.2.0

func SerializeString(s string) []byte

func SetStratumExtraNonce added in v0.2.0

func SetStratumExtraNonce(block btcdwire.MsgBlock, coinbaseParts BitcoinBlockCoinbaseParts, extraNonce []byte) btcdwire.MsgBlock

func Sha256 added in v0.2.0

func Sha256(b []byte) []byte

func Sha256d added in v0.2.0

func Sha256d(b []byte) []byte

func SplitCoinbase added in v0.2.0

func SplitCoinbase(block btcdwire.MsgBlock) ([]byte, []byte)

func StringsIndexOf added in v0.2.0

func StringsIndexOf(data []string, element string) int

func Target2Difficulty added in v0.2.0

func Target2Difficulty(target *big.Int) (float *big.Float)

func Uint256BytesFromHash added in v0.2.0

func Uint256BytesFromHash(h string) ([]byte, error)

func UpdateBeaconExtraNonce added in v0.2.0

func UpdateBeaconExtraNonce(beaconBlock wire.MsgBlock, height int64, extraNonce uint64) (wire.MsgBlock, error)

func UpdateBitcoinExtraNonce added in v0.2.0

func UpdateBitcoinExtraNonce(block btcdwire.MsgBlock, height int64, extraNonce uint64, beaconHash []byte) (btcdwire.MsgBlock, error)

func UpdateMerkleRoot added in v0.2.0

func UpdateMerkleRoot(msgBlock *wire.MsgBlock)

func UpdateShardsMerkleRoot added in v0.2.0

func UpdateShardsMerkleRoot(shardBlock wire.MsgBlock, height int64, shardID uint32,
	extraNonce uint64) (wire.MsgBlock, error)

func VarIntBytes added in v0.2.0

func VarIntBytes(n uint64) []byte

Types

type BitcoinBlockCoinbaseParts added in v0.2.0

type BitcoinBlockCoinbaseParts struct {
	Head []byte
	Tail []byte
}

type StoppableMixin

type StoppableMixin struct {
	Ctx context.Context

	MustBeStopped bool

	IsStopped func() bool

	Done chan struct{}
}

func Init added in v0.2.0

func Init(ctx context.Context) (sm StoppableMixin)

func (*StoppableMixin) Finish added in v0.2.0

func (sm *StoppableMixin) Finish()

func (*StoppableMixin) StopUsing

func (sm *StoppableMixin) StopUsing(wg *sync.WaitGroup)

Jump to

Keyboard shortcuts

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