tezos

package
v0.3.1-beta-rc0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPrivateKey is returned when private key type is unknown
	ErrPrivateKey = errors.New("tezos: unknown private key type")
	// ErrPublicKey is returned when private key type is unknown
	ErrPublicKey = errors.New("tezos: unknown public key type")
	// ErrPrivateKeyValue is returned when elliptic D value of unexpected order is provided
	ErrPrivateKeyValue = errors.New("tezos: invalid elliptic curve private key value")
	// ErrPassphrase is returned when required passphrase is not provided
	ErrPassphrase = errors.New("tezos: passphrase required")
	// ErrPrivateKeyDecrypt is returned if attempt to decrypt the private key has been failed
	ErrPrivateKeyDecrypt = errors.New("tezos: unable to decrypt the private key")
)
View Source
var ErrPrefix = errors.New("unknown Tezos base58 prefix")

ErrPrefix is returned in case of unknown Tezos base58 prefix

View Source
var ErrSignature = errors.New("tezos: unknown signature type")

ErrSignature is the error returned if the signature type is unknown

Functions

func DecodeBase58

func DecodeBase58(text string) ([]byte, error)

func DecodeBase58Check

func DecodeBase58Check(text string) ([]byte, error)

func DecodeChainID

func DecodeChainID(src string) (res [4]byte, err error)

func DecodeValueHash

func DecodeValueHash(src string) (res [32]byte, err error)

func EncodeBase58

func EncodeBase58(data []byte) string

func EncodeBase58Check

func EncodeBase58Check(data []byte) string

func EncodeBinaryPublicKeyHash

func EncodeBinaryPublicKeyHash(s string) (data []byte, err error)

EncodeBinaryPublicKeyHash returns binary representation of the public key hash

func EncodeGenericSignature

func EncodeGenericSignature(sig cryptoutils.Signature) (res string, err error)

EncodeGenericSignature returns encoded version of a digital signature in a generic format

func EncodePrivateKey

func EncodePrivateKey(priv cryptoutils.PrivateKey) (res string, err error)

EncodePrivateKey returns base58 encoded private key

func EncodePublicKey

func EncodePublicKey(pub crypto.PublicKey) (res string, err error)

EncodePublicKey returns base58 encoded public key

func EncodePublicKeyHash

func EncodePublicKeyHash(pub crypto.PublicKey) (hash string, err error)

EncodePublicKeyHash returns base58 encoded public key hash

func EncodeSignature

func EncodeSignature(sig cryptoutils.Signature) (res string, err error)

EncodeSignature returns encoded version of a digital signature in a specific format

func EncodeValueHash

func EncodeValueHash(hash []byte) string

func GetPublicKeyHash

func GetPublicKeyHash(pub crypto.PublicKey) (hash []byte, err error)

GetPublicKeyHash returns BLAKE2B public key hash

func IsEncryptedPrivateKey

func IsEncryptedPrivateKey(data string) (bool, error)

IsEncryptedPrivateKey returns true if the private key is encrypted

func ParsePrivateKey

func ParsePrivateKey(data string, passFunc PassphraseFunc) (priv cryptoutils.PrivateKey, err error)

ParsePrivateKey parses base58 encoded private key

func ParsePublicKey

func ParsePublicKey(data string) (pub crypto.PublicKey, err error)

ParsePublicKey parses base58 encoded public key

func ParseSignature

func ParseSignature(s string, pub crypto.PublicKey) (sig cryptoutils.Signature, err error)

ParseSignature parses base58 encoded signature. pub is used for generic ("sig...") signatures if not nil

Types

type BlockHeader

type BlockHeader struct {
	ShellBlockHeader
	PayloadHash               string
	PayloadRound              int32
	ProofOfWorkNonce          []byte
	SeedNonceHash             string
	LiquidityBakingToggleVote string
}

BlockHeader represents unsigned block header

func (*BlockHeader) GetRound

func (b *BlockHeader) GetRound() int32

type EmmyBlockRequest

type EmmyBlockRequest struct {
	ChainID           string
	*ShellBlockHeader // skip Emmy protocol data for convenience
}

