payment

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDepositTimelocked = errors.New("deposit is timelocked")

ErrDepositTimelocked is returned when a balance is checked but the deposit is timelocked.

View Source
var ErrWithdrawDisabled = errors.New("withdraw is disabled")

ErrWithdrawDisabled is returned when the PaymentService is initialized in read-only mode.

Functions

func ContractPayment added in v0.2.3

func ContractPayment(storeDriver store.AccountStore, address common.Address, backend bind.ContractBackend, transactOpts *bind.TransactOpts) (*contractPayment, error)

ContractPayment returns an abstraction around a vipnode pool payment contract. Contract implements store.NodeBalanceStore.

func SetLogger added in v0.2.3

func SetLogger(w io.Writer)

SetLogger overrides the logger output for this package.

Types

type AccountResponse added in v0.2.6

type AccountResponse struct {
	NodeShortIDs []string      `json:"node_short_ids"`
	Balance      store.Balance `json:"balance"`
}

AccountResponse is returned on RPC calls to pool_account

type AddressMismatchError added in v0.2.4

type AddressMismatchError struct {
	Prelude string
	Want    common.Address
	Got     common.Address
}

AddressMismatchError is used when we require a specific address but the wrong one was provided.

func (AddressMismatchError) Error added in v0.2.4

func (e AddressMismatchError) Error() string

type PaymentService added in v0.2.3

type PaymentService struct {
	NonceStore   store.NonceStore
	AccountStore store.AccountStore
	BalanceStore store.BalanceStore

	// Settle is a function that disburses the given paymentAmount and replaces
	// the current "on-chain" balance with newBalance. It returns a transaction
	// ID. If nil, then Withdraw calls will error with ErrWithdrawDisabled.
	Settle SettleHandler
	// WithdrawFee (optional) takes the withdraw total and returns the new total to withdraw (with any fees applied).
	WithdrawFee func(*big.Int) *big.Int
	// WithdrawMin (optional) is the minimum amount required to allow a withdraw.
	WithdrawMin *big.Int
}

PaymentService is an RPC service for managing pool payment-relatd requests.

func (*PaymentService) Account added in v0.2.6

func (p *PaymentService) Account(ctx context.Context, wallet string) (*AccountResponse, error)

Account is an *unverified* endpoint for retrieving the balance and list of node shortIDs associated with a wallet.

func (*PaymentService) AddNode added in v0.2.3

func (p *PaymentService) AddNode(ctx context.Context, sig string, wallet string, nonce int64, nodeID string) error

AddNode authorizes a nodeID to be spent by a wallet account.

func (*PaymentService) Withdraw added in v0.2.3

func (p *PaymentService) Withdraw(ctx context.Context, sig string, wallet string, nonce int64) error

Withdraw schedules a balance withdraw for an account

type SettleHandler added in v0.2.4

type SettleHandler func(account store.Account, paymentAmount *big.Int, newBalance *big.Int) (txID string, err error)

SettleHandler is a function that settles the balance of a given account by updating the internal balance to newBalance and disbursing paymentAmount.

type WithdrawBalanceMinimumError added in v0.2.4

type WithdrawBalanceMinimumError struct {
	Balance *big.Int
	Minimum *big.Int
}

WithdrawBalanceMinimumError is returned when the account balance is below the configured minimum to withdraw.

func (WithdrawBalanceMinimumError) Error added in v0.2.4

func (err WithdrawBalanceMinimumError) Error() string

Jump to

Keyboard shortcuts

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