action

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2018 License: Apache-2.0 Imports: 25 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.

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

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

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

Table-driven list of all of the possible functions associated with their transactions

Need to fill in the target chain later, since for any set of instructions it changes...

Handle arbitrary, but lossely typed parameters to the function calls

Parse the incoming transactions

TODO: switch from individual wire calls, to reading/writing directly to structs

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

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

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

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.

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.

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

Index

Constants

This section is empty.

Variables

View Source
var FunctionMapping = [][]Object{
	[]Object{
		SWAP,
		INITIATOR,
		Command{
			Function: WAIT_FOR_CHAIN,
			Order:    1,
		},
		Command{
			Function: INITIATE,
			Order:    1,
		},
		Command{
			Function: SUBMIT_TRANSACTION,
			Order:    1,
		},
	},
	[]Object{
		SWAP,
		PARTICIPANT,
		Command{
			Function: WAIT_FOR_CHAIN,
			Order:    2,
		},
	},
	[]Object{
		PUBLISH,
		INITIATOR,
		Command{
			Function: AUDITCONTRACT,
			Order:    2,
		},
		Command{
			Function: REDEEM,
			Order:    2,
		},
		Command{
			Function: SUBMIT_TRANSACTION,
			Order:    2,
		},
		Command{
			Function: FINISH,
		},
	},
	[]Object{
		PUBLISH,
		PARTICIPANT,
		Command{
			Function: AUDITCONTRACT,
			Order:    1,
		},
		Command{
			Function: PARTICIPATE,
			Order:    2,
		},
		Command{
			Function: SUBMIT_TRANSACTION,
			Order:    2,
		},
	},
	[]Object{
		PUBLISH,
		ALL,
		Command{
			Function: EXTRACTSECRET,
			Order:    2,
		},
		Command{
			Function: REDEEM,
			Order:    1,
		},
		Command{
			Function: FINISH,
		},
	},
	[]Object{
		SEND,
		ALL,
		Command{
			Function: PREPARE_TRANSACTION,
		},
	},
	[]Object{
		VERIFY,
		ALL,
		Command{
			Function: REFUND,
		},
	},
}

Table-Driven Mapping between transactions and the specific actions to be performed on a set of chains

Functions

func AuditContract

