action

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Copyright 2017-2018 OneLedger

An incoming transaction, send, swap, ready, verification, etc.

An incoming transaction, send, swap, ready, verification, etc.

Handle Smart Contarct Install and Execute functions

An incoming transaction, send, swap, ready, verification, etc.

Handle arbitrary, but lossely typed parameters to the function calls

An incoming transaction, send, swap, ready, verification, etc.

Easy Access to Persistent App Data, if the data isn't accessible stop immediately

Register this identity with the other nodes. As an externl identity

An incoming transaction, send, swap, ready, verification, etc.

An incoming transaction, send, swap, ready, verification, etc.

An incoming transaction, send, swap, ready, verification, etc.

Declare basic types used by the Application

If a type requires functions or a few types are intertwinded, then should be in their own file.

Index

Constants

View Source
const (
	NOSTAGE swapStageType = iota
	SWAP_MATCHING
	SWAP_MATCHED
	INITIATOR_INITIATE
	PARTICIPANT_PARTICIPATE
	INITIATOR_REDEEM
	PARTICIPANT_REDEEM
	WAIT_FOR_CHAIN
	SWAP_REFUND
	SWAP_FINISH
)

Variables

This section is empty.

Functions

func BroadcastTransaction

func BroadcastTransaction(transaction Transaction, sync bool)

Send out the transaction as an async broadcast

func CheckAmounts

func CheckAmounts(app interface{}, inputs []SendInput, outputs []SendOutput) bool

func CheckAmountsAbsolute added in v0.8.0

func CheckAmountsAbsolute(app interface{}, inputs []SendInput, outputs []SendOutput) bool

func CheckBalance

func CheckBalance(app interface{}, accountKey id.AccountKey, amount data.Coin) bool

func CheckBalances added in v0.8.1

func CheckBalances(app interface{}, owner id.AccountKey, identityAccountKey id.AccountKey, stake data.Coin) bool

func CheckPayTo added in v0.8.0

func CheckPayTo(app interface{}, pay []SendTo) bool

func CheckRegisterFee added in v0.8.1

func CheckRegisterFee(app interface{}, owner id.AccountKey, fee data.Coin) bool

func CheckValidatorList added in v0.8.0

func CheckValidatorList(app interface{}, SendTo []SendTo) bool

func CompareResults added in v0.8.0

func CompareResults(recent OLVMResult, original OLVMResult) bool

func Convert added in v0.8.0

func Convert(installData Install) (id.AccountKey, string, version.Version, data.Script)

func DelayedTransaction

func DelayedTransaction(transaction Transaction, waitTime time.Duration)

Execute a transaction after a specific delay. TODO: The node delays in a separate goroutine, but this should really be handled by the consensus engine, so that the delay is in the mempool.

func DeleteContract added in v0.7.0

func DeleteContract(app interface{}, contractKey []byte, nonce int64)

func DeleteSwap added in v0.7.0

func DeleteSwap(app interface{}, key id.AccountKey)

func FindContract added in v0.5.2

func FindContract(app interface{}, contractKey []byte, nonce int64) []byte

func FindEvent added in v0.5.2

func FindEvent(app interface{}, eventKey Event) bool

func GetAccount

func GetAccount(app interface{}, accountKey id.AccountKey) id.Account

func GetAccountKey

func GetAccountKey(value FunctionValue) id.AccountKey

func GetAccounts

func GetAccounts(app interface{}) *id.Accounts

func GetAdmin

func GetAdmin(app interface{}) data.Datastore

func GetAmount

func GetAmount(value FunctionValue) btcutil.Amount

func GetBalances added in v0.7.1

func GetBalances(app interface{}) *data.ChainState

func GetBool added in v0.7.0

func GetBool(value FunctionValue) *bool

func GetByte32 added in v0.5.0

func GetByte32(value FunctionValue) [32]byte

func GetBytes

func GetBytes(value FunctionValue) []byte

func GetChain added in v0.7.0

func GetChain(value FunctionValue) data.ChainType

func GetChainAccount

func GetChainAccount(app interface{}, name string, chain data.ChainType) id.Account

Map the identity to a specific account on a chain

