payment

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: Apache-2.0 Imports: 8 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 GetBalInfo

func GetBalInfo(ch perun.ChannelAPI) perun.BalInfo

GetBalInfo returns the balance information for this channel.

func RespondPayChProposal

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

RespondPayChProposal sends the response to a payment channel proposal notification.

func RespondPayChUpdate

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

RespondPayChUpdate sends a response for a channel update notification.

func SendPayChUpdate

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

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

func SubPayChCloses

func SubPayChCloses(s perun.SessionAPI, notifier PayChCloseNotifier) error

SubPayChCloses sets up a subscription for payment channel closes.

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.ChannelAPI, notifier PayChUpdateNotifier) error

SubPayChUpdates sets up a subscription for updates on this channel.

func UnsubPayChCloses

func UnsubPayChCloses(s perun.SessionAPI) error

UnsubPayChCloses deletes the existing subscription for payment channel closes.

func UnsubPayChProposals

func UnsubPayChProposals(s perun.SessionAPI) error

UnsubPayChProposals deletes the existing subscription for payment channel proposals.

func UnsubPayChUpdates

func UnsubPayChUpdates(ch perun.ChannelAPI) error

UnsubPayChUpdates deletes the existing subscription for updates on this channel.

Types

type PayChCloseNotif

type PayChCloseNotif struct {
	ClosingState PayChInfo
	Error        string
}

PayChCloseNotif represents the channel close notification data for payment app.

type PayChCloseNotifier

type PayChCloseNotifier func(PayChCloseNotif)

PayChCloseNotifier represents the channel close notification function for payment app.

type PayChInfo

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

PayChInfo represents the interpretation of channelInfo for payment app.

func ClosePayCh

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

ClosePayCh closes the payment channel.

func GetPayChs

func GetPayChs(s perun.SessionAPI) []PayChInfo

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

func OpenPayCh

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

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

type PayChProposalNotif

type PayChProposalNotif struct {
	ProposalID       string
	Currency         string
	OpeningBals      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
	ProposedBals perun.BalInfo
	Version      string
	Final        bool
	Currency     string
	Parts        []string
	Expiry       int64
}

PayChUpdateNotif represents the channel update notification data for payment app.

type PayChUpdateNotifier

type PayChUpdateNotifier func(PayChUpdateNotif)

PayChUpdateNotifier represents the channel update notification function for payment app.

Jump to

Keyboard shortcuts

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