escrow

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package escrow is a generated protocol buffer package.

It is generated from these files:
	x/escrow/codec.proto

It has these top-level messages:
	Escrow
	CreateEscrowMsg
	ReleaseEscrowMsg
	ReturnEscrowMsg
	UpdateEscrowPartiesMsg

Package escrow implements an Escrow.

> An escrow is a financial arrangement where a third party holds and regulates > payment of the funds required for two parties involved in a given transaction. > It helps make transactions more secure by keeping the payment in a secure > escrow account which is only released when all of the terms of an agreement are > met as overseen by the escrow company.

Escrow holds some coins. The arbiter or sender can release them to the recipient. The recipient can return them to the sender. Upon timeout, they will be returned to the sender.

Index

Constants

View Source
const (
	CodeNoEscrow         = 1010
	CodeMissingCondition = 1011
	CodeInvalidCondition = 1012
	CodeInvalidMetadata  = 1013
	CodeInvalidHeight    = 1014
)

ABCI Response Codes escrow takes 1010-1020

View Source
const (
	// BucketName is where we store the escrows
	BucketName = "esc"
	// SequenceName is an auto-increment ID counter for escrows
	SequenceName = "id"
)

Variables

View Source
var (
	ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCodec   = fmt.Errorf("proto: integer overflow")
)

Functions

func Condition

func Condition(key []byte) weave.Condition

Condition calculates the address of an escrow given the key

func ErrEscrowExpired

func ErrEscrowExpired(timeout int64) error

func ErrEscrowNotExpired

func ErrEscrowNotExpired(timeout int64) error

func ErrInvalidCondition

func ErrInvalidCondition(perm []byte) error

func ErrInvalidEscrowID

func ErrInvalidEscrowID(id []byte) error

func ErrInvalidMemo

func ErrInvalidMemo(memo string) error

func ErrInvalidTimeout

func ErrInvalidTimeout(timeout int64) error

func ErrMissingAllConditions

func ErrMissingAllConditions() error

func ErrMissingArbiter

func ErrMissingArbiter() error

func ErrMissingRecipient

func ErrMissingRecipient() error

func ErrMissingSender

func ErrMissingSender() error

func ErrNoSuchEscrow

func ErrNoSuchEscrow(id []byte) error

func IsInvalidConditionErr

func IsInvalidConditionErr(err error) bool

func IsInvalidMetadataErr

func IsInvalidMetadataErr(err error) bool

func IsMissingConditionErr

func IsMissingConditionErr(err error) bool

func IsNoSuchEscrowErr

func IsNoSuchEscrowErr(err error) bool

func NewController added in v0.9.0

func NewController(cash cash.Controller, bucket Bucket) *controller

func NewEscrow

func NewEscrow(id []byte, sender, rcpt weave.Address, arb weave.Condition,
	amount x.Coins, timeout int64, memo string) orm.Object

NewEscrow creates an escrow orm.Object

func RegisterQuery

func RegisterQuery(qr weave.QueryRouter)

RegisterQuery will register this bucket as "/escrows"

func RegisterRoutes

func RegisterRoutes(r weave.Registry, auth x.Authenticator,
	cashctrl cash.Controller)

RegisterRoutes will instantiate and register all handlers in this package

Types

type Bucket

type Bucket struct {
	orm.Bucket
	// contains filtered or unexported fields
}

Bucket is a type-safe wrapper around orm.Bucket

func NewBucket

func NewBucket() Bucket

NewBucket initializes a Bucket with default name

inherit Get and Save from orm.Bucket add Create

func (Bucket) Build added in v0.10.0

func (b Bucket) Build(db weave.KVStore, escrow *Escrow) orm.Object

Build assigns an ID to given escrow instance and returns it as an orm Object. It does not persist the escrow in the store.

func (Bucket) Save

func (b Bucket) Save(db weave.KVStore, obj orm.Object) error

Save enforces the proper type

type CreateEscrowHandler

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

CreateEscrowHandler will set a name for objects in this bucket

func (CreateEscrowHandler) Check

Check just verifies it is properly formed and returns the cost of executing it

func (CreateEscrowHandler) Deliver

Deliver moves the tokens from sender to receiver if all preconditions are met

type CreateEscrowMsg

