Documentation ¶
Index ¶
- Constants
- func GetPayee(participants []types.Address) types.Address
- func GetPayer(participants []types.Address) types.Address
- type ReceiveVoucherSummary
- type Voucher
- type VoucherInfo
- type VoucherManager
- func (vm *VoucherManager) ChannelRegistered(channelId types.Destination) bool
- func (vm *VoucherManager) Paid(chanId types.Destination) (*big.Int, error)
- func (vm *VoucherManager) Pay(channelId types.Destination, amount *big.Int, pk []byte) (Voucher, error)
- func (vm *VoucherManager) Receive(voucher Voucher) (total *big.Int, delta *big.Int, err error)
- func (vm *VoucherManager) Register(channelId types.Destination, payer common.Address, payee common.Address, ...) error
- func (vm *VoucherManager) Remaining(chanId types.Destination) (*big.Int, error)
- func (vm *VoucherManager) Remove(channelId types.Destination) error
- type VoucherStore
Constants ¶
const PAYER_INDEX = 0
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Voucher ¶
A Voucher signed by Alice can be used by Bob to redeem payments in case of a misbehaving Alice.
During normal operation, Alice & Bob would terminate the channel with an outcome reflecting the largest amount signed by Alice. For instance,
- if the channel started with balances {alice: 100, bob: 0}
- and the biggest voucher signed by alice had amount = 20
- then Alice and Bob would cooperatively conclude the channel with outcome {alice: 80, bob: 20}
type VoucherInfo ¶
type VoucherInfo struct { ChannelPayer common.Address ChannelPayee common.Address StartingBalance *big.Int LargestVoucher Voucher }
VoucherInfo contains the largest voucher we've received on a channel. As well as details about the balance and who the payee/payer is.
func (*VoucherInfo) Paid ¶
func (v *VoucherInfo) Paid() *big.Int
Paid is the amount of funds that already have been used as payments
func (*VoucherInfo) Remaining ¶
func (v *VoucherInfo) Remaining() *big.Int
Remaining returns the amount of funds left to be used as payments
type VoucherManager ¶
type VoucherManager struct {
// contains filtered or unexported fields
}
VoucherInfo stores the status of payments for a given payment channel. VoucherManager receives and generates vouchers. It is responsible for storing vouchers.
func NewVoucherManager ¶
func NewVoucherManager(me types.Address, store VoucherStore) *VoucherManager
NewVoucherManager creates a new voucher manager
func (*VoucherManager) ChannelRegistered ¶
func (vm *VoucherManager) ChannelRegistered(channelId types.Destination) bool
ChannelRegistered returns whether a channel has been registered with the voucher manager or not
func (*VoucherManager) Paid ¶
func (vm *VoucherManager) Paid(chanId types.Destination) (*big.Int, error)
Paid returns the total amount paid so far on a channel
func (*VoucherManager) Pay ¶
func (vm *VoucherManager) Pay(channelId types.Destination, amount *big.Int, pk []byte) (Voucher, error)
Pay will deduct amount from balance and add it to paid, returning a signed voucher for the total amount paid.
func (*VoucherManager) Receive ¶
Receive validates the incoming voucher, and returns the total amount received so far as well as the amount received from the voucher
func (*VoucherManager) Register ¶
func (vm *VoucherManager) Register(channelId types.Destination, payer common.Address, payee common.Address, startingBalance *big.Int) error
Register registers a channel for use, given the payer, payee and starting balance of the channel
func (*VoucherManager) Remaining ¶
func (vm *VoucherManager) Remaining(chanId types.Destination) (*big.Int, error)
Remaining returns the remaining amount of funds in the channel
func (*VoucherManager) Remove ¶
func (vm *VoucherManager) Remove(channelId types.Destination) error
Remove deletes the channel's status
type VoucherStore ¶
type VoucherStore interface { SetVoucherInfo(channelId types.Destination, v VoucherInfo) error GetVoucherInfo(channelId types.Destination) (v *VoucherInfo, err error) RemoveVoucherInfo(channelId types.Destination) error }
VoucherStore is an interface for storing voucher information that the voucher manager expects. To avoid import cycles, this interface is defined in the payments package, but implemented in the store package.