localchans: populate funding script for missing edges
When creating a missing edge, we need to populate the funding script too so that the graph builder can update its ChainView appropriately. We use the MakeFundingScript helper from the funding package which ensures that we are using the same logic for creating a funding script as is used for any of the channels that we own.
This commit is contained in:
2 files changed
+25
-5
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"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/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -321,12 +322,19 @@ func (r *Manager) createEdge(channel *channeldb.OpenChannel,
|
||||
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{
|
||||
ChannelID: shortChanID.ToUint64(),
|
||||
ChainHash: channel.ChainHash,
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
Capacity: channel.Capacity,
|
||||
ChannelPoint: channel.FundingOutpoint,
|
||||
ChannelID: shortChanID.ToUint64(),
|
||||
ChainHash: channel.ChainHash,
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
Capacity: channel.Capacity,
|
||||
ChannelPoint: channel.FundingOutpoint,
|
||||
FundingScript: fn.Some(fundingScript),
|
||||
}
|
||||
|
||||
copy(info.NodeKey1Bytes[:], nodeKey1Bytes)
|
||||
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"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/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
@@ -385,6 +387,10 @@ func TestCreateEdgeLower(t *testing.T) {
|
||||
Index: 0,
|
||||
},
|
||||
}
|
||||
|
||||
fundingScript, err := funding.MakeFundingScript(channel)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedInfo := &models.ChannelEdgeInfo{
|
||||
ChannelID: 8,
|
||||
ChainHash: channel.ChainHash,
|
||||
@@ -399,6 +405,7 @@ func TestCreateEdgeLower(t *testing.T) {
|
||||
remoteMultisigKey.SerializeCompressed()),
|
||||
AuthProof: nil,
|
||||
ExtraOpaqueData: nil,
|
||||
FundingScript: fn.Some(fundingScript),
|
||||
}
|
||||
expectedEdge := &models.ChannelEdgePolicy{
|
||||
ChannelID: 8,
|
||||
@@ -473,6 +480,10 @@ func TestCreateEdgeHigher(t *testing.T) {
|
||||
Index: 0,
|
||||
},
|
||||
}
|
||||
|
||||
fundingScript, err := funding.MakeFundingScript(channel)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedInfo := &models.ChannelEdgeInfo{
|
||||
ChannelID: 8,
|
||||
ChainHash: channel.ChainHash,
|
||||
@@ -487,6 +498,7 @@ func TestCreateEdgeHigher(t *testing.T) {
|
||||
localMultisigKey.SerializeCompressed()),
|
||||
AuthProof: nil,
|
||||
ExtraOpaqueData: nil,
|
||||
FundingScript: fn.Some(fundingScript),
|
||||
}
|
||||
expectedEdge := &models.ChannelEdgePolicy{
|
||||
ChannelID: 8,
|
||||
|
||||
Reference in new issue
Block a user