Documentation
¶
Index ¶
- Constants
- type Bid
- type Coinbase
- func (c *Coinbase) AddReward(output *Output)
- func (c *Coinbase) CalculateHash() ([]byte, error)
- func (c *Coinbase) Decode(r io.Reader) error
- func (c *Coinbase) Encode(w io.Writer) error
- func (c *Coinbase) Equals(t Transaction) bool
- func (c *Coinbase) StandardTX() Standard
- func (c *Coinbase) Type() TxType
- type Decoder
- type Encoder
- type Input
- type Inputs
- type Output
- type Outputs
- type Stake
- type Standard
- func (s *Standard) AddInput(input *Input)
- func (s *Standard) AddOutput(output *Output)
- func (s *Standard) CalculateHash() ([]byte, error)
- func (s *Standard) Decode(r io.Reader) error
- func (s *Standard) Encode(w io.Writer) error
- func (s *Standard) Equals(t Transaction) bool
- func (s Standard) StandardTX() Standard
- func (s *Standard) Type() TxType
- type TimeLock
- type Transaction
- type TxType
- type TypeInfo
Constants ¶
const MaxLockTime = 250000
const TimeLockBlockZero = 0x8000000000000000
TimeLockBlockZero is the integer that represents the blockHeight of zero for a timelock transaction
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bid ¶
type Bid struct {
TimeLock
// M represents the pre-image of the secret value k.
// M = H(K)
M []byte // 32 Byte
}
Bid represents the bidding transaction that is used within the blindbid procedure What does the TimeLock represent? In a `Bidding TX` it means that the outputs are locked until after the specified time
func (*Bid) CalculateHash ¶
CalculateHash hashes all of the encoded fields in a tx, if this has not been done already. The resulting byte array is also it's identifier Implements merkletree.Payload interface
func (*Bid) Equals ¶
func (b *Bid) Equals(t Transaction) bool
Equals returns true if two Bid tx's are the same
func (Bid) StandardTX ¶
StandardTX returns the embedded standard tx Implements Transaction interface.
type Coinbase ¶
type Coinbase struct {
// TxType represents the transaction type
TxType TxType
// TxID is the transaction identifier for the current transaction
TxID []byte
R []byte
Score []byte
Proof []byte
Rewards Outputs
}
Coinbase transaction is the transaction that the block generator will create in order to be rewarded for their efforts.
func NewCoinbase ¶
NewCoinbase will return a Coinbase transaction given the zkproof, ephemeral key and the block generators Address.
func (*Coinbase) CalculateHash ¶
CalculateHash hashes all of the encoded fields in a tx, if this has not been done already. The resulting byte array is also it's identifier Implements merkletree.Payload interface
func (*Coinbase) Equals ¶
func (c *Coinbase) Equals(t Transaction) bool
Equals returns true, if two coinbase tx's are equal
func (*Coinbase) StandardTX ¶
StandardTX implements the transaction interface
type Input ¶
type Input struct {
// KeyImage is the image of the key that is being used to
// sign the transaction
KeyImage []byte // 32 bytes
// PubKey is the one-time public key that this output was created with.
// It acts as a output identifer because they can only be used once
PubKey []byte // 32 bytes
// PseudoCommitment acts as the dummy commitment used to construct the
// intermediate ring signatures
PseudoCommitment []byte // 32 bytes
// Signature is the ring signature that is used
// to sign the transaction
Signature []byte // ~2500 bytes
}
Input defines an input in a standard transaction.
type Inputs ¶
type Inputs []*Input
Inputs is a slice of pointers to a set of `input`'s
func (Inputs) HasDuplicates ¶
HasDuplicates checks whether any of the inputs contain duplciates This is done by checking their keyImages
type Output ¶
type Output struct {
// Commitment is the pedersen commitment to the underlying amount
// In a bidding transaction, it is the amount in cleartext
// For this reason, the size is varied. Once bidding transactions use Commitments,
// The size will be changed to a fixed 32 bytes
Commitment []byte // Variable size
// DestKey is the one-time public key of the address that
// the funds should be sent to.
DestKey []byte // 32 bytes
EncryptedAmount, EncryptedMask []byte
}
Output defines an output in a transaction.
func NewOutput ¶
NewOutput constructs a new Output from the passed parameters. This function is placed here for consistency with the rest of the API.
type Outputs ¶
type Outputs []*Output
Outputs is a slice of pointers to a set of `input`'s
func (Outputs) HasDuplicates ¶
HasDuplicates checks whether an output contains a duplicate This is done by checking that there are no matching Destination keys
type Stake ¶
Stake transactions are time lock transactions that are used by nodes to allow them to become provisioners, and participate in the consensus protocol. What does the TimeLock represent? In a `Stake TX` it means that the Outputs, or the node's stake is locked until after the specified time. After this time, they will also no longer be a provisioner, and must re-stake to participate again.
func NewStake ¶
NewStake will return a Stake transaction Given the tx version, the locktime,the fee and M
func (*Stake) CalculateHash ¶
CalculateHash hashes all of the encoded fields in a tx, if this has not been done already. The resulting byte array is also it's identifier Implements merkletree.Payload interface
func (*Stake) Equals ¶
func (s *Stake) Equals(t Transaction) bool
Equals returns true if two Stake tx's are the same
func (*Stake) GetOutputAmount ¶
func (Stake) StandardTX ¶
StandardTX returns the embedded standard tx Implements Transaction interface.
type Standard ¶
type Standard struct {
// TxType represents the transaction type
TxType TxType
// R is the Transaction Public Key
R []byte
// Version is the transaction version. It does not use semver.
// A new transaction version denotes a modification of the previous structure
Version uint8 // 1 byte
// TxID is the hash of the transaction fields.
TxID []byte // TxID (32 bytes)
// Inputs represent a list of inputs to the transaction.
Inputs Inputs
// Outputs represent a list of outputs to the transaction
Outputs Outputs
// Fee is the assosciated fee attached to the transaction. This is in cleartext.
Fee uint64
// RangeProof is the bulletproof rangeproof that proves that the hidden amount
// is between 0 and 2^64
RangeProof []byte // Variable size
}
Standard is a generic transaction. It can also be seen as a stealth transaction. It is used to make basic payments on the dusk network.
func NewStandard ¶
NewStandard will return a Standard transaction given the tx version and the fee atached
func (*Standard) AddOutput ¶
AddOutput will add an output to the list of outputs in the transaction.
func (*Standard) CalculateHash ¶
CalculateHash hashes all of the encoded fields in a tx, if this has not been done already. The resulting byte array is also it's identifier // Implements merkletree.Payload interface
func (*Standard) Equals ¶
func (s *Standard) Equals(t Transaction) bool
Equals returns true if two standard tx's are the same
func (Standard) StandardTX ¶
StandardTX returns the standard struct Implements Transaction interface.
type TimeLock ¶
type TimeLock struct {
Standard
// Lock represents the value for the timelock.
// There are 2^64 possible values.
// The Lock can be specified in either blockheight or unix timestamp
// 0 to 0x8000000000000000 will represent the unixtimestamp in seconds
// >= 0x8000000000000000 will represnt a blockheight
// This means that block zero can be represented as 0x8000000000000000
// And max blockheight for time-lock is `2^64-0x8000000000000000`
Lock uint64
}
TimeLock represents a standard transaction that has an additional time restriction What does the time-lock represent? For a `Standard TimeLock`; that the TX can only become valid after the time stated. This is not the case for others, please check each transaction for the significance of the timelock
func NewTimeLock ¶
NewTimeLock will return a TimeLock transaction Given the tx version, the locktime and the fee
func (*TimeLock) CalculateHash ¶
CalculateHash hashes all of the encoded fields in a tx, if this has not been done already. The resulting byte array is also it's identifier // Implements merkletree.Payload interface
func (*TimeLock) Equals ¶
func (t *TimeLock) Equals(tr Transaction) bool
Equals returns true if two timelocks tx's are the same
func (TimeLock) StandardTX ¶
StandardTX returns the embedded standard tx Implements Transaction interface.
type Transaction ¶
type Transaction interface {
Encoder
Decoder
TypeInfo
merkletree.Payload
Equals(Transaction) bool
StandardTX() Standard
}
Transaction represents all transaction structures All transactions will embed the standard transaction. Returning Standard() allows the caller to fetch the inputs/outputs/fees without type casting the Transaction interface to a specific type
func FromReader ¶
func FromReader(r io.Reader, numOfTXs uint64) ([]Transaction, error)
FromReader will decode into a slice of transactions
type TxType ¶
type TxType uint8
TxType defines a transaction type identifier.
const ( // CoinbaseType is the identifier for a block coinbase CoinbaseType TxType = 0x00 // BidType is the identifier for a blind bid BidType TxType = 0x01 // StakeType is the identifier for a stake StakeType TxType = 0x02 // StandardType is the identifier for a standard transaction StandardType TxType = 0x03 // TimelockType is the identifier for a standard time-locked transaction TimelockType TxType = 0x04 // ContractType is the identifier for a smart contract transaction ContractType TxType = 0x05 )