Skip to content

Commit 53912c3

Browse files
committed
lndclient: add XFindBaseLocalChanAlias
1 parent 3b36ac0 commit 53912c3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

router_client.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ type RouterClient interface {
8989
// will not be communicated to the channel peer via any message.
9090
XDeleteLocalChanAlias(ctx context.Context, alias,
9191
baseScid lnwire.ShortChannelID) error
92+
93+
// XFindBaseLocalChanAlias is an experimental API that looks up the base
94+
// scid for a local chan alias that was registered.
95+
XFindBaseLocalChanAlias(ctx context.Context,
96+
alias lnwire.ShortChannelID) (lnwire.ShortChannelID, error)
9297
}
9398

9499
// PaymentStatus describe the state of a payment.
@@ -1174,3 +1179,25 @@ func (r *routerClient) XDeleteLocalChanAlias(ctx context.Context, alias,
11741179
)
11751180
return err
11761181
}
1182+
1183+
// XFindBaseLocalChanAlias is an experimental API that looks up the base scid
1184+
// for a local chan alias that was registered.
1185+
func (r *routerClient) XFindBaseLocalChanAlias(ctx context.Context,
1186+
alias lnwire.ShortChannelID) (lnwire.ShortChannelID, error) {
1187+
1188+
rpcCtx, cancel := context.WithTimeout(ctx, r.timeout)
1189+
defer cancel()
1190+
1191+
res, err := r.client.XFindBaseLocalChanAlias(
1192+
r.routerKitMac.WithMacaroonAuth(rpcCtx),
1193+
&routerrpc.FindBaseAliasRequest{
1194+
Alias: alias.ToUint64(),
1195+
},
1196+
)
1197+
1198+
if err != nil {
1199+
return lnwire.ShortChannelID{}, err
1200+
}
1201+
1202+
return lnwire.NewShortChanIDFromInt(res.Base), nil
1203+
}

testdata/permissions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,14 @@
911911
"action": "write"
912912
}
913913
]
914+
},
915+
"/routerrpc.Router/XFindBaseLocalChanAlias": {
916+
"permissions": [
917+
{
918+
"entity": "offchain",
919+
"action": "read"
920+
}
921+
]
914922
},
915923
"/signrpc.Signer/ComputeInputScript": {
916924
"permissions": [

0 commit comments

Comments
 (0)