func GetChainID added in v0.5.0

func GetChainID(app interface{}) string

func GetCoin

func GetCoin(value FunctionValue) data.Coin

func GetContract added in v0.5.2

func GetContract(value FunctionValue) common.Contract
func GetETHContract(value FunctionValue) *ethereum.HTLContract {
	switch value.(type) {
	case *ethereum.HTLContract:
		return value.(*ethereum.HTLContract)
	default:
		log.Fatal("Bad Type Cast in Function Parameter", "value", value)
	}
	return nil
}
func GetBTCContract(value FunctionValue) *bitcoin.HTLContract {
	switch value.(type) {
	case *bitcoin.HTLContract:
		return value.(*bitcoin.HTLContract)
	default:
		log.Fatal("Bad Type Cast in Function Parameter", "value", value)
	}
	return nil
}
func GetType(value FunctionValue) Type {
	switch value.(type) {
	case Type:
		return value.(Type)
	default:
		log.Fatal("Bad Type Cast in FUnction Parameter", "value", value)
	}
	return INVALID
}

func GetContracts added in v0.7.0

func GetContracts(app interface{}) data.Datastore

func GetEvent added in v0.5.2

func GetEvent(app interface{}) data.Datastore

func GetExecutionContext added in v0.8.0

func GetExecutionContext(app interface{}) data.Datastore

func GetHeight added in v0.5.2

func GetHeight(app interface{}) int64

func GetIdentities

func GetIdentities(app interface{}) *id.Identities

func GetInt

func GetInt(value FunctionValue) int

func GetInt64

func GetInt64(value FunctionValue) int64

func GetNodeAccount added in v0.5.2

func GetNodeAccount(app interface{}) id.Account

func GetSigners added in v0.7.0

func GetSigners(owner []byte) []id.PublicKey

GetSigners will return the public keys of the signers

func GetSmartContracts added in v0.8.0

func GetSmartContracts(app interface{}) data.Datastore

func GetStatus

func GetStatus(app interface{}) data.Datastore

func GetString

func GetString(value FunctionValue) string

func GetValidators added in v0.8.0

func GetValidators(app interface{}) *id.Validators

func IsEnoughBalance added in v0.8.2

func IsEnoughBalance(balance data.Balance, value data.Coin, fee data.Coin) bool

func PackRequest

func PackRequest(request SignedTransaction) []byte

Pack a request into a transferable format (wire)

func RunScript added in v0.8.0

func RunScript(app interface{}, request *OLVMRequest) interface{}

func SaveContext added in v0.8.0

func SaveContext(app interface{}, owner id.AccountKey, name string, version version.Version, result OLVMResult)

func SaveContract added in v0.5.2

func SaveContract(app interface{}, contractKey []byte, nonce int64, contract []byte)

func SaveEvent added in v0.5.2

func SaveEvent(app interface{}, eventKey Event, status bool)

func SaveSwap

func SaveSwap(app interface{}, swapKey []byte, transaction SwapInit)

func SignAndPack

func SignAndPack(transaction Transaction) []byte

func TransferVT added in v0.8.1

func TransferVT(app interface{}, applyValidator id.ApplyValidator) status.Code

func ValidateSignature added in v0.7.0

func ValidateSignature(transaction SignedTransaction) bool

Types

type ApplyValidator added in v0.7.1

type ApplyValidator struct {
	Base

	AccountKey        id.AccountKey
	Identity          string
	NodeName          string
	TendermintAddress string
	TendermintPubKey  string

	Stake data.Coin
	Purge bool
}

Apply a dynamic validator

func (*ApplyValidator) ProcessCheck added in v0.7.1

func (transaction *ApplyValidator) ProcessCheck(app interface{}) status.Code

func (*ApplyValidator) ProcessDeliver added in v0.7.1

func (transaction *ApplyValidator) ProcessDeliver(app interface{}) status.Code

func (*ApplyValidator) Resolve added in v0.7.1

func (transaction *ApplyValidator) Resolve(app interface{}) Commands

func (*ApplyValidator) ShouldProcess added in v0.7.1

func (transaction *ApplyValidator) ShouldProcess(app interface{}) bool