func (*EmmyBlockRequest) GetChainID

func (e *EmmyBlockRequest) GetChainID() string

GetChainID returns chain ID

func (*EmmyBlockRequest) MessageKind

func (e *EmmyBlockRequest) MessageKind() string

MessageKind returns unsigned message kind name i.e. "block"

type EmmyEndorsementRequest

type EmmyEndorsementRequest struct {
	ChainID string
	Branch  string
	*OpEmmyEndorsement
}

EmmyEndorsementRequest represents unsigned endorsement

func (*EmmyEndorsementRequest) GetChainID

func (e *EmmyEndorsementRequest) GetChainID() string

GetChainID returns chain ID

func (*EmmyEndorsementRequest) MessageKind

func (e *EmmyEndorsementRequest) MessageKind() string

type Endorsement

type Endorsement interface {
	Operation
	GetLevel() int32
	OpEndorsement()
}

type GenericOperationRequest

type GenericOperationRequest struct {
	Branch   string
	Contents []Operation
}

GenericOperationRequest represents operation without a signature

func (*GenericOperationRequest) MessageKind

func (u *GenericOperationRequest) MessageKind() string

MessageKind returns unsigned message kind name i.e. "generic"

func (*GenericOperationRequest) OperationKinds

func (u *GenericOperationRequest) OperationKinds() []string

OperationKinds returns list of uperation kinds

type InlinedEndorsement

type InlinedEndorsement struct {
	Endorsement // either Emmy or Tenderbake
	Branch      string
	Signature   string
}

InlinedEndorsement represents inlined endorsement operation with signature

type InlinedPreendorsement

type InlinedPreendorsement struct {
	OpPreendorsement
	Branch    string
	Signature string
}

InlinedPreendorsement represents inlined preendorsement operation with signature

type Manager

type Manager struct {
	Source       string
	Fee          *big.Int
	Counter      *big.Int
	GasLimit     *big.Int
	StorageLimit *big.Int
}

Manager has fields common for all manager operations

type MessageWithLevel

type MessageWithLevel interface {
	UnsignedMessage
	GetChainID() string
	GetLevel() int32
}

MessageWithLevel is implemented by UnsignedBlockHeader and UnsignedEndorsement. Useful for high water marking.

type MessageWithRound

type MessageWithRound interface {
	MessageWithLevel
	GetRound() int32
}

type OpActivateAccount

type OpActivateAccount struct {
	PublicKeyHash string
	Secret        []byte
}

OpActivateAccount represents "activate_account" operation

func (*OpActivateAccount) OperationKind

func (o *OpActivateAccount) OperationKind() string

OperationKind returns operation name i.e. "activate_account"

type OpBallot

type OpBallot struct {
	Source   string
	Period   int32
	Proposal string
	Ballot   string
}

OpBallot represents "ballot" operation

func (*OpBallot) OperationKind

func (o *OpBallot) OperationKind() string

OperationKind returns operation name i.e. "ballot"

type OpDelegation

type OpDelegation struct {
	Manager
	Delegate string
}

OpDelegation represents "delegation" operation

func (*OpDelegation) OperationKind

func (o *OpDelegation) OperationKind() string

OperationKind returns operation name i.e. "delegation"

type OpDoubleBakingEvidence

type OpDoubleBakingEvidence struct {
	BlockHeader1 *ShellBlockHeader
	BlockHeader2 *ShellBlockHeader
}

OpDoubleBakingEvidence represents "double_baking_evidence" operation

func (*OpDoubleBakingEvidence) OperationKind

func (o *OpDoubleBakingEvidence) OperationKind() string

OperationKind returns operation name i.e. "double_baking_evidence"

type OpDoubleEndorsementEvidence

type OpDoubleEndorsementEvidence struct {
	Op1 *InlinedEndorsement
	Op2 *InlinedEndorsement
}

OpDoubleEndorsementEvidence represents "double_endorsement_evidence" operation

func (*OpDoubleEndorsementEvidence) OperationKind

func (o *OpDoubleEndorsementEvidence) OperationKind() string

OperationKind returns operation name i.e. "double_endorsement_evidence"