type CreateEscrowMsg struct {
	// Sender, Arbiter, Recipient are all weave.Permission
	Src       []byte `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty"`
	Arbiter   []byte `protobuf:"bytes,2,opt,name=arbiter,proto3" json:"arbiter,omitempty"`
	Recipient []byte `protobuf:"bytes,3,opt,name=recipient,proto3" json:"recipient,omitempty"`
	// amount may contain multiple token types
	Amount []*x.Coin `protobuf:"bytes,4,rep,name=amount" json:"amount,omitempty"`
	// if unreleased before timeout, will return to sender
	Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"`
	// max length 128 character
	Memo string `protobuf:"bytes,6,opt,name=memo,proto3" json:"memo,omitempty"`
}

CreateEscrowMsg is a request to create an Escrow with some tokens. If sender is not defined, it defaults to the first signer The rest must be defined

func NewCreateMsg

func NewCreateMsg(send, rcpt weave.Address, arb weave.Condition,
	amount x.Coins, timeout int64, memo string) *CreateEscrowMsg

NewCreateMsg is a helper to quickly build a create escrow message

func (*CreateEscrowMsg) Descriptor

func (*CreateEscrowMsg) Descriptor() ([]byte, []int)

func (*CreateEscrowMsg) GetAmount

func (m *CreateEscrowMsg) GetAmount() []*x.Coin

func (*CreateEscrowMsg) GetArbiter

func (m *CreateEscrowMsg) GetArbiter() []byte

func (*CreateEscrowMsg) GetMemo

func (m *CreateEscrowMsg) GetMemo() string

func (*CreateEscrowMsg) GetRecipient

func (m *CreateEscrowMsg) GetRecipient() []byte

func (*CreateEscrowMsg) GetSrc added in v0.9.0

func (m *CreateEscrowMsg) GetSrc() []byte

func (*CreateEscrowMsg) GetTimeout

func (m *CreateEscrowMsg) GetTimeout() int64

func (*CreateEscrowMsg) Marshal

func (m *CreateEscrowMsg) Marshal() (dAtA []byte, err error)

func (*CreateEscrowMsg) MarshalTo

func (m *CreateEscrowMsg) MarshalTo(dAtA []byte) (int, error)

func (CreateEscrowMsg) Path

func (CreateEscrowMsg) Path() string

Path fulfills weave.Msg interface to allow routing

func (*CreateEscrowMsg) ProtoMessage

func (*CreateEscrowMsg) ProtoMessage()

func (*CreateEscrowMsg) Reset

func (m *CreateEscrowMsg) Reset()

func (*CreateEscrowMsg) Size

func (m *CreateEscrowMsg) Size() (n int)

func (*CreateEscrowMsg) String

func (m *CreateEscrowMsg) String() string

func (*CreateEscrowMsg) Unmarshal

func (m *CreateEscrowMsg) Unmarshal(dAtA []byte) error

func (*CreateEscrowMsg) Validate

func (m *CreateEscrowMsg) Validate() error

Validate makes sure that this is sensible

type Escrow

type Escrow struct {
	// Sender, Arbiter, Recipient are all weave.Permission
	Sender    []byte `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"`
	Arbiter   []byte `protobuf:"bytes,2,opt,name=arbiter,proto3" json:"arbiter,omitempty"`
	Recipient []byte `protobuf:"bytes,3,opt,name=recipient,proto3" json:"recipient,omitempty"`
	// amount may contain multiple token types
	Amount []*x.Coin `protobuf:"bytes,4,rep,name=amount" json:"amount,omitempty"`
	// if unreleased before timeout, will return to sender
	// timeout stored here is absolute block height
	Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"`
	// max length 128 character
	Memo string `protobuf:"bytes,6,opt,name=memo,proto3" json:"memo,omitempty"`
}

Escrow holds some coins. The arbiter or sender can release them to the recipient. The recipient can return them to the sender. Upon timeout, they will be returned to the sender.

Note that if the arbiter is a Hashlock permission, we have an HTLC ;)

func AsEscrow

func AsEscrow(obj orm.Object) *Escrow

AsEscrow extracts an *Escrow value or nil from the object Must be called on a Bucket result that is an *Escrow, will panic on bad type.

func (*Escrow) Copy

func (e *Escrow) Copy() orm.CloneableData

Copy makes a new set with the same coins

func (*Escrow) Descriptor

func (*Escrow) Descriptor() ([]byte, []int)

func (*Escrow) GetAmount

