Skip to content

Commit 9d90485

Browse files
GeorgeTsagkguggero
authored andcommitted
routerrpc: add XAddLocalChanAliases & XDeleteLocalChanAliases
1 parent 5c1b568 commit 9d90485

File tree

13 files changed

+1162
-232
lines changed

13 files changed

+1162
-232
lines changed

lnrpc/marshall_utils.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,31 @@ func UnmarshallCoinSelectionStrategy(strategy CoinSelectionStrategy,
207207
"%v", strategy)
208208
}
209209
}
210+
211+
// ScidAliasMap is a map from a base short channel ID to a set of alias short
212+
// channel IDs.
213+
type ScidAliasMap map[lnwire.ShortChannelID][]lnwire.ShortChannelID
214+
215+
// MarshalAliasMap converts a ScidAliasMap to its proto counterpart. This is
216+
// used in various RPCs that handle scid alias mappings.
217+
func MarshalAliasMap(scidMap ScidAliasMap) []*AliasMap {
218+
res := make([]*AliasMap, 0, len(scidMap))
219+
220+
for base, aliases := range scidMap {
221+
rpcMap := &AliasMap{
222+
BaseScid: base.ToUint64(),
223+
}
224+
225+
rpcMap.Aliases = make([]uint64, 0, len(aliases))
226+
227+
for _, alias := range aliases {
228+
rpcMap.Aliases = append(
229+
rpcMap.Aliases, alias.ToUint64(),
230+
)
231+
}
232+
233+
res = append(res, rpcMap)
234+
}
235+
236+
return res
237+
}

lnrpc/routerrpc/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package routerrpc
22

33
import (
4+
"github.com/lightningnetwork/lnd/aliasmgr"
45
"github.com/lightningnetwork/lnd/macaroons"
56
"github.com/lightningnetwork/lnd/routing"
67
)
@@ -46,6 +47,10 @@ type Config struct {
4647
// RouterBackend contains shared logic between this sub server and the
4748
// main rpc server.
4849
RouterBackend *RouterBackend
50+
51+
// AliasMgr is the alias manager instance that is used to handle all the
52+
// scid alias related information for channels.
53+
AliasMgr *aliasmgr.Manager
4954
}
5055

5156
// DefaultConfig defines the config defaults.

lnrpc/routerrpc/router.pb.go

Lines changed: 496 additions & 218 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: 162 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: 50 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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,23 @@ service Router {
176176
*/
177177
rpc UpdateChanStatus (UpdateChanStatusRequest)
178178
returns (UpdateChanStatusResponse);
179+
180+
/*
181+
XAddLocalChanAliases is an experimental API that creates a set of new
182+
channel SCID alias mappings. The list of successfully created mappings is
183+
returned. This is only a locally stored alias, and will not be communicated
184+
to the channel peer via any message. Therefore, routing over such an alias
185+
will only work of the peer also calls this same RPC on their end.
186+
*/
187+
rpc XAddLocalChanAliases (AddAliasesRequest) returns (AddAliasesResponse);
188+
189+
/*
190+
XDeleteLocalChanAliases is an experimental API that deletes a set of new
191+
alias mappings. The list of successfully deleted mappings is returned. The
192+
deletion will not be communicated to the channel peer via any message.
193+
*/
194+
rpc XDeleteLocalChanAliases (DeleteAliasesRequest)
195+
returns (DeleteAliasesResponse);
179196
}
180197

181198
message SendPaymentRequest {
@@ -1030,3 +1047,19 @@ enum ChanStatusAction {
10301047

10311048
message UpdateChanStatusResponse {
10321049
}
1050+
1051+
message AddAliasesRequest {
1052+
repeated lnrpc.AliasMap alias_maps = 1;
1053+
}
1054+
1055+
message AddAliasesResponse {
1056+
repeated lnrpc.AliasMap alias_maps = 1;
1057+
}
1058+
1059+
message DeleteAliasesRequest {
1060+
repeated lnrpc.AliasMap alias_maps = 1;
1061+
}
1062+
1063+
message DeleteAliasesResponse {
1064+
repeated lnrpc.AliasMap alias_maps = 1;
1065+
}

0 commit comments

Comments
 (0)