mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-19 06:44:23 +01:00
insert channel directly after opening
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/breez/lspd/chain"
|
||||
"github.com/breez/lspd/common"
|
||||
"github.com/breez/lspd/config"
|
||||
"github.com/breez/lspd/history"
|
||||
"github.com/breez/lspd/lightning"
|
||||
"github.com/breez/lspd/lsps0"
|
||||
"github.com/breez/lspd/notifications"
|
||||
@@ -20,9 +21,11 @@ import (
|
||||
)
|
||||
|
||||
type Interceptor struct {
|
||||
nodeid []byte
|
||||
client lightning.Client
|
||||
config *config.NodeConfig
|
||||
store InterceptStore
|
||||
historyStore history.Store
|
||||
openingService common.OpeningService
|
||||
feeEstimator chain.FeeEstimator
|
||||
feeStrategy chain.FeeStrategy
|
||||
@@ -34,15 +37,19 @@ func NewInterceptHandler(
|
||||
client lightning.Client,
|
||||
config *config.NodeConfig,
|
||||
store InterceptStore,
|
||||
historyStore history.Store,
|
||||
openingService common.OpeningService,
|
||||
feeEstimator chain.FeeEstimator,
|
||||
feeStrategy chain.FeeStrategy,
|
||||
notificationService *notifications.NotificationService,
|
||||
) *Interceptor {
|
||||
nodeid, _ := hex.DecodeString(config.NodePubkey)
|
||||
return &Interceptor{
|
||||
nodeid: nodeid,
|
||||
client: client,
|
||||
config: config,
|
||||
store: store,
|
||||
historyStore: historyStore,
|
||||
openingService: openingService,
|
||||
feeEstimator: feeEstimator,
|
||||
feeStrategy: feeStrategy,
|
||||
@@ -238,6 +245,19 @@ func (i *Interceptor) Intercept(req common.InterceptRequest) common.InterceptRes
|
||||
scid = chanResult.ConfirmedScid
|
||||
}
|
||||
|
||||
err = i.historyStore.UpdateChannels(context.TODO(), []*history.ChannelUpdate{{
|
||||
NodeID: i.nodeid,
|
||||
PeerId: destination,
|
||||
AliasScid: chanResult.AliasScid,
|
||||
ConfirmedScid: chanResult.ConfirmedScid,
|
||||
ChannelPoint: channelPoint,
|
||||
LastUpdate: time.Now(),
|
||||
}})
|
||||
if err != nil {
|
||||
// Don't break here, this is not critical.
|
||||
log.Printf("paymentHash: %s, failed to insert newly opened channel in history store. %v", reqPaymentHashStr, channelPoint.String())
|
||||
}
|
||||
|
||||
useLegacyOnionBlob := slices.Contains(i.config.LegacyOnionTokens, token)
|
||||
return common.InterceptResult{
|
||||
Action: common.INTERCEPT_RESUME_WITH_ONION,
|
||||
|
||||
Reference in New Issue
Block a user