func (*ApplyValidator) Validate added in v0.7.1

func (transaction *ApplyValidator) Validate() status.Code

type Base

type Base struct {
	Type    Type   `json:"type"`
	ChainId string `json:"chain_id"`

	Owner  id.AccountKey `json:"owner"`
	Target id.AccountKey `json:"target"`

	Signers []PublicKey `json:"signers"`

	Sequence int64 `json:"sequence"`
	Delay    int64 `json:"delay"` // Pause the transaction in the mempool
}

Base Data for each type

func (Base) GetOwner added in v0.7.1

func (b Base) GetOwner() id.AccountKey

func (Base) GetSigners added in v0.7.1

func (b Base) GetSigners() []id.PublicKey

func (Base) TransactionTags added in v0.7.1

func (b Base) TransactionTags(app interface{}) Tags

func (Base) Validate added in v0.8.0

func (b Base) Validate() status.Code

type BoxLocker

type BoxLocker struct {
	Signature *btcec.Signature
	PubKey    *btcec.PublicKey
}

General BoxLocker struct to act as locker for any information exchange box of transactions, if verify valid then the lock can be release, otherwise box modified somehow

func (*BoxLocker) Sign

func (bl *BoxLocker) Sign(preImage []byte, nonce []byte, message Message) error

Sign the locker with preImage and nonce for message passed, the message should be the full information of Transaction. The nonce is used to preventing the 3rd party from get the message even through he get the preImage, where nonce should only be known by the participants of the message sharing

func (*BoxLocker) Verify

func (bl *BoxLocker) Verify(message Message) bool

Verify the pubKey with the signature for the message got.

type Command

type Command struct {
	// contains filtered or unexported fields
}

A command to execute again a chain, needs to be polymorphic

func (Command) Execute

func (command Command) Execute(app interface{}) (bool, FunctionValues)

type CommandType

type CommandType int
const (
	NOOP CommandType = iota
)

Set of possible commands that can be driven from a transaction

type Commands

type Commands []Command

func (Commands) Count

func (commands Commands) Count() int

func (Commands) Execute added in v0.7.0

func (cs Commands) Execute(app interface{}) status.Code

type Compare added in v0.8.0

type Compare struct {
	//ToDo: all the data you need to compare contract
	Owner   id.AccountKey
	Name    string
	Version version.Version
	Result  OLVMResult
}

type Contract added in v0.8.0

type Contract struct {
	Base
	Data     ContractData     `json:"data"`
	Function ContractFunction `json:"function"`
	Gas      data.Coin        `json:"gas"`
	Fee      data.Coin        `json:"fee"`
}

Synchronize a swap between two users

func (*Contract) Compare added in v0.8.0

func (transaction *Contract) Compare(app interface{}) status.Code

Execute calls this and compare the results TODO: Maybe the compare should be in CheckTx, so that it can fail?

func (*Contract) CreateCompareRequest added in v0.8.0

func (transaction *Contract) CreateCompareRequest(app interface{}, owner id.AccountKey, name string,
	version version.Version, result OLVMResult) []byte

Create a comparison request

func (*Contract) Execute added in v0.8.0

func (transaction *Contract) Execute(app interface{}) Transaction

Execute find the selected validator - who runs the script and keeps the result, then creates a Compare transaction then broadcast, get the results, check the results if they're the same

func (*Contract) Install added in v0.8.0

func (transaction *Contract) Install(app interface{})

Install store the script in the SmartContract database

func (*Contract) ProcessCheck added in v0.8.0

func (transaction *Contract) ProcessCheck(app interface{}) status.Code

func (*Contract) ProcessDeliver added in v0.8.0

func (transaction *Contract) ProcessDeliver(app interface{}) status.Code

func (*Contract) Resolve added in v0.8.0

func (transaction *Contract) Resolve(app interface{}) Commands

func (*Contract) ShouldProcess added in v0.8.0

func (transaction *Contract) ShouldProcess(app interface{}) bool

func (*Contract) TransactionType added in v0.8.0

func (transaction *Contract) TransactionType() Type

func (*Contract) Validate added in v0.8.0

