escrow

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Overview

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 funds. The arbiter or source (sender) can release them to the recipient. The recipient (destination) can return them to the sender (source). Upon timeout, they will be returned to the sender (source).

Index

Constants

This section is empty.

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 NewBucket

func NewBucket() orm.ModelBucket

func NewEscrow

func NewEscrow(
	id []byte,
	source weave.Address,
	destination weave.Address,
	arbiter weave.Address,
	amount coin.Coins,
	timeout weave.UnixTime,
	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 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 source to the escrow account if all preconditions are met.

type CreateMsg added in v0.17.0

type CreateMsg struct {
	Metadata    *weave.Metadata                  `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	Source      github_com_iov_one_weave.Address `protobuf:"bytes,2,opt,name=source,proto3,casttype=github.com/iov-one/weave.Address" json:"source,omitempty"`
	Arbiter     github_com_iov_one_weave.Address `protobuf:"bytes,3,opt,name=arbiter,proto3,casttype=github.com/iov-one/weave.Address" json:"arbiter,omitempty"`
	Destination github_com_iov_one_weave.Address `protobuf:"bytes,4,opt,name=destination,proto3,casttype=github.com/iov-one/weave.Address" json:"destination,omitempty"`
	// amount may contain multiple token types
	Amount []*coin.Coin `protobuf:"bytes,5,rep,name=amount,proto3" json:"amount,omitempty"`
	// Timeout represents wall clock time.
	Timeout github_com_iov_one_weave.UnixTime `protobuf:"varint,6,opt,name=timeout,proto3,casttype=github.com/iov-one/weave.UnixTime" json:"timeout,omitempty"`
	// max length 128 character
	Memo string `protobuf:"bytes,7,opt,name=memo,proto3" json:"memo,omitempty"`
}

CreateMsg is a request to create an Escrow with some tokens. Message must be authorized by the source.

func NewCreateMsg

func NewCreateMsg(
	source weave.Address,
	recipient weave.Address,
	arbiter weave.Address,
	amount coin.Coins,
	timeout weave.UnixTime,
	memo string,
) *CreateMsg

NewCreateMsg is a helper to quickly build a create escrow message

func (*CreateMsg) Descriptor added in v0.17.0

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

func (*CreateMsg) GetAmount added in v0.17.0

func (m *CreateMsg) GetAmount() []*coin.Coin

func (*CreateMsg) GetArbiter added in v0.17.0

func (m *CreateMsg) GetArbiter() github_com_iov_one_weave.Address

func (*CreateMsg) GetDestination added in v0.18.0

func (m *CreateMsg) GetDestination() github_com_iov_one_weave.Address

func (*CreateMsg) GetMemo added in v0.17.0

func (m *CreateMsg) GetMemo() string

func (*CreateMsg) GetMetadata added in v0.17.0

func (m *CreateMsg) GetMetadata() *weave.Metadata

func (*CreateMsg) GetSource added in v0.18.0

func (*CreateMsg) GetTimeout added in v0.17.0

func (*CreateMsg) Marshal added in v0.17.0

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

func (*CreateMsg) MarshalTo added in v0.17.0

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

func (CreateMsg) Path added in v0.17.0

func (CreateMsg) Path() string

func (*CreateMsg) ProtoMessage added in v0.17.0

func (*CreateMsg) ProtoMessage()

func (*CreateMsg) Reset added in v0.17.0

func (m *CreateMsg) Reset()

func (*CreateMsg) Size added in v0.17.0

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

func (*CreateMsg) String added in v0.17.0

func (m *CreateMsg) String() string

func (*CreateMsg) Unmarshal added in v0.17.0

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

func (*CreateMsg) Validate added in v0.17.0

func (m *CreateMsg) Validate() error

Validate makes sure that this is sensible

func (*CreateMsg) XXX_DiscardUnknown added in v0.17.0

func (m *CreateMsg) XXX_DiscardUnknown()

func (*CreateMsg) XXX_Marshal added in v0.17.0

func (m *CreateMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateMsg) XXX_Merge added in v0.17.0

func (m *CreateMsg) XXX_Merge(src proto.Message)

func (*CreateMsg) XXX_Size added in v0.17.0

func (m *CreateMsg) XXX_Size() int

func (*CreateMsg) XXX_Unmarshal added in v0.17.0

func (m *CreateMsg) XXX_Unmarshal(b []byte) error

type Escrow

type Escrow struct {
	Metadata    *weave.Metadata                  `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	Source      github_com_iov_one_weave.Address `protobuf:"bytes,2,opt,name=source,proto3,casttype=github.com/iov-one/weave.Address" json:"source,omitempty"`
	Arbiter     github_com_iov_one_weave.Address `protobuf:"bytes,3,opt,name=arbiter,proto3,casttype=github.com/iov-one/weave.Address" json:"arbiter,omitempty"`
	Destination github_com_iov_one_weave.Address `protobuf:"bytes,4,opt,name=destination,proto3,casttype=github.com/iov-one/weave.Address" json:"destination,omitempty"`
	// If unreleased before timeout, escrow will return to source.
	// Timeout represents wall clock time as read from the block header. Timeout
	// is represented using POSIX time format.
	// Expiration time is inclusive meaning that the escrow expires as soon as
	// the current time is equal or greater than timeout value.
	// nonexpired: [created, timeout)
	// expired: [timeout, infinity)
	Timeout github_com_iov_one_weave.UnixTime `protobuf:"varint,5,opt,name=timeout,proto3,casttype=github.com/iov-one/weave.UnixTime" json:"timeout,omitempty"`
	// max length 128 character
	Memo string `protobuf:"bytes,6,opt,name=memo,proto3" json:"memo,omitempty"`
	// Address of this entity. Set during creation and does not change.
	Address github_com_iov_one_weave.Address `protobuf:"bytes,7,opt,name=address,proto3,casttype=github.com/iov-one/weave.Address" json:"address,omitempty"`
}

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

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) Descriptor

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