type OpDoublePreendorsementEvidence

type OpDoublePreendorsementEvidence struct {
	Op1 *InlinedPreendorsement
	Op2 *InlinedPreendorsement
}

OpDoublePreendorsementEvidence represents "double_preendorsement_evidence" operation

func (*OpDoublePreendorsementEvidence) OperationKind

func (o *OpDoublePreendorsementEvidence) OperationKind() string

OperationKind returns operation name i.e. "double_preendorsement_evidence"

type OpEmmyEndorsement

type OpEmmyEndorsement struct {
	Level int32
}

OpEmmyEndorsement represents "endorsement" operation

func (*OpEmmyEndorsement) GetLevel

func (o *OpEmmyEndorsement) GetLevel() int32

GetLevel returns block level

func (*OpEmmyEndorsement) OpEndorsement

func (*OpEmmyEndorsement) OpEndorsement()

func (*OpEmmyEndorsement) OperationKind

func (o *OpEmmyEndorsement) OperationKind() string

OperationKind returns operation name i.e. "endorsement"

type OpEndorsementWithSlot

type OpEndorsementWithSlot struct {
	InlinedEndorsement
	Slot uint16
}

OpEndorsementWithSlot represents "endorsement" operation

func (*OpEndorsementWithSlot) OperationKind

func (o *OpEndorsementWithSlot) OperationKind() string

OperationKind returns operation name i.e. "endorsement_with_slot"

type OpOrigination

type OpOrigination struct {
	Manager
	Balance  *big.Int
	Delegate string
	Script   *ScriptedContract
}

OpOrigination represents "origination" operation

func (*OpOrigination) OperationKind

func (o *OpOrigination) OperationKind() string

OperationKind returns operation name i.e. "origination"

type OpPreendorsement

type OpPreendorsement OpTenderbakeEndorsement

OpPreendorsement represents "preendorsement" operation

func (*OpPreendorsement) GetLevel

func (o *OpPreendorsement) GetLevel() int32

GetLevel returns block level

func (*OpPreendorsement) GetRound

func (o *OpPreendorsement) GetRound() int32

GetRound returns tenderbake round

func (*OpPreendorsement) OpEndorsement

func (*OpPreendorsement) OpEndorsement()

func (*OpPreendorsement) OperationKind

func (o *OpPreendorsement) OperationKind() string

OperationKind returns operation name i.e. "preendorsement"

type OpProposals

type OpProposals struct {
	Source    string
	Period    int32
	Proposals []string
}

OpProposals represents "proposals" operation

func (*OpProposals) OperationKind

func (o *OpProposals) OperationKind() string

OperationKind returns operation name i.e. "proposals"

type OpRegisterGlobalConstant

type OpRegisterGlobalConstant struct {
	Manager
	Value []byte
}

OpRegisterGlobalConstant represents "register_global_constant" operation

func (*OpRegisterGlobalConstant) OperationKind

func (o *OpRegisterGlobalConstant) OperationKind() string

OperationKind returns operation name i.e. "register_global_constant"

type OpReveal

type OpReveal struct {
	Manager
	PublicKey string
}

OpReveal represents "reveal" operation

func (*OpReveal) OperationKind

func (o *OpReveal) OperationKind() string

OperationKind returns operation name i.e. "reveal"

type OpSeedNonceRevelation

type OpSeedNonceRevelation struct {
	Level int32
	Nonce []byte
}

OpSeedNonceRevelation represents "seed_nonce_revelation" operation

func (*OpSeedNonceRevelation) GetLevel

func (o *OpSeedNonceRevelation) GetLevel() int32

GetLevel returns block level

func (*OpSeedNonceRevelation) OperationKind

func (o *OpSeedNonceRevelation) OperationKind() string

OperationKind returns operation name i.e. "seed_nonce_revelation"

type OpSetDepositsLimit

type OpSetDepositsLimit struct {
	Manager
	Limit *big.Int
}

func (*OpSetDepositsLimit) OperationKind

func (o *OpSetDepositsLimit) OperationKind() string

OperationKind returns operation name i.e. "set_deposits_limit"

