Versions in this module Expand all Collapse all v0 v0.2.17 Dec 28, 2019 v0.2.15 Dec 28, 2019 Changes in this version + const CheckpointConfirmations + const CoinbaseWitnessDataLen + const CoinbaseWitnessPkScriptLength + const MaxBlockBaseSize + const MaxBlockSigOpsCost + const MaxBlockWeight + const MaxCoinbaseScriptLen + const MaxOutputsPerBlock + const MaxTimeOffsetSeconds + const MinCoinbaseScriptLen + const MinTxOutputWeight + const WitnessScaleFactor + var ScryptPowLimit = scryptPowLimit + var ScryptPowLimitBits = BigToCompact(&scryptPowLimit) + var WitnessMagicBytes = []byte + func BigToCompact(n *big.Int) uint32 + func BuildMerkleTreeStore(transactions []*util.Tx, witness bool) []*chainhash.Hash + func CalcBlockSubsidy(height int32, chainParams *netparams.Params) (r int64) + func CalcWork(bits uint32, height int32, algover int32) *big.Int + func CheckBlockSanity(block *util.Block, powLimit *big.Int, timeSource MedianTimeSource, ...) error + func CheckProofOfWork(block *util.Block, powLimit *big.Int, height int32) error + func CheckTransactionInputs(tx *util.Tx, txHeight int32, utxoView *UtxoViewpoint, ...) (int64, error) + func CheckTransactionSanity(tx *util.Tx) error + func CompactToBig(compact uint32) *big.Int + func ContainsBlacklisted(b *BlockChain, tx *util.Tx, blacklist []util.Address) (hasBlacklisted bool) + func CountP2SHSigOps(tx *util.Tx, isCoinBaseTx bool, utxoView *UtxoViewpoint) (int, error) + func CountSigOps(tx *util.Tx) int + func ExtractCoinbaseHeight(coinbaseTx *util.Tx) (int32, error) + func ExtractWitnessCommitment(tx *util.Tx) ([]byte, bool) + func GetBlockWeight(blk *util.Block) int64 + func GetSigOpCost(tx *util.Tx, isCoinBaseTx bool, utxoView *UtxoViewpoint, bip16, segWit bool) (int, error) + func GetTransactionWeight(tx *util.Tx) int64 + func HashMerkleBranches(left *chainhash.Hash, right *chainhash.Hash) *chainhash.Hash + func HashToBig(hash *chainhash.Hash) *big.Int + func Intersects(a, b []util.Address) bool + func IsCoinBase(tx *util.Tx) bool + func IsCoinBaseTx(msgTx *wire.MsgTx) bool + func IsFinalizedTransaction(tx *util.Tx, blockHeight int32, blockTime time.Time) bool + func LockTimeToSequence(isSeconds bool, locktime uint32) uint32 + func RightJustify(s string, w int) string + func SequenceLockActive(sequenceLock *SequenceLock, blockHeight int32, medianTimePast time.Time) bool + func ShouldHaveSerializedBlockHeight(header *wire.BlockHeader) bool + func ValidateTransactionScripts(b *BlockChain, tx *util.Tx, utxoView *UtxoViewpoint, ...) error + func ValidateWitnessCommitment(blk *util.Block) error + type AssertError string + func (e AssertError) Error() string + type BehaviorFlags uint32 + const BFFastAdd + const BFNoPoWCheck + const BFNone + type BestState struct + Bits uint32 + BlockSize uint64 + BlockWeight uint64 + Hash chainhash.Hash + Height int32 + MedianTime time.Time + NumTxns uint64 + TotalTxns uint64 + Version int32 + type BlockChain struct + BestChain *chainView + DifficultyAdjustments map[string]float64 + Index *blockIndex + func New(config *Config) (*BlockChain, error) + func (b *BlockChain) BestSnapshot() *BestState + func (b *BlockChain) BlockByHash(hash *chainhash.Hash) (*util.Block, error) + func (b *BlockChain) BlockByHeight(blockHeight int32) (*util.Block, error) + func (b *BlockChain) BlockHashByHeight(blockHeight int32) (*chainhash.Hash, error) + func (b *BlockChain) BlockHeightByHash(hash *chainhash.Hash) (int32, error) + func (b *BlockChain) BlockLocatorFromHash(hash *chainhash.Hash) BlockLocator + func (b *BlockChain) CalcNextBlockVersion() (uint32, error) + func (b *BlockChain) CalcNextRequiredDifficulty(workerNumber uint32, timestamp ..., algo string) (difficulty uint32, err error) + func (b *BlockChain) CalcNextRequiredDifficultyHalcyon(workerNumber uint32, lastNode *BlockNode, newBlockTime time.Time, ...) (newTargetBits uint32, err error) + func (b *BlockChain) CalcNextRequiredDifficultyPlan9(workerNumber uint32, lastNode *BlockNode, newBlockTime time.Time, ...) (newTargetBits uint32, adjustment float64, err error) + func (b *BlockChain) CalcNextRequiredDifficultyPlan9Controller(lastNode *BlockNode) (newTargetBits *map[int32]uint32, err error) + func (b *BlockChain) CalcSequenceLock(tx *util.Tx, utxoView *UtxoViewpoint, mempool bool) (*SequenceLock, error) + func (b *BlockChain) CheckConnectBlockTemplate(workerNumber uint32, block ...) error + func (b *BlockChain) Checkpoints() []chaincfg.Checkpoint + func (b *BlockChain) FetchSpendJournal(targetBlock *util.Block) ([]SpentTxOut, error) + func (b *BlockChain) FetchUtxoEntry(outpoint wire.OutPoint) (*UtxoEntry, error) + func (b *BlockChain) FetchUtxoView(tx *util.Tx) (*UtxoViewpoint, error) + func (b *BlockChain) GetCommonP9Averages(lastNode *BlockNode, nH int32) (allTimeAv, allTimeDiv, qhourDiv, hourDiv, dayDiv float64) + func (b *BlockChain) GetOrphanRoot(hash *chainhash.Hash) *chainhash.Hash + func (b *BlockChain) GetP9AlgoDiv(allTimeDiv float64, last *BlockNode, startHeight int32, algoVer int32, ...) (algDiv float64) + func (b *BlockChain) GetP9Since(lastNode *BlockNode, algoVer int32) (since, ttpb, timeSinceAlgo float64, startHeight int32, last *BlockNode) + func (b *BlockChain) HasCheckpoints() bool + func (b *BlockChain) HaveBlock(hash *chainhash.Hash) (bool, error) + func (b *BlockChain) HeaderByHash(hash *chainhash.Hash) (wire.BlockHeader, error) + func (b *BlockChain) HeightRange(startHeight, endHeight int32) ([]..., error) + func (b *BlockChain) HeightToHashRange(startHeight int32, endHash *chainhash.Hash, maxResults int) ([]chainhash.Hash, error) + func (b *BlockChain) IntervalBlockHashes(endHash *chainhash.Hash, interval int) ([]chainhash.Hash, error) + func (b *BlockChain) IsCheckpointCandidate(block *util.Block) (bool, error) + func (b *BlockChain) IsCurrent() bool + func (b *BlockChain) IsDeploymentActive(deploymentID uint32) (bool, error) + func (b *BlockChain) IsKnownOrphan(hash *chainhash.Hash) bool + func (b *BlockChain) IsP9HardFork(nH int32) bool + func (b *BlockChain) LatestBlockLocator() (BlockLocator, error) + func (b *BlockChain) LatestCheckpoint() *chaincfg.Checkpoint + func (b *BlockChain) LocateBlocks(locator BlockLocator, hashStop *chainhash.Hash, maxHashes uint32) []chainhash.Hash + func (b *BlockChain) LocateHeaders(locator BlockLocator, hashStop *chainhash.Hash) []wire.BlockHeader + func (b *BlockChain) MainChainHasBlock(hash *chainhash.Hash) bool + func (b *BlockChain) ProcessBlock(workerNumber uint32, block *util.Block, flags BehaviorFlags, height int32) (bool, bool, error) + func (b *BlockChain) Subscribe(callback NotificationCallback) + func (b *BlockChain) ThresholdState(deploymentID uint32) (ThresholdState, error) + type BlockLocator []*chainhash.Hash + type BlockNode struct + DiffMx sync.Mutex + Diffs *map[int32]uint32 + func NewBlockNode(blockHeader *wire.BlockHeader, parent *BlockNode) *BlockNode + func (node *BlockNode) Ancestor(height int32) *BlockNode + func (node *BlockNode) CalcPastMedianTime() time.Time + func (node *BlockNode) GetAlgo() int32 + func (node *BlockNode) GetLastWithAlgo(algo int32) (prev *BlockNode) + func (node *BlockNode) Header() wire.BlockHeader + func (node *BlockNode) RelativeAncestor(distance int32) *BlockNode + type Config struct + ChainParams *netparams.Params + Checkpoints []chaincfg.Checkpoint + DB database.DB + HashCache *txscript.HashCache + IndexManager IndexManager + Interrupt <-chan struct{} + SigCache *txscript.SigCache + TimeSource MedianTimeSource + type DeploymentError uint32 + func (e DeploymentError) Error() string + type ErrorCode int + const ErrBadCheckpoint + const ErrBadCoinbaseHeight + const ErrBadCoinbaseScriptLen + const ErrBadCoinbaseValue + const ErrBadFees + const ErrBadMerkleRoot + const ErrBadTxInput + const ErrBadTxOutValue + const ErrBlacklisted + const ErrBlockTooBig + const ErrBlockVersionTooOld + const ErrBlockWeightTooHigh + const ErrCheckpointTimeTooOld + const ErrDifficultyTooLow + const ErrDuplicateBlock + const ErrDuplicateTx + const ErrDuplicateTxInputs + const ErrFirstTxNotCoinbase + const ErrForkTooOld + const ErrHighHash + const ErrImmatureSpend + const ErrInvalidAncestorBlock + const ErrInvalidTime + const ErrInvalidWitnessCommitment + const ErrMissingCoinbaseHeight + const ErrMissingTxOut + const ErrMultipleCoinbases + const ErrNoTransactions + const ErrNoTxInputs + const ErrNoTxOutputs + const ErrOverwriteTx + const ErrPrevBlockNotBest + const ErrPreviousBlockUnknown + const ErrScriptMalformed + const ErrScriptValidation + const ErrSpendTooHigh + const ErrTimeTooNew + const ErrTimeTooOld + const ErrTooManySigOps + const ErrTxTooBig + const ErrUnexpectedDifficulty + const ErrUnexpectedWitness + const ErrUnfinalizedTx + const ErrWitnessCommitmentMismatch + func (e ErrorCode) String() string + type IndexManager interface + ConnectBlock func(database.Tx, *util.Block, []SpentTxOut) error + DisconnectBlock func(database.Tx, *util.Block, []SpentTxOut) error + Init func(*BlockChain, <-chan struct{}) error + type MedianTimeSource interface + AddTimeSample func(id string, timeVal time.Time) + AdjustedTime func() time.Time + Offset func() time.Duration + func NewMedianTime() MedianTimeSource + type Notification struct + Data interface{} + Type NotificationType + type NotificationCallback func(*Notification) + type NotificationType int + const NTBlockAccepted + const NTBlockConnected + const NTBlockDisconnected + func (n NotificationType) String() string + type RuleError struct + Description string + ErrorCode ErrorCode + func (e RuleError) Error() string + type SequenceLock struct + BlockHeight int32 + Seconds int64 + type SpentTxOut struct + Amount int64 + Height int32 + IsCoinBase bool + PkScript []byte + type ThresholdState byte + const ThresholdActive + const ThresholdDefined + const ThresholdFailed + const ThresholdLockedIn + const ThresholdStarted + func (t ThresholdState) String() string + type UtxoEntry struct + func (entry *UtxoEntry) Amount() int64 + func (entry *UtxoEntry) BlockHeight() int32 + func (entry *UtxoEntry) Clone() *UtxoEntry + func (entry *UtxoEntry) IsCoinBase() bool + func (entry *UtxoEntry) IsSpent() bool + func (entry *UtxoEntry) PkScript() []byte + func (entry *UtxoEntry) Spend() + type UtxoViewpoint struct + func NewUtxoViewpoint() *UtxoViewpoint + func (view *UtxoViewpoint) AddTxOut(tx *util.Tx, txOutIdx uint32, blockHeight int32) + func (view *UtxoViewpoint) AddTxOuts(tx *util.Tx, blockHeight int32) + func (view *UtxoViewpoint) BestHash() *chainhash.Hash + func (view *UtxoViewpoint) Entries() map[wire.OutPoint]*UtxoEntry + func (view *UtxoViewpoint) LookupEntry(outpoint wire.OutPoint) *UtxoEntry + func (view *UtxoViewpoint) RemoveEntry(outpoint wire.OutPoint) + func (view *UtxoViewpoint) SetBestHash(hash *chainhash.Hash)