mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-18 22:34:22 +01:00
insert channel directly after opening
This commit is contained in:
@@ -10,12 +10,14 @@ import (
|
||||
|
||||
"github.com/breez/lspd/chain"
|
||||
"github.com/breez/lspd/common"
|
||||
"github.com/breez/lspd/history"
|
||||
"github.com/breez/lspd/lightning"
|
||||
"github.com/breez/lspd/lsps0"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
type InterceptorConfig struct {
|
||||
NodeId []byte
|
||||
AdditionalChannelCapacitySat uint64
|
||||
MinConfs *uint32
|
||||
TargetConf uint32
|
||||
@@ -29,6 +31,7 @@ type InterceptorConfig struct {
|
||||
|
||||
type Interceptor struct {
|
||||
store Lsps2Store
|
||||
historyStore history.Store
|
||||
openingService common.OpeningService
|
||||
client lightning.Client
|
||||
feeEstimator chain.FeeEstimator
|
||||
@@ -43,6 +46,7 @@ type Interceptor struct {
|
||||
|
||||
func NewInterceptHandler(
|
||||
store Lsps2Store,
|
||||
historyStore history.Store,
|
||||
openingService common.OpeningService,
|
||||
client lightning.Client,
|
||||
feeEstimator chain.FeeEstimator,
|
||||
@@ -54,6 +58,7 @@ func NewInterceptHandler(
|
||||
|
||||
return &Interceptor{
|
||||
store: store,
|
||||
historyStore: historyStore,
|
||||
openingService: openingService,
|
||||
client: client,
|
||||
feeEstimator: feeEstimator,
|
||||
@@ -532,6 +537,19 @@ func (i *Interceptor) ensureChannelOpen(payment *paymentState) {
|
||||
scid = chanResult.ConfirmedScid
|
||||
}
|
||||
|
||||
err := i.historyStore.UpdateChannels(context.TODO(), []*history.ChannelUpdate{{
|
||||
NodeID: i.config.NodeId,
|
||||
PeerId: destination,
|
||||
AliasScid: chanResult.AliasScid,
|
||||
ConfirmedScid: chanResult.ConfirmedScid,
|
||||
ChannelPoint: payment.registration.ChannelPoint,
|
||||
LastUpdate: time.Now(),
|
||||
}})
|
||||
if err != nil {
|
||||
// Don't break here, this is not critical.
|
||||
log.Printf("failed to insert newly opened channel in history store. %v", payment.registration.ChannelPoint.String())
|
||||
}
|
||||
|
||||
i.paymentChanOpened <- &paymentChanOpenedEvent{
|
||||
paymentId: payment.id,
|
||||
scid: *scid,
|
||||
|
||||
Reference in New Issue
Block a user