Documentation ¶
Index ¶
- Constants
- Variables
- func Base58CheckEncode(b58Prefix Base58CheckPrefix, input []byte) (string, error)
- func ComputeMinimumFee(gasLimit, operationSizeBytes *big.Int) *big.Int
- func VerifyMessage(message string, signature Signature, publicKey crypto.PublicKey) error
- type AccountType
- type Base58CheckPrefix
- type BranchID
- type ContentsTag
- type ContractID
- type ContractIDTag
- type ContractScript
- type Delegation
- type Endorsement
- type Entrypoint
- type EntrypointTag
- type MichelineBytes
- type MichelineInt
- type MichelineNode
- type MichelinePrim
- type MichelineSeq
- type MichelineString
- type Operation
- type OperationContents
- type OperationHash
- type Origination
- type PrivateKey
- type PrivateKeySeed
- type PubKeyHashTag
- type PubKeyTag
- type PublicKey
- type Revelation
- type Signature
- type SignedOperation
- type Transaction
- type TransactionParameters
- type TransactionParametersValue
- type TransactionParametersValueRawBytes
- type Watermark
Constants ¶
const ( // ContractHashLen is the length in bytes of a serialized contract hash ContractHashLen = 20 // ContractIDLen is the length in bytes of a serialized contract ID ContractIDLen = 22 )
Field lengths
const ( // StorageCostPerByte is the amount of mutez burned per byte of storage used. // Reference: https://gitlab.com/tezos/tezos/blob/f5c50c8ba1670b7a2ee58bed8a7806f00c43340c/src/proto_alpha/lib_protocol/constants_repr.ml#L126 StorageCostPerByte = int64(1000) // NewAccountStorageLimitBytes is the storage needed to create a new // account, either implicit or originated. NewAccountStorageLimitBytes = int64(257) // NewAccountCreationBurn is the cost in mutez burned from an account that signs // an operation creating a new account, either by a transferring to a new implicit address // or by originating a KT1 address. The value is equal to ꜩ0.257 NewAccountCreationBurn = NewAccountStorageLimitBytes * StorageCostPerByte // DefaultMinimalFees is a flat fee that represents the cost of broadcasting // an operation to the network. This flat fee is added to the variable minimal // fees for gas spent and storage used. // Reference: https://gitlab.com/tezos/tezos/blob/f5c50c8ba1670b7a2ee58bed8a7806f00c43340c/src/proto_alpha/lib_client/client_proto_args.ml#L251 DefaultMinimalFees = int64(100) // DefaultMinimalMutezPerGasUnit is the default fee rate in mutez that nodes expect // per unit gas spent by an operation (and all its contents). // Reference: https://gitlab.com/tezos/tezos/blob/f5c50c8ba1670b7a2ee58bed8a7806f00c43340c/src/proto_alpha/lib_client/client_proto_args.ml#L252 DefaultMinimalNanotezPerGasUnit = int64(100) // DefaultMinimalMutezPerByte is the default fee rate in mutez that nodes expect per // byte of a serialized, signed operation -- including header and all contents. // Reference: https://gitlab.com/tezos/tezos/blob/f5c50c8ba1670b7a2ee58bed8a7806f00c43340c/src/proto_alpha/lib_client/client_proto_args.ml#L253 DefaultMinimalNanotezPerByte = int64(1000) // RevelationGasLimit is the gas consumed by a revelation RevelationGasLimit = int64(10000) // RevelationStorageLimitBytes is the storage limit required for revelations. Note that // it is zero. RevelationStorageLimitBytes = int64(0) // RevelationStorageBurn is the amount burned by an account as a consequence // of signing a revelation. Note that it is zero. RevelationStorageBurn = RevelationStorageLimitBytes * StorageCostPerByte // MinimumTransactionGasLimit is the gas consumed by a transaction with no parameters // that does not result in any Michelson code execution. MinimumTransactionGasLimit = int64(10207) // DelegationGasLimit is the gas consumed by a delegation DelegationGasLimit = int64(10000) // DelegationStorageLimitBytes is the storage limit required for delegations. Note that // it is zero. DelegationStorageLimitBytes = int64(0) // DelegationStorageBurn is the amount burned by an account as a consequence // of signing a delegation. Note that it is zero. DelegationStorageBurn = DelegationStorageLimitBytes * StorageCostPerByte )
Common values for fees
const ( // PubKeyHashLen is the length in bytes of a serialized public key hash PubKeyHashLen = 20 // TaggedPubKeyHashLen is the length in bytes of a serialized, tagged public key hash TaggedPubKeyHashLen = PubKeyHashLen + 1 // PubKeyLenEd25519 is the length in bytes of a serialized Ed25519 public key PubKeyLenEd25519 = 32 // PubKeyLenSecp256k1 is the length in bytes of a serialized Secp256k1 public key PubKeyLenSecp256k1 = 33 // PubKeyLenP256 is the length in bytes of a serialized P256 public key PubKeyLenP256 = 33 )
Field lengths
const ( // PrimK_parameter and the remaining constants are adapted from Adapted from // https://gitlab.com/tezos/tezos/blob/master/src%2Fproto_alpha%2Flib_protocol%2Fmichelson_v1_primitives.ml // They don't follow go's name conventions in order to preserve easy comparison // with the original ocaml code and easy updates to keep up with protocol changes // The right order is defined in prim_encoding PrimK_parameter byte = iota PrimK_storage PrimK_code PrimD_False PrimD_Elt PrimD_Left PrimD_None PrimD_Pair PrimD_Right PrimD_Some PrimD_True PrimD_Unit PrimI_PACK PrimI_UNPACK PrimI_BLAKE2B PrimI_SHA256 PrimI_SHA512 PrimI_ABS PrimI_ADD PrimI_AMOUNT PrimI_AND PrimI_BALANCE PrimI_CAR PrimI_CDR PrimI_CHECK_SIGNATURE PrimI_COMPARE PrimI_CONCAT PrimI_CONS PrimI_CREATE_ACCOUNT PrimI_CREATE_CONTRACT PrimI_IMPLICIT_ACCOUNT PrimI_DIP PrimI_DROP PrimI_DUP PrimI_EDIV PrimI_EMPTY_MAP PrimI_EMPTY_SET PrimI_EQ PrimI_EXEC PrimI_FAILWITH PrimI_GE PrimI_GET PrimI_GT PrimI_HASH_KEY PrimI_IF PrimI_IF_CONS PrimI_IF_LEFT PrimI_IF_NONE PrimI_INT PrimI_LAMBDA PrimI_LE PrimI_LEFT PrimI_LOOP PrimI_LSL PrimI_LSR PrimI_LT PrimI_MAP PrimI_MEM PrimI_MUL PrimI_NEG PrimI_NEQ PrimI_NIL PrimI_NONE PrimI_NOT PrimI_NOW PrimI_OR PrimI_PAIR PrimI_PUSH PrimI_RIGHT PrimI_SIZE PrimI_SOME PrimI_SOURCE PrimI_SENDER PrimI_SELF PrimI_STEPS_TO_QUOTA PrimI_SUB PrimI_SWAP PrimI_TRANSFER_TOKENS PrimI_SET_DELEGATE PrimI_UNIT PrimI_UPDATE PrimI_XOR PrimI_ITER PrimI_LOOP_LEFT PrimI_ADDRESS PrimI_CONTRACT PrimI_ISNAT PrimI_CAST PrimI_RENAME PrimT_bool PrimT_contract PrimT_int PrimT_key PrimT_key_hash PrimT_lambda PrimT_list PrimT_map PrimT_big_map PrimT_nat PrimT_option PrimT_or PrimT_pair PrimT_set PrimT_signature PrimT_string PrimT_bytes PrimT_mutez PrimT_timestamp PrimT_unit PrimT_operation PrimT_address PrimI_SLICE PrimI_DIG PrimI_DUG PrimI_EMPTY_BIG_MAP PrimI_APPLY PrimT_chain_id PrimI_CHAIN_ID )
const ( // BlockHashLen is the length in bytes of a serialized block hash BlockHashLen = 32 // OperationHashLen is the length in bytes of a serialized operation hash OperationHashLen = 32 // OperationSignatureLen is the length in bytes of a serialized operation signature OperationSignatureLen = 64 )
Field lengths
Variables ¶
var ( // AllBase58CheckPrefixes is the list of all defined base58check prefixes AllBase58CheckPrefixes = []Base58CheckPrefix{} PrefixBlockHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{1, 52}, }) PrefixOperationHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{5, 116}, }) PrefixOperationListHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{133, 233}, }) PrefixOperationListListHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{29, 159, 109}, }) PrefixProtocolHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{2, 170}, }) PrefixContextHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{79, 199}, }) PrefixEd25519PublicKeyHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 20, prefixBytes: []byte{6, 161, 159}, }) PrefixSecp256k1PublicKeyHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 20, prefixBytes: []byte{6, 161, 161}, }) PrefixP256PublicKeyHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 20, prefixBytes: []byte{6, 161, 164}, }) PrefixCryptoboxPublicKeyHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 16, prefixBytes: []byte{153, 103}, }) PrefixEd25519Seed = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{13, 15, 58, 7}, }) PrefixEd25519PublicKey = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{13, 15, 37, 217}, }) PrefixSecp256k1SecretKey = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{17, 162, 224, 201}, }) PrefixP256SecretKey = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 32, prefixBytes: []byte{16, 81, 238, 189}, }) PrefixEd25519EncryptedSeed = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 56, prefixBytes: []byte{7, 90, 60, 179, 41}, }) PrefixSecp256k1EncryptedSecretKey = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 56, prefixBytes: []byte{9, 237, 241, 174, 150}, }) PrefixP256EncryptedSecretKey = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 56, prefixBytes: []byte{9, 48, 57, 115, 171}, }) PrefixSecp256k1PublicKey = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 33, prefixBytes: []byte{3, 254, 226, 86}, }) PrefixP256PublicKey = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 33, prefixBytes: []byte{3, 178, 139, 127}, }) PrefixSecp256k1Scalar = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 33, prefixBytes: []byte{38, 248, 136}, }) PrefixSecp256k1Element = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 33, prefixBytes: []byte{5, 92, 0}, }) PrefixEd25519SecretKey = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 64, prefixBytes: []byte{43, 246, 78, 7}, }) PrefixEd25519Signature = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 64, prefixBytes: []byte{9, 245, 205, 134, 18}, }) PrefixSecp256k1Signature = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 64, prefixBytes: []byte{13, 115, 101, 19, 63}, }) PrefixP256Signature = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 64, prefixBytes: []byte{54, 240, 44, 52}, }) PrefixGenericSignature = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 64, prefixBytes: []byte{4, 130, 43}, }) PrefixChainID = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 4, prefixBytes: []byte{87, 82, 0}, }) // PrefixContractHash is referenced from https://gitlab.com/tezos/tezos/blob/master/src/proto_alpha/lib_protocol/contract_hash.ml#L26 PrefixContractHash = registerBase58CheckPrefix(base58CheckPrefixInfo{ payloadLength: 20, prefixBytes: []byte{2, 90, 121}, }) )
Base58Check prefixes
var ( EntrypointDefault = Entrypoint{/* contains filtered or unexported fields */} EntrypointRoot = Entrypoint{/* contains filtered or unexported fields */} EntrypointDo = Entrypoint{/* contains filtered or unexported fields */} EntrypointSetDelegate = Entrypoint{/* contains filtered or unexported fields */} EntrypointRemoveDelegate = Entrypoint{/* contains filtered or unexported fields */} )
Preset entrypoints (those with an implicit name)
Functions ¶
func Base58CheckEncode ¶
func Base58CheckEncode(b58Prefix Base58CheckPrefix, input []byte) (string, error)
Base58CheckEncode encodes the given binary payload to base58check. Prefix must be a valid tezos base58check prefix.
func ComputeMinimumFee ¶
ComputeMinimumFee returns the minimum fee required according to the constraint:
fees >= (minimal_fees + minimal_nanotez_per_byte * size + minimal_nanotez_per_gas_unit * gas)
Amount returned is in units of mutez. Reference: http://tezos.gitlab.io/mainnet/protocols/003_PsddFKi3.html#baker
Types ¶
type AccountType ¶
type AccountType string
AccountType is either an implicit account or an originated account
const ( // AccountTypeImplicit indicates an implicit account AccountTypeImplicit AccountType = "implicit" // AccountTypeOriginated indicates an originated account AccountTypeOriginated AccountType = "originated" )
type Base58CheckPrefix ¶
type Base58CheckPrefix int
Base58CheckPrefix in an enum that models a base58check prefix used specifically by tezos
func Base58CheckDecode ¶
func Base58CheckDecode(input string) (Base58CheckPrefix, []byte, error)
Base58CheckDecode decodes the given base58check string and returns the payload and prefix. Errors if the given string does not include a tezos prefix, or if the checksum does not match.
func (Base58CheckPrefix) PayloadLength ¶
func (b Base58CheckPrefix) PayloadLength() int
PayloadLength is the number of bytes expected to be in the base58 encoded payload
func (Base58CheckPrefix) PrefixBytes ¶
func (b Base58CheckPrefix) PrefixBytes() []byte
PrefixBytes are the bytes to append as a prefix before base58 encoding
func (Base58CheckPrefix) String ¶
func (b Base58CheckPrefix) String() string
String prints a human regodnizable string representation of this prefix
type BranchID ¶
type BranchID string
BranchID encodes a tezos branch ID in base58check encoding
func (BranchID) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*BranchID) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler
type ContentsTag ¶
type ContentsTag byte
ContentsTag captures the possible tag values for operation contents
const ( // ContentsTagRevelation is the tag for revelations ContentsTagRevelation ContentsTag = 107 // ContentsTagTransaction is the tag for transactions ContentsTagTransaction ContentsTag = 108 // ContentsTagOrigination is the tag for originations ContentsTagOrigination ContentsTag = 109 // ContentsTagDelegation is the tag for delegations ContentsTagDelegation ContentsTag = 110 // ContentsTagEndorsement is the tag for endorsements ContentsTagEndorsement ContentsTag = 0 )
type ContractID ¶
type ContractID string
ContractID encodes a tezos contract ID (either implicit or originated) in base58check encoding.
func NewContractIDFromOrigination ¶
func NewContractIDFromOrigination(operationHash OperationHash, nonce uint32) (ContractID, error)
NewContractIDFromOrigination returns the address (contract ID) of an account that would be originated by this operation. Nonce disambiguates which account in the case that multiple accounts would be originated by this same operation. Nonce starts at 0 for the first account. AccountType is "originated."
func NewContractIDFromPublicKey ¶
func NewContractIDFromPublicKey(pubKey PublicKey) (ContractID, error)
NewContractIDFromPublicKey creates a new contract ID from a public key. AccountType is "implicit."
func (ContractID) AccountType ¶
func (c ContractID) AccountType() (AccountType, error)
AccountType returns the account type represented by this contract ID
func (ContractID) EncodePubKeyHash ¶
func (c ContractID) EncodePubKeyHash() ([]byte, error)
EncodePubKeyHash returns the public key hash corresponding to this contract ID. This is only possible for implicit addresses, which are themselves just a base58check encoding of a public key hash. Method returns an error for originated addresses, whose public key hashes are not inferrable from their contract ID.
func (ContractID) MarshalBinary ¶
func (c ContractID) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler. Reference: http://tezos.gitlab.io/mainnet/api/p2p.html#contract-id-22-bytes-8-bit-tag
func (*ContractID) UnmarshalBinary ¶
func (c *ContractID) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler. It accepts a 22 byte $contract_id or a 21 byte $public_key_hash
type ContractIDTag ¶
type ContractIDTag byte
ContractIDTag captures the possible tag values for $contract_id
const ( // ContractIDTagImplicit is the tag for implicit accounts ContractIDTagImplicit ContractIDTag = 0 // ContractIDTagOriginated is the tag for originated accounts ContractIDTagOriginated ContractIDTag = 1 )
type ContractScript ¶
ContractScript models $scripted.contracts
func (ContractScript) MarshalBinary ¶
func (c ContractScript) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler. Reference: http://tezos.gitlab.io/mainnet/api/p2p.html#contract-id-22-bytes-8-bit-tag
func (*ContractScript) UnmarshalBinary ¶
func (c *ContractScript) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type Delegation ¶
type Delegation struct { Source ContractID Fee *big.Int Counter *big.Int GasLimit *big.Int StorageLimit *big.Int Delegate *ContractID }
Delegation models the tezos delegation operation type
func (*Delegation) GetSource ¶
func (d *Delegation) GetSource() ContractID
GetSource returns the operation's source
func (*Delegation) GetTag ¶
func (d *Delegation) GetTag() ContentsTag
GetTag implements OperationContents
func (*Delegation) MarshalBinary ¶
func (d *Delegation) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler
func (*Delegation) String ¶
func (d *Delegation) String() string
func (*Delegation) UnmarshalBinary ¶
func (d *Delegation) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary implements encoding.BinaryUnmarshaler
type Endorsement ¶
type Endorsement struct {
Level int32
}
Endorsement models the tezos endorsement operation type
func (*Endorsement) GetTag ¶
func (e *Endorsement) GetTag() ContentsTag
GetTag implements OperationContents
func (*Endorsement) MarshalBinary ¶
func (e *Endorsement) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler
func (*Endorsement) String ¶
func (e *Endorsement) String() string
func (*Endorsement) UnmarshalBinary ¶
func (e *Endorsement) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary implements encoding.BinaryUnmarshaler
type Entrypoint ¶
type Entrypoint struct {
// contains filtered or unexported fields
}
Entrypoint models $entrypoint
func NewNamedEntrypoint ¶
func NewNamedEntrypoint(name string) (Entrypoint, error)
NewNamedEntrypoint creates a named entrypoint. This should be used when attempting to invoke a custom entrypoint that is not one of the reserved ones (%default, %root, %do, etcetera...).
func (Entrypoint) MarshalBinary ¶
func (e Entrypoint) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (Entrypoint) Name ¶
func (e Entrypoint) Name() (string, error)
Name returns the entrypoint name
func (*Entrypoint) UnmarshalBinary ¶
func (e *Entrypoint) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type EntrypointTag ¶
type EntrypointTag byte
EntrypointTag captures the possible tag values for $entrypoint.Tag
const ( EntrypointTagDefault EntrypointTag = 0 EntrypointTagRoot EntrypointTag = 1 EntrypointTagDo EntrypointTag = 2 EntrypointTagSetDelegate EntrypointTag = 3 EntrypointTagRemoveDelegate EntrypointTag = 4 EntrypointTagNamed EntrypointTag = 255 )
EntrypointTag values
type MichelineBytes ¶
type MichelineBytes []byte
MichelineBytes represents a byte array in a Micheline expression
func (MichelineBytes) MarshalBinary ¶
func (m MichelineBytes) MarshalBinary() ([]byte, error)
MarshalBinary implements the MichelineNode interface
func (*MichelineBytes) UnmarshalBinary ¶
func (m *MichelineBytes) UnmarshalBinary([]byte) error
UnmarshalBinary implements the MichelineNode interface
type MichelineInt ¶
MichelineInt represents an integer in a Micheline expression
func (MichelineInt) MarshalBinary ¶
func (m MichelineInt) MarshalBinary() ([]byte, error)
MarshalBinary implements the MichelineNode interface
func (*MichelineInt) UnmarshalBinary ¶
func (m *MichelineInt) UnmarshalBinary([]byte) error
UnmarshalBinary implements the MichelineNode interface
type MichelineNode ¶
type MichelineNode interface { MarshalBinary() ([]byte, error) UnmarshalBinary([]byte) error // contains filtered or unexported methods }
MichelineNode represents one node in the tree of Micheline expressions
type MichelinePrim ¶
type MichelinePrim struct { Prim byte Args []MichelineNode Annots []string }
MichelinePrim likely represents a Michelson primitive in a Micheline expression
func (MichelinePrim) MarshalBinary ¶
func (m MichelinePrim) MarshalBinary() ([]byte, error)
MarshalBinary implements the MichelineNode interface
func (*MichelinePrim) UnmarshalBinary ¶
func (m *MichelinePrim) UnmarshalBinary([]byte) error
UnmarshalBinary implements the MichelineNode interface
type MichelineSeq ¶
type MichelineSeq []MichelineNode
MichelineSeq represents a sequence of nodes in a Micheline expression
func (MichelineSeq) MarshalBinary ¶
func (m MichelineSeq) MarshalBinary() ([]byte, error)
MarshalBinary implements the MichelineNode interface
func (*MichelineSeq) UnmarshalBinary ¶
func (m *MichelineSeq) UnmarshalBinary([]byte) error
UnmarshalBinary implements the MichelineNode interface
type MichelineString ¶
type MichelineString string
MichelineString represents a string in a Micheline expression
func (MichelineString) MarshalBinary ¶
func (m MichelineString) MarshalBinary() ([]byte, error)
MarshalBinary implements the MichelineNode interface
func (*MichelineString) UnmarshalBinary ¶
func (m *MichelineString) UnmarshalBinary([]byte) error
UnmarshalBinary implements the MichelineNode interface
type Operation ¶
type Operation struct { Branch BranchID Contents []OperationContents }
Operation models a tezos operation with variable length contents.
func (*Operation) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler. It encodes the operation unsigned, in the format suitable for signing and transmission.
func (*Operation) SignatureHash ¶
SignatureHash returns the hash of the operation to be signed, including watermark
func (*Operation) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler
type OperationContents ¶
type OperationContents interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler fmt.Stringer GetTag() ContentsTag }
OperationContents models one of multiple contents of a tezos operation. Reference: http://tezos.gitlab.io/mainnet/api/p2p.html#operation-alpha-contents-determined-from-data-8-bit-tag
type OperationHash ¶
type OperationHash string
OperationHash encodes an operation hash in base58check encoding
func (OperationHash) MarshalBinary ¶
func (o OperationHash) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*OperationHash) UnmarshalBinary ¶
func (o *OperationHash) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type Origination ¶
type Origination struct { Source ContractID Fee *big.Int Counter *big.Int GasLimit *big.Int StorageLimit *big.Int Balance *big.Int Delegate *ContractID Script ContractScript }
Origination models the tezos origination operation type.
func (*Origination) GetSource ¶
func (o *Origination) GetSource() ContractID
GetSource returns the operation's source
func (*Origination) GetTag ¶
func (o *Origination) GetTag() ContentsTag
GetTag implements OperationContents
func (*Origination) MarshalBinary ¶
func (o *Origination) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler
func (*Origination) String ¶
func (o *Origination) String() string
func (*Origination) UnmarshalBinary ¶
func (o *Origination) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary implements encoding.BinaryUnmarshaler
type PrivateKey ¶
type PrivateKey string
PrivateKey encodes a tezos private key in base58check encoding
func NewPrivateKeyFromCryptoPrivateKey ¶
func NewPrivateKeyFromCryptoPrivateKey(cryptoPrivateKey crypto.PrivateKey) (PrivateKey, error)
NewPrivateKeyFromCryptoPrivateKey creates a new PrivateKey from a crypto.PrivateKey
func (PrivateKey) CryptoPrivateKey ¶
func (p PrivateKey) CryptoPrivateKey() (crypto.PrivateKey, error)
CryptoPrivateKey returns a crypto.PrivateKey
func (PrivateKey) MarshalBinary ¶
func (p PrivateKey) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
type PrivateKeySeed ¶
type PrivateKeySeed string
PrivateKeySeed encodes a tezos private key seed in base58check encoding.
func (PrivateKeySeed) PrivateKey ¶
func (p PrivateKeySeed) PrivateKey() (PrivateKey, error)
PrivateKey returns the private key derived from this private key seed.
type PubKeyHashTag ¶
type PubKeyHashTag byte
PubKeyHashTag captures the possible tag values for $public_key_hash
const ( // PubKeyHashTagEd25519 is the tag for Ed25519 pubkey hashes PubKeyHashTagEd25519 PubKeyHashTag = 0 // PubKeyHashTagSecp256k1 is the tag for Secp256k1 pubkey hashes PubKeyHashTagSecp256k1 PubKeyHashTag = 1 // PubKeyHashTagP256 is the tag for P256 pubkey hashes PubKeyHashTagP256 PubKeyHashTag = 2 )
type PublicKey ¶
type PublicKey string
PublicKey encodes a tezos public key in base58check encoding
func NewPublicKeyFromCryptoPublicKey ¶
NewPublicKeyFromCryptoPublicKey creates a new PublicKey from a crypto.PublicKey
func (PublicKey) CryptoPublicKey ¶
CryptoPublicKey returns a crypto.PublicKey
func (PublicKey) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler. Reference: http://tezos.gitlab.io/mainnet/api/p2p.html#public-key-determined-from-data-8-bit-tag
func (*PublicKey) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler
type Revelation ¶
type Revelation struct { Source ContractID Fee *big.Int Counter *big.Int GasLimit *big.Int StorageLimit *big.Int PublicKey PublicKey }
Revelation models the revelation operation type
func (*Revelation) GetSource ¶
func (r *Revelation) GetSource() ContractID
GetSource returns the operation's source
func (*Revelation) GetTag ¶
func (r *Revelation) GetTag() ContentsTag
GetTag implements OperationContents
func (*Revelation) MarshalBinary ¶
func (r *Revelation) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler
func (*Revelation) String ¶
func (r *Revelation) String() string
func (*Revelation) UnmarshalBinary ¶
func (r *Revelation) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary implements encoding.BinaryUnmarshaler
type Signature ¶
type Signature string
Signature is a tezos base58check encoded signature. It may be in either the generic or non-generic format.
func SignMessage ¶
func SignMessage(message string, privateKey PrivateKey) (Signature, error)
SignMessage signs the given text based message using the provided signing key. It returns the base58check-encoded signature which does not include the message. It uses the 0x04 non-standard watermark.
func (Signature) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler
type SignedOperation ¶
SignedOperation represents a signed operation
func SignOperation ¶
func SignOperation(operation *Operation, privateKey PrivateKey) (SignedOperation, error)
SignOperation signs the given tezos operation using the provided signing key. The returned bytes are the signed operation, encoded as (operation bytes || signature bytes).
func (SignedOperation) GetHash ¶
func (s SignedOperation) GetHash() (OperationHash, error)
GetHash returns the hash of a signed operation.
func (SignedOperation) MarshalBinary ¶
func (s SignedOperation) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler
func (*SignedOperation) UnmarshalBinary ¶
func (s *SignedOperation) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler. In cases where the signature type cannot be inferred, PrefixGenericSignature is used instead.
type Transaction ¶
type Transaction struct { Source ContractID Fee *big.Int Counter *big.Int GasLimit *big.Int StorageLimit *big.Int Amount *big.Int Destination ContractID Parameters *TransactionParameters }
Transaction models the tezos transaction type
func (*Transaction) GetSource ¶
func (t *Transaction) GetSource() ContractID
GetSource returns the operation's source
func (*Transaction) GetTag ¶
func (t *Transaction) GetTag() ContentsTag
GetTag implements OperationContents
func (*Transaction) MarshalBinary ¶
func (t *Transaction) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler
func (*Transaction) String ¶
func (t *Transaction) String() string
func (*Transaction) UnmarshalBinary ¶
func (t *Transaction) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary implements encoding.BinaryUnmarshaler
type TransactionParameters ¶
type TransactionParameters struct { Entrypoint Entrypoint Value TransactionParametersValue }
TransactionParameters models $X_o. Reference: http://tezos.gitlab.io/babylonnet/api/p2p.html#x-0
func (TransactionParameters) MarshalBinary ¶
func (t TransactionParameters) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*TransactionParameters) UnmarshalBinary ¶
func (t *TransactionParameters) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type TransactionParametersValue ¶
type TransactionParametersValue interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
TransactionParametersValue models $X_o.value
type TransactionParametersValueRawBytes ¶
type TransactionParametersValueRawBytes []byte
TransactionParametersValueRawBytes is an interim way to provide the value for transaction parameters, until support for Michelson is added.
func (*TransactionParametersValueRawBytes) MarshalBinary ¶
func (t *TransactionParametersValueRawBytes) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*TransactionParametersValueRawBytes) UnmarshalBinary ¶
func (t *TransactionParametersValueRawBytes) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type Watermark ¶
type Watermark byte
Watermark is the first byte of a signable payload that indicates the type of data represented.
const ( // BlockHeaderWatermark is the special byte prepended to serialized block headers before signing BlockHeaderWatermark Watermark = 1 // EndorsementWatermark is the special byte prepended to serialized endorsements before signing EndorsementWatermark Watermark = 2 // OperationWatermark is the special byte prepended to serialized operations before signing OperationWatermark Watermark = 3 // CustomWatermark is for custom purposes CustomWatermark Watermark = 4 // TextWatermark is the special byte prepended to plaintext messages before signing. It is not // yet part of the standard but has some precedent here: // https://tezos.stackexchange.com/questions/1177/whats-the-easiest-way-for-an-account-holder-to-verify-sign-that-they-are-the-ri/1178#1178 TextWatermark Watermark = 5 )
References: https://gitlab.com/tezos/tezos/blob/master/src/lib_crypto/signature.ml#L43