func (m *Escrow) GetAmount() []*x.Coin

func (*Escrow) GetArbiter

func (m *Escrow) GetArbiter() []byte

func (*Escrow) GetMemo

func (m *Escrow) GetMemo() string

func (*Escrow) GetRecipient

func (m *Escrow) GetRecipient() []byte

func (*Escrow) GetSender

func (m *Escrow) GetSender() []byte

func (*Escrow) GetTimeout

func (m *Escrow) GetTimeout() int64

func (*Escrow) Marshal

func (m *Escrow) Marshal() (dAtA []byte, err error)

func (*Escrow) MarshalTo

func (m *Escrow) MarshalTo(dAtA []byte) (int, error)

func (*Escrow) ProtoMessage

func (*Escrow) ProtoMessage()

func (*Escrow) Reset

func (m *Escrow) Reset()

func (*Escrow) Size

func (m *Escrow) Size() (n int)

func (*Escrow) String

func (m *Escrow) String() string

func (*Escrow) Unmarshal

func (m *Escrow) Unmarshal(dAtA []byte) error

func (*Escrow) Validate

func (e *Escrow) Validate() error

Validate ensures the escrow is valid

type ReleaseEscrowHandler

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

ReleaseEscrowHandler will set a name for objects in this bucket

func (ReleaseEscrowHandler) Check

Check just verifies it is properly formed and returns the cost of executing it

func (ReleaseEscrowHandler) Deliver

Deliver moves the tokens from sender to receiver if all preconditions are met

type ReleaseEscrowMsg

type ReleaseEscrowMsg struct {
	EscrowId []byte    `protobuf:"bytes,1,opt,name=escrow_id,json=escrowId,proto3" json:"escrow_id,omitempty"`
	Amount   []*x.Coin `protobuf:"bytes,2,rep,name=amount" json:"amount,omitempty"`
}

ReleaseEscrowMsg releases the content to the recipient. Must be authorized by sender or arbiter. If amount not provided, defaults to entire escrow, May be a subset of the current balance.

func (*ReleaseEscrowMsg) Descriptor

func (*ReleaseEscrowMsg) Descriptor() ([]byte, []int)

func (*ReleaseEscrowMsg) GetAmount

func (m *ReleaseEscrowMsg) GetAmount() []*x.Coin

func (*ReleaseEscrowMsg) GetEscrowId

func (m *ReleaseEscrowMsg) GetEscrowId() []byte

func (*ReleaseEscrowMsg) Marshal

func (m *ReleaseEscrowMsg) Marshal() (dAtA []byte, err error)

func (*ReleaseEscrowMsg) MarshalTo

func (m *ReleaseEscrowMsg) MarshalTo(dAtA []byte) (int, error)

func (ReleaseEscrowMsg) Path

func (ReleaseEscrowMsg) Path() string

Path fulfills weave.Msg interface to allow routing

func (*ReleaseEscrowMsg) ProtoMessage

func (*ReleaseEscrowMsg) ProtoMessage()

func (*ReleaseEscrowMsg) Reset

func (m *ReleaseEscrowMsg) Reset()

func (*ReleaseEscrowMsg) Size

func (m *ReleaseEscrowMsg) Size() (n int)

func (*ReleaseEscrowMsg) String

func (m *ReleaseEscrowMsg) String() string

func (*ReleaseEscrowMsg) Unmarshal

func (m *ReleaseEscrowMsg) Unmarshal(dAtA []byte) error

func (*ReleaseEscrowMsg) Validate

func (m *ReleaseEscrowMsg) Validate() error

Validate makes sure that this is sensible

type ReturnEscrowHandler

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

ReturnEscrowHandler will set a name for objects in this bucket

func (ReturnEscrowHandler) Check

Check just verifies it is properly formed and returns the cost of executing it

func (ReturnEscrowHandler) Deliver

Deliver moves the tokens from sender to receiver if all preconditions are met

type ReturnEscrowMsg

type ReturnEscrowMsg struct {
	EscrowId []byte `protobuf:"bytes,1,opt,name=escrow_id,json=escrowId,proto3" json:"escrow_id,omitempty"`
}

ReturnEscrowMsg returns the content to the sender. Must be authorized by the sender or an expired timeout

func (*ReturnEscrowMsg) Descriptor

func (*ReturnEscrowMsg) Descriptor() ([]byte, []int)