type OpTenderbakeEndorsement

type OpTenderbakeEndorsement struct {
	Slot             uint16
	Level            int32
	Round            int32
	BlockPayloadHash string
}

OpTenderbakeEndorsement represents "endorsement" operation

func (*OpTenderbakeEndorsement) GetLevel

func (o *OpTenderbakeEndorsement) GetLevel() int32

GetLevel returns block level

func (*OpTenderbakeEndorsement) GetRound

func (o *OpTenderbakeEndorsement) GetRound() int32

GetRound returns tenderbake round

func (*OpTenderbakeEndorsement) OpEndorsement

func (*OpTenderbakeEndorsement) OpEndorsement()

func (*OpTenderbakeEndorsement) OperationKind

func (o *OpTenderbakeEndorsement) OperationKind() string

OperationKind returns operation name i.e. "endorsement"

type OpTransaction

type OpTransaction struct {
	Manager
	Amount      *big.Int
	Destination string
	Parameters  *TxParameters
}

OpTransaction represents "transaction" operation

func (*OpTransaction) OperationKind

func (o *OpTransaction) OperationKind() string

OperationKind returns operation name i.e. "transaction"

type OpTxRollupOrigination

type OpTxRollupOrigination Manager

func (*OpTxRollupOrigination) OperationKind

func (o *OpTxRollupOrigination) OperationKind() string

OperationKind returns operation name i.e. "tx_rollup_origination"

type Operation

type Operation interface {
	OperationKind() string
}

Operation is implemented by all operations

type PassphraseFunc

type PassphraseFunc func() ([]byte, error)

PassphraseFunc is a callback used to obtain a passphrase for decryption of the private key

type PreendorsementRequest

type PreendorsementRequest struct {
	ChainID string
	Branch  string
	*OpPreendorsement
}

PreendorsementRequest represents unsigned preendorsement

func (*PreendorsementRequest) GetChainID

func (u *PreendorsementRequest) GetChainID() string

GetChainID returns chain ID

func (*PreendorsementRequest) MessageKind

func (u *PreendorsementRequest) MessageKind() string

MessageKind returns unsigned message kind name i.e. "preendorsement"

type ScriptedContract

type ScriptedContract struct {
	Code    []byte
	Storage []byte
}

ScriptedContract contains contract data

type ShellBlockHeader

type ShellBlockHeader struct {
	Level          int32
	Proto          byte
	Predecessor    string
	Timestamp      time.Time
	ValidationPass byte
	OperationsHash string
	Fitness        [][]byte
	Context        string
}

func (*ShellBlockHeader) GetLevel

func (b *ShellBlockHeader) GetLevel() int32

GetLevel returns block level

type TenderbakeBlockRequest

type TenderbakeBlockRequest struct {
	ChainID string
	*BlockHeader
}

TenderbakeBlockRequest represents unsigned block header

func (*TenderbakeBlockRequest) GetChainID

func (t *TenderbakeBlockRequest) GetChainID() string

GetChainID returns chain ID

func (*TenderbakeBlockRequest) MessageKind

func (t *TenderbakeBlockRequest) MessageKind() string

MessageKind returns unsigned message kind name i.e. "block"

type TenderbakeEndorsementRequest

type TenderbakeEndorsementRequest struct {
	ChainID string
	Branch  string
	*OpTenderbakeEndorsement
}

TenderbakeEndorsementRequest represents unsigned endorsement

func (*TenderbakeEndorsementRequest) GetChainID

func (t *TenderbakeEndorsementRequest) GetChainID() string

GetChainID returns chain ID

func (*TenderbakeEndorsementRequest) MessageKind

func (t *TenderbakeEndorsementRequest) MessageKind() string

type TxParameters

type TxParameters struct {
	Value      []byte
	Entrypoint string // post Babylon
}

TxParameters represents transaction parameters

type UnsignedMessage

type UnsignedMessage interface {
	MessageKind() string
}

UnsignedMessage is implemented by all kinds of sign request payloads

func ParseRequest

func ParseRequest(data []byte) (u UnsignedMessage, err error)

ParseRequest returns parsed sign request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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