Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.20.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
* [Fix potential sql tx exhaustion
issue](https://github.com/lightningnetwork/lnd/pull/10428) in LND which might
happen when running postgres with a limited number of connections configured.

* Fix a bug where [missing edges for own channels could not be added to the
graph DB](https://github.com/lightningnetwork/lnd/pull/10443)
Comment on lines +62 to +63

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The link for this bug fix points to pull/xxxxx, which seems to be a placeholder. Please update it with the correct pull request number.

due to validation checks in the graph Builder that were resurfaced after the
graph refactor work.

# New Features

Expand Down
10 changes: 5 additions & 5 deletions funding/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ func (f *Manager) advancePendingChannelState(channel *channeldb.OpenChannel,
}

txid := &channel.FundingOutpoint.Hash
fundingScript, err := makeFundingScript(channel)
fundingScript, err := MakeFundingScript(channel)
if err != nil {
log.Errorf("unable to create funding script for "+
"ChannelPoint(%v): %v",
Expand Down Expand Up @@ -3037,9 +3037,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.
Comment on lines +3040 to 3041

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Per the LND Style Guide, exported functions should have detailed comments. The current comment for MakeFundingScript is quite brief. It would be beneficial to expand it to explain what kind of script is being created (e.g., P2WSH for legacy channels, P2TR for taproot channels) and why it's needed, similar to the detailed example provided in the style guide for DeriveRevocationPubkey.

References
  1. Exported functions require detailed comments for the caller. The provided example for a 'RIGHT' comment is very descriptive, explaining the 'why' and 'how' of the function. (link)

func makeFundingScript(channel *channeldb.OpenChannel) ([]byte, error) {
func MakeFundingScript(channel *channeldb.OpenChannel) ([]byte, error) {
localKey := channel.LocalChanCfg.MultiSigKey.PubKey
remoteKey := channel.RemoteChanCfg.MultiSigKey.PubKey

Expand Down Expand Up @@ -3086,7 +3086,7 @@ func (f *Manager) waitForFundingConfirmation(
// Register with the ChainNotifier for a notification once the funding
// transaction reaches `numConfs` confirmations.
txid := completeChan.FundingOutpoint.Hash
fundingScript, err := makeFundingScript(completeChan)
fundingScript, err := MakeFundingScript(completeChan)
if err != nil {
log.Errorf("unable to create funding script for "+
"ChannelPoint(%v): %v", completeChan.FundingOutpoint,
Expand Down Expand Up @@ -3802,7 +3802,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
shortChanID.ToUint64(), completeChan.FundingOutpoint,
numConfs)

fundingScript, err := makeFundingScript(completeChan)
fundingScript, err := MakeFundingScript(completeChan)
if err != nil {
return fmt.Errorf("unable to create funding script "+
"for ChannelPoint(%v): %v",
Expand Down
18 changes: 13 additions & 5 deletions routing/localchans/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions routing/localchans/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -399,6 +405,7 @@ func TestCreateEdgeLower(t *testing.T) {
remoteMultisigKey.SerializeCompressed()),
AuthProof: nil,
ExtraOpaqueData: nil,
FundingScript: fn.Some(fundingScript),
}
expectedEdge := &models.ChannelEdgePolicy{
ChannelID: 8,
Expand Down Expand Up @@ -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,
Expand All @@ -487,6 +498,7 @@ func TestCreateEdgeHigher(t *testing.T) {
localMultisigKey.SerializeCompressed()),
AuthProof: nil,
ExtraOpaqueData: nil,
FundingScript: fn.Some(fundingScript),
}
expectedEdge := &models.ChannelEdgePolicy{
ChannelID: 8,
Expand Down
Loading