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) perun.APIError
- func SubPayChUpdates(ch perun.ChAPI, notifier PayChUpdateNotifier) perun.APIError
- func UnsubPayChProposals(s perun.SessionAPI) perun.APIError
- func UnsubPayChUpdates(ch perun.ChAPI) perun.APIError
- type ErrInfoFailedPreCondUnclosedPayChs
- type Error
- type PayChInfo
- func ClosePayCh(pctx context.Context, ch perun.ChAPI) (PayChInfo, perun.APIError)
- func CloseSession(s perun.SessionAPI, force bool) ([]PayChInfo, perun.APIError)
- func GetPayChInfo(ch perun.ChAPI) PayChInfo
- func GetPayChsInfo(s perun.SessionAPI) []PayChInfo
- func OpenPayCh(pctx context.Context, s perun.SessionAPI, openingBalInfo perun.BalInfo, ...) (PayChInfo, perun.APIError)
- func OpenSession(n perun.NodeAPI, configFile string) (string, []PayChInfo, perun.APIError)
- func RespondPayChProposal(pctx context.Context, s perun.SessionAPI, proposalID string, accept bool) (PayChInfo, perun.APIError)
- func RespondPayChUpdate(pctx context.Context, ch perun.ChAPI, updateID string, accept bool) (PayChInfo, perun.APIError)
- func SendPayChUpdate(pctx context.Context, ch perun.ChAPI, payments []Payment) (PayChInfo, perun.APIError)
- type PayChProposalNotif
- type PayChProposalNotifier
- type PayChUpdateNotif
- type PayChUpdateNotifier
- type Payment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SubPayChProposals ¶
func SubPayChProposals(s perun.SessionAPI, notifier PayChProposalNotifier) perun.APIError
SubPayChProposals sets up a subscription for incoming channel proposals and interprets the notifications as payment channel notifiations.
See session.SubChProposals for the list of errors returned by this API.
func SubPayChUpdates ¶
func SubPayChUpdates(ch perun.ChAPI, notifier PayChUpdateNotifier) perun.APIError
SubPayChUpdates sets up a subscription for incoming channel updates and interprets the notifications as payment update notifiations.
See session.SubChUpdates for the list of errors returned by this API.
func UnsubPayChProposals ¶
func UnsubPayChProposals(s perun.SessionAPI) perun.APIError
UnsubPayChProposals deletes the existing subscription for channel proposals.
See session.UnsubChProposals for the list of errors returned by this API.
func UnsubPayChUpdates ¶
func UnsubPayChUpdates(ch perun.ChAPI) perun.APIError
UnsubPayChUpdates deletes the existing subscription for updates on this channel.
See session.UnsubChUpdates for the list of errors returned by this API.
Types ¶
type ErrInfoFailedPreCondUnclosedPayChs ¶ added in v0.6.0
type ErrInfoFailedPreCondUnclosedPayChs struct {
PayChs []PayChInfo
}
ErrInfoFailedPreCondUnclosedPayChs is the interpretation of ErrInfoFailedPreCondUnclosedChs for payment application.
type Error ¶ added in v0.6.0
type Error string
Error type is used to define error constants for this package.
Definition of error constants for this package.
type PayChInfo ¶
PayChInfo represents the interpretation of channelInfo for payment app.
func ClosePayCh ¶
ClosePayCh closes the channel and interprets the closing channel info as payment channel info.
See session.CloseCh for the list of errors returned by this API.
func CloseSession ¶ added in v0.4.0
CloseSession closes the current session.
See session.CloseSession for the list of errors returned by this API.
func GetPayChInfo ¶ added in v0.4.0
func GetPayChInfo(ch perun.ChAPI) PayChInfo
GetPayChInfo fetches the channel info for this channel and interprets it as payment channel info.
func GetPayChsInfo ¶ added in v0.4.0
func GetPayChsInfo(s perun.SessionAPI) []PayChInfo
GetPayChsInfo fetches the list of all channels info in the session and interprets them as payment channel info.
func OpenPayCh ¶
func OpenPayCh(pctx context.Context, s perun.SessionAPI, openingBalInfo perun.BalInfo, challengeDurSecs uint64) ( PayChInfo, perun.APIError)
OpenPayCh opens a channel with payment app with the specified parameters. It interprets the returned channel info as payment channel info.
See session.OpenCh for the list of errors returned by this API.
func OpenSession ¶ added in v0.4.0
OpenSession opens a session and interprets the restored channels info as payment channels info.
See node.OpenSession for the list of errors returned by this API.
func RespondPayChProposal ¶
func RespondPayChProposal(pctx context.Context, s perun.SessionAPI, proposalID string, accept bool) (PayChInfo, perun.APIError)
RespondPayChProposal sends the response to a payment channel proposal notification and interprets the opening channel info as payment channel info.
See session.RespondChProposal for the list of errors returned by this API.
func RespondPayChUpdate ¶
func RespondPayChUpdate(pctx context.Context, ch perun.ChAPI, updateID string, accept bool) ( PayChInfo, perun.APIError)
RespondPayChUpdate sends a response for a channel update notification and interprets the updated channel info as payment channel info.
See session.RespondChUpdate for the list of errors returned by this API.
func SendPayChUpdate ¶
func SendPayChUpdate(pctx context.Context, ch perun.ChAPI, payments []Payment) (PayChInfo, perun.APIError)
SendPayChUpdate sends a payment update on the channel that can send or request funds. Use `self` in the `payee` field to pay the user itself and "alias of the peer" to pay the peer.
If there is an error, it will be one of the following codes: - ErrResourceNotFound with ResourceType: "peerID" when any of the peer aliases are not known. - ErrInvalidArgument with Name:"Amount" when the amount is invalid. or any of the errors returned by the session.SendChUpdate API.
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 perun.APIError }
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.