paychan

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package paychan is a generated protocol buffer package.

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

It has these top-level messages:
	PaymentChannel
	CreatePaymentChannelMsg
	Payment
	TransferPaymentChannelMsg
	ClosePaymentChannelMsg

Package paychan implements payment side channel functionality.

Payment channel functionality allows to deposit an amount that can be later transferred in chunks over that payment channel. Owner of the payment channel can choose to send full allocated amount or just a part of it over time and recipient can claim received money. When funds from a payment channel are claimed, payment channel is closed and any remaining tokens are returned to the payment channel owner.

Except creation and final closing transaction, all payment channel operations are made off the chain and therefore are very fast and cheap to execute.

Payment channel can be closed only by the recipient when claiming received funds or by the payment channel owner after the deadline was reached.

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 ErrInvalidAmount

func ErrInvalidAmount(c *x.Coin) error

func ErrInvalidChainID

func ErrInvalidChainID(chainID string) error

func ErrInvalidMemo

func ErrInvalidMemo(memo string) error

func ErrInvalidSenderPublicKey

func ErrInvalidSenderPublicKey() error

func ErrInvalidSignature

func ErrInvalidSignature() error

func ErrInvalidTimeout

func ErrInvalidTimeout(timeout int64) error

func ErrInvalidTotal

func ErrInvalidTotal(total *x.Coin) error

func ErrInvalidTransferred

func ErrInvalidTransferred(trans *x.Coin) error

func ErrMissingChainID

func ErrMissingChainID() error

func ErrMissingChannelID

func ErrMissingChannelID() error

func ErrMissingPayment

func ErrMissingPayment() error

func ErrMissingRecipient

func ErrMissingRecipient() error

func ErrMissingSenderPubkey

func ErrMissingSenderPubkey() error

func ErrMissingSignature

func ErrMissingSignature() error

func ErrMissingSrc

func ErrMissingSrc() error

func ErrNoSuchPaymentChannel

func ErrNoSuchPaymentChannel(id []byte) error

func ErrNotAllowed

func ErrNotAllowed(reason string) error

func IsInvalidAmountErr

func IsInvalidAmountErr(err error) bool

func IsInvalidChainErr

func IsInvalidChainErr(err error) bool

func IsInvalidConditionErr

func IsInvalidConditionErr(err error) bool

func IsInvalidMemoErr

func IsInvalidMemoErr(err error) bool

func IsInvalidSenderPublicKeyErr

func IsInvalidSenderPublicKeyErr(err error) bool

func IsInvalidSignatureErr

func IsInvalidSignatureErr(err error) bool

func IsInvalidTotalErr

func IsInvalidTotalErr(err error) bool

func IsInvalidTransferredErr

func IsInvalidTransferredErr(err error) bool

func IsMissingChainErr

func IsMissingChainErr(err error) bool

func IsMissingChannelIDErr

func IsMissingChannelIDErr(err error) bool

func IsMissingConditionErr

func IsMissingConditionErr(err error) bool

func IsMissingPaymentErr

func IsMissingPaymentErr(err error) bool

func IsMissingRecipientErr

func IsMissingRecipientErr(err error) bool

func IsMissingSenderErr

func IsMissingSenderErr(err error) bool

func IsMissingSenderPublicKeyErr

func IsMissingSenderPublicKeyErr(err error) bool

func IsMissingSignatureErr

func IsMissingSignatureErr(err error) bool

func IsNoSuchPaymentChannelErr

func IsNoSuchPaymentChannelErr(err error) bool

func IsNotAllowedErr

func IsNotAllowedErr(err error) bool

func IsNotFoundErr

func IsNotFoundErr(err error) bool

func RegisterQuery

func RegisterQuery(qr weave.QueryRouter)

RegisterQuery registers payment channel bucket under /paychans.

func RegisterRoutes

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

RegisterRouters registers payment channel message handelers in given registry.

Types

type ClosePaymentChannelMsg

type ClosePaymentChannelMsg struct {
	ChannelID []byte `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
	// Max length 128 character.
	Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"`
}

ClosePaymentChannelMsg close a payment channel and release remaining founds by sending them back to the sender account.

Recipient account can close channel at any moment.

Sender can close channel only if the timeout chain height was reached.

func (*ClosePaymentChannelMsg) Descriptor

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

func (*ClosePaymentChannelMsg) GetChannelID added in v0.10.0

func (m *ClosePaymentChannelMsg) GetChannelID() []byte

func (*ClosePaymentChannelMsg) GetMemo

func (m *ClosePaymentChannelMsg) GetMemo() string

func (*ClosePaymentChannelMsg) Marshal

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

