Skip to content

Commit fdb7620

Browse files
committed
lndservices: move router_client.go into the new package
1 parent 4394aa2 commit fdb7620

File tree

3 files changed

+61
-54
lines changed

3 files changed

+61
-54
lines changed

lnd_services.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,9 @@ import (
44
"context"
55

66
"github.com/lightninglabs/lndclient"
7-
"github.com/lightninglabs/taproot-assets/rfq"
87
"github.com/lightninglabs/taproot-assets/tapchannel"
9-
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
10-
"github.com/lightningnetwork/lnd/lnwire"
118
)
129

13-
// LndRouterClient is an LND router RPC client.
14-
type LndRouterClient struct {
15-
lnd *lndclient.LndServices
16-
}
17-
18-
// NewLndRouterClient creates a new LND router client for a given LND service.
19-
func NewLndRouterClient(lnd *lndclient.LndServices) *LndRouterClient {
20-
return &LndRouterClient{
21-
lnd: lnd,
22-
}
23-
}
24-
25-
// InterceptHtlcs intercepts all incoming HTLCs and calls the given handler
26-
// function with the HTLC details. The handler function can then decide whether
27-
// to accept or reject the HTLC.
28-
func (l *LndRouterClient) InterceptHtlcs(
29-
ctx context.Context, handler lndclient.HtlcInterceptHandler) error {
30-
31-
return l.lnd.Router.InterceptHtlcs(ctx, handler)
32-
}
33-
34-
// AddLocalAlias adds a database mapping from the passed alias to the passed
35-
// base SCID.
36-
func (l *LndRouterClient) AddLocalAlias(ctx context.Context, alias,
37-
baseScid lnwire.ShortChannelID) error {
38-
39-
return l.lnd.Router.XAddLocalChanAlias(ctx, alias, baseScid)
40-
}
41-
42-
// DeleteLocalAlias removes a mapping from the database and the Manager's maps.
43-
func (l *LndRouterClient) DeleteLocalAlias(ctx context.Context, alias,
44-
baseScid lnwire.ShortChannelID) error {
45-
46-
return l.lnd.Router.XDeleteLocalChanAlias(ctx, alias, baseScid)
47-
}
48-
49-
// SubscribeHtlcEvents subscribes to a stream of events related to
50-
// HTLC updates.
51-
func (l *LndRouterClient) SubscribeHtlcEvents(
52-
ctx context.Context) (<-chan *routerrpc.HtlcEvent,
53-
<-chan error, error) {
54-
55-
return l.lnd.Router.SubscribeHtlcEvents(ctx)
56-
}
57-
58-
// Ensure LndRouterClient implements the rfq.HtlcInterceptor interface.
59-
var _ rfq.HtlcInterceptor = (*LndRouterClient)(nil)
60-
var _ rfq.ScidAliasManager = (*LndRouterClient)(nil)
61-
var _ rfq.HtlcSubscriber = (*LndRouterClient)(nil)
62-
6310
// LndInvoicesClient is an LND invoices RPC client.
6411
type LndInvoicesClient struct {
6512
lnd *lndclient.LndServices

lndservices/router_client.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package lndservices
2+
3+
import (
4+
"context"
5+
6+
"github.com/lightninglabs/lndclient"
7+
"github.com/lightninglabs/taproot-assets/rfq"
8+
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
9+
"github.com/lightningnetwork/lnd/lnwire"
10+
)
11+
12+
// LndRouterClient is an LND router RPC client.
13+
type LndRouterClient struct {
14+
lnd *lndclient.LndServices
15+
}
16+
17+
// NewLndRouterClient creates a new LND router client for a given LND service.
18+
func NewLndRouterClient(lnd *lndclient.LndServices) *LndRouterClient {
19+
return &LndRouterClient{
20+
lnd: lnd,
21+
}
22+
}
23+
24+
// InterceptHtlcs intercepts all incoming HTLCs and calls the given handler
25+
// function with the HTLC details. The handler function can then decide whether
26+
// to accept or reject the HTLC.
27+
func (l *LndRouterClient) InterceptHtlcs(
28+
ctx context.Context, handler lndclient.HtlcInterceptHandler) error {
29+
30+
return l.lnd.Router.InterceptHtlcs(ctx, handler)
31+
}
32+
33+
// AddLocalAlias adds a database mapping from the passed alias to the passed
34+
// base SCID.
35+
func (l *LndRouterClient) AddLocalAlias(ctx context.Context, alias,
36+
baseScid lnwire.ShortChannelID) error {
37+
38+
return l.lnd.Router.XAddLocalChanAlias(ctx, alias, baseScid)
39+
}
40+
41+
// DeleteLocalAlias removes a mapping from the database and the Manager's maps.
42+
func (l *LndRouterClient) DeleteLocalAlias(ctx context.Context, alias,
43+
baseScid lnwire.ShortChannelID) error {
44+
45+
return l.lnd.Router.XDeleteLocalChanAlias(ctx, alias, baseScid)
46+
}
47+
48+
// SubscribeHtlcEvents subscribes to a stream of events related to
49+
// HTLC updates.
50+
func (l *LndRouterClient) SubscribeHtlcEvents(
51+
ctx context.Context) (<-chan *routerrpc.HtlcEvent,
52+
<-chan error, error) {
53+
54+
return l.lnd.Router.SubscribeHtlcEvents(ctx)
55+
}
56+
57+
// Ensure LndRouterClient implements the rfq.HtlcInterceptor interface.
58+
var _ rfq.HtlcInterceptor = (*LndRouterClient)(nil)
59+
var _ rfq.ScidAliasManager = (*LndRouterClient)(nil)
60+
var _ rfq.HtlcSubscriber = (*LndRouterClient)(nil)

tapcfg/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
109109
walletAnchor := tap.NewLndRpcWalletAnchor(lndServices)
110110
chainBridge := lndservices.NewLndRpcChainBridge(lndServices, assetStore)
111111
msgTransportClient := lndservices.NewLndMsgTransportClient(lndServices)
112-
lndRouterClient := tap.NewLndRouterClient(lndServices)
112+
lndRouterClient := lndservices.NewLndRouterClient(lndServices)
113113
lndInvoicesClient := tap.NewLndInvoicesClient(lndServices)
114114
lndFeatureBitsVerifier := tap.NewLndFeatureBitVerifier(lndServices)
115115
lndFsmDaemonAdapters := lndservices.NewLndFsmDaemonAdapters(lndServices)

0 commit comments

Comments
 (0)