cheque

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: BSD-3-Clause Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoCheque is the error returned if there is no prior cheque for a chainAddress or beneficiary.
	ErrNoCheque = errors.New("no cheque")
	// ErrChequeNotIncreasing is the error returned if the cheque amount is the same or lower.
	ErrChequeNotIncreasing = errors.New("cheque cumulativePayout is not increasing")
	// ErrChequeInvalid is the error returned if the cheque itself is invalid.
	ErrChequeInvalid = errors.New("invalid cheque")
	// ErrWrongBeneficiary is the error returned if the cheque has the wrong beneficiary.
	ErrWrongBeneficiary = errors.New("wrong beneficiary")
	// ErrBouncingCheque is the error returned if the chainAddress is demonstrably illiquid.
	ErrBouncingCheque = errors.New("bouncing cheque")
)
View Source
var ChequeTypes = eip712.Types{
	"EIP712Domain": eip712.EIP712DomainType,
	"Cheque": []eip712.Type{
		{
			Name: "recipient",
			Type: "address",
		},
		{
			Name: "beneficiary",
			Type: "address",
		},
		{
			Name: "cumulativePayout",
			Type: "uint256",
		},
	},
}

ChequeTypes are the needed type descriptions for cheque signing

Functions

func RecoverCheque

func RecoverCheque(cheque *SignedCheque, chaindID int64) (common.Address, error)

RecoverCheque recovers the issuer ethereum address from a signed cheque

Types

type CashoutService

type CashoutService interface {
	// CashCheque
	CashCheque(ctx context.Context, beneficiary common.Address, recipient common.Address) (common.Hash, error)
	//WaitForReceipt
	WaitForReceipt(ctx context.Context, ctxHash common.Hash) (uint64, error)
}

CashoutService is the service responsible for managing cashout actions

func NewCashoutService

func NewCashoutService(store storage.StateStorer, transactionService chain.Transaction, trafficService chain.Traffic, chequeStore ChequeStore, trafficContractAddr common.Address) CashoutService

NewCashoutService creates a new CashoutService

type Cheque

type Cheque struct {
	Recipient        common.Address
	Beneficiary      common.Address
	CumulativePayout *big.Int
}

Cheque represents a cheque for a SimpleSwap chequebook

func (*Cheque) Equal

func (cheque *Cheque) Equal(other *Cheque) bool

func (*Cheque) String

func (cheque *Cheque) String() string

type ChequeSigner

type ChequeSigner interface {
	// Sign signs a cheque
	Sign(cheque *Cheque) ([]byte, error)
}

ChequeSigner signs cheque

func NewChequeSigner

func NewChequeSigner(signer crypto.Signer, chainID int64) ChequeSigner

NewChequeSigner creates a new cheque signer for the given chainID.

type ChequeStore

type ChequeStore interface {
	// ReceiveCheque verifies and stores a cheque. It returns the totam amount earned.
	ReceiveCheque(ctx context.Context, cheque *SignedCheque) (*big.Int, error)

	PutSendCheque(ctx context.Context, cheque *Cheque, chainAddress common.Address) error
	// LastReceivedCheque returns the last cheque we received from a specific chainAddress.
	LastReceivedCheque(chainAddress common.Address) (*SignedCheque, error)
	// LastReceivedCheques returns the last received cheques from every known chainAddress.
	LastReceivedCheques() (map[common.Address]*SignedCheque, error)

	LastSendCheque(chainAddress common.Address) (*Cheque, error)

	LastSendCheques() (map[common.Address]*Cheque, error)

	PutRetrieveTraffic(chainAddress common.Address, traffic *big.Int) error

	PutTransferTraffic(chainAddress common.Address, traffic *big.Int) error

	GetRetrieveTraffic(chainAddress common.Address) (traffic *big.Int, err error)

	GetTransferTraffic(chainAddress common.Address) (traffic *big.Int, err error)

	PutReceivedCheques(chainAddress common.Address, cheque SignedCheque) error

	VerifyCheque(cheque *SignedCheque, chaindID int64) (common.Address, error)
}

ChequeStore handles the verification and storage of received cheques

func NewChequeStore

func NewChequeStore(
	store storage.StateStorer,
	recipient common.Address,
	recoverChequeFunc RecoverChequeFunc,
	chainID int64) ChequeStore

NewChequeStore creates new ChequeStore

type RecoverChequeFunc

type RecoverChequeFunc func(cheque *SignedCheque, chainID int64) (common.Address, error)

type SignedCheque

type SignedCheque struct {
	Cheque
	Signature []byte
}

SignedCheque represents a cheque together with its signature

func (*SignedCheque) Equal

func (cheque *SignedCheque) Equal(other *SignedCheque) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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