func (transaction *Contract) Validate() status.Code

type ContractData added in v0.8.0

type ContractData interface {
}

type ContractFunction added in v0.8.0

type ContractFunction int
const (
	INSTALL ContractFunction = iota
	EXECUTE
	COMPARE
)

type Event added in v0.5.2

type Event struct {
	Type        Type   `json:"type"`
	SwapKeyHash []byte `json:"swapkeyhash"`
	Step        int    `json:"step"`
}

func (Event) ToKey added in v0.5.2

func (e Event) ToKey() []byte

type Execute

type Execute struct {
	//ToDo: all the data you need to execute contract
	Owner   id.AccountKey
	Name    string
	Version version.Version
}

type ExternalSend

type ExternalSend struct {
	Base

	Gas data.Coin `json:"gas"`
	Fee data.Coin `json:"fee"`

	ExGas    data.Coin      `json:"exgas"`
	ExFee    data.Coin      `json:"exfee"`
	Chain    data.ChainType `json:"chain"`
	Sender   string         `json:"sender"`
	Receiver string         `json:"receiver"`
	Amount   data.Coin      `json:"amount"`
}

Synchronize a swap between two users

func (*ExternalSend) ProcessCheck

func (transaction *ExternalSend) ProcessCheck(app interface{}) status.Code

func (*ExternalSend) ProcessDeliver

func (transaction *ExternalSend) ProcessDeliver(app interface{}) status.Code

func (*ExternalSend) Resolve

func (transaction *ExternalSend) Resolve(app interface{}) Commands

func (*ExternalSend) ShouldProcess

func (transaction *ExternalSend) ShouldProcess(app interface{}) bool

func (*ExternalSend) Validate

func (transaction *ExternalSend) Validate() status.Code

type FunctionValue

type FunctionValue interface{}

type FunctionValues added in v0.7.0

type FunctionValues map[Parameter]FunctionValue

func AuditContract

