payment

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package payment implements a payment API that can used with the generic session and channel APIs to open, use and close payment channels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SubPayChProposals

func SubPayChProposals(s perun.SessionAPI, notifier PayChProposalNotifier) error

SubPayChProposals sets up a subscription for payment channel proposals.

func SubPayChUpdates

func SubPayChUpdates(ch perun.ChAPI, notifier PayChUpdateNotifier) error

SubPayChUpdates sets up a subscription for updates on this channel.

func UnsubPayChProposals

func UnsubPayChProposals(s perun.SessionAPI) error

UnsubPayChProposals deletes the existing subscription for payment channel proposals.

func UnsubPayChUpdates

func UnsubPayChUpdates(ch perun.ChAPI) error

UnsubPayChUpdates deletes the existing subscription for updates on this channel.

Types

type PayChInfo

type PayChInfo struct {
	ChID    string
	BalInfo perun.BalInfo
	Version string
}

PayChInfo represents the interpretation of channelInfo for payment app.

func ClosePayCh

func ClosePayCh(pctx context.Context, ch perun.ChAPI) (PayChInfo, error)

ClosePayCh closes the payment channel.

func CloseSession added in v0.4.0

func CloseSession(s perun.SessionAPI, force bool) ([]PayChInfo, error)

CloseSession closes the current session.

func GetPayChInfo added in v0.4.0

func GetPayChInfo(ch perun.ChAPI) PayChInfo

GetPayChInfo returns the balance information for this channel.

func GetPayChsInfo added in v0.4.0

func GetPayChsInfo(s perun.SessionAPI) []PayChInfo

GetPayChsInfo returns a list of payment channel info for all the channels in this session.

func OpenPayCh

func OpenPayCh(pctx context.Context, s perun.SessionAPI, openingBalInfo perun.BalInfo, challengeDurSecs uint64) (
	PayChInfo, error)

OpenPayCh opens a payment channel using the given sessionAPI instance with the specified parameters.

func OpenSession added in v0.4.0

func OpenSession(n perun.NodeAPI, configFile string) (string, []PayChInfo, error)

OpenSession opens a session and interprets the restored channels as payment channels.

func RespondPayChProposal

func RespondPayChProposal(pctx context.Context, s perun.SessionAPI, proposalID string, accept bool) (PayChInfo, error)

RespondPayChProposal sends the response to a payment channel proposal notification.

func RespondPayChUpdate

func RespondPayChUpdate(pctx context.Context, ch perun.ChAPI, updateID string, accept bool) (PayChInfo, error)

RespondPayChUpdate sends a response for a channel update notification.

func SendPayChUpdate

func SendPayChUpdate(pctx context.Context, ch perun.ChAPI, payee, amount string) (PayChInfo, error)

SendPayChUpdate send the given amount to the payee. Payee should be one of the channel participants. Use "self" to request payments.

type PayChProposalNotif

type PayChProposalNotif struct {
	ProposalID       string
	OpeningBalInfo   perun.BalInfo
	ChallengeDurSecs uint64
	Expiry           int64
}

PayChProposalNotif represents the channel update notification data for payment app.

type PayChProposalNotifier

type PayChProposalNotifier func(PayChProposalNotif)

PayChProposalNotifier represents the channel update notification function for payment app.

type PayChUpdateNotif

type PayChUpdateNotif struct {
	UpdateID          string
	ProposedPayChInfo PayChInfo
	Type              perun.ChUpdateType
	Expiry            int64
	Error             string
}

PayChUpdateNotif represents the interpretation of channel update notification for payment app. ProposedChInfo (of ChUpdateNotif) is sent in the ChInfo field for regular updates and CurrChInfo (of ChCloseNotif) is sent in the ChInfo field for channel close update. See perun.ChUpdateNotif for documentation on the other struct fields.

type PayChUpdateNotifier

type PayChUpdateNotifier func(PayChUpdateNotif)

PayChUpdateNotifier represents the interpretation of channel update notifier for payment app.

Jump to

Keyboard shortcuts

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