rename initialchannelid to aliasScid and make optional

This commit is contained in:
Jesse de Wit
2023-12-29 11:26:56 +01:00
parent fb36dc8864
commit 81a24439d4
6 changed files with 81 additions and 40 deletions

View File

@@ -224,11 +224,18 @@ func (i *Interceptor) Intercept(req common.InterceptRequest) common.InterceptRes
for {
chanResult, _ := i.client.GetChannel(destination, *channelPoint)
if chanResult != nil {
log.Printf("paymentHash: %s, channel opened successfully alias: %v, confirmed: %v", reqPaymentHashStr, chanResult.InitialChannelID.ToString(), chanResult.ConfirmedChannelID.ToString())
log.Printf("paymentHash: %s, channel opened successfully alias: '%v', confirmed: '%v'", reqPaymentHashStr, chanResult.AliasScid.ToString(), chanResult.ConfirmedScid.ToString())
channelID := chanResult.ConfirmedChannelID
if uint64(channelID) == 0 {
channelID = chanResult.InitialChannelID
var scid *lightning.ShortChannelID
if chanResult.ConfirmedScid == nil {
if chanResult.AliasScid == nil {
log.Printf("Error: GetChannel: Both confirmed scid and alias scid are nil: %+v", chanResult)
<-time.After(1 * time.Second)
continue
}
scid = chanResult.AliasScid
} else {
scid = chanResult.ConfirmedScid
}
useLegacyOnionBlob := slices.Contains(i.config.LegacyOnionTokens, token)
@@ -236,7 +243,7 @@ func (i *Interceptor) Intercept(req common.InterceptRequest) common.InterceptRes
Action: common.INTERCEPT_RESUME_WITH_ONION,
Destination: destination,
ChannelPoint: channelPoint,
Scid: channelID,
Scid: *scid,
PaymentSecret: paymentSecret,
AmountMsat: uint64(amt),
TotalAmountMsat: uint64(outgoingAmountMsat),
@@ -244,7 +251,7 @@ func (i *Interceptor) Intercept(req common.InterceptRequest) common.InterceptRes
}, nil
}
log.Printf("paymentHash: %s, waiting for channel to get opened.... %v", reqPaymentHashStr, destination)
log.Printf("paymentHash: %s, waiting for channel to get opened... %x", reqPaymentHashStr, destination)
if time.Now().After(deadline) {
log.Printf("paymentHash: %s, Stop retrying getChannel(%v, %v)", reqPaymentHashStr, destination, channelPoint.String())
break