Skip to content

Commit

Permalink
Merge pull request #1186 from GeorgeTsagk/rfq-track-accepted-amount
Browse files Browse the repository at this point in the history
Track HTLCs in rfq policies
  • Loading branch information
guggero authored Dec 6, 2024
2 parents 3d3b254 + 8d9bb75 commit 8113fa8
Show file tree
Hide file tree
Showing 4 changed files with 248 additions and 10 deletions.
11 changes: 11 additions & 0 deletions chain_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/lightninglabs/taproot-assets/tapgarden"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/funding"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
Expand Down Expand Up @@ -376,9 +377,19 @@ func (l *LndRouterClient) DeleteLocalAlias(ctx context.Context, alias,
return l.lnd.Router.XDeleteLocalChanAlias(ctx, alias, baseScid)
}

// SubscribeHtlcEvents subscribes to a stream of events related to
// HTLC updates.
func (l *LndRouterClient) SubscribeHtlcEvents(
ctx context.Context) (<-chan *routerrpc.HtlcEvent,
<-chan error, error) {

return l.lnd.Router.SubscribeHtlcEvents(ctx)
}

// Ensure LndRouterClient implements the rfq.HtlcInterceptor interface.
var _ rfq.HtlcInterceptor = (*LndRouterClient)(nil)
var _ rfq.ScidAliasManager = (*LndRouterClient)(nil)
var _ rfq.HtlcSubscriber = (*LndRouterClient)(nil)

// LndInvoicesClient is an LND invoices RPC client.
type LndInvoicesClient struct {
Expand Down
5 changes: 5 additions & 0 deletions rfq/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ type ManagerCfg struct {
// intercept and accept/reject HTLCs.
HtlcInterceptor HtlcInterceptor

// HtlcSubscriber is a subscriber that is used to retrieve live HTLC
// event updates.
HtlcSubscriber HtlcSubscriber

// PriceOracle is the price oracle that the RFQ manager will use to
// determine whether a quote is accepted or rejected.
PriceOracle PriceOracle
Expand Down Expand Up @@ -207,6 +211,7 @@ func (m *Manager) startSubsystems(ctx context.Context) error {
m.orderHandler, err = NewOrderHandler(OrderHandlerCfg{
CleanupInterval: CacheCleanupInterval,
HtlcInterceptor: m.cfg.HtlcInterceptor,
HtlcSubscriber: m.cfg.HtlcSubscriber,
AcceptHtlcEvents: m.acceptHtlcEvents,
})
if err != nil {
Expand Down
Loading

0 comments on commit 8113fa8

Please sign in to comment.