types

package
v0.0.0-...-da14a15 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteOptionData

func DeleteOptionData(store types.KVStore, data OptionData)

func EscrowTxBytes

func EscrowTxBytes(tx EscrowTx) []byte

func OptionsTxBytes

func OptionsTxBytes(tx OptionsTx) []byte

func StoreOptionData

func StoreOptionData(store types.KVStore, data OptionData)

Types

type BuyOptionTx

type BuyOptionTx struct {
	Addr []byte // address of the refered option
}

BuyOptionTx is used to purchase the right to exercise the option

type CreateEscrowTx

type CreateEscrowTx struct {
	Recipient  []byte
	Arbiter    []byte
	Expiration uint64 // height when the offer expires

}

CreateEscrowTx is used to create an escrow in the first place

type CreateOptionTx

type CreateOptionTx struct {
	Expiration uint64      // height when the offer expires
	Trade      types.Coins // this is the money that can exercise the option
}

CreateOptionTx is used to create an option in the first place

type DisolveOptionTx

type DisolveOptionTx struct {
	Addr []byte // address of the refered option
}

DisolveOptionTx returns Bond to issue if expired or unpurchased

type EscrowData

type EscrowData struct {
	Sender     []byte
	Recipient  []byte
	Arbiter    []byte
	Expiration uint64 // height when the offer expires (0 = never)
	Amount     types.Coins
}

EscrowData is our principal data structure in the db

func LoadEscrow

func LoadEscrow(store types.KVStore, addr []byte) (EscrowData, error)

func ParseEscrow

func ParseEscrow(data []byte) (EscrowData, error)

func (EscrowData) Address

func (d EscrowData) Address() []byte

Address is the ripemd160 hash of the escrow contents, which is constant

func (EscrowData) Bytes

func (d EscrowData) Bytes() []byte

func (EscrowData) IsExpired

func (d EscrowData) IsExpired(h uint64) bool

type EscrowTx

type EscrowTx interface{}

func ParseEscrowTx

func ParseEscrowTx(data []byte) (EscrowTx, error)

type ExerciseOptionTx

type ExerciseOptionTx struct {
	Addr []byte // address of the refered option
}

ExerciseOptionTx must send Trade and recieve Bond

type ExpireEscrowTx

type ExpireEscrowTx struct {
	Escrow []byte
}

ExpireEscrowTx can be signed by anyone, and only succeeds if the Expiration height has passed. All coins go back to the Sender (Intended to be used by the sender to recover old payments)

type OptionData

type OptionData struct {
	OptionIssue
	OptionHolder
}

OptionData is our principal data structure in the db

func LoadOptionData

func LoadOptionData(store types.KVStore, addr []byte) (OptionData, error)

func ParseOptionData

func ParseOptionData(data []byte) (OptionData, error)

func (OptionData) Bytes

func (d OptionData) Bytes() []byte

func (OptionData) CanBuy

func (d OptionData) CanBuy(buyer []byte) bool

To buy, this option must be for sale, and the buyer must be listed (or an open sale)

func (OptionData) CanDissolve

func (d OptionData) CanDissolve(addr []byte, h uint64) bool

CanDissolve if it is expired, or the holder, issue, and caller are the same

func (OptionData) CanExercise

func (d OptionData) CanExercise(addr []byte, h uint64) bool

func (OptionData) CanSell

func (d OptionData) CanSell(buyer []byte) bool

type OptionHolder

type OptionHolder struct {
	// this is for buying/selling the option (should be a separate struct?)
	Holder    []byte
	NewHolder []byte      // set to allow for only one buyer, empty for any buyer
	Price     types.Coins // required payment to transfer ownership
}

OptionHolder is the dynamic section of who can excercise the options

type OptionIssue

type OptionIssue struct {
	// this is for the normal option functionality
	Issuer     []byte
	Serial     int         // this sequence number is from the apptx that created it
	Expiration uint64      // height when the offer expires (0 = never)
	Bond       types.Coins // this is stored upon creation of the option
	Trade      types.Coins // this is the money that can exercise the option
}

OptionIssue is the constant part, created wth the option, never changes

func (OptionIssue) Address

func (i OptionIssue) Address() []byte

Address is the ripemd160 hash of the constant part of the option

func (OptionIssue) Bytes

func (i OptionIssue) Bytes() []byte

func (OptionIssue) IsExpired

func (i OptionIssue) IsExpired(h uint64) bool

type OptionsTx

type OptionsTx interface{}

func ParseOptionsTx

func ParseOptionsTx(data []byte) (OptionsTx, error)

type ResolveEscrowTx

type ResolveEscrowTx struct {
	Escrow []byte
	Payout bool // if true, to Recipient, else back to Sender
}

ResolveEscrowTx must be signed by the Arbiter and resolves the escrow by sending the money to Sender or Recipient as specified

type SellOptionTx

type SellOptionTx struct {
	Addr      []byte      // address of the refered option
	Price     types.Coins // required payment to transfer ownership
	NewHolder []byte      // set to allow for only one buyer, empty for any buyer
}

SellOptionTx is used to offer the option for sale

Jump to

Keyboard shortcuts

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