Documentation ¶
Index ¶
- Constants
- Variables
- func BestSpendableByLane(ctx context.Context, api BestSpendableAPI, ch address.Address) (map[uint64]*paych.SignedVoucher, error)
- type BestSpendableAPI
- type ChannelInfo
- type ErrInsufficientFunds
- type GetOpts
- type Manager
- func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, ...) (types.BigInt, error)
- func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, ...) (types.BigInt, error)
- func (pm *Manager) AllocateLane(ctx context.Context, ch address.Address) (uint64, error)
- func (pm *Manager) AvailableFunds(ctx context.Context, ch address.Address) (*api.ChannelAvailableFunds, error)
- func (pm *Manager) AvailableFundsByFromTo(ctx context.Context, from address.Address, to address.Address) (*api.ChannelAvailableFunds, error)
- func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, ...) (bool, error)
- func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error
- func (pm *Manager) Collect(ctx context.Context, addr address.Address) (cid.Cid, error)
- func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher paych.SignedVoucher) (*api.VoucherCreateResult, error)
- func (pm *Manager) GetChannelInfo(ctx context.Context, addr address.Address) (*ChannelInfo, error)
- func (pm *Manager) GetPaych(ctx context.Context, from, to address.Address, amt types.BigInt, opts GetOpts) (address.Address, cid.Cid, error)
- func (pm *Manager) GetPaychWaitReady(ctx context.Context, mcid cid.Cid) (address.Address, error)
- func (pm *Manager) ListChannels(ctx context.Context) ([]address.Address, error)
- func (pm *Manager) ListVouchers(ctx context.Context, ch address.Address) ([]*VoucherInfo, error)
- func (pm *Manager) Settle(ctx context.Context, addr address.Address) (cid.Cid, error)
- func (pm *Manager) Start() error
- func (pm *Manager) Stop() error
- func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, ...) (cid.Cid, error)
- type MsgInfo
- type PaychAPI
- type Store
- func (ps *Store) AllocateLane(ctx context.Context, ch address.Address) (uint64, error)
- func (ps *Store) ByAddress(ctx context.Context, addr address.Address) (*ChannelInfo, error)
- func (ps *Store) ByChannelID(ctx context.Context, channelID string) (*ChannelInfo, error)
- func (ps *Store) ByMessageCid(ctx context.Context, mcid cid.Cid) (*ChannelInfo, error)
- func (ps *Store) CreateChannel(ctx context.Context, from address.Address, to address.Address, ...) (*ChannelInfo, error)
- func (ps *Store) GetMessage(ctx context.Context, mcid cid.Cid) (*MsgInfo, error)
- func (ps *Store) ListChannels(ctx context.Context) ([]address.Address, error)
- func (ps *Store) MarkVoucherSubmitted(ctx context.Context, ci *ChannelInfo, sv *paych.SignedVoucher) error
- func (ps *Store) OutboundActiveByFromTo(ctx context.Context, sma stateManagerAPI, from address.Address, ...) (*ChannelInfo, error)
- func (ps *Store) RemoveChannel(ctx context.Context, channelID string) error
- func (ps *Store) SaveMessageResult(ctx context.Context, mcid cid.Cid, msgErr error) error
- func (ps *Store) SaveNewMessage(ctx context.Context, channelID string, mcid cid.Cid) error
- func (ps *Store) TrackChannel(ctx context.Context, ci *ChannelInfo) (*ChannelInfo, error)
- func (ps *Store) VouchersForPaych(ctx context.Context, ch address.Address) ([]*VoucherInfo, error)
- func (ps *Store) WithPendingAddFunds(ctx context.Context) ([]ChannelInfo, error)
- type VoucherInfo
Constants ¶
const ( DirInbound = 1 DirOutbound = 2 )
Variables ¶
var ErrChannelNotTracked = errors.New("channel not tracked")
Functions ¶
func BestSpendableByLane ¶ added in v0.5.2
func BestSpendableByLane(ctx context.Context, api BestSpendableAPI, ch address.Address) (map[uint64]*paych.SignedVoucher, error)
Types ¶
type BestSpendableAPI ¶ added in v0.5.2
type ChannelInfo ¶
type ChannelInfo struct { // ChannelID is a uuid set at channel creation ChannelID string // Channel address - may be nil if the channel hasn't been created yet Channel *address.Address // Control is the address of the local node Control address.Address // Target is the address of the remote node (on the other end of the channel) Target address.Address // Direction indicates if the channel is inbound (Control is the "to" address) // or outbound (Control is the "from" address) Direction uint64 // Vouchers is a list of all vouchers sent on the channel Vouchers []*VoucherInfo // NextLane is the number of the next lane that should be used when the // client requests a new lane (eg to create a voucher for a new deal) NextLane uint64 // Amount added to the channel. // Note: This amount is only used by GetPaych to keep track of how much // has locally been added to the channel. It should reflect the channel's // Balance on chain as long as all operations occur on the same datastore. Amount types.BigInt // AvailableAmount indicates how much afil is non-reserved AvailableAmount types.BigInt // PendingAvailableAmount is available amount that we're awaiting confirmation of PendingAvailableAmount types.BigInt // PendingAmount is the amount that we're awaiting confirmation of PendingAmount types.BigInt // CreateMsg is the CID of a pending create message (while waiting for confirmation) CreateMsg *cid.Cid // AddFundsMsg is the CID of a pending add funds message (while waiting for confirmation) AddFundsMsg *cid.Cid // Settling indicates whether the channel has entered into the settling state Settling bool }
ChannelInfo keeps track of information about a channel
func (*ChannelInfo) MarshalCBOR ¶
func (t *ChannelInfo) MarshalCBOR(w io.Writer) error
func (*ChannelInfo) UnmarshalCBOR ¶
func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error
type ErrInsufficientFunds ¶ added in v0.6.0
type ErrInsufficientFunds struct {
// contains filtered or unexported fields
}
func (*ErrInsufficientFunds) Error ¶ added in v0.6.0
func (e *ErrInsufficientFunds) Error() string
func (*ErrInsufficientFunds) Shortfall ¶ added in v0.6.0
func (e *ErrInsufficientFunds) Shortfall() types.BigInt
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) AddVoucherInbound ¶ added in v0.5.2
func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error)
AddVoucherInbound adds a voucher for an inbound channel. If the channel is not in the store, fetches the channel from state (and checks that the channel To address is owned by the wallet).
func (*Manager) AddVoucherOutbound ¶ added in v0.5.2
func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error)
AddVoucherOutbound adds a voucher for an outbound channel. Returns an error if the channel is not already in the store.
func (*Manager) AllocateLane ¶
func (*Manager) AvailableFunds ¶ added in v0.6.0
func (*Manager) AvailableFundsByFromTo ¶ added in v0.6.0
func (*Manager) CheckVoucherSpendable ¶
func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error)
CheckVoucherSpendable checks if the given voucher is currently spendable
func (*Manager) CheckVoucherValid ¶
func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error
CheckVoucherValid checks if the given voucher is valid (is or could become spendable at some point). If the channel is not in the store, fetches the channel from state (and checks that the channel To address is owned by the wallet).
func (*Manager) CreateVoucher ¶ added in v0.6.0
func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher paych.SignedVoucher) (*api.VoucherCreateResult, error)
func (*Manager) GetChannelInfo ¶
func (pm *Manager) GetChannelInfo(ctx context.Context, addr address.Address) (*ChannelInfo, error)
func (*Manager) GetPaychWaitReady ¶ added in v0.5.0
GetPaychWaitReady waits until the create channel / add funds message with the given message CID arrives. The returned channel address can safely be used against the Manager methods.
func (*Manager) ListChannels ¶
func (*Manager) ListVouchers ¶
func (pm *Manager) ListVouchers(ctx context.Context, ch address.Address) ([]*VoucherInfo, error)
func (*Manager) Start ¶ added in v0.5.0
Start restarts tracking of any messages that were sent to chain.
func (*Manager) SubmitVoucher ¶ added in v0.5.5
func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error)
TODO: secret vs proof doesn't make sense, there is only one, not two
type MsgInfo ¶ added in v0.5.0
type MsgInfo struct { // ChannelID links the message to a channel ChannelID string // MsgCid is the CID of the message MsgCid cid.Cid // Received indicates whether a response has been received Received bool // Err is the error received in the response Err string }
MsgInfo stores information about a create channel / add funds message that has been sent
type PaychAPI ¶ added in v0.5.0
type PaychAPI interface { StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error) StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) MpoolPushMessage(ctx context.Context, msg *types.Message, maxFee *api.MessageSendSpec) (*types.SignedMessage, error) WalletHas(ctx context.Context, addr address.Address) (bool, error) WalletSign(ctx context.Context, k address.Address, msg []byte) (*crypto.Signature, error) StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error) }
paychAPI defines the API methods needed by the payment channel manager
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AllocateLane ¶
AllocateLane allocates a new lane for the given channel
func (*Store) ByAddress ¶ added in v0.5.0
func (ps *Store) ByAddress(ctx context.Context, addr address.Address) (*ChannelInfo, error)
ByAddress gets the channel that matches the given address
func (*Store) ByChannelID ¶ added in v0.5.0
ByChannelID gets channel info by channel ID
func (*Store) ByMessageCid ¶ added in v0.5.0
func (ps *Store) ByMessageCid(ctx context.Context, mcid cid.Cid) (*ChannelInfo, error)
ByMessageCid gets the channel associated with a message
func (*Store) CreateChannel ¶ added in v0.5.0
func (ps *Store) CreateChannel(ctx context.Context, from address.Address, to address.Address, createMsgCid cid.Cid, amt, avail types.BigInt) (*ChannelInfo, error)
CreateChannel creates an outbound channel for the given from / to
func (*Store) GetMessage ¶ added in v0.5.0
GetMessage gets the message info for a given message CID
func (*Store) ListChannels ¶
ListChannels returns the addresses of all channels that have been created
func (*Store) MarkVoucherSubmitted ¶ added in v0.5.5
func (ps *Store) MarkVoucherSubmitted(ctx context.Context, ci *ChannelInfo, sv *paych.SignedVoucher) error
func (*Store) OutboundActiveByFromTo ¶ added in v0.5.0
func (ps *Store) OutboundActiveByFromTo(ctx context.Context, sma stateManagerAPI, from address.Address, to address.Address) (*ChannelInfo, error)
OutboundActiveByFromTo looks for outbound channels that have not been settled, with the given from / to addresses
func (*Store) RemoveChannel ¶ added in v0.5.0
RemoveChannel removes the channel with the given channel ID
func (*Store) SaveMessageResult ¶ added in v0.5.0
SaveMessageResult is called when the result of a message is received
func (*Store) SaveNewMessage ¶ added in v0.5.0
SaveNewMessage is called when a message is sent
func (*Store) TrackChannel ¶
func (ps *Store) TrackChannel(ctx context.Context, ci *ChannelInfo) (*ChannelInfo, error)
TrackChannel stores a channel, returning an error if the channel was already being tracked
func (*Store) VouchersForPaych ¶
func (ps *Store) VouchersForPaych(ctx context.Context, ch address.Address) ([]*VoucherInfo, error)
VouchersForPaych gets the vouchers for the given channel
func (*Store) WithPendingAddFunds ¶ added in v0.5.0
func (ps *Store) WithPendingAddFunds(ctx context.Context) ([]ChannelInfo, error)
WithPendingAddFunds is used on startup to find channels for which a create channel or add funds message has been sent, but lotus shut down before the response was received.
type VoucherInfo ¶
type VoucherInfo struct { Voucher *paych.SignedVoucher Proof []byte // ignored Submitted bool }
func (*VoucherInfo) MarshalCBOR ¶
func (t *VoucherInfo) MarshalCBOR(w io.Writer) error
func (*VoucherInfo) UnmarshalCBOR ¶
func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) error