func (*Escrow) GetAddress added in v0.19.0

func (m *Escrow) GetAddress() github_com_iov_one_weave.Address

func (*Escrow) GetArbiter

func (m *Escrow) GetArbiter() github_com_iov_one_weave.Address

func (*Escrow) GetDestination added in v0.18.0

func (m *Escrow) GetDestination() github_com_iov_one_weave.Address

func (*Escrow) GetMemo

func (m *Escrow) GetMemo() string

func (*Escrow) GetMetadata added in v0.15.0

func (m *Escrow) GetMetadata() *weave.Metadata

func (*Escrow) GetSource added in v0.18.0

func (m *Escrow) GetSource() github_com_iov_one_weave.Address

func (*Escrow) GetTimeout

func (m *Escrow) GetTimeout() github_com_iov_one_weave.UnixTime

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

func (*Escrow) XXX_DiscardUnknown added in v0.12.0

func (m *Escrow) XXX_DiscardUnknown()

func (*Escrow) XXX_Marshal added in v0.12.0

func (m *Escrow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Escrow) XXX_Merge added in v0.12.0

func (m *Escrow) XXX_Merge(src proto.Message)

func (*Escrow) XXX_Size added in v0.12.0

func (m *Escrow) XXX_Size() int

func (*Escrow) XXX_Unmarshal added in v0.12.0

func (m *Escrow) XXX_Unmarshal(b []byte) error

type Initializer added in v0.12.0

type Initializer struct {
	Minter cash.CoinMinter
}

Initializer fulfils the Initializer interface to load data from the genesis file

func (*Initializer) FromGenesis added in v0.12.0

func (i *Initializer) FromGenesis(opts weave.Options, params weave.GenesisParams, kv weave.KVStore) error