func (*ReturnEscrowMsg) GetEscrowId

func (m *ReturnEscrowMsg) GetEscrowId() []byte

func (*ReturnEscrowMsg) Marshal

func (m *ReturnEscrowMsg) Marshal() (dAtA []byte, err error)

func (*ReturnEscrowMsg) MarshalTo

func (m *ReturnEscrowMsg) MarshalTo(dAtA []byte) (int, error)

func (ReturnEscrowMsg) Path

func (ReturnEscrowMsg) Path() string

Path fulfills weave.Msg interface to allow routing

func (*ReturnEscrowMsg) ProtoMessage

func (*ReturnEscrowMsg) ProtoMessage()

func (*ReturnEscrowMsg) Reset

func (m *ReturnEscrowMsg) Reset()

func (*ReturnEscrowMsg) Size

func (m *ReturnEscrowMsg) Size() (n int)

func (*ReturnEscrowMsg) String

func (m *ReturnEscrowMsg) String() string

func (*ReturnEscrowMsg) Unmarshal

func (m *ReturnEscrowMsg) Unmarshal(dAtA []byte) error

func (*ReturnEscrowMsg) Validate

func (m *ReturnEscrowMsg) Validate() error

Validate always returns true for no data

type UpdateEscrowHandler

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

UpdateEscrowHandler will set a name for objects in this bucket

func (UpdateEscrowHandler) Check

Check just verifies it is properly formed and returns the cost of executing it

func (UpdateEscrowHandler) Deliver

Deliver moves the tokens from sender to receiver if all preconditions are met

type UpdateEscrowPartiesMsg

type UpdateEscrowPartiesMsg struct {
	EscrowId  []byte `protobuf:"bytes,1,opt,name=escrow_id,json=escrowId,proto3" json:"escrow_id,omitempty"`
	Sender    []byte `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"`
	Arbiter   []byte `protobuf:"bytes,3,opt,name=arbiter,proto3" json:"arbiter,omitempty"`
	Recipient []byte `protobuf:"bytes,4,opt,name=recipient,proto3" json:"recipient,omitempty"`
}

UpdateEscrowPartiesMsg changes any of the parties of the escrow: sender, arbiter, recipient. This must be authorized by the current holder of that position (eg. only sender can update sender).

Represents delegating responsibility

func (*UpdateEscrowPartiesMsg) Descriptor

func (*UpdateEscrowPartiesMsg) Descriptor() ([]byte, []int)

func (*UpdateEscrowPartiesMsg) GetArbiter

func (m *UpdateEscrowPartiesMsg) GetArbiter() []byte

func (*UpdateEscrowPartiesMsg) GetEscrowId

func (m *UpdateEscrowPartiesMsg) GetEscrowId() []byte

func (*UpdateEscrowPartiesMsg) GetRecipient

func (m *UpdateEscrowPartiesMsg) GetRecipient() []byte

func (*UpdateEscrowPartiesMsg) GetSender

func (m *UpdateEscrowPartiesMsg) GetSender() []byte

func (*UpdateEscrowPartiesMsg) Marshal

func (m *UpdateEscrowPartiesMsg) Marshal() (dAtA []byte, err error)

func (*UpdateEscrowPartiesMsg) MarshalTo

func (m *UpdateEscrowPartiesMsg) MarshalTo(dAtA []byte) (int, error)

func (UpdateEscrowPartiesMsg) Path

Path fulfills weave.Msg interface to allow routing

func (*UpdateEscrowPartiesMsg) ProtoMessage

func (*UpdateEscrowPartiesMsg) ProtoMessage()

func (*UpdateEscrowPartiesMsg) Reset

func (m *UpdateEscrowPartiesMsg) Reset()

func (*UpdateEscrowPartiesMsg) Size

func (m *UpdateEscrowPartiesMsg) Size() (n int)

func (*UpdateEscrowPartiesMsg) String

func (m *UpdateEscrowPartiesMsg) String() string

func (*UpdateEscrowPartiesMsg) Unmarshal

func (m *UpdateEscrowPartiesMsg) Unmarshal(dAtA []byte) error

func (*UpdateEscrowPartiesMsg) Validate

func (m *UpdateEscrowPartiesMsg) Validate() error

Validate makes sure any included items are valid permissions and there is at least one change

Jump to

Keyboard shortcuts

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