Documentation
¶
Index ¶
- Constants
- Variables
- func AbandonCanceledChannels(matchedOrders map[order.Nonce][]*order.MatchedOrder, batchTx *wire.MsgTx, ...) error
- func CancelPendingFundingShims(matchedOrders map[order.Nonce][]*order.MatchedOrder, baseClient BaseClient, ...) error
- func UseLogger(logger btclog.Logger)
- type BaseClient
- type Manager
- func (m *Manager) BatchChannelSetup(batch *order.Batch, quit <-chan struct{}) (map[wire.OutPoint]*chaninfo.ChannelInfo, error)
- func (m *Manager) DeletePendingBatch() error
- func (m *Manager) PrepChannelFunding(batch *order.Batch, traderBehindTor bool, quit <-chan struct{}) error
- func (m *Manager) RemovePendingBatchArtifacts(matchedOrders map[order.Nonce][]*order.MatchedOrder, batchTx *wire.MsgTx) error
- type MatchRejectErr
Constants ¶
const Subsystem = "FNDG"
Variables ¶
var ( // DefaultBatchStepTimeout is the default time we allow an action that // blocks the batch conversation (like peer connection establishment or // channel open) to take. If any action takes longer, we might reject // the order from that slow peer. This value SHOULD be lower than the // defaultMsgTimeout on the server side otherwise nodes might get kicked // out of the match making process for timing out even though it was // their peer's fault. DefaultBatchStepTimeout = 15 * time.Second )
Functions ¶
func AbandonCanceledChannels ¶
func AbandonCanceledChannels(matchedOrders map[order.Nonce][]*order.MatchedOrder, batchTx *wire.MsgTx, wallet lndclient.WalletKitClient, baseClient BaseClient, fetchOrder order.Fetcher) error
AbandonCanceledChannels removes all channels from lnd's channel database that were created for an iteration of a batch that never made it to chain in the provided configuration. This should be called whenever a batch is replaced with an updated version because some traders were offline or rejected the batch. If a non-nil error is returned, something with reading the local order or extracting the channel outpoint went wrong and we should fail hard. If the channel cannot be abandoned for some reason, the error is just logged but not returned.
func CancelPendingFundingShims ¶
func CancelPendingFundingShims(matchedOrders map[order.Nonce][]*order.MatchedOrder, baseClient BaseClient, fetchOrder order.Fetcher) error
CancelPendingFundingShims cancels all funding shims we registered when preparing for the orders in a batch. This should be called if for any reason we need to reject the batch, so we're able to process any subsequent modified batches.
Types ¶
type BaseClient ¶
type BaseClient interface {
// FundingStateStep is an advanced funding related call that allows the
// caller to either execute some preparatory steps for a funding
// workflow, or manually progress a funding workflow.
FundingStateStep(ctx context.Context, req *lnrpc.FundingTransitionMsg,
opts ...grpc.CallOption) (*lnrpc.FundingStateStepResp, error)
// OpenChannel attempts to open a singly funded channel specified in the
// request to a remote peer.
OpenChannel(ctx context.Context, req *lnrpc.OpenChannelRequest,
opts ...grpc.CallOption) (lnrpc.Lightning_OpenChannelClient,
error)
// ListPeers returns a verbose listing of all currently active peers.
ListPeers(ctx context.Context, req *lnrpc.ListPeersRequest,
opts ...grpc.CallOption) (*lnrpc.ListPeersResponse, error)
// SubscribePeerEvents creates a uni-directional stream from the server
// to the client in which any events relevant to the state of peers are
// sent over. Events include peers going online and offline.
SubscribePeerEvents(ctx context.Context, r *lnrpc.PeerEventSubscription,
opts ...grpc.CallOption) (
lnrpc.Lightning_SubscribePeerEventsClient, error)
// AbandonChannel removes all channel state from the database except for
// a close summary. This method can be used to get rid of permanently
// unusable channels due to bugs fixed in newer versions of lnd. This
// method can also be used to remove externally funded channels where
// the funding transaction was never broadcast. Only available for
// non-externally funded channels in dev build.
AbandonChannel(ctx context.Context, in *lnrpc.AbandonChannelRequest,
opts ...grpc.CallOption) (*lnrpc.AbandonChannelResponse, error)
}
BaseClient is an interface that contains all methods necessary to open a channel with a funding shim and query peer connections.
type Manager ¶
type Manager struct {
// DB is the client database.
DB *clientdb.DB
// WalletKit is an lndclient wrapped walletrpc client.
WalletKit lndclient.WalletKitClient
// LightningClient is an lndclient wrapped lnrpc client.
LightningClient lndclient.LightningClient
// BaseClient is a raw lnrpc client that implements all methods the
// funding manager needs.
BaseClient BaseClient
// NewNodesOnly specifies if the funding manager should only accept
// matched orders with channels from new nodes that the connected lnd
// node doesn't already have channels with.
NewNodesOnly bool
// PendingOpenChannels is a channel through which we'll receive
// notifications for pending open channels resulting from a successful
// batch.
PendingOpenChannels chan *lnrpc.ChannelEventUpdate_PendingOpenChannel
// BatchStepTimeout is the timeout the manager uses when executing a
// single batch step.
BatchStepTimeout time.Duration
}
func (*Manager) BatchChannelSetup ¶
func (m *Manager) BatchChannelSetup(batch *order.Batch, quit <-chan struct{}) (map[wire.OutPoint]*chaninfo.ChannelInfo, error)
BatchChannelSetup will attempt to establish new funding flows with all matched takers (people buying our channels) in the passed batch. This method will block until the channel is considered pending. Once this phase is complete, and the batch execution transaction broadcast, the channel will be finalized and locked in.
func (*Manager) DeletePendingBatch ¶
DeletePendingBatch removes all references to the current pending batch without applying its staged updates to accounts and orders. If no pending batch exists, this acts as a no-op.
NOTE: This is part of the auctioneer.BatchCleaner interface.
func (*Manager) PrepChannelFunding ¶
func (m *Manager) PrepChannelFunding(batch *order.Batch, traderBehindTor bool, quit <-chan struct{}) error
PrepChannelFunding preps the backing node to either receive or initiate a channel funding based on the items in the order batch.
func (*Manager) RemovePendingBatchArtifacts ¶
func (m *Manager) RemovePendingBatchArtifacts( matchedOrders map[order.Nonce][]*order.MatchedOrder, batchTx *wire.MsgTx) error
RemovePendingBatchArtifacts removes any funding shims or pending channels from a batch that was never finalized. Some non-terminal errors are logged only and not returned. Therefore if this method returns an error, it should be handled as terminal error.
NOTE: This is part of the auctioneer.BatchCleaner interface.
type MatchRejectErr ¶
type MatchRejectErr struct {
// RejectedOrders is the map of matches we reject, keyed with our order
// nonce.
RejectedOrders map[order.Nonce]*auctioneerrpc.OrderReject
}
MatchRejectErr is an error type that is returned from the funding manager if the trader rejects certain orders instead of the whole batch.
func (*MatchRejectErr) Error ¶
func (e *MatchRejectErr) Error() string
Error returns the underlying error string.
NOTE: This is part of the error interface.