Documentation
¶
Overview ¶
implement smart contract transaction. smart contract transaction is value transaction with special payload
Index ¶
- Constants
- func OutputValueOfColor(tx *Transaction, addr address.Address, color balance.Color) int64
- func ReadRequestId(r io.Reader, reqid *RequestId) error
- type NewStateBlockParams
- type Properties
- type RequestBlock
- func (req *RequestBlock) Address() address.Address
- func (req *RequestBlock) Args() kv.RCodec
- func (req *RequestBlock) Clone() *RequestBlock
- func (req *RequestBlock) Read(r io.Reader) error
- func (req *RequestBlock) RequestCode() RequestCode
- func (req *RequestBlock) SetArgs(args kv.Map)
- func (req *RequestBlock) String(reqId *RequestId) string
- func (req *RequestBlock) Timelock() uint32
- func (req *RequestBlock) WithTimelock(tl uint32) *RequestBlock
- func (req *RequestBlock) WithTimelockUntil(deadline time.Time) *RequestBlock
- func (req *RequestBlock) Write(w io.Writer) error
- type RequestCode
- type RequestId
- func (rid *RequestId) Bytes() []byte
- func (rid *RequestId) Index() uint16
- func (rid *RequestId) Read(r io.Reader) error
- func (rid *RequestId) Short() string
- func (rid *RequestId) String() string
- func (rid *RequestId) ToBase58() string
- func (rid *RequestId) TransactionId() *valuetransaction.ID
- func (rid *RequestId) Write(w io.Writer) error
- type RequestRef
- type StateBlock
- func (sb *StateBlock) Clone() *StateBlock
- func (sb *StateBlock) Color() balance.Color
- func (sb *StateBlock) Read(r io.Reader) error
- func (sb *StateBlock) StateHash() hashing.HashValue
- func (sb *StateBlock) StateIndex() uint32
- func (sb *StateBlock) Timestamp() int64
- func (sb *StateBlock) WithStateParams(stateIndex uint32, h *hashing.HashValue, ts int64) *StateBlock
- func (sb *StateBlock) Write(w io.Writer) error
- type Transaction
- func (tx *Transaction) MustProperties() *Properties
- func (tx *Transaction) MustState() *StateBlock
- func (tx *Transaction) NumRequestsToAddress(addr *address.Address) int
- func (tx *Transaction) OutputBalancesByAddress(addr *address.Address) ([]*balance.Balance, bool)
- func (tx *Transaction) Properties() (*Properties, error)
- func (tx *Transaction) Requests() []*RequestBlock
- func (tx *Transaction) Sender() *address.Address
- func (tx *Transaction) State() (*StateBlock, bool)
- func (tx *Transaction) String() string
- func (tx *Transaction) ValidateBlocks(addr *address.Address) (bool, error)
Constants ¶
const ( RequestCodeReserved = uint16(0x8000) RequestCodeProtected = uint16(0x4000) RequestCodeProtectedReserved = RequestCodeReserved | RequestCodeProtected )
user-defined request codes: unprotected from 0 to 2^14-1 protected from 2^16 - 2^14 - 1
const RequestIdSize = hashing.HashSize + 2
Variables ¶
This section is empty.
Functions ¶
func OutputValueOfColor ¶
Types ¶
type NewStateBlockParams ¶
type Properties ¶
type Properties struct {
// contains filtered or unexported fields
}
func (*Properties) IsOrigin ¶
func (prop *Properties) IsOrigin() bool
func (*Properties) IsState ¶
func (prop *Properties) IsState() bool
func (*Properties) MustStateAddress ¶
func (prop *Properties) MustStateAddress() *address.Address
func (*Properties) MustStateColor ¶
func (prop *Properties) MustStateColor() *balance.Color
func (*Properties) NumFreeMintedTokens ¶
func (prop *Properties) NumFreeMintedTokens() int64
NumFreeMintedTokens return total minted tokens minus number of requests
func (*Properties) Sender ¶
func (prop *Properties) Sender() *address.Address
type RequestBlock ¶
type RequestBlock struct {
// contains filtered or unexported fields
}
func NewRequestBlock ¶
func NewRequestBlock(addr address.Address, reqCode RequestCode) *RequestBlock
func (*RequestBlock) Address ¶
func (req *RequestBlock) Address() address.Address
func (*RequestBlock) Args ¶
func (req *RequestBlock) Args() kv.RCodec
func (*RequestBlock) Clone ¶
func (req *RequestBlock) Clone() *RequestBlock
func (*RequestBlock) RequestCode ¶
func (req *RequestBlock) RequestCode() RequestCode
func (*RequestBlock) SetArgs ¶
func (req *RequestBlock) SetArgs(args kv.Map)
func (*RequestBlock) String ¶
func (req *RequestBlock) String(reqId *RequestId) string
func (*RequestBlock) Timelock ¶
func (req *RequestBlock) Timelock() uint32
func (*RequestBlock) WithTimelock ¶
func (req *RequestBlock) WithTimelock(tl uint32) *RequestBlock
func (*RequestBlock) WithTimelockUntil ¶
func (req *RequestBlock) WithTimelockUntil(deadline time.Time) *RequestBlock
type RequestCode ¶
type RequestCode uint16
func (RequestCode) Bytes ¶
func (rc RequestCode) Bytes() []byte
func (RequestCode) IsProtected ¶
func (rc RequestCode) IsProtected() bool
func (RequestCode) IsReserved ¶
func (rc RequestCode) IsReserved() bool
func (RequestCode) IsUserDefined ¶
func (rc RequestCode) IsUserDefined() bool
func (RequestCode) String ¶
func (rc RequestCode) String() string
type RequestId ¶
type RequestId [RequestIdSize]byte
func NewRequestId ¶
func NewRequestId(txid valuetransaction.ID, index uint16) (ret RequestId)
func NewRequestIdFromString ¶
func RequestIdFromBase58 ¶
func TakeRequestIds ¶
func TakeRequestIds(lst []RequestRef) []RequestId
func (*RequestId) TransactionId ¶
func (rid *RequestId) TransactionId() *valuetransaction.ID
type RequestRef ¶
type RequestRef struct {
Tx *Transaction
Index uint16
}
func (*RequestRef) IsAuthorised ¶
func (ref *RequestRef) IsAuthorised(ownerAddr *address.Address) bool
request block is authorised if the containing transaction's inputs contain owner's address
func (*RequestRef) RequestBlock ¶
func (ref *RequestRef) RequestBlock() *RequestBlock
func (*RequestRef) RequestId ¶
func (ref *RequestRef) RequestId() *RequestId
func (*RequestRef) Sender ¶
func (ref *RequestRef) Sender() *address.Address
type StateBlock ¶
type StateBlock struct {
// contains filtered or unexported fields
}
state block of the SC transaction. Represents SC state update previous state block can be determined by the chain transfer of the SC token in the UTXO part of the transaction
func NewStateBlock ¶
func NewStateBlock(par NewStateBlockParams) *StateBlock
func (*StateBlock) Clone ¶
func (sb *StateBlock) Clone() *StateBlock
func (*StateBlock) Color ¶
func (sb *StateBlock) Color() balance.Color
func (*StateBlock) StateHash ¶
func (sb *StateBlock) StateHash() hashing.HashValue
func (*StateBlock) StateIndex ¶
func (sb *StateBlock) StateIndex() uint32
func (*StateBlock) Timestamp ¶
func (sb *StateBlock) Timestamp() int64
func (*StateBlock) WithStateParams ¶
func (sb *StateBlock) WithStateParams(stateIndex uint32, h *hashing.HashValue, ts int64) *StateBlock
type Transaction ¶
type Transaction struct {
*valuetransaction.Transaction
// contains filtered or unexported fields
}
Smart contract transaction wraps value transaction the stateBlock and requestBlocks are parsed from the dataPayload of the value transaction
func NewTransaction ¶
func NewTransaction(vtx *valuetransaction.Transaction, stateBlock *StateBlock, requestBlocks []*RequestBlock) (*Transaction, error)
creates new sc transaction. It is immutable, i.e. tx hash is stable
func ParseValueTransaction ¶
func ParseValueTransaction(vtx *valuetransaction.Transaction) (*Transaction, error)
parses dataPayload. Error is returned only if pre-parsing succeeded and parsing failed usually this can happen only due to targeted attack or
func (*Transaction) MustProperties ¶
func (tx *Transaction) MustProperties() *Properties
func (*Transaction) MustState ¶
func (tx *Transaction) MustState() *StateBlock
func (*Transaction) NumRequestsToAddress ¶
func (tx *Transaction) NumRequestsToAddress(addr *address.Address) int
func (*Transaction) OutputBalancesByAddress ¶
func (*Transaction) Properties ¶
func (tx *Transaction) Properties() (*Properties, error)
return valid properties if sc transaction is semantically correct
func (*Transaction) Requests ¶
func (tx *Transaction) Requests() []*RequestBlock
func (*Transaction) Sender ¶
func (tx *Transaction) Sender() *address.Address
Sender returns first input address. It is the unique address, because ParseValueTransaction doesn't allow other options
func (*Transaction) State ¶
func (tx *Transaction) State() (*StateBlock, bool)
func (*Transaction) String ¶
func (tx *Transaction) String() string
func (*Transaction) ValidateBlocks ¶
func (tx *Transaction) ValidateBlocks(addr *address.Address) (bool, error)
validates state block and requests and returns if it origin state (if not error) address is address of the SC
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
vtxbuilder
package to build value transaction
|
package to build value transaction |