func AuditContract(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func AuditContractBTC added in v0.5.0

func AuditContractBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func AuditContractETH added in v0.5.0

func AuditContractETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func AuditContractOLT added in v0.5.0

func AuditContractOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func BroadcastTransaction

func BroadcastTransaction(ttype Type, transaction Transaction)

Send out the transaction as an async broadcast

func CheckAmounts

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

func CheckBalance

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

func CreateContractBTC

func CreateContractBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func CreateContractETH

func CreateContractETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func CreateContractOLT

func CreateContractOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func DelayedTransaction

func DelayedTransaction(ttype Type, 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 Execute

func Execute(app interface{}, command Command, lastResult map[Parameter]FunctionValue) (err.Code, map[Parameter]FunctionValue)

Execute the function

func ExtractSecret

func ExtractSecret(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func ExtractSecretBTC added in v0.5.0

func ExtractSecretBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func ExtractSecretETH added in v0.5.0

func ExtractSecretETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func ExtractSecretOLT added in v0.5.0

func ExtractSecretOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

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 GetBTCContract added in v0.5.0

func GetBTCContract(value FunctionValue) *bitcoin.HTLContract

func GetByte32 added in v0.5.0

func GetByte32(value FunctionValue) [32]byte

func GetBytes

func GetBytes(value FunctionValue) []byte

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(app interface{}) *data.Datastore

func GetETHContract

func GetETHContract(value FunctionValue) *ethereum.HTLContract

func GetEvent added in v0.5.2

func GetEvent(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 GetStatus

func GetStatus(app interface{}) *data.Datastore

func GetString

func GetString(value FunctionValue) string

func GetUtxo

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

func Initiate

func Initiate(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func MatchSwap

func MatchSwap(left *Swap, right *Swap) bool

Two matching swap requests from different parties

func Noop

func Noop(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func PackRequest

func PackRequest(ttype Type, request Transaction) []byte

Pack a request into a transferable format (wire)

func Participate

func Participate(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func ParticipateBTC added in v0.5.0

func ParticipateBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func ParticipateETH

func ParticipateETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func ParticipateOLT added in v0.5.0

func ParticipateOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func PrepareTransaction added in v0.5.0

func PrepareTransaction(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func Redeem

func Redeem(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func RedeemBTC added in v0.5.0

func RedeemBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func RedeemETH

func RedeemETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func RedeemOLT added in v0.5.0

func RedeemOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func Refund

func Refund(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func RefundBTC added in v0.5.0

func RefundBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func RefundETH

func RefundETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func RefundOLT added in v0.5.0

func RefundOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func SaveContract added in v0.5.2

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

func SaveEvent added in v0.5.2

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

func SaveSwap

func SaveSwap(status *data.Datastore, accountKey id.AccountKey, transaction *Swap)

func SignAndPack

func SignAndPack(ttype Type, transaction Transaction) []byte

func SubmitTransaction

func SubmitTransaction(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

func SubmitTransactionOLT added in v0.5.0

func SubmitTransactionOLT(context map[Parameter]FunctionValue, chain data.ChainType) (bool, map[Parameter]FunctionValue)

func UnpackMessage

func UnpackMessage(message Message) (Type, Message)

Pull out the type, so that the message can be deserialized

func WaitForChain

func WaitForChain(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)

Types

type Base

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

	Owner   id.AccountKey `json:"owner"`
	Signers []PublicKey   `json:"signers"`

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

Base Data for each type

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 {
	Function CommandType
	Chain    data.ChainType
	Data     map[Parameter]FunctionValue
	Order    int
}

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

func (Command) Execute

func (command Command) Execute(app interface{}) (bool, map[Parameter]FunctionValue)

type CommandType

type CommandType int
const (
	NOOP CommandType = iota
	PREPARE_TRANSACTION
	SUBMIT_TRANSACTION
	INITIATE
	PARTICIPATE
	REDEEM
	REFUND
	EXTRACTSECRET
	AUDITCONTRACT
	WAIT_FOR_CHAIN
	FINISH
)

Set of possible commands that can be driven from a transaction

type Commands

type Commands []Command

func GetCommands

func GetCommands(action Type, role Role, chains []data.ChainType) Commands

Given an action and a chain, return a list of commands

func (Commands) Count

func (commands Commands) Count() int

type Commit

type Commit struct {
	Base

	Target string `json:"target"`
}

TODO: This needs to be filled out properly, need a model for other-chain actions...

func ParseCommit

func ParseCommit(message Message) *Commit

Parse a ready request

func (*Commit) Expand

func (transaction *Commit) Expand(app interface{}) Commands

Given a transaction, expand it into a list of Commands to execute against various chains.

func (*Commit) ProcessCheck

func (transaction *Commit) ProcessCheck(app interface{}) err.Code

func (*Commit) ProcessDeliver

func (transaction *Commit) ProcessDeliver(app interface{}) err.Code

func (*Commit) Resolve

func (transaction *Commit) Resolve(app interface{}, commands Commands)

func (*Commit) ShouldProcess

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

func (*Commit) Validate

func (transaction *Commit) Validate() err.Code

type Event added in v0.5.2

type Event struct {
	Type  Type          `json:"type"`
	Key   id.AccountKey `json:"key"`
	Nonce int64         `json:"result"`
}

func (Event) ToKey added in v0.5.2

func (e Event) ToKey() []byte

type ExternalLock

type ExternalLock struct {
	Base

	Gas     data.Coin    `json:"gas"`
	Fee     data.Coin    `json:"fee"`
	Inputs  []SendInput  `json:"inputs"`
	Outputs []SendOutput `json:"outputs"`
}

Synchronize a swap between two users

func ParseExternalLock

func ParseExternalLock(message Message) *ExternalLock

Parse a send request

func (*ExternalLock) Expand

func (transaction *ExternalLock) Expand(app interface{}) Commands

Given a transaction, expand it into a list of Commands to execute against various chains.

func (*ExternalLock) ProcessCheck

func (transaction *ExternalLock) ProcessCheck(app interface{}) err.Code

func (*ExternalLock) ProcessDeliver

func (transaction *ExternalLock) ProcessDeliver(app interface{}) err.Code

func (*ExternalLock) Resolve

func (transaction *ExternalLock) Resolve(app interface{}, commands Commands)

func (*ExternalLock) ShouldProcess

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

func (*ExternalLock) Validate

func (transaction *ExternalLock) Validate() err.Code

type ExternalSend

type ExternalSend struct {
	Base

	Gas     data.Coin    `json:"gas"`
	Fee     data.Coin    `json:"fee"`
	Inputs  []SendInput  `json:"inputs"`
	Outputs []SendOutput `json:"outputs"`
}

Synchronize a swap between two users

func ParseExternalSend

func ParseExternalSend(message Message) *ExternalSend

Parse a send request

func (*ExternalSend) Expand

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

Given a transaction, expand it into a list of Commands to execute against various chains.

func (*ExternalSend) ProcessCheck

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

func (*ExternalSend) ProcessDeliver

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

func (*ExternalSend) Resolve

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

func (*ExternalSend) ShouldProcess

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

func (*ExternalSend) Validate

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

type Forget

type Forget struct {
	Base

	Target string `json:"target"`
}

func ParseForget

func ParseForget(message Message) *Forget

Forget the transaction

func (*Forget) Expand

func (transaction *Forget) Expand(app interface{}) Commands

Given a transaction, expand it into a list of Commands to execute against various chains.

func (*Forget) ProcessCheck

func (transaction *Forget) ProcessCheck(app interface{}) err.Code

func (*Forget) ProcessDeliver

func (transaction *Forget) ProcessDeliver(app interface{}) err.Code

func (*Forget) Resolve

func (transaction *Forget) Resolve(app interface{}, commands Commands)

func (*Forget) ShouldProcess

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

func (*Forget) Validate

func (transaction *Forget) Validate() err.Code

type FunctionValue

type FunctionValue interface{}

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 Message

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

func FindContract added in v0.5.2

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

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 Object

type Object interface{}

type Parameter

type Parameter byte
const (
	ROLE Parameter = iota
	MY_ACCOUNT
	THEM_ACCOUNT

	AMOUNT
	EXCHANGE
	NONCE
	PREIMAGE

	PASSWORD
	ETHCONTRACT
	BTCCONTRACT

	LOCKTIME
	COUNT
	CHAINID

	EVENTTYPE
)

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 Prepare

type Prepare struct {
	Base

	Target string `json:"target"`
}

TODO: This needs to be filled out properly, need a model for other-chain actions...

func ParsePrepare

func ParsePrepare(message Message) *Prepare

Parse a ready request

func (*Prepare) Expand

func (transaction *Prepare) Expand(app interface{}) Commands

Given a transaction, expand it into a list of Commands to execute against various chains.

func (*Prepare) ProcessCheck

func (transaction *Prepare) ProcessCheck(app interface{}) err.Code

func (*Prepare) ProcessDeliver

func (transaction *Prepare) ProcessDeliver(app interface{}) err.Code

func (*Prepare) Resolve

func (transaction *Prepare) Resolve(app interface{}, commands Commands)

func (*Prepare) ShouldProcess

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

func (*Prepare) Validate

func (transaction *Prepare) Validate() err.Code

type PublicKey

type PublicKey = crypto.PubKey

type Publish added in v0.5.0

type Publish struct {
	Base

	Target     id.AccountKey `json:"target"`
	Contract   Message       `json:"message"` //message converted from HTLContract
	SecretHash [32]byte      `json:"secrethash"`
	Count      int           `json:"count"`
}

Synchronize a publish between two users

func ParsePublish added in v0.5.0

func ParsePublish(message Message) *Publish

func (*Publish) Expand added in v0.5.0

func (publish *Publish) Expand(app interface{}) Commands

Given a transaction, expand it into a list of Commands to execute against various chains.

func (*Publish) FindSwap added in v0.5.0

func (publish *Publish) FindSwap(app interface{}) *Swap

func (*Publish) ProcessCheck added in v0.5.0

func (publish *Publish) ProcessCheck(app interface{}) err.Code

func (*Publish) ProcessDeliver added in v0.5.0

func (publish *Publish) ProcessDeliver(app interface{}) err.Code

Start the publish

func (*Publish) Resolve added in v0.5.0

func (publish *Publish) Resolve(app interface{}, commands Commands)

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

func (*Publish) ShouldProcess added in v0.5.0

func (publish *Publish) ShouldProcess(app interface{}) bool

Is this node one of the partipants in the publish

func (*Publish) Validate added in v0.5.0

func (publish *Publish) Validate() err.Code

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

type Register

type Register struct {
	Base

	Identity   string
	NodeName   string
	AccountKey id.AccountKey
}

Register an identity with the chain

func ParseRegister

func ParseRegister(message Message) *Register

Forget the transaction

func (Register) Expand

func (transaction Register) Expand(app interface{}) Commands

Given a transaction, expand it into a list of Commands to execute against various chains.

func (Register) ProcessCheck

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

Test to see if the identity already exists

func (Register) ProcessDeliver

func (transaction Register) ProcessDeliver(app interface{}) err.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 Commands)

func (Register) ShouldProcess

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

func (Register) Validate

func (transaction Register) Validate() err.Code

Check the fields to make sure they have valid values.

type Role

type Role byte
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

	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 ParseSend

func ParseSend(message Message) *Send

Parse a send request

func (*Send) Expand

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

Given a transaction, expand it into a list of Commands to execute against various chains.

func (*Send) ProcessCheck

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

func (*Send) ProcessDeliver

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

func (*Send) Resolve

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

func (*Send) ShouldProcess

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

func (*Send) Validate

func (transaction *Send) Validate() err.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 Swap

type Swap struct {
	Base

	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"`
}

Synchronize a swap between two users

func FindMatchingSwap

func FindMatchingSwap(status *data.Datastore, accountKey id.AccountKey, transaction *Swap, isParty bool) (matched *Swap)

TODO: Change to return Role as INITIATOR or PARTICIPANT

func ParseSwap

func ParseSwap(message Message) *Swap

Parse a swap request

func ProcessSwap

func ProcessSwap(app interface{}, transaction *Swap) *Swap

func (*Swap) Expand

func (transaction *Swap) Expand(app interface{}) Commands

Given a transaction, expand it into a list of Commands to execute against various chains.

func (*Swap) IsParty

func (transaction *Swap) IsParty(account id.Account) *bool

func (*Swap) ProcessCheck

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

func (*Swap) ProcessDeliver

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

Start the swap

func (*Swap) Resolve

func (swap *Swap) Resolve(app interface{}, commands 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) Validate

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

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

type Transaction

type Transaction interface {
	Validate() err.Code
	ProcessCheck(interface{}) err.Code
	ShouldProcess(interface{}) bool
	ProcessDeliver(interface{}) err.Code
	Expand(interface{}) Commands
	Resolve(interface{}, Commands)
}

Polymorphism and Serializable

func FindSwap

func FindSwap(status *data.Datastore, key id.AccountKey) Transaction

func Parse

func Parse(message Message) (Transaction, err.Code)

TODO: Need a better way to handle the polymorphism... Parse a message into the appropriate transaction

func SignTransaction

func SignTransaction(transaction Transaction) Transaction

SignTransaction with the local keys

type Type

type Type byte

ENUM for type

const (
	INVALID       Type = iota
	REGISTER           // Register a new identity with the chain
	SEND               // Do a normal send transaction on local chain
	EXTERNAL_SEND      // Do send on external chain
	EXTERNAL_LOCK      // Lock some data on external chain
	SWAP               // Start a swap between chains
	VERIFY             // Verify if a transaction finished
	PUBLISH            // Exchange data on a chain
	READ               // Read a specific transaction on a chain
	PREPARE            // Do everything, except commit
	COMMIT             // Commit to doing the work
	FORGET             // Rollback and forget that this happened
)

func GetType added in v0.5.2

func GetType(value FunctionValue) Type

type Verify

type Verify struct {
	Base

	Target  id.AccountKey `json:"target"`
	Event   Event         `json:"event"`
	Message Message       `json:"Message"`
}

instead of a model for other-chain actions, we make this available by event, when a action (external/internal) is done, a event related to other chain is stored with status(false/true, representing finished or not), this verify just check the event status.

func ParseVerify

func ParseVerify(message Message) *Verify

Forget the transaction

func (Verify) Expand

func (transaction Verify) Expand(app interface{}) Commands

Given a transaction, expand it into a list of Commands to execute against various chains.

func (Verify) ProcessCheck

func (transaction Verify) ProcessCheck(app interface{}) err.Code

func (Verify) ProcessDeliver

func (transaction Verify) ProcessDeliver(app interface{}) err.Code

func (Verify) Resolve

func (transaction Verify) Resolve(app interface{}, commands Commands)

func (Verify) ShouldProcess

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

func (Verify) Validate

func (transaction Verify) Validate() err.Code

Jump to

Keyboard shortcuts

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