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") ErrCashOut = errors.New("cashout not completing") )
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, peer boson.Address, 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
type ChequeSigner ¶
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) VerifyCheque(cheque *SignedCheque, chaindID int64) (common.Address, error) PutSendCheque(ctx context.Context, cheque *Cheque, chainAddress common.Address) error PutReceivedCheques(chainAddress common.Address, cheque SignedCheque) 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) PutChainRetrieveTraffic(chainAddress common.Address, traffic *big.Int) error PutChainTransferTraffic(chainAddress common.Address, traffic *big.Int) error GetChainRetrieveTraffic(chainAddress common.Address) (traffic *big.Int, err error) GetChainTransferTraffic(chainAddress common.Address) (traffic *big.Int, err error) // GetAllRetrieveTransferAddresses return all addresses that we have transferred or retrieved traffic GetAllRetrieveTransferAddresses() (map[common.Address]struct{}, 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 ¶
SignedCheque represents a cheque together with its signature
func (*SignedCheque) Equal ¶
func (cheque *SignedCheque) Equal(other *SignedCheque) bool
Click to show internal directories.
Click to hide internal directories.