fcrpaymentmgr

package
v0.0.0-...-12ab560 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 24 Imported by: 2

Documentation

Overview

Package fcrpaymentmgr - provides common methods facilitate payment process for parties.

Methods like pay, receive payment, top up balance and verify payment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FCRPaymentMgr

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

FCRPaymentMgr - payment manager, manages all payment related functions

func NewFCRPaymentMgr

func NewFCRPaymentMgr(privateKey, lotusAPIAddr, authToken string) (*FCRPaymentMgr, error)

NewFCRPaymentMgr creates a new payment manager.

func (*FCRPaymentMgr) Pay

func (mgr *FCRPaymentMgr) Pay(recipient string, lane uint64, amount *big.Int) (string, string, bool, error)

Pay will generate a voucher and pay the recipient a given amount. Return channel address, voucher, true if needs to top up, and error.

func (*FCRPaymentMgr) Receive

func (mgr *FCRPaymentMgr) Receive(channel string, voucher string) (*big.Int, error)

Receive will receive a given voucher at a given payment channel and return the amount received. Amount of 1000000000000000000 means 1 coin received.

func (*FCRPaymentMgr) Shutdown

func (mgr *FCRPaymentMgr) Shutdown()

Shutdown will safely shutdown the payment manager.

func (*FCRPaymentMgr) Topup

func (mgr *FCRPaymentMgr) Topup(recipient string, amount *big.Int) error

Topup will topup a payment channel to recipient with given amount. (amount of value "1" equals 1 coin)

type SecpSigner

type SecpSigner struct{}

SecpSigner is used to sign, and the following code is taken from lotus source code.

func (SecpSigner) GenPrivate

func (SecpSigner) GenPrivate() ([]byte, error)

GenPrivate generates a private key

func (SecpSigner) Sign

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

Sign signs the given msg using given private key

func (SecpSigner) ToPublic

func (SecpSigner) ToPublic(pk []byte) ([]byte, error)

ToPublic gets the public key of a given private key

func (SecpSigner) Verify

func (SecpSigner) Verify(sig []byte, a address.Address, msg []byte) error

Verify verifies the given msg, using given signature and given public key

Jump to

Keyboard shortcuts

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