fcrlotusmgr

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: 23 Imported by: 2

Documentation

Overview

Package fcrlotusmgr - lotus manager handles the interaction with filecoin via lotus.

Package fcrlotusmgr - lotus manager handles the interaction with filecoin via lotus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateVoucher

func GenerateVoucher(privKey string, chAddr string, lane uint64, nonce uint64, newRedeemed *big.Int) (string, error)

GenerateVoucher generates a voucher by given private key, channel address, lane number and amount.

func Sign

func Sign(pk []byte, msg []byte) ([]byte, error)

Sign signs the given msg using given private key

func Verify

func Verify(sig []byte, msg []byte) (string, error)

Verify calculates the sender address from signature and message

func VerifyVoucher

func VerifyVoucher(voucher string) (string, string, uint64, uint64, *big.Int, error)

VerifyVoucher verifies a voucher by given voucher. It returns the sender's address, channel address, lane, nonce, new redeemed, and error)

Types

type FCRLotusMgr

type FCRLotusMgr interface {
	// CreatePaymentChannel creates a payment channel using the given private key, recipient address and a given amount.
	CreatePaymentChannel(privKey string, recipientAddr string, amt *big.Int) (string, error)

	// TopupPaymentChannel topups a payment channel using the given private key, channel address and a given amount.
	TopupPaymentChannel(privKey string, chAddr string, amt *big.Int) error

	// SettlePaymentChannel settles a payment channel using the given private key, channel address and a final voucher.
	SettlePaymentChannel(privKey string, chAddr string, vouchers []string) error

	// CollectPaymentChannel collects a payment channel using the given private key, channel address.
	CollectPaymentChannel(privKey string, chAddr string) error

	// CheckPaymentChannel checks the state of a channel.
	// It returns a boolean indicating if the channel is settling/settled, the channel balance, the recipient address and error.
	CheckPaymentChannel(chAddr string) (bool, *big.Int, string, error)

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

	// GetCostToSettle gets the current cost to settle a payment channel + updating voucher.
	GetCostToSettle(privKey string, chAddr string, vouchers []string) (*big.Int, error)

	// GetPaymentChannelCreationBlock gets the block number at which given payment channel is created.
	GetPaymentChannelCreationBlock(chAddr string) (*big.Int, error)

	// GetPaymentChannelSettlementBlock gets the block number at which given payment channel is called to settle.
	GetPaymentChannelSettlementBlock(chAddr string) (*big.Int, error)
}

FCRLotusMgr represents the manager that interacts with the lotus.

func NewFCRLotusMgrImplV1

func NewFCRLotusMgrImplV1(lotusAPIAddr string, authToken string, getLotusAPI func(authToken, lotusAPIAddr string) (LotusAPI, jsonrpc.ClientCloser, error)) FCRLotusMgr

type FCRLotusMgrImplV1

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

func (*FCRLotusMgrImplV1) CheckPaymentChannel

func (mgr *FCRLotusMgrImplV1) CheckPaymentChannel(chAddr string) (bool, *big.Int, string, error)

func (*FCRLotusMgrImplV1) CollectPaymentChannel

func (mgr *FCRLotusMgrImplV1) CollectPaymentChannel(privKey string, chAddr string) error

func (*FCRLotusMgrImplV1) CreatePaymentChannel

func (mgr *FCRLotusMgrImplV1) CreatePaymentChannel(privKey string, recipientAddr string, amt *big.Int) (string, error)

func (*FCRLotusMgrImplV1) GetCostToCreate

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

func (*FCRLotusMgrImplV1) GetCostToSettle

func (mgr *FCRLotusMgrImplV1) GetCostToSettle(privKey string, chAddr string, vouchers []string) (*big.Int, error)

func (*FCRLotusMgrImplV1) GetPaymentChannelCreationBlock

func (mgr *FCRLotusMgrImplV1) GetPaymentChannelCreationBlock(chAddr string) (*big.Int, error)

func (*FCRLotusMgrImplV1) GetPaymentChannelSettlementBlock

func (mgr *FCRLotusMgrImplV1) GetPaymentChannelSettlementBlock(chAddr string) (*big.Int, error)

func (*FCRLotusMgrImplV1) SettlePaymentChannel

func (mgr *FCRLotusMgrImplV1) SettlePaymentChannel(privKey string, chAddr string, vouchers []string) error

func (*FCRLotusMgrImplV1) TopupPaymentChannel

func (mgr *FCRLotusMgrImplV1) TopupPaymentChannel(privKey string, chAddr string, amt *big.Int) error

type LotusAPI

type LotusAPI interface {
	ChainReadObj(ctx context.Context, obj cid.Cid) ([]byte, error)

	GasEstimateFeeCap(ctx context.Context, msg *types.Message, maxqueueblks int64, tsk types.TipSetKey) (types.BigInt, error)

	GasEstimateGasLimit(ctx context.Context, msg *types.Message, tsk types.TipSetKey) (int64, error)

	GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)

	MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error)

	MpoolPush(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error)

	StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)

	StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)

	StateGetReceipt(ctx context.Context, msg cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error)
}

LotusAPI is the minimum interface interacting with the Lotus to achieve payment function.

Jump to

Keyboard shortcuts

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