fees

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinimumFeeAmount = 3 * txbuilder.MaxFee
)

Variables

View Source
var (
	ErrMinimumFeeAmount         = errors.New("insufficient fee amount")
	ErrLockedBillWrongPartition = errors.New("locked bill for wrong partition")
)

Functions

This section is empty.

Types

type AddFeeCmd

type AddFeeCmd struct {
	AccountIndex uint64
	Amount       uint64
}

type AddFeeCmdResponse

type AddFeeCmdResponse struct {
	TransferFC *wallet.Proof
	AddFC      *wallet.Proof
}

type FeeManager

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

func NewFeeManager

func NewFeeManager(
	am account.Manager,
	unitLocker UnitLocker,
	moneySystemID []byte,
	moneyTxPublisher TxPublisher,
	moneyBackendClient MoneyClient,
	partitionSystemID []byte,
	partitionTxPublisher TxPublisher,
	partitionBackendClient PartitionDataProvider,
	fcrIDFn GenerateFcrIDFromPublicKey,
) *FeeManager

NewFeeManager creates new fee credit manager. Parameters: - account manager - unit locker

- money partition:

  • systemID
  • tx publisher with proof confirmation
  • money backend client

- user partition:

  • systemID
  • tx publisher with proof confirmation
  • partition data provider e.g. backend client

func (*FeeManager) AddFeeCredit

func (w *FeeManager) AddFeeCredit(ctx context.Context, cmd AddFeeCmd) (*AddFeeCmdResponse, error)

AddFeeCredit creates fee credit for the given amount. Wallet must have a bill large enough for the required amount plus fees. Returns transferFC and/or addFC transaction proofs.

func (*FeeManager) Close

func (w *FeeManager) Close()

func (*FeeManager) GetFeeCredit

func (w *FeeManager) GetFeeCredit(ctx context.Context, cmd GetFeeCreditCmd) (*wallet.Bill, error)

GetFeeCredit returns fee credit bill for given account, can return nil if fee credit bill has not been created yet.

func (*FeeManager) ReclaimFeeCredit

func (w *FeeManager) ReclaimFeeCredit(ctx context.Context, cmd ReclaimFeeCmd) (*ReclaimFeeCmdResponse, error)

ReclaimFeeCredit reclaims fee credit. Reclaimed fee credit is added to the largest bill in wallet. Returns closeFC and/or reclaimFC transaction proofs.

type GenerateFcrIDFromPublicKey

type GenerateFcrIDFromPublicKey func(shardPart, pubKey []byte) types.UnitID

GenerateFcrIDFromPublicKey function to generate fee credit UnitID from shard number nad public key

type GetFeeCreditCmd

type GetFeeCreditCmd struct {
	AccountIndex uint64
}

type MoneyClient

type MoneyClient interface {
	GetBills(ctx context.Context, pubKey []byte) ([]*wallet.Bill, error)
	GetLockedFeeCredit(ctx context.Context, systemID []byte, fcbID []byte) (*types.TransactionRecord, error)
	PartitionDataProvider
}

type PartitionDataProvider

type PartitionDataProvider interface {
	GetRoundNumber(ctx context.Context) (uint64, error)
	GetFeeCreditBill(ctx context.Context, unitID types.UnitID) (*wallet.Bill, error)
	GetTxProof(ctx context.Context, unitID types.UnitID, txHash wallet.TxHash) (*wallet.Proof, error)
}

type ReclaimFeeCmd

type ReclaimFeeCmd struct {
	AccountIndex uint64
}

type ReclaimFeeCmdResponse

type ReclaimFeeCmdResponse struct {
	CloseFC   *wallet.Proof
	ReclaimFC *wallet.Proof
}

type TxPublisher

type TxPublisher interface {
	SendTx(ctx context.Context, tx *types.TransactionOrder, senderPubKey []byte) (*wallet.Proof, error)
	Close()
}

type UnitLocker

type UnitLocker interface {
	GetUnits(accountID []byte) ([]*unitlock.LockedUnit, error)
	GetUnit(accountID, unitID []byte) (*unitlock.LockedUnit, error)
	LockUnit(lockedBill *unitlock.LockedUnit) error
	UnlockUnit(accountID, unitID []byte) error
	Close() error
}

Jump to

Keyboard shortcuts

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