Documentation
¶
Index ¶
- Constants
- func MnemonicToSeed(mnemonicPhrase string, mnemonicPassword string) []byte
- func UnitsPerErgo() int64
- func VerifySignature(address Address, message []byte, signature SignedMessage) (bool, error)
- type Address
- type BatchMerkleProof
- type BlockHeader
- type BlockHeaders
- type BlockId
- type BlockIds
- type Box
- type BoxAssetsData
- type BoxAssetsDataList
- type BoxCandidate
- type BoxCandidateBuilder
- type BoxCandidates
- type BoxId
- type BoxSelection
- type BoxValue
- type Boxes
- type ByteArray
- type ByteArrays
- type CommitmentHint
- type Constant
- func NewConstant(s string) (Constant, error)
- func NewConstantFromBox(box Box) Constant
- func NewConstantFromBytes(b []byte) (Constant, error)
- func NewConstantFromECPointBytes(b []byte) (Constant, error)
- func NewConstantFromInt16(i int16) Constant
- func NewConstantFromInt32(i int32) Constant
- func NewConstantFromInt64(i int64) Constant
- type ContextExtension
- type Contract
- type DataInput
- type DataInputs
- type DerivationPath
- type ExtendedPublicKey
- type ExtendedSecretKey
- type HintsBag
- type Input
- type Inputs
- type MerkleProof
- type MnemonicGenerator
- type NipopowProof
- type NipopowVerifier
- type Parameters
- type PoPowHeader
- type PreHeader
- type Propositions
- type ProverResult
- type ReducedTransaction
- type SecretKey
- type SecretKeys
- type SignedMessage
- type SimpleBoxSelector
- type StateContext
- type Token
- type TokenAmount
- type TokenId
- type Tokens
- type Transaction
- type TransactionHintsBag
- type Tree
- type TxBuilder
- type TxId
- type UnsignedInput
- type UnsignedInputs
- type UnsignedTransaction
- type Wallet
Constants ¶
const ( // MainnetPrefix is the network prefix used in mainnet address encoding MainnetPrefix networkPrefix = 0 // TestnetPrefix is the network prefix used in testnet address encoding TestnetPrefix = 16 )
const ( // P2PkPrefix 0x01 - Pay-to-PublicKey(P2PK) address P2PkPrefix addressTypePrefix = 1 // Pay2ShPrefix 0x02 - Pay-to-Script-Hash(P2SH) Pay2ShPrefix addressTypePrefix = 2 // Pay2SPrefix 0x03 - Pay-to-Script(P2S) Pay2SPrefix addressTypePrefix = 3 )
const ( // R4 id for the non-mandatory R4 register R4 nonMandatoryRegisterId = 4 // R5 id for the non-mandatory R5 register R5 nonMandatoryRegisterId = 5 // R6 id for the non-mandatory R6 register R6 nonMandatoryRegisterId = 6 // R7 id for the non-mandatory R7 register R7 nonMandatoryRegisterId = 7 // R8 id for the non-mandatory R8 register R8 nonMandatoryRegisterId = 8 // R9 id for the non-mandatory R9 register R9 nonMandatoryRegisterId = 9 )
const ( // Left represents left side the node is on in the merkle tree Left nodeSide = 0 // Right represents right side the node is on in the merkle tree Right nodeSide = 1 )
Variables ¶
This section is empty.
Functions ¶
func MnemonicToSeed ¶ added in v0.28.0
MnemonicToSeed converts a mnemonic phrase into a mnemonic seed mnemonicPassword is optional and is used to salt the seed
func UnitsPerErgo ¶
func UnitsPerErgo() int64
UnitsPerErgo returns number of units inside one ERGO (i.e. one ERG using nano ERG representation)
func VerifySignature ¶
func VerifySignature(address Address, message []byte, signature SignedMessage) (bool, error)
VerifySignature verifies that the signature is presented to satisfy SigmaProp conditions
Types ¶
type Address ¶
type Address interface { // Base58 converts an Address to a base58 string using the provided networkPrefix. Base58(prefix networkPrefix) string // TypePrefix returns the addressTypePrefix for the Address. // 0x01 - Pay-to-PublicKey(P2PK) address. // 0x02 - Pay-to-Script-Hash(P2SH). // 0x03 - Pay-to-Script(P2S). TypePrefix() addressTypePrefix // Tree returns the Address as Tree Tree() Tree // contains filtered or unexported methods }
func NewAddress ¶
NewAddress creates an Address from a base58 string.
func NewAddressFromPublicKey ¶ added in v0.28.0
NewAddressFromPublicKey creates a new Address from public key bytes
func NewAddressFromTree ¶ added in v0.28.0
NewAddressFromTree creates a new Address from supplied Tree
type BatchMerkleProof ¶
func NewBatchMerkleProof ¶
func NewBatchMerkleProof(json string) (BatchMerkleProof, error)
type BlockHeader ¶
type BlockHeader interface { // BlockId returns the BlockId of the BlockHeader BlockId() BlockId // Equals checks if provided BlockHeader is same Equals(blockHeader BlockHeader) bool // contains filtered or unexported methods }
BlockHeader represents data of the block header available in Sigma proposition
func NewBlockHeader ¶
func NewBlockHeader(json string) (BlockHeader, error)
NewBlockHeader creates a new BlockHeader from block header array JSON (Node API)
type BlockHeaders ¶
type BlockHeaders interface { // Len returns the length of the collection Len() int // Get returns the BlockHeader at the provided index if it exists Get(index int) (BlockHeader, error) // Add adds provided BlockHeader to the end of the collection Add(blockHeader BlockHeader) // All returns an iterator over all BlockHeader inside the collection All() iter.Seq2[int, BlockHeader] // contains filtered or unexported methods }
BlockHeaders an ordered collection of BlockHeader
func NewBlockHeaders ¶
func NewBlockHeaders() BlockHeaders
NewBlockHeaders creates an empty BlockHeaders collection
type BlockId ¶
type BlockId interface { // Equals checks if provided BlockId is same Equals(blockId BlockId) bool // contains filtered or unexported methods }
BlockId represents the id of a BlockHeader
func NewBlockId ¶
NewBlockId creates a new BlockId from hex-encoded string
type BlockIds ¶
type BlockIds interface { // Len returns the length of the collection Len() int // Get returns the BlockId at the provided index if it exists Get(index int) (BlockId, error) // Add adds provided BlockId to the end of the collection Add(blockId BlockId) // All returns an iterator over all BlockId inside the collection All() iter.Seq2[int, BlockId] }
BlockIds an ordered collection of BlockId
type Box ¶
type Box interface { // BoxId returns the BoxId of the Box BoxId() BoxId // RegisterValue returns value (Constant) stored in the register or nil if the register is empty RegisterValue(registerId nonMandatoryRegisterId) (Constant, error) // CreationHeight returns the creation height of the Box CreationHeight() uint32 // Tokens returns the ergo Tokens for the Box Tokens() Tokens // Tree returns the ergo Tree for the Box Tree() Tree // BoxValue returns the BoxValue of the Box BoxValue() BoxValue // Json returns json representation of Box as string (compatible with Ergo Node/Explorer API, numbers are encoded as numbers) Json() (string, error) // JsonEIP12 returns json representation of Box as string according to EIP-12 https://github.com/ergoplatform/eips/pull/23 JsonEIP12() (string, error) // Size calculates serialized box size(in bytes) Size() uint32 // Equals checks if provided Box is same Equals(box Box) bool // contains filtered or unexported methods }
Box that is taking part in some transaction on the chain Differs with BoxCandidate by added transaction id and an index in the input of that transaction
func NewBox ¶
func NewBox(boxValue BoxValue, creationHeight uint32, contract Contract, txId TxId, index uint16, tokens Tokens) (Box, error)
NewBox creates a new Box from provided parameters: boxValue - amount of money associated with the box creationHeight - height when a transaction containing the box is created. contract - guarding contract(Contract), which should be evaluated to true in order to open(spend) this box txId - transaction id in which this box was "created" (participated in outputs) index - index (in outputs) in the transaction
func NewBoxFromJson ¶
NewBoxFromJson parse Box from JSON. Supports Ergo Node/Explorer API and box values and token amount encoded as strings.
type BoxAssetsData ¶
type BoxAssetsData interface { // BoxValue returns the BoxValue of the BoxAssetsData BoxValue() BoxValue // Tokens returns the Tokens of the BoxAssetsData Tokens() Tokens // Equals checks if provided BoxAssetsData is same Equals(boxAssetsData BoxAssetsData) bool // contains filtered or unexported methods }
BoxAssetsData is a pair of value and tokens for a box
func NewBoxAssetsData ¶
func NewBoxAssetsData(boxValue BoxValue, tokens Tokens) BoxAssetsData
NewBoxAssetsData creates a new BoxAssetsData from the supplied BoxValue and Tokens
type BoxAssetsDataList ¶
type BoxAssetsDataList interface { // Len returns the length of the collection Len() int // Get returns the BoxAssetsData at the provided index if it exists Get(index int) (BoxAssetsData, error) // Add adds provided BoxAssetsData to the end of the collection Add(boxAssetsData BoxAssetsData) // All returns an iterator over all BoxAssetsData inside the collection All() iter.Seq2[int, BoxAssetsData] // contains filtered or unexported methods }
BoxAssetsDataList is an ordered collection of BoxAssetsData
func NewBoxAssetsDataList ¶
func NewBoxAssetsDataList() BoxAssetsDataList
NewBoxAssetsDataList creates an empty BoxAssetsDataList
type BoxCandidate ¶
type BoxCandidate interface { // RegisterValue returns value (Constant) stored in the register or nil if the register is empty RegisterValue(registerId nonMandatoryRegisterId) (Constant, error) // CreationHeight returns the creation height of the BoxCandidate CreationHeight() uint32 // Tokens returns the ergo Tokens for the BoxCandidate Tokens() Tokens // Tree returns the ergo Tree for the BoxCandidate Tree() Tree // BoxValue returns the BoxValue of the BoxCandidate BoxValue() BoxValue // Equals checks if provided BoxCandidate is same Equals(candidate BoxCandidate) bool // contains filtered or unexported methods }
BoxCandidate contains the same fields as Box except for transaction id and index, that will be calculated after full transaction formation. Use BoxCandidateBuilder to create an instance
type BoxCandidateBuilder ¶
type BoxCandidateBuilder interface { // SetMinBoxValuePerByte sets minimal value (per byte of the serialized box size) SetMinBoxValuePerByte(minBoxValuePerByte uint32) // MinBoxValuePerByte returns minimal value (per byte of the serialized box size) MinBoxValuePerByte() uint32 // SetValue sets new box value SetValue(boxValue BoxValue) // Value returns box value Value() BoxValue // CalcBoxSizeBytes calculates serialized box size(in bytes) CalcBoxSizeBytes() (uint32, error) // CalcMinBoxValue calculates minimal box value for the current box serialized size(in bytes) CalcMinBoxValue() (BoxValue, error) // SetRegisterValue sets register with a given id (R4 - R9) to the given value SetRegisterValue(registerId nonMandatoryRegisterId, constant Constant) // RegisterValue returns register value for the given register id (R4 - R9), or nil if the register is empty RegisterValue(registerId nonMandatoryRegisterId) (Constant, error) // DeleteRegisterValue deletes register value(make register empty) for the given register id (R4 - R9) DeleteRegisterValue(registerId nonMandatoryRegisterId) // MintToken mints token, as defined in https://github.com/ergoplatform/eips/blob/master/eip-0004.md // Parameters: // token - token id(box id of the first input box in transaction) and token amount // tokenName - token name (will be encoded in R4) // tokenDesc - token description (will be encoded in R5) // numDecimals - number of decimals (will be encoded in R6) MintToken(token Token, tokenName string, tokenDesc string, numDecimals uint32) // AddToken adds given token id and token amount AddToken(tokenId TokenId, tokenAmount TokenAmount) // Build builds the box candidate Build() (BoxCandidate, error) }
BoxCandidateBuilder is a builder to build a BoxCandidate
func NewBoxCandidateBuilder ¶
func NewBoxCandidateBuilder(boxValue BoxValue, contract Contract, creationHeight uint32) BoxCandidateBuilder
NewBoxCandidateBuilder creates a BoxCandidateBuilder with required box parameters. Parameters: boxValue - amount of money associated with the box contract - guard Contract which should be evaluated to true in order to open/spend this box creationHeight - height when a transaction containing the box is created. It should not exceed the height of the block, containing the transaction with this box.
type BoxCandidates ¶
type BoxCandidates interface { // Len returns the length of the collection Len() int // Get returns the BoxCandidate at the provided index if it exists Get(index int) (BoxCandidate, error) // Add adds provided BoxCandidate to the end of the collection Add(boxCandidate BoxCandidate) // All returns an iterator over all BoxCandidate inside the collection All() iter.Seq2[int, BoxCandidate] // contains filtered or unexported methods }
BoxCandidates is an ordered collection of BoxCandidate
func NewBoxCandidates ¶
func NewBoxCandidates() BoxCandidates
NewBoxCandidates creates an empty BoxCandidates collection
type BoxId ¶
type BoxId interface { // Base16 returns the BoxId as base16 encoded string Base16() string // Equals checks if provided BoxId is same Equals(boxId BoxId) bool // contains filtered or unexported methods }
BoxId (32-byte digest)
type BoxSelection ¶
type BoxSelection interface { // Boxes returns selected boxes to spend as transaction inputs Boxes() Boxes // ChangeBoxes returns selected boxes to use as change ChangeBoxes() BoxAssetsDataList // Equals checks if provided BoxSelection is same Equals(boxSelection BoxSelection) bool // contains filtered or unexported methods }
BoxSelection represents selected boxes with change boxes. Instance are created by SimpleBoxSelector
func NewBoxSelection ¶
func NewBoxSelection(ergoBoxes Boxes, changeErgoBoxes BoxAssetsDataList) BoxSelection
NewBoxSelection creates a selection to easily inject custom selection algorithms
type BoxValue ¶
type BoxValue interface { // Int64 returns BoxValue value as int64 Int64() int64 // Equals checks if provided BoxValue is same Equals(boxValue BoxValue) bool // contains filtered or unexported methods }
BoxValue in nanoERGs with bound checks
func NewBoxValue ¶
NewBoxValue creates a BoxValue from int64
func SafeUserMinBoxValue ¶
func SafeUserMinBoxValue() BoxValue
SafeUserMinBoxValue returns recommended (safe) minimal BoxValue to use in case box size estimation is unavailable. Allows box size upto 2777 bytes with current min box value per byte of 360 nanoERGs
func SuggestedTxFee ¶
func SuggestedTxFee() BoxValue
SuggestedTxFee returns the suggested transaction fee (semi-default value used across wallets and dApp as of Oct 2020)
type Boxes ¶
type Boxes interface { // Len returns the length of the collection Len() int // Get returns the Box at the provided index if it exists Get(index int) (Box, error) // Add adds provided Box to the end of the collection Add(box Box) // All returns an iterator over all Box inside the collection All() iter.Seq2[int, Box] // contains filtered or unexported methods }
Boxes an ordered collection of Box
type ByteArray ¶
type ByteArray interface {
// contains filtered or unexported methods
}
func NewByteArray ¶
type ByteArrays ¶
type ByteArrays interface { Len() int Get(index int) (ByteArray, error) Add(byteArray ByteArray) All() iter.Seq2[int, ByteArray] // contains filtered or unexported methods }
func NewByteArrays ¶
func NewByteArrays() ByteArrays
type CommitmentHint ¶
type CommitmentHint interface {
// contains filtered or unexported methods
}
CommitmentHint is a family of hints which are about a correspondence between a public image of a secret image and prover's commitment to randomness ("a" in a sigma protocol).
type Constant ¶
type Constant interface { // Base16 encode as Base16-encoded ErgoTree serialized value or throw an error if serialization failed Base16() (string, error) // Type returns the Constant type as string Type() (string, error) // Value returns the Constant value as string Value() (string, error) // Int16 extracts int16 value and returns error if wrong Constant type Int16() (int16, error) // Int32 extracts int32 value and returns error if wrong Constant type Int32() (int32, error) // Int64 extracts int64 value and returns error if wrong Constant type Int64() (int64, error) // Bytes extracts byte array and returns error if wrong Constant type Bytes() ([]byte, error) // Equals checks if provided Constant is same Equals(constant Constant) bool // contains filtered or unexported methods }
Constant represents Ergo constant(evaluated) values
func NewConstant ¶
NewConstant creates a new Constant from Base16-encoded ErgoTree serialized value
func NewConstantFromBox ¶
NewConstantFromBox creates a new Constant from Box
func NewConstantFromBytes ¶
NewConstantFromBytes creates a new Constant from byte array
func NewConstantFromECPointBytes ¶
NewConstantFromECPointBytes parse from raw EcPoint value from bytes and make ProveDlog Constant
func NewConstantFromInt16 ¶ added in v0.28.0
NewConstantFromInt16 creates a new Constant from int16 value
func NewConstantFromInt32 ¶
NewConstantFromInt32 creates a new Constant from int32 value
func NewConstantFromInt64 ¶
NewConstantFromInt64 creates a new Constant from int64 value
type ContextExtension ¶
type ContextExtension interface { // Keys returns iterator over all keys in the ContextExtension Keys() iter.Seq[uint8] // Get returns Constant at provided key or nil if it doesn't exist Get(key uint8) (Constant, error) // Set adds Constant at provided key Set(key uint8, constant Constant) // All returns iterator over all key,value pairs in the ContextExtension All() iter.Seq2[uint8, Constant] // Values returns iterator over all Constant in the ContextExtension Values() iter.Seq[Constant] // contains filtered or unexported methods }
ContextExtension represent user-defined variables to be put into context
func NewContextExtension ¶ added in v0.28.0
func NewContextExtension() ContextExtension
NewContextExtension creates new empty ContextExtension instance
type Contract ¶
type Contract interface { // Tree returns the ergo Tree of the Contract Tree() Tree // Equals checks if provided Contract is same Equals(contract Contract) bool // contains filtered or unexported methods }
Contract defines the contract(script) that will be guarding box contents
func NewContractCompileFromString ¶
NewContractCompileFromString compiles a contract from ErgoScript source code
func NewContractFromTree ¶
NewContractFromTree creates a new Contract from ergo Tree
func NewContractPayToAddress ¶
NewContractPayToAddress creates a new Contract that allows spending of the guarded box by a given recipient (Address)
type DataInput ¶
type DataInput interface { // BoxId returns the BoxId of the DataInput BoxId() BoxId // contains filtered or unexported methods }
DataInput represent inputs that are used to enrich script context, but won't be spent by the transaction
func NewDataInput ¶
NewDataInput create DataInput from BoxId
type DataInputs ¶
type DataInputs interface { // Len returns the length of the collection Len() int // Get returns the Input at the provided index if it exists Get(index int) (DataInput, error) // Add adds provided DataInput to the end of the collection Add(dataInput DataInput) // All returns an iterator over all DataInput inside the collection All() iter.Seq2[int, DataInput] // contains filtered or unexported methods }
DataInputs an ordered collection if DataInput
func NewDataInputs ¶
func NewDataInputs() DataInputs
NewDataInputs creates an empty DataInputs collection
type DerivationPath ¶ added in v0.28.0
type DerivationPath interface { // String returns the DerivationPath formatted as string in the m/44/429/acc'/0/addr format String() string // Depth returns the length of the DerivationPath Depth() uint32 // Next returns a new DerivationPath with the last element of the derivation path being increased, e.g. m/1/2 -> m/1/3 Next() (DerivationPath, error) // contains filtered or unexported methods }
func NewDerivationPath ¶ added in v0.28.0
func NewDerivationPath(account uint32, addressIndices []uint32) (DerivationPath, error)
NewDerivationPath creates DerivationPath from account index and address indices
func NewDerivationPathFromString ¶ added in v0.28.0
func NewDerivationPathFromString(s string) (DerivationPath, error)
NewDerivationPathFromString creates DerivationPath from string which should be in the form of m/44/429/acc'/0/addr
type ExtendedPublicKey ¶ added in v0.28.0
type ExtendedPublicKey interface { // Child derives a new ExtendedPublicKey from the provided index Child(childIndex uint32) (ExtendedPublicKey, error) // Derive derives a new ExtendedPublicKey from the supplied DerivationPath Derive(derivationPath DerivationPath) (ExtendedPublicKey, error) // Address returns the Address associated with the ExtendedPublicKey Address() Address // contains filtered or unexported methods }
func NewExtendedPublicKey ¶ added in v0.28.0
func NewExtendedPublicKey(publicKeyBytes []byte, chainCode []byte, derivationPath DerivationPath) (ExtendedPublicKey, error)
NewExtendedPublicKey creates a new ExtendedPublicKey from publicKeyBytes, chainCode and derivationPath publicKeyBytes needs to be the length of 33 bytes chainCode needs to be the length of 32 bytes
type ExtendedSecretKey ¶ added in v0.28.0
type ExtendedSecretKey interface { // Child derives a new ExtendedSecretKey from the provided index // The index is in the form of soft or hardened indices // For example: 4 or 4' respectively Child(index string) (ExtendedSecretKey, error) // Path returns the DerivationPath of the ExtendedSecretKey Path() DerivationPath // SecretKey returns the SecretKey of the ExtendedSecretKey SecretKey() SecretKey // ExtendedPublicKey returns the ExtendedPublicKey associated with the ExtendedSecretKey ExtendedPublicKey() ExtendedPublicKey // Derive derives a new ExtendedSecretKey from the supplied DerivationPath Derive(derivationPath DerivationPath) (ExtendedSecretKey, error) }
func DeriveMaster ¶ added in v0.28.0
func DeriveMaster(seed []byte) (ExtendedSecretKey, error)
DeriveMaster derives root ExtendedSecretKey from seed bytes
func NewExtendedSecretKey ¶ added in v0.28.0
func NewExtendedSecretKey(secretKeyBytes []byte, chainCode []byte, derivationPath DerivationPath) (ExtendedSecretKey, error)
NewExtendedSecretKey creates a new ExtendedSecretKey from secretKeyBytes, chainCode and derivationPath secretKeyBytes needs to be the length of 32 bytes chainCode needs to be the length of 32 bytes
type HintsBag ¶
type HintsBag interface { // Add adds CommitmentHint to the bag Add(hint CommitmentHint) // Len returns the length of the HintsBag Len() int // Get returns the CommitmentHint at the provided index if it exists Get(index int) (CommitmentHint, error) // All returns an iterator over all CommitmentHint inside the collection All() iter.Seq2[int, CommitmentHint] // contains filtered or unexported methods }
HintsBag is a collection of CommitmentHint to be used by a prover
type Input ¶
type Input interface { // BoxId returns BoxId of Input BoxId() BoxId // SpendingProof returns spending proof of Input as ProverResult SpendingProof() ProverResult // contains filtered or unexported methods }
Input represents signed inputs in signed transaction
type Inputs ¶
type Inputs interface { // Len returns the length of the collection Len() int // Get returns the Input at the provided index if it exists Get(index int) (Input, error) // Add adds provided Input to the end of the collection Add(input Input) // All returns an iterator over all Input inside the collection All() iter.Seq2[int, Input] }
Inputs an ordered collection of Input
type MerkleProof ¶
type MerkleProof interface { // AddNode adds a new node and it's hash to the MerkleProof. Hash must be 32 bytes in size AddNode(hash []byte, side nodeSide) error // Valid validates the MerkleProof against the provided root hash Valid(expectedRoot []byte) bool // ValidBase16 validates the MerkleProof against the provided base16 root hash ValidBase16(expectedRoot string) bool }
func NewMerkleProof ¶
func NewMerkleProof(leafData []byte) (MerkleProof, error)
func NewMerkleProofFromJson ¶
func NewMerkleProofFromJson(json string) (MerkleProof, error)
type MnemonicGenerator ¶
type MnemonicGenerator interface { // Generate a new mnemonic sentence using random entropy Generate() (string, error) // GenerateFromEntropy generates a new mnemonic sentence using provided entropy GenerateFromEntropy(entropy []byte) (string, error) }
MnemonicGenerator generates new mnemonic seed phrases
func NewMnemonicGenerator ¶
func NewMnemonicGenerator(language string, strength uint32) (MnemonicGenerator, error)
NewMnemonicGenerator creates a new MnemonicGenerator based on supplied language and strength
type NipopowProof ¶
type NipopowProof interface { // IsBetterThan implementation of the ≥ algorithm from KMZ17, see Algorithm 4 // https://fc20.ifca.ai/preproceedings/74.pdf IsBetterThan(otherProof NipopowProof) (bool, error) // SuffixHead returns suffix head SuffixHead() PoPowHeader // Json returns json representation of NipopowProof as text Json() (string, error) // contains filtered or unexported methods }
func NewNipopowProof ¶
func NewNipopowProof(json string) (NipopowProof, error)
NewNipopowProof parse NipopowProof from JSON
type NipopowVerifier ¶
type NipopowVerifier interface { // BestProof returns the best NipopowProof BestProof() NipopowProof // BestChain returns chain of BlockHeaders from the best proof BestChain() BlockHeaders // Process given NipopowProof Process(newProof NipopowProof) error }
NipopowVerifier a verifier for PoPow proofs. During its lifetime, it processes many proofs with the aim of deducing at any given point what is the best (sub)chain rooted at the specified genesis
func NewNipopowVerifier ¶
func NewNipopowVerifier(genesisBlockId BlockId) NipopowVerifier
NewNipopowVerifier creates a new NipopowVerifier
type Parameters ¶ added in v0.28.0
type Parameters interface {
// contains filtered or unexported methods
}
func DefaultParameters ¶ added in v0.28.0
func DefaultParameters() Parameters
DefaultParameters returns default blockchain parameters that were set at genesis
func NewParameters ¶ added in v0.28.0
func NewParameters( blockVersion int32, storageFeeFactor int32, minValuePerByte int32, maxBlockSize int32, maxBlockCost int32, tokenAccessCost int32, inputCost int32, dataInputCost int32, outputCost int32) Parameters
NewParameters creates new Parameters from provided blockchain parameters
func NewParametersFromJson ¶ added in v0.28.0
func NewParametersFromJson(json string) (Parameters, error)
NewParametersFromJson parses parameters from JSON. Support Ergo Node API/Explorer API
type PoPowHeader ¶
type PoPowHeader interface { // Header returns BlockHeader of PoPowHeader Header() (BlockHeader, error) // Interlinks returns BlockIds of PoPowHeader Interlinks() (BlockIds, error) // InterlinksProof returns BatchMerkleProof of PoPowHeader InterlinksProof() (BatchMerkleProof, error) // CheckInterlinksProof checks interlinks proof CheckInterlinksProof() bool // Json returns json representation of PoPowHeader as string Json() (string, error) // Equals checks if provided PoPowHeader is same Equals(poPowHeader PoPowHeader) bool // contains filtered or unexported methods }
func NewPoPowHeader ¶
func NewPoPowHeader(json string) (PoPowHeader, error)
NewPoPowHeader parses PoPowHeader from json string
type PreHeader ¶
type PreHeader interface { // Equals checks if provided PreHeader is same Equals(preHeader PreHeader) bool // contains filtered or unexported methods }
PreHeader represents a block header with the current SpendingTransaction, that can be predicted by a miner before its formation
func NewPreHeader ¶
func NewPreHeader(header BlockHeader) PreHeader
NewPreHeader creates PreHeader using data from BlockHeader
type Propositions ¶
type Propositions interface { // Add adds new proposition Add(bytes []byte) error // contains filtered or unexported methods }
Propositions list(public keys)
func NewPropositions ¶
func NewPropositions() Propositions
NewPropositions creates empty proposition holder
type ProverResult ¶
type ProverResult interface { // Bytes returns proof bytes Bytes() []byte // ContextExtension returns ContextExtension of ProverResult ContextExtension() ContextExtension // Json representation as text (compatible with Ergo Node/Explorer API, numbers are encoded as numbers) Json() (string, error) }
ProverResult represents proof of correctness of tx spending
type ReducedTransaction ¶
type ReducedTransaction interface { // UnsignedTransaction returns the UnsignedTransaction UnsignedTransaction() UnsignedTransaction // contains filtered or unexported methods }
ReducedTransaction represents reduced transaction, i.e. unsigned transaction where each unsigned input is augmented with ReducedInput which contains a script reduction result. After an unsigned transaction is reduced it can be signed without context. Thus, it can be serialized and transferred for example to Cold Wallet and signed in an environment where secrets are known. see EIP-19 for more details - https://github.com/ergoplatform/eips/blob/f280890a4163f2f2e988a0091c078e36912fc531/eip-0019.md
func NewReducedTransaction ¶
func NewReducedTransaction(unsignedTx UnsignedTransaction, boxesToSpent Boxes, dataBoxes Boxes, stateContext StateContext) (ReducedTransaction, error)
NewReducedTransaction creates a ReducedTransaction i.e unsigned transaction where each unsigned input is augmented with ReducedInput which contains a script reduction result
type SecretKey ¶
type SecretKey interface { // Address returns address of the SecretKey Address() Address // Bytes returns SecretKey encoded to bytes Bytes() []byte // contains filtered or unexported methods }
SecretKey represents secret key for the prover
func NewSecretKeyFromBytes ¶
NewSecretKeyFromBytes parses dlog secret key from bytes (SEC-1-encoded scalar) provided secret key bytes must be of length 32
type SecretKeys ¶
type SecretKeys interface { // Len returns the length of the collection Len() int // Get returns the SecretKey at the provided index if it exists Get(index int) (SecretKey, error) // Add adds provided SecretKey to the end of the collection Add(secretKey SecretKey) // All returns an iterator over all SecretKey inside the collection All() iter.Seq2[int, SecretKey] // contains filtered or unexported methods }
SecretKeys an ordered collection of SecretKey
func NewSecretKeys ¶
func NewSecretKeys() SecretKeys
NewSecretKeys creates an empty SecretKeys collection
type SignedMessage ¶
type SignedMessage interface {
// contains filtered or unexported methods
}
type SimpleBoxSelector ¶
type SimpleBoxSelector interface { // Select selects inputs to satisfy target balance and tokens // Parameters: // inputs - available inputs (returns an error, if empty) // targetBalance - coins (in nanoERGs) needed // targetTokens - amount of tokens needed // Returns: selected inputs and box assets(value+tokens) with change Select(inputs Boxes, targetBalance BoxValue, targetTokens Tokens) (BoxSelection, error) }
SimpleBoxSelector is a naive box selector, collects inputs until target balance is reached
func NewSimpleBoxSelector ¶
func NewSimpleBoxSelector() SimpleBoxSelector
NewSimpleBoxSelector creates a new SimpleBoxSelector
type StateContext ¶
type StateContext interface { // Equals checks if provided StateContext is same Equals(stateContext StateContext) bool // contains filtered or unexported methods }
StateContext represents blockchain state (last headers, etc.)
func NewStateContext ¶
func NewStateContext(preHeader PreHeader, headers BlockHeaders, parameters Parameters) (StateContext, error)
NewStateContext creates StateContext from PreHeader and BlockHeaders
type Token ¶
type Token interface { // Id returns TokenId of the Token Id() TokenId // Amount returns TokenAmount of the Token Amount() TokenAmount // JsonEIP12 returns json representation of Token as string according to EIP-12 https://github.com/ergoplatform/eips/pull/23 JsonEIP12() (string, error) // Equals checks if provided Token is same Equals(token Token) bool // contains filtered or unexported methods }
Token represented with TokenId paired with its TokenAmount
func NewToken ¶
func NewToken(tokenId TokenId, tokenAmount TokenAmount) Token
NewToken creates Token from provided TokenId and TokenAmount
type TokenAmount ¶
type TokenAmount interface { // Int64 converts TokenAmount to int64 Int64() int64 // Equals checks if provided TokenAmount is same Equals(tokenAmount TokenAmount) bool // contains filtered or unexported methods }
TokenAmount is token amount with bound checks
func NewTokenAmount ¶
func NewTokenAmount(amount int64) (TokenAmount, error)
NewTokenAmount creates TokenAmount from int64
type TokenId ¶
type TokenId interface { // Base16 returns the TokenId as base16 encoded string Base16() string // Equals checks if provided TokenId is same Equals(tokenId TokenId) bool // contains filtered or unexported methods }
TokenId (32-byte digest)
func NewTokenId ¶
NewTokenId creates a TokenId from a base16-encoded string (32 byte digest)
func NewTokenIdFromBoxId ¶
NewTokenIdFromBoxId creates a TokenId from ergo box id (32 byte digest)
type Tokens ¶
type Tokens interface { // Len returns the length of the collection Len() int // Get returns the Token at the provided index if it exists Get(index int) (Token, error) // Add adds provided Token to the end of the collection Add(token Token) // All returns an iterator over all Token inside the collection All() iter.Seq2[int, Token] // contains filtered or unexported methods }
Tokens an ordered collection of Token
type Transaction ¶
type Transaction interface { // TxId returns TxId for this Transaction TxId() TxId // Inputs returns Inputs for this Transaction Inputs() Inputs // DataInputs returns DataInputs for this Transaction DataInputs() DataInputs // OutputCandidates returns BoxCandidates for this Transaction OutputCandidates() BoxCandidates // Outputs returns Boxes for this Transaction Outputs() Boxes // Json returns json representation of Transaction as string (compatible with Ergo Node/Explorer API, numbers are encoded as numbers) Json() (string, error) // JsonEIP12 returns json representation of Transaction as string according to EIP-12 https://github.com/ergoplatform/eips/pull/23 JsonEIP12() (string, error) // Validate validates the current Transaction Validate(stateContext StateContext, boxesToSpent Boxes, dataBoxes Boxes) error // contains filtered or unexported methods }
Transaction is an atomic state transition operation. It destroys Boxes from the state and creates new ones. If transaction is spending boxes protected by some non-trivial scripts, its inputs should also contain proof of spending correctness - context extension (user-defined key-value map) and data inputs (links to existing boxes in the state) that may be used during script reduction to crypto, signatures that satisfies the remaining cryptographic protection of the script. Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block.
func NewTransaction ¶
func NewTransaction(unsignedTx UnsignedTransaction, proofs ByteArrays) (Transaction, error)
NewTransaction creates Transaction from UnsignedTransaction and an array of proofs in the same order as UnsignedTransaction inputs with empty proof indicated with empty ByteArray
func NewTransactionFromJson ¶
func NewTransactionFromJson(json string) (Transaction, error)
NewTransactionFromJson parse Transaction from JSON. Supports Ergo Node/Explorer API and box values and token amount encoded as strings.
type TransactionHintsBag ¶
type TransactionHintsBag interface { // AddHintsForInput adds hints for input AddHintsForInput(index uint32, hintsBag HintsBag) // AllHintsForInput gets HintsBag corresponding to input index AllHintsForInput(index uint32) HintsBag // contains filtered or unexported methods }
func ExtractHintsFromSignedTransaction ¶
func ExtractHintsFromSignedTransaction( transaction Transaction, stateContext StateContext, boxesToSpend Boxes, dataBoxes Boxes, realPropositions Propositions, simulatedPropositions Propositions) (TransactionHintsBag, error)
ExtractHintsFromSignedTransaction extracts hints from signed transaction
func NewTransactionHintsBag ¶
func NewTransactionHintsBag() TransactionHintsBag
NewTransactionHintsBag creates empty TransactionHintsBag
type Tree ¶
type Tree interface { // Base16 converts the Tree to a base16 encoded string. Base16() (string, error) // Address converts the Tree to an Address. Address() (Address, error) // TemplateBytesLength determines the length of the byte array TemplateBytesLength() (int, error) // TemplateHash returns the hash of the template bytes as string TemplateHash() (string, error) // ConstantsLength returns the number of constants stored in the serialized ErgoTree or throws error if the parsing of constants failed ConstantsLength() (int, error) // Constant returns Constant with given index (as stored in serialized ErgoTree) if it exists or throws error if the parsing of constants failed Constant(index int) (Constant, error) // Constants returns all Constant within the Tree or throws error if the parsing of constants failed Constants() ([]Constant, error) // Equals checks if provided Tree is same Equals(tree Tree) bool // contains filtered or unexported methods }
Tree is the root of ErgoScript IR. Serialized instances of Tree are self-sufficient and can be passed around
type TxBuilder ¶
type TxBuilder interface { // SetDataInputs set data inputs for transaction SetDataInputs(dataInputs DataInputs) // SetContextExtension sets context extension for a given input SetContextExtension(boxId BoxId, contextExtension ContextExtension) // SetTokenBurnPermit permits the burn of the given token amount, i.e. allows this token amount to be omitted in the outputs SetTokenBurnPermit(tokens Tokens) // DataInputs returns DataInputs of the TxBuilder DataInputs() DataInputs // BoxSelection returns BoxSelection of the TxBuilder BoxSelection() BoxSelection // OutputCandidates returns BoxCandidates of the TxBuilder OutputCandidates() BoxCandidates // CurrentHeight returns the current height CurrentHeight() uint32 // FeeAmount returns the fee amount of the TxBuilder FeeAmount() BoxValue // ChangeAddress returns the change address of the TxBuilder ChangeAddress() Address // Build builds the UnsignedTransaction Build() (UnsignedTransaction, error) }
TxBuilder builds UnsignedTransaction
func NewTxBuilder ¶
func NewTxBuilder( boxSelection BoxSelection, outputCandidates BoxCandidates, currentHeight uint32, feeAmount BoxValue, changeAddress Address) TxBuilder
NewTxBuilder creates a new TxBuilder Parameters boxSelection - selected input boxes outputCandidates - output boxes to be "created" in this transaction currentHeight - chain height that will be used in additionally created boxes (change, miner's fee, etc.) feeAmount - miner's fee changeAddress - change (inputs - outputs) will be sent to this address
type TxId ¶
type TxId interface { // String returns TxId as string String() (string, error) // Equals checks if provided TxId is same Equals(txId TxId) bool // contains filtered or unexported methods }
TxId represents transaction id
type UnsignedInput ¶
type UnsignedInput interface { // BoxId returns the BoxId of the UnsignedInput BoxId() BoxId // ContextExtension returns the ContextExtension of the UnsignedInput ContextExtension() ContextExtension // contains filtered or unexported methods }
UnsignedInput used in construction of UnsignedTransactions
type UnsignedInputs ¶
type UnsignedInputs interface { // Len returns the length of the collection Len() int // Get returns the UnsignedInput at the provided index if it exists Get(index int) (UnsignedInput, error) // Add adds provided UnsignedInput to the end of the collection Add(unsignedInput UnsignedInput) // All returns an iterator over all UnsignedInput inside the collection All() iter.Seq2[int, UnsignedInput] }
UnsignedInputs an ordered collection of UnsignedInput
func NewUnsignedInputs ¶
func NewUnsignedInputs() UnsignedInputs
NewUnsignedInputs creates an empty UnsignedInputs collection
type UnsignedTransaction ¶
type UnsignedTransaction interface { // TxId returns TxId for this UnsignedTransaction TxId() TxId // UnsignedInputs returns UnsignedInputs for this UnsignedTransaction UnsignedInputs() UnsignedInputs // DataInputs returns DataInputs for this UnsignedTransaction DataInputs() DataInputs // OutputCandidates returns BoxCandidates for this UnsignedTransaction OutputCandidates() BoxCandidates // Json returns json representation of UnsignedTransaction as string (compatible with Ergo Node/Explorer API, numbers are encoded as numbers) Json() (string, error) // JsonEIP12 returns json representation of UnsignedTransaction as string according to EIP-12 https://github.com/ergoplatform/eips/pull/23 JsonEIP12() (string, error) // contains filtered or unexported methods }
UnsignedTransaction represents an unsigned transaction (inputs without proofs)
func NewUnsignedTransactionFromJson ¶
func NewUnsignedTransactionFromJson(json string) (UnsignedTransaction, error)
NewUnsignedTransactionFromJson parse UnsignedTransaction from JSON. Supports Ergo Node/Explorer API and box values and token amount encoded as strings.
type Wallet ¶
type Wallet interface { // AddSecret adds a secret to the wallets prover AddSecret(secret SecretKey) error // SignTransaction signs a transaction SignTransaction(stateContext StateContext, unsignedTx UnsignedTransaction, boxesToSpend Boxes, dataBoxes Boxes) (Transaction, error) // SignTransactionMulti signs a multi signature transaction SignTransactionMulti(stateContext StateContext, unsignedTx UnsignedTransaction, boxesToSpend Boxes, dataBoxes Boxes, txHints TransactionHintsBag) (Transaction, error) // SignReducedTransaction signs a reduced transaction (generating proofs for inputs) SignReducedTransaction(reducedTx ReducedTransaction) (Transaction, error) // SignReducedTransactionMulti signs a multi signature reduced transaction SignReducedTransactionMulti(reducedTx ReducedTransaction, txHints TransactionHintsBag) (Transaction, error) // GenerateCommitments generates Commitments for unsigned tx GenerateCommitments(stateContext StateContext, unsignedTx UnsignedTransaction, boxesToSpend Boxes, dataBoxes Boxes) (TransactionHintsBag, error) // GenerateCommitmentsForReducedTransaction generates Commitments for reduced transaction GenerateCommitmentsForReducedTransaction(reducedTx ReducedTransaction) (TransactionHintsBag, error) // SignMessageUsingP2PK signs an arbitrary message using a P2PK address SignMessageUsingP2PK(address Address, message []byte) (SignedMessage, error) }
func NewWallet ¶
NewWallet creates a Wallet instance loading secret key from mnemonic or throws error if a DlogSecretKey cannot be parsed from the provided phrase
func NewWalletFromSecretKeys ¶
func NewWalletFromSecretKeys(secrets SecretKeys) Wallet
NewWalletFromSecretKeys creates a Wallet from secrets
Source Files
¶
- address.go
- batchmerkleproof.go
- blockheader.go
- box.go
- boxcandidatebuilder.go
- boxselector.go
- bytearray.go
- cgo.go
- constant.go
- contextextension.go
- contract.go
- datainput.go
- derivationpath.go
- errors.go
- extendedpublickey.go
- extendedsecretkey.go
- input.go
- merkleproof.go
- mnemonic.go
- nipopow.go
- parameters.go
- preheader.go
- reducedtransaction.go
- secretkey.go
- statecontext.go
- token.go
- transaction.go
- tree.go
- txbuilder.go
- verifier.go
- wallet.go
Directories
¶
Path | Synopsis |
---|---|
packaged
|
|
include
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
lib
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
lib/darwin-aarch64
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
lib/darwin-amd64
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
lib/linux-aarch64
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
lib/linux-amd64
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
lib/windows-amd64
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |