Skip to content

Commit f14190c

Browse files
committed
lnrpc: add XFindBaseLocalChanAlias rpc
Add the new RPC method that looks up the base scid for a given alias. Given the previous stepping stones this commit is fairly simple, we just call into the alias manager and return the lookup result.
1 parent 472a2f9 commit f14190c

File tree

8 files changed

+600
-225
lines changed

8 files changed

+600
-225
lines changed

lnrpc/routerrpc/router.pb.go

Lines changed: 361 additions & 225 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/routerrpc/router.pb.gw.go

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/routerrpc/router.pb.json.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/routerrpc/router.proto

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ service Router {
195195
*/
196196
rpc XDeleteLocalChanAliases (DeleteAliasesRequest)
197197
returns (DeleteAliasesResponse);
198+
199+
/*
200+
XFindBaseLocalChanAlias is an experimental API that looks up the base scid
201+
for a local chan alias that was registered during the current runtime.
202+
*/
203+
rpc XFindBaseLocalChanAlias (FindBaseAliasRequest)
204+
returns (FindBaseAliasResponse);
198205
}
199206

200207
message SendPaymentRequest {
@@ -1116,4 +1123,14 @@ message DeleteAliasesRequest {
11161123

11171124
message DeleteAliasesResponse {
11181125
repeated lnrpc.AliasMap alias_maps = 1;
1126+
}
1127+
1128+
message FindBaseAliasRequest {
1129+
// The alias we want to look up the base scid for.
1130+
uint64 alias = 1;
1131+
}
1132+
1133+
message FindBaseAliasResponse {
1134+
// The base scid that resulted from the base scid look up.
1135+
uint64 base = 1;
11191136
}

lnrpc/routerrpc/router.swagger.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,39 @@
580580
]
581581
}
582582
},
583+
"/v2/router/x/findbasealias": {
584+
"post": {
585+
"summary": "XFindBaseLocalChanAlias is an experimental API that looks up the base scid\nfor a local chan alias that was registered during the current runtime.",
586+
"operationId": "Router_XFindBaseLocalChanAlias",
587+
"responses": {
588+
"200": {
589+
"description": "A successful response.",
590+
"schema": {
591+
"$ref": "#/definitions/routerrpcFindBaseAliasResponse"
592+
}
593+
},
594+
"default": {
595+
"description": "An unexpected error response.",
596+
"schema": {
597+
"$ref": "#/definitions/rpcStatus"
598+
}
599+
}
600+
},
601+
"parameters": [
602+
{
603+
"name": "body",
604+
"in": "body",
605+
"required": true,
606+
"schema": {
607+
"$ref": "#/definitions/routerrpcFindBaseAliasRequest"
608+
}
609+
}
610+
],
611+
"tags": [
612+
"Router"
613+
]
614+
}
615+
},
583616
"/v2/router/x/importhistory": {
584617
"post": {
585618
"summary": "lncli: `importmc`\nXImportMissionControl is an experimental API that imports the state provided\nto the internal mission control's state, using all results which are more\nrecent than our existing values. These values will only be imported\nin-memory, and will not be persisted across restarts.",
@@ -1411,6 +1444,26 @@
14111444
}
14121445
}
14131446
},
1447+
"routerrpcFindBaseAliasRequest": {
1448+
"type": "object",
1449+
"properties": {
1450+
"alias": {
1451+
"type": "string",
1452+
"format": "uint64",
1453+
"description": "The alias we want to look up the base scid for."
1454+
}
1455+
}
1456+
},
1457+
"routerrpcFindBaseAliasResponse": {
1458+
"type": "object",
1459+
"properties": {
1460+
"base": {
1461+
"type": "string",
1462+
"format": "uint64",
1463+
"description": "The base scid that resulted from the base scid look up."
1464+
}
1465+
}
1466+
},
14141467
"routerrpcForwardEvent": {
14151468
"type": "object",
14161469
"properties": {

lnrpc/routerrpc/router.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ http:
5454
- selector: routerrpc.Router.XDeleteLocalChanAliases
5555
post: "/v2/router/x/deletealiases"
5656
body: "*"
57+
- selector: routerrpc.Router.XFindBaseLocalChanAlias
58+
post: "/v2/router/x/findbasealias"
59+
body: "*"
5760

lnrpc/routerrpc/router_grpc.pb.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/routerrpc/router_server.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,22 @@ func (s *Server) XDeleteLocalChanAliases(_ context.Context,
17641764
}, nil
17651765
}
17661766

1767+
// XFindBaseLocalChanAlias is an experimental API that looks up the base scid
1768+
// for a local chan alias that was registered.
1769+
func (s *Server) XFindBaseLocalChanAlias(_ context.Context,
1770+
in *FindBaseAliasRequest) (*FindBaseAliasResponse, error) {
1771+
1772+
aliasScid := lnwire.NewShortChanIDFromInt(in.Alias)
1773+
base, err := s.cfg.AliasMgr.FindBaseSCID(aliasScid)
1774+
if err != nil {
1775+
return nil, err
1776+
}
1777+
1778+
return &FindBaseAliasResponse{
1779+
Base: base.ToUint64(),
1780+
}, nil
1781+
}
1782+
17671783
func extractOutPoint(req *UpdateChanStatusRequest) (*wire.OutPoint, error) {
17681784
chanPoint := req.GetChanPoint()
17691785
txid, err := lnrpc.GetChanPointFundingTxid(chanPoint)

0 commit comments

Comments
 (0)