|
7 | 7 | "github.com/btcsuite/btcd/chaincfg/chainhash"
|
8 | 8 | "github.com/btcsuite/btcd/wire"
|
9 | 9 | "github.com/lightninglabs/lndclient"
|
| 10 | + "github.com/lightninglabs/taproot-assets/rfq" |
10 | 11 | "github.com/lightninglabs/taproot-assets/tapgarden"
|
11 | 12 | "github.com/lightningnetwork/lnd/chainntnfs"
|
12 | 13 | "github.com/lightningnetwork/lnd/lnrpc/verrpc"
|
@@ -203,3 +204,61 @@ func (l *LndRpcChainBridge) EstimateFee(ctx context.Context,
|
203 | 204 | // A compile time assertion to ensure LndRpcChainBridge meets the
|
204 | 205 | // tapgarden.ChainBridge interface.
|
205 | 206 | var _ tapgarden.ChainBridge = (*LndRpcChainBridge)(nil)
|
| 207 | + |
| 208 | +// LndMsgTransportClient is an LND RPC message transport client. |
| 209 | +type LndMsgTransportClient struct { |
| 210 | + lnd *lndclient.LndServices |
| 211 | +} |
| 212 | + |
| 213 | +// NewLndMsgTransportClient creates a new message transport RPC client for a |
| 214 | +// given LND service. |
| 215 | +func NewLndMsgTransportClient( |
| 216 | + lnd *lndclient.LndServices) *LndMsgTransportClient { |
| 217 | + |
| 218 | + return &LndMsgTransportClient{ |
| 219 | + lnd: lnd, |
| 220 | + } |
| 221 | +} |
| 222 | + |
| 223 | +// SubscribeCustomMessages creates a subscription to custom messages received |
| 224 | +// from our peers. |
| 225 | +func (l *LndMsgTransportClient) SubscribeCustomMessages( |
| 226 | + ctx context.Context) (<-chan lndclient.CustomMessage, |
| 227 | + <-chan error, error) { |
| 228 | + |
| 229 | + return l.lnd.Client.SubscribeCustomMessages(ctx) |
| 230 | +} |
| 231 | + |
| 232 | +// SendCustomMessage sends a custom message to a peer. |
| 233 | +func (l *LndMsgTransportClient) SendCustomMessage(ctx context.Context, |
| 234 | + msg lndclient.CustomMessage) error { |
| 235 | + |
| 236 | + return l.lnd.Client.SendCustomMessage(ctx, msg) |
| 237 | +} |
| 238 | + |
| 239 | +// Ensure LndMsgTransportClient implements the rfq.PeerMessenger interface. |
| 240 | +var _ rfq.PeerMessenger = (*LndMsgTransportClient)(nil) |
| 241 | + |
| 242 | +// LndRouterClient is an LND router RPC client. |
| 243 | +type LndRouterClient struct { |
| 244 | + lnd *lndclient.LndServices |
| 245 | +} |
| 246 | + |
| 247 | +// NewLndRouterClient creates a new LND router client for a given LND service. |
| 248 | +func NewLndRouterClient(lnd *lndclient.LndServices) *LndRouterClient { |
| 249 | + return &LndRouterClient{ |
| 250 | + lnd: lnd, |
| 251 | + } |
| 252 | +} |
| 253 | + |
| 254 | +// InterceptHtlcs intercepts all incoming HTLCs and calls the given handler |
| 255 | +// function with the HTLC details. The handler function can then decide whether |
| 256 | +// to accept or reject the HTLC. |
| 257 | +func (l *LndRouterClient) InterceptHtlcs( |
| 258 | + ctx context.Context, handler lndclient.HtlcInterceptHandler) error { |
| 259 | + |
| 260 | + return l.lnd.Router.InterceptHtlcs(ctx, handler) |
| 261 | +} |
| 262 | + |
| 263 | +// Ensure LndRouterClient implements the rfq.HtlcInterceptor interface. |
| 264 | +var _ rfq.HtlcInterceptor = (*LndRouterClient)(nil) |
0 commit comments