func (*ClosePaymentChannelMsg) MarshalTo

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

func (ClosePaymentChannelMsg) Path

func (*ClosePaymentChannelMsg) ProtoMessage

func (*ClosePaymentChannelMsg) ProtoMessage()

func (*ClosePaymentChannelMsg) Reset

func (m *ClosePaymentChannelMsg) Reset()

func (*ClosePaymentChannelMsg) Size

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

func (*ClosePaymentChannelMsg) String

func (m *ClosePaymentChannelMsg) String() string

func (*ClosePaymentChannelMsg) Unmarshal

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

func (*ClosePaymentChannelMsg) Validate

func (m *ClosePaymentChannelMsg) Validate() error

type CreatePaymentChannelMsg

type CreatePaymentChannelMsg struct {
	// Sender address (weave.Address).
	Src []byte `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty"`
	// Sender public key is for validating transfer message signature.
	SenderPubkey *crypto.PublicKey `protobuf:"bytes,2,opt,name=sender_pubkey,json=senderPubkey" json:"sender_pubkey,omitempty"`
	// Recipient address  (weave.Address).
	Recipient []byte `protobuf:"bytes,3,opt,name=recipient,proto3" json:"recipient,omitempty"`
	// Maximum amount that can be transferred via this channel.
	Total *x.Coin `protobuf:"bytes,4,opt,name=total" json:"total,omitempty"`
	// Absolute block height value. If reached, channel can be closed by
	// anyone.
	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"`
}

CreatePaymentChannelMsg creates a new payment channel that can be used to transfer value between two parties.

Total amount will be taken from the senders account and allocated for user in the transactions done via created payment channel.

func (*CreatePaymentChannelMsg) Descriptor

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

func (*CreatePaymentChannelMsg) GetMemo

func (m *CreatePaymentChannelMsg) GetMemo() string

func (*CreatePaymentChannelMsg) GetRecipient

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

func (*CreatePaymentChannelMsg) GetSenderPubkey

func (m *CreatePaymentChannelMsg) GetSenderPubkey() *crypto.PublicKey

func (*CreatePaymentChannelMsg) GetSrc

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

func (*CreatePaymentChannelMsg) GetTimeout

func (m *CreatePaymentChannelMsg) GetTimeout() int64

func (*CreatePaymentChannelMsg) GetTotal

func (m *CreatePaymentChannelMsg) GetTotal() *x.Coin

func (*CreatePaymentChannelMsg) Marshal

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

func (*CreatePaymentChannelMsg) MarshalTo

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

func (CreatePaymentChannelMsg) Path

func (*CreatePaymentChannelMsg) ProtoMessage

func (*CreatePaymentChannelMsg) ProtoMessage()

func (*CreatePaymentChannelMsg) Reset

func (m *CreatePaymentChannelMsg) Reset()

func (*CreatePaymentChannelMsg) Size

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

func (*CreatePaymentChannelMsg) String

func (m *CreatePaymentChannelMsg) String() string

func (*CreatePaymentChannelMsg) Unmarshal

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

func (*CreatePaymentChannelMsg) Validate

func (m *CreatePaymentChannelMsg) Validate() error

type Payment

type Payment struct {
	ChainID   string  `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
	ChannelID []byte  `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
	Amount    *x.Coin `protobuf:"bytes,3,opt,name=amount" json:"amount,omitempty"`
	// Max length 128 character.
	Memo string `protobuf:"bytes,4,opt,name=memo,proto3" json:"memo,omitempty"`
}

Payment is created by the sender. Sender should give the message to the recipient, so that it can be redeemed at any time.

Each Payment should be created with amount greater than the previous one.

func (*Payment) Descriptor

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

func (*Payment) GetAmount

func (m *Payment) GetAmount() *x.Coin

func (*Payment) GetChainID added in v0.10.0

func (m *Payment) GetChainID() string

func (*Payment) GetChannelID added in v0.10.0

func (m *Payment) GetChannelID() []byte

func (*Payment) GetMemo

func (m *Payment) GetMemo() string

func (*Payment) Marshal

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

func (*Payment) MarshalTo

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

func (*Payment) ProtoMessage

func (*Payment) ProtoMessage()

func (*Payment) Reset

func (m *Payment) Reset()

func (*Payment) Size

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

func (*Payment) String

func (m *Payment) String() string

func (*Payment) Unmarshal

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

type PaymentChannel

