coinutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMultipleMinerRewards is returned when a block contains multiple miner rewards.
	ErrMultipleMinerRewards = errors.New("only one miner reward transaction is allowed per block")
)

Functions

func GetBlockFees

func GetBlockFees(block *pb.Block) uint64

GetBlockFees sums the fees from all transactions in a block.

func GetMinerReward

func GetMinerReward(block *pb.Block) (*pb.Transaction, error)

GetMinerReward verifies that there is a single reward transaction in the block and returns it.

func GetTxCount

func GetTxCount(block *pb.Block) uint32

GetTxCount returns the number of user transactions in a block. It skips the miner rewards.

func HashHeader

func HashHeader(header *pb.Header) (multihash.Multihash, error)

HashHeader computes the hash of a given header.

func HashTransaction

func HashTransaction(tx *pb.Transaction) (multihash.Multihash, error)

HashTransaction computes the hash of a given transaction.

func TransactionRoot

func TransactionRoot(txs []*pb.Transaction) ([]byte, error)

TransactionRoot computes the merkle root of a set of transactions.

Types

type PrivateKey

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

PrivateKey is a private key.

func NewPrivateKey

func NewPrivateKey(privKey ic.PrivKey, keyType pb.KeyType) *PrivateKey

NewPrivateKey creates a new PrivateKey from a libp2p one.

func (PrivateKey) Bytes

func (k PrivateKey) Bytes() ([]byte, error)

Bytes returns the key bytes.

func (PrivateKey) GetPublicKey

func (k PrivateKey) GetPublicKey() *PublicKey

GetPublicKey returns the corresponding PublicKey.

func (PrivateKey) Sign

func (k PrivateKey) Sign(payload []byte) ([]byte, error)

Sign signs the given payload.

type PublicKey

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

PublicKey is a public key.

func NewPublicKey

func NewPublicKey(pubKey ic.PubKey, keyType pb.KeyType) *PublicKey

NewPublicKey creates a PublicKey from a libp2p one.

func (PublicKey) Bytes

func (k PublicKey) Bytes() ([]byte, error)

Bytes returns the key bytes.

func (PublicKey) Verify

func (k PublicKey) Verify(payload, sig []byte) (bool, error)

Verify verifies a signature.

Jump to

Keyboard shortcuts

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