Merge pull request #10410 from ellemouton/bypassBuilderForMissingEdges

localchans: populate FundingScript for missing edges
This commit is contained in:
Elle authored and GitHub committed 2025-12-12 10:22:14 +02:00
commit 363aeb5f15
4 files changed
+30 -5

No files matched your search

@@ -51,6 +51,11 @@
the EstimateRouteFee API can probe Eclair and LDK nodes which enforce the the EstimateRouteFee API can probe Eclair and LDK nodes which enforce the
payment address/secret. payment address/secret.
* Fix a bug where [missing edges for own channels could not be added to the
graph DB](https://github.com/lightningnetwork/lnd/pull/10410)
due to validation checks in the graph Builder that were resurfaced after the
graph refactor work.
# New Features # New Features
## Functional Enhancements ## Functional Enhancements
+5 -5
View File
@@ -1365,7 +1365,7 @@ func (f *Manager) advancePendingChannelState(channel *channeldb.OpenChannel,
} }
txid := &channel.FundingOutpoint.Hash txid := &channel.FundingOutpoint.Hash
fundingScript, err := makeFundingScript(channel) fundingScript, err := MakeFundingScript(channel)
if err != nil { if err != nil {
log.Errorf("unable to create funding script for "+ log.Errorf("unable to create funding script for "+
"ChannelPoint(%v): %v", "ChannelPoint(%v): %v",
@@ -3053,9 +3053,9 @@ func (f *Manager) waitForFundingWithTimeout(
} }
} }
// makeFundingScript re-creates the funding script for the funding transaction // MakeFundingScript re-creates the funding script for the funding transaction
// of the target channel. // of the target channel.
func makeFundingScript(channel *channeldb.OpenChannel) ([]byte, error) { func MakeFundingScript(channel *channeldb.OpenChannel) ([]byte, error) {
localKey := channel.LocalChanCfg.MultiSigKey.PubKey localKey := channel.LocalChanCfg.MultiSigKey.PubKey
remoteKey := channel.RemoteChanCfg.MultiSigKey.PubKey remoteKey := channel.RemoteChanCfg.MultiSigKey.PubKey
@@ -3102,7 +3102,7 @@ func (f *Manager) waitForFundingConfirmation(
// Register with the ChainNotifier for a notification once the funding // Register with the ChainNotifier for a notification once the funding
// transaction reaches `numConfs` confirmations. // transaction reaches `numConfs` confirmations.
txid := completeChan.FundingOutpoint.Hash txid := completeChan.FundingOutpoint.Hash
fundingScript, err := makeFundingScript(completeChan) fundingScript, err := MakeFundingScript(completeChan)
if err != nil { if err != nil {
log.Errorf("unable to create funding script for "+ log.Errorf("unable to create funding script for "+
"ChannelPoint(%v): %v", completeChan.FundingOutpoint, "ChannelPoint(%v): %v", completeChan.FundingOutpoint,
@@ -3818,7 +3818,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
shortChanID.ToUint64(), completeChan.FundingOutpoint, shortChanID.ToUint64(), completeChan.FundingOutpoint,
numConfs) numConfs)
fundingScript, err := makeFundingScript(completeChan) fundingScript, err := MakeFundingScript(completeChan)
if err != nil { if err != nil {
return fmt.Errorf("unable to create funding script "+ return fmt.Errorf("unable to create funding script "+
"for ChannelPoint(%v): %v", "for ChannelPoint(%v): %v",
+8
View File
@@ -13,6 +13,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/discovery"
"github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/funding"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@@ -321,12 +322,19 @@ func (r *Manager) createEdge(channel *channeldb.OpenChannel,
shortChanID = channel.ZeroConfRealScid() shortChanID = channel.ZeroConfRealScid()
} }
fundingScript, err := funding.MakeFundingScript(channel)
if err != nil {
return nil, nil, fmt.Errorf("unable to create funding "+
"script: %v", err)
}
info := &models.ChannelEdgeInfo{ info := &models.ChannelEdgeInfo{
ChannelID: shortChanID.ToUint64(), ChannelID: shortChanID.ToUint64(),
ChainHash: channel.ChainHash, ChainHash: channel.ChainHash,
Features: lnwire.EmptyFeatureVector(), Features: lnwire.EmptyFeatureVector(),
Capacity: channel.Capacity, Capacity: channel.Capacity,
ChannelPoint: channel.FundingOutpoint, ChannelPoint: channel.FundingOutpoint,
FundingScript: fn.Some(fundingScript),
} }
copy(info.NodeKey1Bytes[:], nodeKey1Bytes) copy(info.NodeKey1Bytes[:], nodeKey1Bytes)
+12
View File
@@ -13,6 +13,8 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/discovery"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/funding"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
@@ -385,6 +387,10 @@ func TestCreateEdgeLower(t *testing.T) {
Index: 0, Index: 0,
}, },
} }
fundingScript, err := funding.MakeFundingScript(channel)
require.NoError(t, err)
expectedInfo := &models.ChannelEdgeInfo{ expectedInfo := &models.ChannelEdgeInfo{
ChannelID: 8, ChannelID: 8,
ChainHash: channel.ChainHash, ChainHash: channel.ChainHash,
@@ -399,6 +405,7 @@ func TestCreateEdgeLower(t *testing.T) {
remoteMultisigKey.SerializeCompressed()), remoteMultisigKey.SerializeCompressed()),
AuthProof: nil, AuthProof: nil,
ExtraOpaqueData: nil, ExtraOpaqueData: nil,
FundingScript: fn.Some(fundingScript),
} }
expectedEdge := &models.ChannelEdgePolicy{ expectedEdge := &models.ChannelEdgePolicy{
ChannelID: 8, ChannelID: 8,
@@ -473,6 +480,10 @@ func TestCreateEdgeHigher(t *testing.T) {
Index: 0, Index: 0,
}, },
} }
fundingScript, err := funding.MakeFundingScript(channel)
require.NoError(t, err)
expectedInfo := &models.ChannelEdgeInfo{ expectedInfo := &models.ChannelEdgeInfo{
ChannelID: 8, ChannelID: 8,
ChainHash: channel.ChainHash, ChainHash: channel.ChainHash,
@@ -487,6 +498,7 @@ func TestCreateEdgeHigher(t *testing.T) {
localMultisigKey.SerializeCompressed()), localMultisigKey.SerializeCompressed()),
AuthProof: nil, AuthProof: nil,
ExtraOpaqueData: nil, ExtraOpaqueData: nil,
FundingScript: fn.Some(fundingScript),
} }
expectedEdge := &models.ChannelEdgePolicy{ expectedEdge := &models.ChannelEdgePolicy{
ChannelID: 8, ChannelID: 8,