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 ¶
- func SubPayChProposals(s perun.SessionAPI, notifier PayChProposalNotifier) error
- func SubPayChUpdates(ch perun.ChAPI, notifier PayChUpdateNotifier) error
- func UnsubPayChProposals(s perun.SessionAPI) error
- func UnsubPayChUpdates(ch perun.ChAPI) error
- type PayChInfo
- func ClosePayCh(pctx context.Context, ch perun.ChAPI) (PayChInfo, error)
- func CloseSession(s perun.SessionAPI, force bool) ([]PayChInfo, error)
- func GetPayChInfo(ch perun.ChAPI) PayChInfo
- func GetPayChsInfo(s perun.SessionAPI) []PayChInfo
- func OpenPayCh(pctx context.Context, s perun.SessionAPI, openingBalInfo perun.BalInfo, ...) (PayChInfo, error)
- func OpenSession(n perun.NodeAPI, configFile string) (string, []PayChInfo, error)
- func RespondPayChProposal(pctx context.Context, s perun.SessionAPI, proposalID string, accept bool) (PayChInfo, error)
- func RespondPayChUpdate(pctx context.Context, ch perun.ChAPI, updateID string, accept bool) (PayChInfo, error)
- func SendPayChUpdate(pctx context.Context, ch perun.ChAPI, payee, amount string) (PayChInfo, error)
- type PayChProposalNotif
- type PayChProposalNotifier
- type PayChUpdateNotif
- type PayChUpdateNotifier
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 ¶
UnsubPayChUpdates deletes the existing subscription for updates on this channel.
Types ¶
type PayChInfo ¶
PayChInfo represents the interpretation of channelInfo for payment app.
func ClosePayCh ¶
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
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
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.
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.