mirror of
https://github.com/callebtc/electronwall.git
synced 2025-12-17 15:14:25 +01:00
to alias
This commit is contained in:
@@ -72,7 +72,7 @@ func (app *app) dispatchChannelAcceptor(ctx context.Context) {
|
|||||||
|
|
||||||
res := lnrpc.ChannelAcceptResponse{}
|
res := lnrpc.ChannelAcceptResponse{}
|
||||||
if accept {
|
if accept {
|
||||||
log.Infof("✅ [channel-mode %s] Allow channel %s", Configuration.ChannelMode, channel_info_string)
|
log.Infof("✅ [channel %s] Allow channel %s", Configuration.ChannelMode, channel_info_string)
|
||||||
res = lnrpc.ChannelAcceptResponse{Accept: true,
|
res = lnrpc.ChannelAcceptResponse{Accept: true,
|
||||||
PendingChanId: req.PendingChanId,
|
PendingChanId: req.PendingChanId,
|
||||||
CsvDelay: req.CsvDelay,
|
CsvDelay: req.CsvDelay,
|
||||||
@@ -83,7 +83,7 @@ func (app *app) dispatchChannelAcceptor(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.Infof("❌ [channel-mode %s] Reject channel %s", Configuration.ChannelMode, channel_info_string)
|
log.Infof("❌ [channel %s] Reject channel %s", Configuration.ChannelMode, channel_info_string)
|
||||||
res = lnrpc.ChannelAcceptResponse{Accept: false,
|
res = lnrpc.ChannelAcceptResponse{Accept: false,
|
||||||
Error: Configuration.ChannelRejectMessage}
|
Error: Configuration.ChannelRejectMessage}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,26 +93,43 @@ func (app *app) interceptHtlcEvents(ctx context.Context, interceptor routerrpc.R
|
|||||||
log.Error("Error getting pubkey for channel %d", event.IncomingCircuitKey.ChanId)
|
log.Error("Error getting pubkey for channel %d", event.IncomingCircuitKey.ChanId)
|
||||||
}
|
}
|
||||||
|
|
||||||
var remote_pubkey, alias string
|
var pubkeyFrom, aliasFrom, pubkeyTo, aliasTo string
|
||||||
if channelEdge.node1Pub.String() != app.myPubkey {
|
if channelEdge.node1Pub.String() != app.myPubkey {
|
||||||
remote_pubkey = channelEdge.node1Pub.String()
|
pubkeyFrom = channelEdge.node1Pub.String()
|
||||||
} else {
|
} else {
|
||||||
remote_pubkey = channelEdge.node2Pub.String()
|
pubkeyFrom = channelEdge.node2Pub.String()
|
||||||
}
|
}
|
||||||
alias, err = app.getNodeAlias(ctx, remote_pubkey)
|
aliasFrom, err = app.getNodeAlias(ctx, pubkeyFrom)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error getting alias for node %s", remote_pubkey)
|
aliasFrom = trimPubKey([]byte(pubkeyFrom))
|
||||||
|
log.Error("Error getting alias for node %s", aliasFrom)
|
||||||
}
|
}
|
||||||
forward_info_string := fmt.Sprintf("from %s (%d sat, htlc_id:%d, chan_id:%d->%d)", alias, event.IncomingAmountMsat/1000, event.IncomingCircuitKey.HtlcId, event.IncomingCircuitKey.ChanId, event.OutgoingRequestedChanId)
|
|
||||||
|
channelEdgeTo, err := app.getPubKeyFromChannel(ctx, event.OutgoingRequestedChanId)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error getting pubkey for channel %d", event.OutgoingRequestedChanId)
|
||||||
|
}
|
||||||
|
if channelEdgeTo.node1Pub.String() != app.myPubkey {
|
||||||
|
pubkeyTo = channelEdgeTo.node1Pub.String()
|
||||||
|
} else {
|
||||||
|
pubkeyTo = channelEdgeTo.node2Pub.String()
|
||||||
|
}
|
||||||
|
aliasTo, err = app.getNodeAlias(ctx, pubkeyTo)
|
||||||
|
if err != nil {
|
||||||
|
aliasTo = trimPubKey([]byte(pubkeyTo))
|
||||||
|
log.Error("Error getting alias for node %s", aliasTo)
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_info_string := fmt.Sprintf("from %s to %s (%d sat, htlc_id:%d, chan_id:%d->%d)", aliasFrom, aliasTo, event.IncomingAmountMsat/1000, event.IncomingCircuitKey.HtlcId, event.IncomingCircuitKey.ChanId, event.OutgoingRequestedChanId)
|
||||||
|
|
||||||
response := &routerrpc.ForwardHtlcInterceptResponse{
|
response := &routerrpc.ForwardHtlcInterceptResponse{
|
||||||
IncomingCircuitKey: event.IncomingCircuitKey,
|
IncomingCircuitKey: event.IncomingCircuitKey,
|
||||||
}
|
}
|
||||||
if <-decision_chan {
|
if <-decision_chan {
|
||||||
log.Infof("✅ [forward-mode %s] Accept HTLC %s", Configuration.ForwardMode, forward_info_string)
|
log.Infof("✅ [forward %s] Accept HTLC %s", Configuration.ForwardMode, forward_info_string)
|
||||||
response.Action = routerrpc.ResolveHoldForwardAction_RESUME
|
response.Action = routerrpc.ResolveHoldForwardAction_RESUME
|
||||||
} else {
|
} else {
|
||||||
log.Infof("❌ [forward-mode %s] Reject HTLC %s", Configuration.ForwardMode, forward_info_string)
|
log.Infof("❌ [forward %s] Reject HTLC %s", Configuration.ForwardMode, forward_info_string)
|
||||||
response.Action = routerrpc.ResolveHoldForwardAction_FAIL
|
response.Action = routerrpc.ResolveHoldForwardAction_FAIL
|
||||||
}
|
}
|
||||||
err = interceptor.Send(response)
|
err = interceptor.Send(response)
|
||||||
|
|||||||
Reference in New Issue
Block a user