type PaymentChannel struct {
	// Sender is the source that the founds are allocated from (weave.Address).
	Src []byte `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty"`
	// Sender public key is a key that must be used to verify signature of
	// transfer message. Sender creates signed transfer messages and gives them
	// to the recipient. Signature prevents from altering transfer message.
	SenderPubkey *crypto.PublicKey `protobuf:"bytes,2,opt,name=sender_pubkey,json=senderPubkey" json:"sender_pubkey,omitempty"`
	// Recipient is the party that receives payments through this channel
	// (weave.Address).
	Recipient []byte `protobuf:"bytes,3,opt,name=recipient,proto3" json:"recipient,omitempty"`
	// Total represents a maximum value that can be transferred via this
	// payment channel.
	Total *x.Coin `protobuf:"bytes,4,opt,name=total" json:"total,omitempty"`
	// Absolute block height value. If reached, channel can be closed by
	// 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"`
	// Transferred represents total amount that was transferred using allocated
	// (total) value. Transferred must never exceed total value.
	Transferred *x.Coin `protobuf:"bytes,7,opt,name=transferred" json:"transferred,omitempty"`
}

PaymentChannel holds the state of a payment channel during its lifetime.

func (PaymentChannel) Copy

func (pc PaymentChannel) Copy() orm.CloneableData

Copy returns a shallow copy of this PaymentChannel.

func (*PaymentChannel) Descriptor

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

func (*PaymentChannel) GetMemo

func (m *PaymentChannel) GetMemo() string

func (*PaymentChannel) GetRecipient

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

func (*PaymentChannel) GetSenderPubkey

func (m *PaymentChannel) GetSenderPubkey() *crypto.PublicKey

func (*PaymentChannel) GetSrc

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

func (*PaymentChannel) GetTimeout

func (m *PaymentChannel) GetTimeout() int64

func (*PaymentChannel) GetTotal

func (m *PaymentChannel) GetTotal() *x.Coin

func (*PaymentChannel) GetTransferred

func (m *PaymentChannel) GetTransferred() *x.Coin

func (*PaymentChannel) Marshal

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

func (*PaymentChannel) MarshalTo

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

func (*PaymentChannel) ProtoMessage

func (*PaymentChannel) ProtoMessage()

func (*PaymentChannel) Reset

func (m *PaymentChannel) Reset()

func (*PaymentChannel) Size

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

func (*PaymentChannel) String

func (m *PaymentChannel) String() string

func (*PaymentChannel) Unmarshal

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

func (*PaymentChannel) Validate

func (pc *PaymentChannel) Validate() error

Validate ensures the payment channel is valid.

type PaymentChannelBucket

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

PaymentChannelBucket is a wrapper over orm.Bucket that ensures that only PaymentChannel entities can be persisted.

func NewPaymentChannelBucket

func NewPaymentChannelBucket() PaymentChannelBucket

NewPaymentChannelBucket returns a bucket for storing PaymentChannel state.

func (*PaymentChannelBucket) Create

Create adds given payment store entity to the store and returns the ID of the newly inserted entity.

func (*PaymentChannelBucket) GetPaymentChannel

func (b *PaymentChannelBucket) GetPaymentChannel(db weave.KVStore, paymentChannelID []byte) (*PaymentChannel, error)

GetPaymentChannel returns a payment channel instance with given ID or returns an error.

func (*PaymentChannelBucket) Save

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

Save updates the state of given PaymentChannel entity in the store.

type TransferPaymentChannelMsg

type TransferPaymentChannelMsg struct {
	Payment   *Payment          `protobuf:"bytes,1,opt,name=payment" json:"payment,omitempty"`
	Signature *crypto.Signature `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"`
}

TransferPaymentChannelMsg binds Payment with a signature created using senders private key. Signature is there to ensure that payment message was not altered.

func (*TransferPaymentChannelMsg) Descriptor

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

func (*TransferPaymentChannelMsg) GetPayment

func (m *TransferPaymentChannelMsg) GetPayment() *Payment

func (*TransferPaymentChannelMsg) GetSignature

func (m *TransferPaymentChannelMsg) GetSignature() *crypto.Signature

func (*TransferPaymentChannelMsg) Marshal

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

func (*TransferPaymentChannelMsg) MarshalTo

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

func (TransferPaymentChannelMsg) Path

func (*TransferPaymentChannelMsg) ProtoMessage

func (*TransferPaymentChannelMsg) ProtoMessage()

func (*TransferPaymentChannelMsg) Reset

func (m *TransferPaymentChannelMsg) Reset()

func (*TransferPaymentChannelMsg) Size

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

func (*TransferPaymentChannelMsg) String

func (m *TransferPaymentChannelMsg) String() string

func (*TransferPaymentChannelMsg) Unmarshal

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

func (*TransferPaymentChannelMsg) Validate

func (m *TransferPaymentChannelMsg) Validate() error

Jump to

Keyboard shortcuts

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