From 8bf903d1677f2189bcc9b8c15177526c52d667f0 Mon Sep 17 00:00:00 2001 From: Jesse de Wit Date: Fri, 29 Dec 2023 11:06:23 +0100 Subject: [PATCH] remove existing insertchannel call --- interceptor/intercept_handler.go | 16 ---------------- interceptor/store.go | 3 --- postgresql/intercept_store.go | 21 --------------------- 3 files changed, 40 deletions(-) diff --git a/interceptor/intercept_handler.go b/interceptor/intercept_handler.go index dfea2e9..a5d2e63 100644 --- a/interceptor/intercept_handler.go +++ b/interceptor/intercept_handler.go @@ -226,22 +226,6 @@ func (i *Interceptor) Intercept(req common.InterceptRequest) common.InterceptRes if chanResult != nil { log.Printf("paymentHash: %s, channel opened successfully alias: %v, confirmed: %v", reqPaymentHashStr, chanResult.InitialChannelID.ToString(), chanResult.ConfirmedChannelID.ToString()) - err := i.store.InsertChannel( - uint64(chanResult.InitialChannelID), - uint64(chanResult.ConfirmedChannelID), - channelPoint.String(), - destination, - time.Now(), - ) - - if err != nil { - log.Printf("paymentHash: %s, insertChannel error: %v", reqPaymentHashStr, err) - return common.InterceptResult{ - Action: common.INTERCEPT_FAIL_HTLC_WITH_CODE, - FailureCode: common.FAILURE_TEMPORARY_CHANNEL_FAILURE, - }, nil - } - channelID := chanResult.ConfirmedChannelID if uint64(channelID) == 0 { channelID = chanResult.InitialChannelID diff --git a/interceptor/store.go b/interceptor/store.go index 4dcd982..eeb2527 100644 --- a/interceptor/store.go +++ b/interceptor/store.go @@ -1,8 +1,6 @@ package interceptor import ( - "time" - "github.com/breez/lspd/common" "github.com/btcsuite/btcd/wire" ) @@ -11,5 +9,4 @@ type InterceptStore interface { PaymentInfo(htlcPaymentHash []byte) (string, *common.OpeningFeeParams, []byte, []byte, []byte, int64, int64, *wire.OutPoint, *string, error) SetFundingTx(paymentHash []byte, channelPoint *wire.OutPoint) error RegisterPayment(token string, params *common.OpeningFeeParams, destination, paymentHash, paymentSecret []byte, incomingAmountMsat, outgoingAmountMsat int64, tag string) error - InsertChannel(initialChanID, confirmedChanId uint64, channelPoint string, nodeID []byte, lastUpdate time.Time) error } diff --git a/postgresql/intercept_store.go b/postgresql/intercept_store.go index 46b5e68..cac0e53 100644 --- a/postgresql/intercept_store.go +++ b/postgresql/intercept_store.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "log" - "time" "github.com/breez/lspd/common" "github.com/breez/lspd/lightning" @@ -102,23 +101,3 @@ func (s *PostgresInterceptStore) RegisterPayment(token string, params *common.Op } return nil } - -func (s *PostgresInterceptStore) InsertChannel(initialChanID, confirmedChanId uint64, channelPoint string, nodeID []byte, lastUpdate time.Time) error { - - query := `INSERT INTO - channels (initial_chanid, confirmed_chanid, channel_point, nodeid, last_update) - VALUES ($1, NULLIF($2, 0::int8), $3, $4, $5) - ON CONFLICT (channel_point) DO UPDATE SET confirmed_chanid=NULLIF($2, 0::int8), last_update=$5` - - c, err := s.pool.Exec(context.Background(), - query, int64(initialChanID), int64(confirmedChanId), channelPoint, nodeID, lastUpdate) - if err != nil { - log.Printf("insertChannel(%v, %v, %s, %x) error: %v", - initialChanID, confirmedChanId, channelPoint, nodeID, err) - return fmt.Errorf("insertChannel(%v, %v, %s, %x) error: %w", - initialChanID, confirmedChanId, channelPoint, nodeID, err) - } - log.Printf("insertChannel(%v, %v, %x) result: %v", - initialChanID, confirmedChanId, nodeID, c.String()) - return nil -}