Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ require (
github.com/lib/pq v1.10.9
github.com/lightninglabs/aperture v0.3.13-beta
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3
github.com/lightninglabs/lndclient v0.20.0-1
github.com/lightninglabs/lndclient v0.20.0-3
github.com/lightninglabs/neutrino/cache v1.1.2
github.com/lightninglabs/taproot-assets/taprpc v1.0.9
github.com/lightningnetwork/lnd v0.19.0-beta.rc5.0.20250925062351-f293566849f2
github.com/lightningnetwork/lnd v0.20.0-beta.rc1
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/clock v1.1.1
github.com/lightningnetwork/lnd/fn/v2 v2.0.8
Expand Down Expand Up @@ -132,7 +132,7 @@ require (
github.com/lightningnetwork/lnd/healthcheck v1.2.6 // indirect
github.com/lightningnetwork/lnd/kvdb v1.4.16 // indirect
github.com/lightningnetwork/lnd/queue v1.1.1 // indirect
github.com/lightningnetwork/lnd/sqldb v1.0.11-0.20250925062351-f293566849f2 // indirect
github.com/lightningnetwork/lnd/sqldb v1.0.11-0.20250930033359-90c96c7df117 // indirect
github.com/lightningnetwork/lnd/ticker v1.1.1 // indirect
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1140,8 +1140,8 @@ github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3 h1:NuDp6Z+QNM
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3/go.mod h1:bDnEKRN1u13NFBuy/C+bFLhxA5bfd3clT25y76QY0AM=
github.com/lightninglabs/lightning-node-connect/mailbox v1.0.1 h1:RWmohykp3n/DTMWY8b18RNTEcLDf+KT/AZHKYdOObkM=
github.com/lightninglabs/lightning-node-connect/mailbox v1.0.1/go.mod h1:NYtNexZE9gO1eOeegTxmIW9fqanl7eZ9cOrE9yewSAk=
github.com/lightninglabs/lndclient v0.20.0-1 h1:xwDoh7z3bszXc4mkMO6ksEcXhkQw9v0XHJ7fB0LKDNo=
github.com/lightninglabs/lndclient v0.20.0-1/go.mod h1:LcbsTCCd0Qw5C4zlv/YqrPY81XUVA6wN1lA/qEWIs+Y=
github.com/lightninglabs/lndclient v0.20.0-3 h1:hL37EJHYupIEQRSgogA6AFbFQ/6l+A+DuqJMGZ8vm8s=
github.com/lightninglabs/lndclient v0.20.0-3/go.mod h1:GMqsKYJ/CkKY2DgPJfcvvHf98qiwr4fpKir8oAN7TiI=
github.com/lightninglabs/migrate/v4 v4.18.2-9023d66a-fork-pr-2 h1:eFjp1dIB2BhhQp/THKrjLdlYuPugO9UU4kDqu91OX/Q=
github.com/lightninglabs/migrate/v4 v4.18.2-9023d66a-fork-pr-2/go.mod h1:99BKpIi6ruaaXRM1A77eqZ+FWPQ3cfRa+ZVy5bmWMaY=
github.com/lightninglabs/neutrino v0.16.1 h1:5Kz4ToxncEVkpKC6fwUjXKtFKJhuxlG3sBB3MdJTJjs=
Expand All @@ -1152,8 +1152,8 @@ github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9 h1:6D3LrdagJweLLdFm1JNodZsBk6iU4TTsBBFLQ4yiXfI=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9/go.mod h1:EDqJ3MuZIbMq0QI1czTIKDJ/GS8S14RXPwapHw8cw6w=
github.com/lightningnetwork/lnd v0.19.0-beta.rc5.0.20250925062351-f293566849f2 h1:6R3TIiMAJVf4uCAlu1UsrXlYu/1BEEcHEQ19AQNIaJo=
github.com/lightningnetwork/lnd v0.19.0-beta.rc5.0.20250925062351-f293566849f2/go.mod h1:JTrMWr7r8Itu0td4ApgqsAyux2mAZ41LeqKr8V3aFuc=
github.com/lightningnetwork/lnd v0.20.0-beta.rc1 h1:8Rm3/pcSLQI+tpCjKfYADfMjmEVFkrtoEom470siKRA=
github.com/lightningnetwork/lnd v0.20.0-beta.rc1/go.mod h1:SgniBRmo5pE7IImxIfhUofhgdXkutcV9Znrf/rEZ7TM=
github.com/lightningnetwork/lnd/cert v1.2.2 h1:71YK6hogeJtxSxw2teq3eGeuy4rHGKcFf0d0Uy4qBjI=
github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bqGVxViXhX6Cd7HXM6U=
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
Expand All @@ -1166,8 +1166,8 @@ github.com/lightningnetwork/lnd/kvdb v1.4.16 h1:9BZgWdDfjmHRHLS97cz39bVuBAqMc4/p
github.com/lightningnetwork/lnd/kvdb v1.4.16/go.mod h1:HW+bvwkxNaopkz3oIgBV6NEnV4jCEZCACFUcNg4xSjM=
github.com/lightningnetwork/lnd/queue v1.1.1 h1:99ovBlpM9B0FRCGYJo6RSFDlt8/vOkQQZznVb18iNMI=
github.com/lightningnetwork/lnd/queue v1.1.1/go.mod h1:7A6nC1Qrm32FHuhx/mi1cieAiBZo5O6l8IBIoQxvkz4=
github.com/lightningnetwork/lnd/sqldb v1.0.11-0.20250925062351-f293566849f2 h1:HNujNZQwZW1Ve3bflUJ7MWxx2Fe3320TZJvbwd8OAt4=
github.com/lightningnetwork/lnd/sqldb v1.0.11-0.20250925062351-f293566849f2/go.mod h1:oOdZ7vjmAUmI9He+aFHTunnxKVefHZAfJttZdz16hSg=
github.com/lightningnetwork/lnd/sqldb v1.0.11-0.20250930033359-90c96c7df117 h1:f351uGAVayRRe7NEp94kGPC6X7u0lLEvGhLkE+4V3GI=
github.com/lightningnetwork/lnd/sqldb v1.0.11-0.20250930033359-90c96c7df117/go.mod h1:oOdZ7vjmAUmI9He+aFHTunnxKVefHZAfJttZdz16hSg=
github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM=
github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA=
github.com/lightningnetwork/lnd/tlv v1.3.2 h1:MO4FCk7F4k5xPMqVZF6Nb/kOpxlwPrUQpYjmyKny5s0=
Expand Down
7 changes: 7 additions & 0 deletions lndservices/router_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ func (l *LndRouterClient) DeleteLocalAlias(ctx context.Context, alias,
return l.lnd.Router.XDeleteLocalChanAlias(ctx, alias, baseScid)
}

// FindBaseAlias finds the base channel ID for a given alias.
func (l *LndRouterClient) FindBaseAlias(ctx context.Context,
alias lnwire.ShortChannelID) (lnwire.ShortChannelID, error) {

return l.lnd.Router.XFindBaseLocalChanAlias(ctx, alias)
}

// SubscribeHtlcEvents subscribes to a stream of events related to
// HTLC updates.
func (l *LndRouterClient) SubscribeHtlcEvents(
Expand Down
5 changes: 5 additions & 0 deletions rfq/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ type ScidAliasManager interface {
// Manager's maps.
DeleteLocalAlias(ctx context.Context, alias,
baseScid lnwire.ShortChannelID) error

// FindBaseAlias finds the base channel ID for a given alias.
FindBaseAlias(ctx context.Context,
alias lnwire.ShortChannelID) (lnwire.ShortChannelID, error)
}

type (
Expand Down Expand Up @@ -261,6 +265,7 @@ func (m *Manager) startSubsystems(ctx context.Context) error {
HtlcInterceptor: m.cfg.HtlcInterceptor,
HtlcSubscriber: m.cfg.HtlcSubscriber,
AcceptHtlcEvents: m.acceptHtlcEvents,
AliasManager: m.cfg.AliasManager,
SpecifierChecker: m.AssetMatchesSpecifier,
NoOpHTLCs: m.cfg.NoOpHTLCs,
AuxChanNegotiator: m.cfg.AuxChanNegotiator,
Expand Down
54 changes: 48 additions & 6 deletions rfq/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,10 @@ type OrderHandlerCfg struct {
// intercept and accept/reject HTLCs.
HtlcInterceptor HtlcInterceptor

// AliasManager is the SCID alias manager. This component is used to add
// and remove SCID aliases.
AliasManager ScidAliasManager

// AcceptHtlcEvents is a channel that receives accepted HTLCs.
AcceptHtlcEvents chan<- *AcceptHtlcEvent

Expand Down Expand Up @@ -918,7 +922,7 @@ func (h *OrderHandler) subscribeHtlcs(ctx context.Context) error {
func (h *OrderHandler) Start() error {
var startErr error
h.startOnce.Do(func() {
// Start the main event loop in a separate goroutine.
// Start the HTLC interceptor in a separate go routine.
h.Wg.Add(1)
go func() {
defer h.Wg.Done()
Expand All @@ -932,6 +936,12 @@ func (h *OrderHandler) Start() error {
"interception: %v", startErr)
return
}
}()

// Start the main event loop in a separate go routine.
h.Wg.Add(1)
go func() {
defer h.Wg.Done()
Comment on lines +941 to +944
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use h.ContextGuard.Goroutine here (and above if you like)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL go1.25.0 apparently also adds a WaitGroup.Go method for handling the Add(1)/Done pattern.


h.mainEventLoop()
}()
Expand Down Expand Up @@ -968,8 +978,8 @@ func (h *OrderHandler) RegisterAssetSalePolicy(buyAccept rfqmsg.BuyAccept) {
h.policies.Store(policy.AcceptedQuoteId.Scid(), policy)
}

// RegisterAssetPurchasePolicy generates and registers an asset buy policy with the
// order handler. This function takes an incoming sell accept message as an
// RegisterAssetPurchasePolicy generates and registers an asset buy policy with
// the order handler. This function takes an incoming sell accept message as an
// argument.
func (h *OrderHandler) RegisterAssetPurchasePolicy(
sellAccept rfqmsg.SellAccept) {
Expand Down Expand Up @@ -1112,9 +1122,41 @@ func (h *OrderHandler) cleanupStalePolicies() {

h.policies.ForEach(
func(scid SerialisedScid, policy Policy) error {
if policy.HasExpired() {
staleCounter++
h.policies.Delete(scid)
if !policy.HasExpired() {
return nil
}

staleCounter++

// Delete the local entry of this policy.
h.policies.Delete(scid)

ctx, cancel := h.WithCtxQuitCustomTimeout(
h.DefaultTimeout,
)
defer cancel()

aliasScid := lnwire.NewShortChanIDFromInt(
uint64(scid),
)

// Find the base SCID for the alias.
baseScid, err := h.cfg.AliasManager.FindBaseAlias(
ctx, aliasScid,
)
if err != nil {
log.Warnf("Error finding base SCID for alias "+
"%d: %v", scid, err)
return nil
}

// Delete the alias scid mapping on LND.
err = h.cfg.AliasManager.DeleteLocalAlias(
ctx, aliasScid, baseScid,
)
if err != nil {
log.Warnf("Error deleting SCID alias %d: %v",
scid, err)
}

return nil
Expand Down
Loading