Documentation
¶
Overview ¶
Copyright 2017-2018 OneLedger
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017 - 2018 OneLedger ¶
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...
Copyright 2017 - 2018 OneLedger ¶
Handle arbitrary, but lossely typed parameters to the function calls ¶
Copyright 2017-2018 OneLedger ¶
Parse the incoming transactions ¶
TODO: switch from individual wire calls, to reading/writing directly to structs
Copyright 2017 - 2018 OneLedger ¶
Easy Access to Persistent App Data, if the persistent data isn't avoid stop immediately
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, publish, ready, verification, etc.
Copyright 2017 - 2018 OneLedger ¶
Register this identity with the other nodes. As an externl identity
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017 - 2018 OneLedger ¶
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017-2018 OneLedger ¶
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.
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Index ¶
- Variables
- func AuditContract(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func AuditContractBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func AuditContractETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func AuditContractOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func BroadcastTransaction(ttype Type, transaction Transaction)
- func CheckAmounts(app interface{}, inputs []SendInput, outputs []SendOutput) bool
- func CheckBalance(app interface{}, accountKey id.AccountKey, amount data.Coin) bool
- func CreateContractBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func CreateContractETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func CreateContractOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func DelayedTransaction(ttype Type, transaction Transaction, waitTime time.Duration)
- func Execute(app interface{}, command Command, lastResult map[Parameter]FunctionValue) (err.Code, map[Parameter]FunctionValue)
- func ExtractSecret(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func ExtractSecretBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func ExtractSecretETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func ExtractSecretOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func FindEvent(app interface{}, eventKey Event) bool
- func GetAccount(app interface{}, accountKey id.AccountKey) id.Account
- func GetAccountKey(value FunctionValue) id.AccountKey
- func GetAccounts(app interface{}) *id.Accounts
- func GetAdmin(app interface{}) *data.Datastore
- func GetAmount(value FunctionValue) btcutil.Amount
- func GetBTCContract(value FunctionValue) *bitcoin.HTLContract
- func GetByte32(value FunctionValue) [32]byte
- func GetBytes(value FunctionValue) []byte
- func GetChainAccount(app interface{}, name string, chain data.ChainType) id.Account
- func GetChainID(app interface{}) string
- func GetCoin(value FunctionValue) data.Coin
- func GetContract(app interface{}) *data.Datastore
- func GetETHContract(value FunctionValue) *ethereum.HTLContract
- func GetEvent(app interface{}) *data.Datastore
- func GetHeight(app interface{}) int64
- func GetIdentities(app interface{}) *id.Identities
- func GetInt(value FunctionValue) int
- func GetInt64(value FunctionValue) int64
- func GetNodeAccount(app interface{}) id.Account
- func GetStatus(app interface{}) *data.Datastore
- func GetString(value FunctionValue) string
- func GetUtxo(app interface{}) *data.ChainState
- func Initiate(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func MatchSwap(left *Swap, right *Swap) bool
- func Noop(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func PackRequest(ttype Type, request Transaction) []byte
- func Participate(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func ParticipateBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func ParticipateETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func ParticipateOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func PrepareTransaction(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func Redeem(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func RedeemBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func RedeemETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func RedeemOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func Refund(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func RefundBTC(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func RefundETH(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func RefundOLT(app interface{}, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func SaveContract(app interface{}, contractKey []byte, nonce int64, contract common.Contract)
- func SaveEvent(app interface{}, eventKey Event, status bool)
- func SaveSwap(status *data.Datastore, accountKey id.AccountKey, transaction *Swap)
- func SignAndPack(ttype Type, transaction Transaction) []byte
- func SubmitTransaction(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- func SubmitTransactionOLT(context map[Parameter]FunctionValue, chain data.ChainType) (bool, map[Parameter]FunctionValue)
- func UnpackMessage(message Message) (Type, Message)
- func WaitForChain(app interface{}, chain data.ChainType, context map[Parameter]FunctionValue) (bool, map[Parameter]FunctionValue)
- type Base
- type BoxLocker
- type Command
- type CommandType
- type Commands
- type Commit
- func (transaction *Commit) Expand(app interface{}) Commands
- func (transaction *Commit) ProcessCheck(app interface{}) err.Code
- func (transaction *Commit) ProcessDeliver(app interface{}) err.Code
- func (transaction *Commit) Resolve(app interface{}, commands Commands)
- func (transaction *Commit) ShouldProcess(app interface{}) bool
- func (transaction *Commit) Validate() err.Code
- type Event
- type ExternalLock
- func (transaction *ExternalLock) Expand(app interface{}) Commands
- func (transaction *ExternalLock) ProcessCheck(app interface{}) err.Code
- func (transaction *ExternalLock) ProcessDeliver(app interface{}) err.Code
- func (transaction *ExternalLock) Resolve(app interface{}, commands Commands)
- func (transaction *ExternalLock) ShouldProcess(app interface{}) bool
- func (transaction *ExternalLock) Validate() err.Code
- type ExternalSend
- func (transaction *ExternalSend) Expand(app interface{}) Commands
- func (transaction *ExternalSend) ProcessCheck(app interface{}) err.Code
- func (transaction *ExternalSend) ProcessDeliver(app interface{}) err.Code
- func (transaction *ExternalSend) Resolve(app interface{}, commands Commands)
- func (transaction *ExternalSend) ShouldProcess(app interface{}) bool
- func (transaction *ExternalSend) Validate() err.Code
- type Forget
- func (transaction *Forget) Expand(app interface{}) Commands
- func (transaction *Forget) ProcessCheck(app interface{}) err.Code
- func (transaction *Forget) ProcessDeliver(app interface{}) err.Code
- func (transaction *Forget) Resolve(app interface{}, commands Commands)
- func (transaction *Forget) ShouldProcess(app interface{}) bool
- func (transaction *Forget) Validate() err.Code
- type FunctionValue
- type HtlContract
- type Message
- type MultiSigBox
- type Object
- type Parameter
- type Party
- type Prepare
- func (transaction *Prepare) Expand(app interface{}) Commands
- func (transaction *Prepare) ProcessCheck(app interface{}) err.Code
- func (transaction *Prepare) ProcessDeliver(app interface{}) err.Code
- func (transaction *Prepare) Resolve(app interface{}, commands Commands)
- func (transaction *Prepare) ShouldProcess(app interface{}) bool
- func (transaction *Prepare) Validate() err.Code
- type PublicKey
- type Publish
- func (publish *Publish) Expand(app interface{}) Commands
- func (publish *Publish) FindSwap(app interface{}) *Swap
- func (publish *Publish) ProcessCheck(app interface{}) err.Code
- func (publish *Publish) ProcessDeliver(app interface{}) err.Code
- func (publish *Publish) Resolve(app interface{}, commands Commands)
- func (publish *Publish) ShouldProcess(app interface{}) bool
- func (publish *Publish) Validate() err.Code
- type Register
- func (transaction Register) Expand(app interface{}) Commands
- func (transaction Register) ProcessCheck(app interface{}) err.Code
- func (transaction Register) ProcessDeliver(app interface{}) err.Code
- func (transaction Register) Resolve(app interface{}, commands Commands)
- func (transaction Register) ShouldProcess(app interface{}) bool
- func (transaction Register) Validate() err.Code
- type Role
- type Send
- func (transaction *Send) Expand(app interface{}) Commands
- func (transaction *Send) ProcessCheck(app interface{}) err.Code
- func (transaction *Send) ProcessDeliver(app interface{}) err.Code
- func (transaction *Send) Resolve(app interface{}, commands Commands)
- func (transaction *Send) ShouldProcess(app interface{}) bool
- func (transaction *Send) Validate() err.Code
- type SendInput
- type SendOutput
- type Swap
- func (transaction *Swap) Expand(app interface{}) Commands
- func (transaction *Swap) IsParty(account id.Account) *bool
- func (transaction *Swap) ProcessCheck(app interface{}) err.Code
- func (transaction *Swap) ProcessDeliver(app interface{}) err.Code
- func (swap *Swap) Resolve(app interface{}, commands Commands)
- func (transaction *Swap) ShouldProcess(app interface{}) bool
- func (transaction *Swap) Validate() err.Code
- type Transaction
- type Type
- type Verify
- func (transaction Verify) Expand(app interface{}) Commands
- func (transaction Verify) ProcessCheck(app interface{}) err.Code
- func (transaction Verify) ProcessDeliver(app interface{}) err.Code
- func (transaction Verify) Resolve(app interface{}, commands Commands)
- func (transaction Verify) ShouldProcess(app interface{}) bool
- func (transaction Verify) Validate() err.Code
Constants ¶
This section is empty.
Variables ¶
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 GetAccount ¶
func GetAccount(app interface{}, accountKey id.AccountKey) id.Account
func GetAccountKey ¶
func GetAccountKey(value FunctionValue) id.AccountKey
func GetAccounts ¶
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 ¶
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 GetETHContract ¶
func GetETHContract(value FunctionValue) *ethereum.HTLContract
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 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 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 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 ¶
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 ¶
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 ¶
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
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
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 ¶
Given an action and a chain, return a list of commands
type Commit ¶
TODO: This needs to be filled out properly, need a model for other-chain actions...
func (*Commit) Expand ¶
Given a transaction, expand it into a list of Commands to execute against various chains.
func (*Commit) ProcessCheck ¶
func (*Commit) ProcessDeliver ¶
func (*Commit) ShouldProcess ¶
type Event ¶ added in v0.5.2
type Event struct {
Type Type `json:"type"`
Key id.AccountKey `json:"key"`
Nonce int64 `json:"result"`
}
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 (*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 (*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 ¶
func (*Forget) Expand ¶
Given a transaction, expand it into a list of Commands to execute against various chains.
func (*Forget) ProcessCheck ¶
func (*Forget) ProcessDeliver ¶
func (*Forget) ShouldProcess ¶
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
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 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 ¶
TODO: This needs to be filled out properly, need a model for other-chain actions...
func (*Prepare) Expand ¶
Given a transaction, expand it into a list of Commands to execute against various chains.
func (*Prepare) ProcessCheck ¶
func (*Prepare) ProcessDeliver ¶
func (*Prepare) ShouldProcess ¶
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 (*Publish) Expand ¶ added in v0.5.0
Given a transaction, expand it into a list of Commands to execute against various chains.
func (*Publish) ProcessCheck ¶ added in v0.5.0
func (*Publish) ProcessDeliver ¶ added in v0.5.0
Start the publish
func (*Publish) Resolve ¶ added in v0.5.0
Plug in data from the rest of a system into a set of commands
func (*Publish) ShouldProcess ¶ added in v0.5.0
Is this node one of the partipants in the publish
type Register ¶
type Register struct {
Base
Identity string
NodeName string
AccountKey id.AccountKey
}
Register an identity with the chain
func (Register) Expand ¶
Given a transaction, expand it into a list of Commands to execute against various chains.
func (Register) ProcessCheck ¶
Test to see if the identity already exists
func (Register) ProcessDeliver ¶
Add the identity into the database as external, don't overwrite a local identity
func (Register) ShouldProcess ¶
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 (*Send) Expand ¶
Given a transaction, expand it into a list of Commands to execute against various chains.
func (*Send) ProcessCheck ¶
func (*Send) ProcessDeliver ¶
func (*Send) ShouldProcess ¶
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 ProcessSwap ¶
func (*Swap) Expand ¶
Given a transaction, expand it into a list of Commands to execute against various chains.
func (*Swap) ProcessCheck ¶
func (*Swap) ProcessDeliver ¶
Start the swap
func (*Swap) ShouldProcess ¶
Is this node one of the partipants in the swap
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 (Verify) Expand ¶
Given a transaction, expand it into a list of Commands to execute against various chains.