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 ¶
- Variables
- func ErrInvalidAmount(c *x.Coin) error
- func ErrInvalidChainID(chainID string) error
- func ErrInvalidMemo(memo string) error
- func ErrInvalidSenderPublicKey() error
- func ErrInvalidSignature() error
- func ErrInvalidTimeout(timeout int64) error
- func ErrInvalidTotal(total *x.Coin) error
- func ErrInvalidTransferred(trans *x.Coin) error
- func ErrMissingChainID() error
- func ErrMissingChannelID() error
- func ErrMissingPayment() error
- func ErrMissingRecipient() error
- func ErrMissingSenderPubkey() error
- func ErrMissingSignature() error
- func ErrMissingSrc() error
- func ErrNoSuchPaymentChannel(id []byte) error
- func ErrNotAllowed(reason string) error
- func IsInvalidAmountErr(err error) bool
- func IsInvalidChainErr(err error) bool
- func IsInvalidConditionErr(err error) bool
- func IsInvalidMemoErr(err error) bool
- func IsInvalidSenderPublicKeyErr(err error) bool
- func IsInvalidSignatureErr(err error) bool
- func IsInvalidTotalErr(err error) bool
- func IsInvalidTransferredErr(err error) bool
- func IsMissingChainErr(err error) bool
- func IsMissingChannelIDErr(err error) bool
- func IsMissingConditionErr(err error) bool
- func IsMissingPaymentErr(err error) bool
- func IsMissingRecipientErr(err error) bool
- func IsMissingSenderErr(err error) bool
- func IsMissingSenderPublicKeyErr(err error) bool
- func IsMissingSignatureErr(err error) bool
- func IsNoSuchPaymentChannelErr(err error) bool
- func IsNotAllowedErr(err error) bool
- func IsNotFoundErr(err error) bool
- func RegisterQuery(qr weave.QueryRouter)
- func RegisterRoutes(r weave.Registry, auth x.Authenticator, cash cash.Controller)
- type ClosePaymentChannelMsg
- func (*ClosePaymentChannelMsg) Descriptor() ([]byte, []int)
- func (m *ClosePaymentChannelMsg) GetChannelID() []byte
- func (m *ClosePaymentChannelMsg) GetMemo() string
- func (m *ClosePaymentChannelMsg) Marshal() (dAtA []byte, err error)
- func (m *ClosePaymentChannelMsg) MarshalTo(dAtA []byte) (int, error)
- func (ClosePaymentChannelMsg) Path() string
- func (*ClosePaymentChannelMsg) ProtoMessage()
- func (m *ClosePaymentChannelMsg) Reset()
- func (m *ClosePaymentChannelMsg) Size() (n int)
- func (m *ClosePaymentChannelMsg) String() string
- func (m *ClosePaymentChannelMsg) Unmarshal(dAtA []byte) error
- func (m *ClosePaymentChannelMsg) Validate() error
- type CreatePaymentChannelMsg
- func (*CreatePaymentChannelMsg) Descriptor() ([]byte, []int)
- func (m *CreatePaymentChannelMsg) GetMemo() string
- func (m *CreatePaymentChannelMsg) GetRecipient() []byte
- func (m *CreatePaymentChannelMsg) GetSenderPubkey() *crypto.PublicKey
- func (m *CreatePaymentChannelMsg) GetSrc() []byte
- func (m *CreatePaymentChannelMsg) GetTimeout() int64
- func (m *CreatePaymentChannelMsg) GetTotal() *x.Coin
- func (m *CreatePaymentChannelMsg) Marshal() (dAtA []byte, err error)
- func (m *CreatePaymentChannelMsg) MarshalTo(dAtA []byte) (int, error)
- func (CreatePaymentChannelMsg) Path() string
- func (*CreatePaymentChannelMsg) ProtoMessage()
- func (m *CreatePaymentChannelMsg) Reset()
- func (m *CreatePaymentChannelMsg) Size() (n int)
- func (m *CreatePaymentChannelMsg) String() string
- func (m *CreatePaymentChannelMsg) Unmarshal(dAtA []byte) error
- func (m *CreatePaymentChannelMsg) Validate() error
- type Payment
- func (*Payment) Descriptor() ([]byte, []int)
- func (m *Payment) GetAmount() *x.Coin
- func (m *Payment) GetChainID() string
- func (m *Payment) GetChannelID() []byte
- func (m *Payment) GetMemo() string
- func (m *Payment) Marshal() (dAtA []byte, err error)
- func (m *Payment) MarshalTo(dAtA []byte) (int, error)
- func (*Payment) ProtoMessage()
- func (m *Payment) Reset()
- func (m *Payment) Size() (n int)
- func (m *Payment) String() string
- func (m *Payment) Unmarshal(dAtA []byte) error
- type PaymentChannel
- func (pc PaymentChannel) Copy() orm.CloneableData
- func (*PaymentChannel) Descriptor() ([]byte, []int)
- func (m *PaymentChannel) GetMemo() string
- func (m *PaymentChannel) GetRecipient() []byte
- func (m *PaymentChannel) GetSenderPubkey() *crypto.PublicKey
- func (m *PaymentChannel) GetSrc() []byte
- func (m *PaymentChannel) GetTimeout() int64
- func (m *PaymentChannel) GetTotal() *x.Coin
- func (m *PaymentChannel) GetTransferred() *x.Coin
- func (m *PaymentChannel) Marshal() (dAtA []byte, err error)
- func (m *PaymentChannel) MarshalTo(dAtA []byte) (int, error)
- func (*PaymentChannel) ProtoMessage()
- func (m *PaymentChannel) Reset()
- func (m *PaymentChannel) Size() (n int)
- func (m *PaymentChannel) String() string
- func (m *PaymentChannel) Unmarshal(dAtA []byte) error
- func (pc *PaymentChannel) Validate() error
- type PaymentChannelBucket
- type TransferPaymentChannelMsg
- func (*TransferPaymentChannelMsg) Descriptor() ([]byte, []int)
- func (m *TransferPaymentChannelMsg) GetPayment() *Payment
- func (m *TransferPaymentChannelMsg) GetSignature() *crypto.Signature
- func (m *TransferPaymentChannelMsg) Marshal() (dAtA []byte, err error)
- func (m *TransferPaymentChannelMsg) MarshalTo(dAtA []byte) (int, error)
- func (TransferPaymentChannelMsg) Path() string
- func (*TransferPaymentChannelMsg) ProtoMessage()
- func (m *TransferPaymentChannelMsg) Reset()
- func (m *TransferPaymentChannelMsg) Size() (n int)
- func (m *TransferPaymentChannelMsg) String() string
- func (m *TransferPaymentChannelMsg) Unmarshal(dAtA []byte) error
- func (m *TransferPaymentChannelMsg) Validate() error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") )
Functions ¶
func ErrInvalidAmount ¶
func ErrInvalidChainID ¶
func ErrInvalidMemo ¶
func ErrInvalidSenderPublicKey ¶
func ErrInvalidSenderPublicKey() error
func ErrInvalidSignature ¶
func ErrInvalidSignature() error
func ErrInvalidTimeout ¶
func ErrInvalidTotal ¶
func ErrInvalidTransferred ¶
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 ErrNotAllowed ¶
func IsInvalidAmountErr ¶
func IsInvalidChainErr ¶
func IsInvalidConditionErr ¶
func IsInvalidMemoErr ¶
func IsInvalidSignatureErr ¶
func IsInvalidTotalErr ¶
func IsInvalidTransferredErr ¶
func IsMissingChainErr ¶
func IsMissingChannelIDErr ¶
func IsMissingConditionErr ¶
func IsMissingPaymentErr ¶
func IsMissingRecipientErr ¶
func IsMissingSenderErr ¶
func IsMissingSignatureErr ¶
func IsNotAllowedErr ¶
func IsNotFoundErr ¶
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) Path() string
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) Path() string
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) GetChainID ¶ added in v0.10.0
func (*Payment) GetChannelID ¶ added in v0.10.0
func (*Payment) ProtoMessage ¶
func (*Payment) ProtoMessage()
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) 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 ¶
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 ¶
func (b *PaymentChannelBucket) Create(db weave.KVStore, pc *PaymentChannel) (orm.Object, error)
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.
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) Path() string
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