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 ¶
Handle Smart Contarct Install and Execute functions ¶
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017 - 2018 OneLedger ¶
Handle arbitrary, but lossely typed parameters to the function calls ¶
Copyright 2017-2018 OneLedger ¶
An incoming transaction, send, swap, ready, verification, etc.
Copyright 2017 - 2018 OneLedger ¶
Easy Access to Persistent App Data, if the data isn't accessible stop immediately
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 ¶
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.
Index ¶
- Constants
- func BroadcastTransaction(transaction Transaction, sync bool)
- func CheckAmounts(app interface{}, inputs []SendInput, outputs []SendOutput) bool
- func CheckAmountsAbsolute(app interface{}, inputs []SendInput, outputs []SendOutput) bool
- func CheckBalance(app interface{}, accountKey id.AccountKey, amount data.Coin) bool
- func CheckPayTo(app interface{}, pay []SendTo) bool
- func CheckSendTo(balance data.Balance, sendTo SendTo, fee data.Coin) bool
- func CheckValidatorList(app interface{}, SendTo []SendTo) bool
- func CompareResults(recent OLVMResult, original OLVMResult) bool
- func Convert(installData Install) (id.AccountKey, string, version.Version, data.Script)
- func DelayedTransaction(transaction Transaction, waitTime time.Duration)
- func DeleteContract(app interface{}, contractKey []byte, nonce int64)
- func DeleteSwap(app interface{}, key id.AccountKey)
- func FindContract(app interface{}, contractKey []byte, nonce int64) []byte
- 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 GetBalances(app interface{}) *data.ChainState
- func GetBool(value FunctionValue) *bool
- func GetByte32(value FunctionValue) [32]byte
- func GetBytes(value FunctionValue) []byte
- func GetChain(value FunctionValue) data.ChainType
- func GetChainAccount(app interface{}, name string, chain data.ChainType) id.Account
- func GetChainID(app interface{}) string
- func GetCoin(value FunctionValue) data.Coin
- func GetContract(value FunctionValue) common.Contract
- func GetContracts(app interface{}) data.Datastore
- func GetEvent(app interface{}) data.Datastore
- func GetExecutionContext(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 GetSigners(owner []byte) []id.PublicKey
- func GetSmartContracts(app interface{}) data.Datastore
- func GetStatus(app interface{}) data.Datastore
- func GetString(value FunctionValue) string
- func GetValidators(app interface{}) *id.Validators
- func PackRequest(request SignedTransaction) []byte
- func RunScript(app interface{}, request *OLVMRequest) interface{}
- func SaveContext(app interface{}, owner id.AccountKey, name string, version version.Version, ...)
- func SaveContract(app interface{}, contractKey []byte, nonce int64, contract []byte)
- func SaveEvent(app interface{}, eventKey Event, status bool)
- func SaveSwap(app interface{}, swapKey []byte, transaction SwapInit)
- func SignAndPack(transaction Transaction) []byte
- func ValidateSignature(transaction SignedTransaction) bool
- type ApplyValidator
- func (transaction *ApplyValidator) ProcessCheck(app interface{}) status.Code
- func (transaction *ApplyValidator) ProcessDeliver(app interface{}) status.Code
- func (transaction *ApplyValidator) Resolve(app interface{}) Commands
- func (transaction *ApplyValidator) ShouldProcess(app interface{}) bool
- func (transaction *ApplyValidator) Validate() status.Code
- type Base
- type BoxLocker
- type Command
- type CommandType
- type Commands
- type Compare
- type Contract
- func (transaction *Contract) Compare(app interface{}) status.Code
- func (transaction *Contract) CreateCompareRequest(app interface{}, owner id.AccountKey, name string, version version.Version, ...) []byte
- func (transaction *Contract) Execute(app interface{}) Transaction
- func (transaction *Contract) Install(app interface{})
- func (transaction *Contract) ProcessCheck(app interface{}) status.Code
- func (transaction *Contract) ProcessDeliver(app interface{}) status.Code
- func (transaction *Contract) Resolve(app interface{}) Commands
- func (transaction *Contract) ShouldProcess(app interface{}) bool
- func (transaction *Contract) TransactionType() Type
- func (transaction *Contract) Validate() status.Code
- type ContractData
- type ContractFunction
- type Event
- type Execute
- type ExternalSend
- func (transaction *ExternalSend) ProcessCheck(app interface{}) status.Code
- func (transaction *ExternalSend) ProcessDeliver(app interface{}) status.Code
- func (transaction *ExternalSend) Resolve(app interface{}) Commands
- func (transaction *ExternalSend) ShouldProcess(app interface{}) bool
- func (transaction *ExternalSend) Validate() status.Code
- type FunctionValue
- type FunctionValues
- func AuditContract(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func AuditContractBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func AuditContractETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func AuditContractOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func CreateCheckEvent(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func CreateContractBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func CreateContractETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func CreateContractOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func ExtractSecret(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func ExtractSecretBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func ExtractSecretETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func ExtractSecretOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func FinalizeSwap(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func Initiate(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func NextStage(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func Noop(app interface{}, chain data.ChainType, context FunctionValues) (bool, FunctionValues)
- func Participate(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func ParticipateBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func ParticipateETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func ParticipateOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func Redeem(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func RedeemBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func RedeemETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func RedeemOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func Refund(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func RefundBTC(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func RefundETH(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func RefundOLT(app interface{}, context FunctionValues, tx Transaction) (bool, FunctionValues)
- func VerifySwap(app interface{}, chain data.ChainType, context FunctionValues, tx Transaction) (bool, FunctionValues)
- type HtlContract
- type Install
- type Message
- type MultiSigBox
- type OLVMContext
- type OLVMRequest
- type OLVMResult
- type Parameter
- type Party
- type Payment
- func (transaction *Payment) ProcessCheck(app interface{}) status.Code
- func (transaction *Payment) ProcessDeliver(app interface{}) status.Code
- func (transaction *Payment) Resolve(app interface{}) Commands
- func (transaction *Payment) ShouldProcess(app interface{}) bool
- func (transaction *Payment) Validate() status.Code
- type PaymentRecord
- type PublicKey
- type Register
- func (transaction Register) ProcessCheck(app interface{}) status.Code
- func (transaction Register) ProcessDeliver(app interface{}) status.Code
- func (transaction *Register) Resolve(app interface{}) Commands
- func (transaction Register) ShouldProcess(app interface{}) bool
- func (transaction Register) Validate() status.Code
- type Role
- type Send
- func (transaction *Send) ProcessCheck(app interface{}) status.Code
- func (transaction *Send) ProcessDeliver(app interface{}) status.Code
- func (transaction *Send) Resolve(app interface{}) Commands
- func (transaction *Send) ShouldProcess(app interface{}) bool
- func (transaction Send) TransactionTags(app interface{}) Tags
- func (transaction *Send) Validate() status.Code
- type SendInput
- type SendOutput
- type SendTo
- type Send_Absolute
- func (transaction *Send_Absolute) ProcessCheck(app interface{}) status.Code
- func (transaction *Send_Absolute) ProcessDeliver(app interface{}) status.Code
- func (transaction *Send_Absolute) Resolve(app interface{}) Commands
- func (transaction *Send_Absolute) ShouldProcess(app interface{}) bool
- func (transaction *Send_Absolute) TransactionType() Type
- func (transaction *Send_Absolute) Validate() status.Code
- type SignedTransaction
- type Swap
- func (swap *Swap) CommandExecute(app interface{}, commands Commands, c chan status.Code)
- func (transaction *Swap) ProcessCheck(app interface{}) status.Code
- func (transaction *Swap) ProcessDeliver(app interface{}) status.Code
- func (swap *Swap) Resolve(app interface{}) Commands
- func (transaction *Swap) ShouldProcess(app interface{}) bool
- func (transaction Swap) TransactionTags(app interface{}) Tags
- func (transaction *Swap) Validate() status.Code
- type SwapExchange
- type SwapInit
- type SwapKey
- type SwapMessage
- type SwapVerify
- type Tags
- type Transaction
- type TransactionSignature
- type Type
Constants ¶
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 CheckPayTo ¶ added in v0.8.0
func CheckSendTo ¶ added in v0.8.0
func CheckValidatorList ¶ added in v0.8.0
func CompareResults ¶ added in v0.8.0
func CompareResults(recent OLVMResult, original OLVMResult) bool
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 DeleteSwap ¶ added in v0.7.0
func DeleteSwap(app interface{}, key id.AccountKey)
func FindContract ¶ added in v0.5.2
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 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 ¶
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 GetExecutionContext ¶ added in v0.8.0
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 GetSigners ¶ added in v0.7.0
GetSigners will return the public keys of the signers
func GetSmartContracts ¶ added in v0.8.0
func GetString ¶
func GetString(value FunctionValue) string
func GetValidators ¶ added in v0.8.0
func GetValidators(app interface{}) *id.Validators
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 SignAndPack ¶
func SignAndPack(transaction Transaction) []byte
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 (Base) TransactionTags ¶ added in v0.7.1
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 {
// 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 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
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 (*Contract) ProcessDeliver ¶ added in v0.8.0
func (*Contract) ShouldProcess ¶ added in v0.8.0
func (*Contract) TransactionType ¶ added in v0.8.0
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 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 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 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 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
Synchronize a swap between two users
func (*Payment) ProcessCheck ¶ added in v0.7.1
func (*Payment) ProcessDeliver ¶ added in v0.7.1
func (*Payment) ShouldProcess ¶ added in v0.7.1
type PaymentRecord ¶ added in v0.7.1
type Register ¶
type Register struct {
Base
Identity string
NodeName string
AccountKey id.AccountKey
TendermintAddress string
TendermintPubKey string
}
Register an identity with the chain
func CreateRegisterRequest ¶ added in v0.7.0
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
SendTo SendTo `json:"SendTo"`
Gas data.Coin `json:"gas"`
Fee data.Coin `json:"fee"`
}
simple send transaction
func (*Send) ProcessCheck ¶
func (*Send) ProcessDeliver ¶
func (*Send) ShouldProcess ¶
func (Send) TransactionTags ¶ added in v0.8.0
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"`
}
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 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) ProcessCheck ¶
func (*Swap) ProcessDeliver ¶
Start the swap
func (*Swap) ShouldProcess ¶
Is this node one of the partipants in the swap
func (Swap) TransactionTags ¶ added in v0.8.0
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 (SwapInit) GetKeyHash ¶ added in v0.8.0
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"`
}
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 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 )