FromGenesis will parse initial escrow info from genesis and save it in the database.

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 escrow account to the receiver if all preconditions are met. When the escrow account is empty it is deleted.

type ReleaseMsg added in v0.17.0

type ReleaseMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	EscrowId []byte          `protobuf:"bytes,2,opt,name=escrow_id,json=escrowId,proto3" json:"escrow_id,omitempty"`
	Amount   []*coin.Coin    `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
}

ReleaseMsg releases the content to the destination. Message must be authorized by the source or arbiter. If amount not provided, defaults to entire escrow, May be a subset of the current balance.

func (*ReleaseMsg) Descriptor added in v0.17.0

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

func (*ReleaseMsg) GetAmount added in v0.17.0

func (m *ReleaseMsg) GetAmount() []*coin.Coin

func (*ReleaseMsg) GetEscrowId added in v0.17.0

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

func (*ReleaseMsg) GetMetadata added in v0.17.0

func (m *ReleaseMsg) GetMetadata() *weave.Metadata

func (*ReleaseMsg) Marshal added in v0.17.0

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

func (*ReleaseMsg) MarshalTo added in v0.17.0

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

func (ReleaseMsg) Path added in v0.17.0

func (ReleaseMsg) Path() string

func (*ReleaseMsg) ProtoMessage added in v0.17.0

func (*ReleaseMsg) ProtoMessage()

func (*ReleaseMsg) Reset added in v0.17.0

func (m *ReleaseMsg) Reset()

func (*ReleaseMsg) Size added in v0.17.0

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

func (*ReleaseMsg) String added in v0.17.0

func (m *ReleaseMsg) String() string

func (*ReleaseMsg) Unmarshal added in v0.17.0

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

func (*ReleaseMsg) Validate added in v0.17.0

func (m *ReleaseMsg) Validate() error

Validate makes sure that this is sensible

func (*ReleaseMsg) XXX_DiscardUnknown added in v0.17.0

func (m *ReleaseMsg) XXX_DiscardUnknown()

func (*ReleaseMsg) XXX_Marshal added in v0.17.0

func (m *ReleaseMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ReleaseMsg) XXX_Merge added in v0.17.0

func (m *ReleaseMsg) XXX_Merge(src proto.Message)

func (*ReleaseMsg) XXX_Size added in v0.17.0

func (m *ReleaseMsg) XXX_Size() int

func (*ReleaseMsg) XXX_Unmarshal added in v0.17.0

func (m *ReleaseMsg) XXX_Unmarshal(b []byte) error

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 all the tokens from the escrow to the defined source if all preconditions are met. The escrow is deleted afterwards.

type ReturnMsg added in v0.17.0

type ReturnMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	EscrowId []byte          `protobuf:"bytes,2,opt,name=escrow_id,json=escrowId,proto3" json:"escrow_id,omitempty"`
}

ReturnMsg returns the content to the source. Must be authorized by the source or an expired timeout

func (*ReturnMsg) Descriptor added in v0.17.0

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

func (*ReturnMsg) GetEscrowId added in v0.17.0

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

func (*ReturnMsg) GetMetadata added in v0.17.0

func (m *ReturnMsg) GetMetadata() *weave.Metadata

func (*ReturnMsg) Marshal added in v0.17.0

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

func (*ReturnMsg) MarshalTo added in v0.17.0

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

func (ReturnMsg) Path added in v0.17.0

func (ReturnMsg) Path() string

func (*ReturnMsg) ProtoMessage added in v0.17.0

func (*ReturnMsg) ProtoMessage()

func (*ReturnMsg) Reset added in v0.17.0

func (m *ReturnMsg) Reset()

func (*ReturnMsg) Size added in v0.17.0

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

func (*ReturnMsg) String added in v0.17.0

func (m *ReturnMsg) String() string

func (*ReturnMsg) Unmarshal added in v0.17.0

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

func (*ReturnMsg) Validate added in v0.17.0

func (m *ReturnMsg) Validate() error

Validate always returns true for no data

func (*ReturnMsg) XXX_DiscardUnknown added in v0.17.0

func (m *ReturnMsg) XXX_DiscardUnknown()

func (*ReturnMsg) XXX_Marshal added in v0.17.0

func (m *ReturnMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ReturnMsg) XXX_Merge added in v0.17.0

func (m *ReturnMsg) XXX_Merge(src proto.Message)

func (*ReturnMsg) XXX_Size added in v0.17.0

func (m *ReturnMsg) XXX_Size() int

func (*ReturnMsg) XXX_Unmarshal added in v0.17.0

func (m *ReturnMsg) XXX_Unmarshal(b []byte) error

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 updates the any of the source, recipient or arbiter if all preconditions are met. No coins are moved.

type UpdatePartiesMsg added in v0.17.0

type UpdatePartiesMsg struct {
	Metadata    *weave.Metadata                  `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	EscrowId    []byte                           `protobuf:"bytes,2,opt,name=escrow_id,json=escrowId,proto3" json:"escrow_id,omitempty"`
	Source      github_com_iov_one_weave.Address `protobuf:"bytes,3,opt,name=source,proto3,casttype=github.com/iov-one/weave.Address" json:"source,omitempty"`
	Arbiter     github_com_iov_one_weave.Address `protobuf:"bytes,4,opt,name=arbiter,proto3,casttype=github.com/iov-one/weave.Address" json:"arbiter,omitempty"`
	Destination github_com_iov_one_weave.Address `protobuf:"bytes,5,opt,name=destination,proto3,casttype=github.com/iov-one/weave.Address" json:"destination,omitempty"`
}

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

