fcrpaymentmgr

package
v0.0.0-...-7a4b066 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package fcrpaymentmgr - payment manager manages all payment related functions.

Package fcrpaymentmgr - payment manager manages all payment related functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FCRPaymentMgr

type FCRPaymentMgr interface {
	// Start starts the manager's routine.
	Start() error

	// Shutdown ends the manager's routine safely.
	Shutdown()

	/* For outbound payment */
	// Create creates a payment channel with given initial balance to given recipient.
	Create(recipientAddr string, amt *big.Int) error

	// Topup topups an existing payment channel with given amount.
	Topup(recipientAddr string, amt *big.Int) error

	// Pay pays a given recipient in given land with given amount.
	// It returns the voucher,
	// a boolean indicates whether or not to create a payment channel,
	// a boolean indicates whether or not to topup a payment channel,
	// error if any.
	Pay(recipientAddr string, lane uint64, amt *big.Int) (string, bool, bool, error)

	// Revert the recent pay
	RevertPay(recipientAddr string, lane uint64)

	// ReceiveRefund receives a refund from recipient.
	// It returns the amount received from the refund.
	ReceiveRefund(recipientAddr string, voucher string) (*big.Int, error)

	// GetOutboundChStatus gets the outbound payment channel status by a given recipient addr.
	// It returns the payment channel address, balance and redeemed amount.
	GetOutboundChStatus(recipientAddr string) (string, *big.Int, *big.Int, error)

	// RemoveOutboundCh removes the outbound payment channel status by a given recipient addr.
	RemoveOutboundCh(recipientAddr string) error

	// GetCostToCreate gets the current cost to create a payment channel.
	GetCostToCreate(recipientAddr string, amt *big.Int) (*big.Int, error)

	// CheckRecipientSettlementValidity checks if it is valid for the recipient to settle a selling payment channel.
	CheckRecipientSettlementValidity(recipientAddr string) (bool, error)

	/* For inbound payment */
	// Settle settles a payment channel by given sender addr.
	Settle(senderAddr string) error

	// Receive receives a payment. It returns the amount received and the lane number.
	Receive(senderAddr string, voucher string) (*big.Int, uint64, error)

	// Refund creates a voucher used to refund by given sender addr, given lane and given amount.
	Refund(senderAddr string, lane uint64, amt *big.Int) (string, error)

	// RemoveInboundCh removes the inbound payment channel status by a given sender addr.
	RemoveInboundCh(senderAddr string) error

	// GetInboundChStatus gets the inbound payment channel status by a given sender addr.
	// It returns the payment channel address, balance and redeemed amount.
	GetInboundChStatus(senderAddr string) (string, *big.Int, *big.Int, error)

	// GetCostToSettle gets the current cost to settle a payment channel.
	GetCostToSettle(senderAddr string) (*big.Int, error)

	// CheckSettlementValidity checks if it is valid to settle a payment channel.
	CheckSettlementValidity(senderAddr string) (bool, error)
}

FCRPaymentMgr represents the manager that manages all payment.

func NewFCRPaymentMgrImplV1

func NewFCRPaymentMgrImplV1(privKey string, lotusMgr fcrlotusmgr.FCRLotusMgr) FCRPaymentMgr

type FCRPaymentMgrImplV1

type FCRPaymentMgrImplV1 struct {
	// contains filtered or unexported fields
}

FCRPaymentMgrImplV1 implements FCRPaymentMgr, it is an in-memory version.

func (*FCRPaymentMgrImplV1) CheckRecipientSettlementValidity

func (mgr *FCRPaymentMgrImplV1) CheckRecipientSettlementValidity(recipientAddr string) (bool, error)

func (*FCRPaymentMgrImplV1) CheckSettlementValidity

func (mgr *FCRPaymentMgrImplV1) CheckSettlementValidity(senderAddr string) (bool, error)

func (*FCRPaymentMgrImplV1) Create

func (mgr *FCRPaymentMgrImplV1) Create(recipientAddr string, amt *big.Int) error

func (*FCRPaymentMgrImplV1) GetCostToCreate

func (mgr *FCRPaymentMgrImplV1) GetCostToCreate(recipientAddr string, amt *big.Int) (*big.Int, error)

func (*FCRPaymentMgrImplV1) GetCostToSettle

func (mgr *FCRPaymentMgrImplV1) GetCostToSettle(senderAddr string) (*big.Int, error)

func (*FCRPaymentMgrImplV1) GetInboundChStatus

func (mgr *FCRPaymentMgrImplV1) GetInboundChStatus(senderAddr string) (string, *big.Int, *big.Int, error)

func (*FCRPaymentMgrImplV1) GetOutboundChStatus

func (mgr *FCRPaymentMgrImplV1) GetOutboundChStatus(recipientAddr string) (string, *big.Int, *big.Int, error)

func (*FCRPaymentMgrImplV1) Pay

func (mgr *FCRPaymentMgrImplV1) Pay(recipientAddr string, lane uint64, amt *big.Int) (string, bool, bool, error)

func (*FCRPaymentMgrImplV1) Receive

func (mgr *FCRPaymentMgrImplV1) Receive(senderAddr string, voucher string) (*big.Int, uint64, error)

func (*FCRPaymentMgrImplV1) ReceiveRefund

func (mgr *FCRPaymentMgrImplV1) ReceiveRefund(recipientAddr string, voucher string) (*big.Int, error)

func (*FCRPaymentMgrImplV1) Refund

func (mgr *FCRPaymentMgrImplV1) Refund(senderAddr string, lane uint64, amt *big.Int) (string, error)

func (*FCRPaymentMgrImplV1) RemoveInboundCh

func (mgr *FCRPaymentMgrImplV1) RemoveInboundCh(senderAddr string) error

func (*FCRPaymentMgrImplV1) RemoveOutboundCh

func (mgr *FCRPaymentMgrImplV1) RemoveOutboundCh(recipientAddr string) error

func (*FCRPaymentMgrImplV1) RevertPay

func (mgr *FCRPaymentMgrImplV1) RevertPay(recipientAddr string, lane uint64)

func (*FCRPaymentMgrImplV1) Settle

func (mgr *FCRPaymentMgrImplV1) Settle(senderAddr string) error

func (*FCRPaymentMgrImplV1) Shutdown

func (mgr *FCRPaymentMgrImplV1) Shutdown()

func (*FCRPaymentMgrImplV1) Start

func (mgr *FCRPaymentMgrImplV1) Start() error

func (*FCRPaymentMgrImplV1) Topup

func (mgr *FCRPaymentMgrImplV1) Topup(recipientAddr string, amt *big.Int) error

Jump to

Keyboard shortcuts

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