func AuditContract(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

func AuditContractBTC added in v0.5.0

func AuditContractBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func AuditContractETH added in v0.5.0

func AuditContractETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func AuditContractOLT added in v0.5.0

func AuditContractOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func CreateCheckEvent added in v0.7.0

func CreateCheckEvent(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

func CreateContractBTC

func CreateContractBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func CreateContractETH

func CreateContractETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func CreateContractOLT

func CreateContractOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func ExtractSecret

func ExtractSecret(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

func ExtractSecretBTC added in v0.5.0

func ExtractSecretBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func ExtractSecretETH added in v0.5.0

func ExtractSecretETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func ExtractSecretOLT added in v0.5.0

func ExtractSecretOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func FinalizeSwap added in v0.7.0

func FinalizeSwap(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

func Initiate

func Initiate(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

func NextStage added in v0.7.0

func NextStage(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

get the next stage from the current stage

func Noop

func Noop(app interface{}, chain data.ChainType, context FunctionValues) (bool, FunctionValues)

func Participate

func Participate(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

func ParticipateBTC added in v0.5.0

func ParticipateBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func ParticipateETH

func ParticipateETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func ParticipateOLT added in v0.5.0

func ParticipateOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func Redeem

func Redeem(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

func RedeemBTC added in v0.5.0

func RedeemBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func RedeemETH

func RedeemETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func RedeemOLT added in v0.5.0

func RedeemOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func Refund

func Refund(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

func RefundBTC added in v0.5.0

func RefundBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func RefundETH

func RefundETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func RefundOLT added in v0.5.0

func RefundOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)

func VerifySwap added in v0.7.0

func VerifySwap(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)

type HtlContract added in v0.5.3

type HtlContract struct {
	Transaction     Transaction `json:"transaction"`
	Secrethash      [32]byte    `json:"secrethash"`
	LockHeight      int64       `json:"lockheight"`
	StartFromHeight int64       `json:"startfromheight"`
}

func CreateHtlContract added in v0.5.3

func CreateHtlContract(app interface{}, transaction Transaction, scrhash [32]byte, lock time.Duration) *HtlContract

type Install added in v0.8.0

type Install struct {
	//ToDo: all the data you need to install contract
	Owner   id.AccountKey
	Name    string
	Version version.Version
	Script  []byte
}

type Message

type Message = []byte // Contents of a transaction

type MultiSigBox added in v0.5.3

type MultiSigBox struct {
	Lockers []BoxLocker `json:"lockers"`
	M       int         `json:"m"`
	N       int         `json:"n"`
	// contains filtered or unexported fields
}

func NewMultiSigBox added in v0.5.3

func NewMultiSigBox(m int, n int, message Message) *MultiSigBox

func (MultiSigBox) Sign added in v0.5.3

func (msb MultiSigBox) Sign(locker *BoxLocker) error

func (MultiSigBox) Unlock added in v0.5.3

func (msb MultiSigBox) Unlock(signs []BoxLocker) *Message

type OLVMContext added in v0.8.0

type OLVMContext struct {
	Data map[string]interface{}
}

func (OLVMContext) GetValue added in v0.8.2

func (context OLVMContext) GetValue(key string) interface{}

type OLVMRequest added in v0.8.0

type OLVMRequest struct {
	From        string
	Address     string
	CallString  string
	Value       int
	SourceCode  []byte
	Transaction Transaction
	Context     OLVMContext
}

All of the input necessary to perform a computation on a transaction

func NewOLVMRequest added in v0.8.0

func NewOLVMRequest(script []byte, context OLVMContext) *OLVMRequest

type OLVMResult added in v0.8.0

type OLVMResult struct {
	Status  status.Code
	Out     string
	Ret     string // TODO: Should be a real name
	Elapsed string

	Transactions []Transaction
	Context      OLVMContext
}

All of the output received from the computation

func GetContext added in v0.8.0

func GetContext(app interface{}, owner id.AccountKey, name string, version version.Version) OLVMResult

func NewOLVMResult added in v0.8.0

func NewOLVMResult() *OLVMResult

type Parameter

type Parameter byte
const (
	ROLE Parameter = iota
	PREIMAGE
	PASSWORD
	CONTRACT

	LOCKTIME
	DELAYTIME
	CHAIN
	NEXTCHAINNAME
	SWAPMESSAGE
	STOREKEY
	STAGE
	NEXTSTAGE
	OWNER
	TARGET
	PREVIOUS
	FINISHED
)

TODO: Move to parameter.go

type Party

type Party struct {
	Key      id.AccountKey             `json:"key"`
	Accounts map[data.ChainType][]byte `json:"accounts"`
}

func GetParty

func GetParty(value FunctionValue) Party

type Payment added in v0.7.1

type Payment struct {
	Base

	SendTo []SendTo `json:"payto"`
}

Synchronize a swap between two users

func (*Payment) ProcessCheck added in v0.7.1

func (transaction *Payment) ProcessCheck(app interface{}) status.Code

func (*Payment) ProcessDeliver added in v0.7.1

func (transaction *Payment) ProcessDeliver(app interface{}) status.Code

func (*Payment) Resolve added in v0.7.1

func (transaction *Payment) Resolve(app interface{}) Commands

func (*Payment) ShouldProcess added in v0.7.1

func (transaction *Payment) ShouldProcess(app interface{}) bool

func (*Payment) Validate added in v0.7.1

func (transaction *Payment) Validate() status.Code

type PaymentRecord added in v0.7.1

type PaymentRecord struct {
	Amount      data.Coin
	BlockHeight int64
}

type PublicKey

type PublicKey = id.PublicKey

type Register

type Register struct {
	Base

	Identity          string
	NodeName          string
	AccountKey        id.AccountKey
	TendermintAddress string
	TendermintPubKey  string
	Fee               data.Coin `json:"fee"`
}

Register an identity with the chain

func CreateRegisterRequest added in v0.7.0

func CreateRegisterRequest(identity string, chainId string, sequence int64, nodeName string,
	signers []PublicKey, accountKey id.AccountKey, fee float64) *Register

func (Register) ProcessCheck

func (transaction Register) ProcessCheck(app interface{}) status.Code

Test to see if the identity already exists

func (Register) ProcessDeliver

func (transaction Register) ProcessDeliver(app interface{}) status.Code

Add the identity into the database as external, don't overwrite a local identity

func (*Register) Resolve

func (transaction *Register) Resolve(app interface{}) Commands

func (Register) ShouldProcess

func (transaction Register) ShouldProcess(app interface{}) bool

func (Register) Validate

func (transaction Register) Validate() status.Code

Check the fields to make sure they have valid values.

type Role

type Role int
const (
	ALL         Role = iota
	INITIATOR        // Register a new identity with the chain
	PARTICIPANT      // Do a normal send transaction on local chain
	NONE
)

func GetRole

func GetRole(value FunctionValue) Role

type Send

type Send struct {
	Base
	SendTo SendTo    `json:"SendTo"`
	Fee    data.Coin `json:"fee"`
}

simple send transaction

func (*Send) ProcessCheck

func (transaction *Send) ProcessCheck(app interface{}) status.Code

func (*Send) ProcessDeliver

func (transaction *Send) ProcessDeliver(app interface{}) status.Code

func (*Send) Resolve

func (transaction *Send) Resolve(app interface{}) Commands

func (*Send) ShouldProcess

func (transaction *Send) ShouldProcess(app interface{}) bool

func (Send) TransactionTags added in v0.8.0

func (transaction Send) TransactionTags(app interface{}) Tags

func (*Send) Validate

func (transaction *Send) Validate() status.Code

type SendInput

type SendInput struct {
	AccountKey id.AccountKey `json:"account_key"`
	PubKey     PublicKey     `json:"pub_key"`
	Signature  id.Signature  `json:"signature"`

	Amount data.Coin `json:"coin"`

	// TODO: Is sequence needed per input?
	Sequence int `json:"sequence"`
}

inputs into a send transaction (similar to Bitcoin)

func NewSendInput

func NewSendInput(accountKey id.AccountKey, amount data.Coin) SendInput

type SendOutput

type SendOutput struct {
	AccountKey id.AccountKey `json:"account_key"`
	Amount     data.Coin     `json:"coin"`
}

outputs for a send transaction (similar to Bitcoin)

func NewSendOutput

func NewSendOutput(accountKey id.AccountKey, amount data.Coin) SendOutput

type SendTo added in v0.8.0

type SendTo struct {
	AccountKey id.AccountKey `json:"account_key"`
	Amount     data.Coin     `json:"coin"`
}

func (SendTo) IsValid added in v0.8.0

func (st SendTo) IsValid() bool

type Send_Absolute added in v0.8.0

type Send_Absolute struct {
	Base

	Inputs  []SendInput  `json:"inputs"`
	Outputs []SendOutput `json:"outputs"`

	Gas data.Coin `json:"gas"`
	Fee data.Coin `json:"fee"`
}

Synchronize a swap between two users

func (*Send_Absolute) ProcessCheck added in v0.8.0

func (transaction *Send_Absolute) ProcessCheck(app interface{}) status.Code

func (*Send_Absolute) ProcessDeliver added in v0.8.0

func (transaction *Send_Absolute) ProcessDeliver(app interface{}) status.Code

func (*Send_Absolute) Resolve added in v0.8.0

func (transaction *Send_Absolute) Resolve(app interface{}) Commands

func (*Send_Absolute) ShouldProcess added in v0.8.0

func (transaction *Send_Absolute) ShouldProcess(app interface{}) bool

func (*Send_Absolute) TransactionType added in v0.8.0

func (transaction *Send_Absolute) TransactionType() Type

func (*Send_Absolute) Validate added in v0.8.0

func (transaction *Send_Absolute) Validate() status.Code

type SignedTransaction added in v0.7.0

type SignedTransaction struct {
	Transaction
	Signatures []TransactionSignature
}

func Parse

func Parse(message Message) (SignedTransaction, status.Code)

func SignTransaction

func SignTransaction(transaction Transaction) SignedTransaction

SignTransaction with the local keys

type Swap

type Swap struct {
	Base
	SwapMessage SwapMessage   `json:"swapmessage"`
	Stage       swapStageType `json:"stage"`
}

Synchronize a swap between two users

func (*Swap) CommandExecute added in v0.7.0

func (swap *Swap) CommandExecute(app interface{}, commands Commands, c chan status.Code)

func (*Swap) ProcessCheck

func (transaction *Swap) ProcessCheck(app interface{}) status.Code

func (*Swap) ProcessDeliver

func (transaction *Swap) ProcessDeliver(app interface{}) status.Code

Start the swap

func (*Swap) Resolve

func (swap *Swap) Resolve(app interface{}) Commands

Plug in data from the rest of a system into a set of commands

func (*Swap) ShouldProcess

func (transaction *Swap) ShouldProcess(app interface{}) bool

Is this node one of the partipants in the swap

func (Swap) TransactionTags added in v0.8.0

func (transaction Swap) TransactionTags(app interface{}) Tags

func (*Swap) Validate

func (transaction *Swap) Validate() status.Code

Ensure that all of the base values are at least reasonable.

type SwapExchange added in v0.7.0

type SwapExchange struct {
	Contract    common.Contract `json:"message"`
	SwapKeyHash []byte          `json:"swapkeyhash"`
	Chain       data.ChainType  `json:"chain"`
	PreviousTx  []byte          `json:"previoustx"`
}

func (SwapExchange) GetKeyHash added in v0.8.0

func (se SwapExchange) GetKeyHash(app interface{}) string

type SwapInit added in v0.7.0

type SwapInit struct {
	Party        Party     `json:"party"`
	CounterParty Party     `json:"counter_party"`
	Amount       data.Coin `json:"amount"`
	Exchange     data.Coin `json:"exchange"`
	Fee          data.Coin `json:"fee"`
	Gas          data.Coin `json:"fee"`
	Nonce        int64     `json:"nonce"`
	Preimage     []byte    `json:"preimage"`
}

func FindSwap

func FindSwap(app interface{}, key []byte) *SwapInit

func (SwapInit) GetKey added in v0.8.0

func (si SwapInit) GetKey() *SwapKey

func (SwapInit) GetKeyHash added in v0.8.0

func (si SwapInit) GetKeyHash(app interface{}) string

type SwapKey added in v0.7.0

type SwapKey struct {
	Initiator   id.AccountKey `json:"initiator"`
	Participant id.AccountKey `json:"participant"`
	Amount      data.Coin     `json:"amount"`
	Exchange    data.Coin     `json:"exchange"`
	Nonce       int64         `json:"nonce"`
}

func (SwapKey) Hash added in v0.8.0

func (sk SwapKey) Hash() []byte

type SwapMessage added in v0.7.0

type SwapMessage interface {
	GetKeyHash(interface{}) string
	// contains filtered or unexported methods
}

func GetSwapMessage added in v0.7.0

func GetSwapMessage(value FunctionValue) SwapMessage

type SwapVerify added in v0.7.0

type SwapVerify struct {
	Event Event `json:"event"`
}

func (SwapVerify) GetKeyHash added in v0.8.0

func (sv SwapVerify) GetKeyHash(app interface{}) string

type Tags added in v0.7.1

type Tags common.KVPairs

type Transaction

type Transaction interface {
	GetSigners() []id.PublicKey
	GetOwner() id.AccountKey
	TransactionTags(interface{}) Tags
	Validate() status.Code
	ProcessCheck(interface{}) status.Code
	ShouldProcess(interface{}) bool
	ProcessDeliver(interface{}) status.Code
	Resolve(interface{}) Commands
}

Polymorphism and Serializable

type TransactionSignature added in v0.7.0

type TransactionSignature struct {
	Signature []byte
}

type Type

type Type int

ENUM for type

const (
	INVALID         Type = iota
	REGISTER             // Register a new identity with the chain
	SEND                 // Do a normal send transaction on local chain
	PAYMENT              // Do a payment transaction on local chain
	EXTERNAL_SEND        // Do send on external chain
	SWAP                 // Start a swap between chains
	SMART_CONTRACT       // Install and Execute smart contracts
	APPLY_VALIDATOR      // Apply a dynamic validator
)

func (Type) String added in v0.7.1

func (t Type) String() string

Jump to

Keyboard shortcuts

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