Represents delegating responsibility

func (*UpdatePartiesMsg) Descriptor added in v0.17.0

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

func (*UpdatePartiesMsg) GetArbiter added in v0.17.0

func (*UpdatePartiesMsg) GetDestination added in v0.18.0

func (*UpdatePartiesMsg) GetEscrowId added in v0.17.0

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

func (*UpdatePartiesMsg) GetMetadata added in v0.17.0

func (m *UpdatePartiesMsg) GetMetadata() *weave.Metadata

func (*UpdatePartiesMsg) GetSource added in v0.18.0

func (*UpdatePartiesMsg) Marshal added in v0.17.0

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

func (*UpdatePartiesMsg) MarshalTo added in v0.17.0

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

func (UpdatePartiesMsg) Path added in v0.17.0

func (UpdatePartiesMsg) Path() string

func (*UpdatePartiesMsg) ProtoMessage added in v0.17.0

func (*UpdatePartiesMsg) ProtoMessage()

func (*UpdatePartiesMsg) Reset added in v0.17.0

func (m *UpdatePartiesMsg) Reset()

func (*UpdatePartiesMsg) Size added in v0.17.0

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

func (*UpdatePartiesMsg) String added in v0.17.0

func (m *UpdatePartiesMsg) String() string

func (*UpdatePartiesMsg) Unmarshal added in v0.17.0

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

func (*UpdatePartiesMsg) Validate added in v0.17.0

func (m *UpdatePartiesMsg) Validate() error

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

func (*UpdatePartiesMsg) XXX_DiscardUnknown added in v0.17.0

func (m *UpdatePartiesMsg) XXX_DiscardUnknown()

func (*UpdatePartiesMsg) XXX_Marshal added in v0.17.0

func (m *UpdatePartiesMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdatePartiesMsg) XXX_Merge added in v0.17.0

func (m *UpdatePartiesMsg) XXX_Merge(src proto.Message)

func (*UpdatePartiesMsg) XXX_Size added in v0.17.0

func (m *UpdatePartiesMsg) XXX_Size() int

func (*UpdatePartiesMsg) XXX_Unmarshal added in v0.17.0

func (m *UpdatePartiesMsg) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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