What changed, and why it matters
This commit is a small internal code cleanup in the LND lightning node software. It changes several functions so they receive a short channel identifier (SCID) directly by value instead of by pointer. There is no user-facing behavior change, no bug fix, and no security-relevant change visible in the diff.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors FetchPKScript, FetchFundingTxWrapper, FetchFundingTx, FetchPKScriptWithQuit, and related call sites to pass lnwire.ShortChannelID by value rather than by pointer. It updates function signatures, call sites, and a test mock accordingly. The change is purely stylistic/idiomatic Go and does not alter control flow, validation logic, or data handling.
Changed components
discovery/gossiper.golnwallet/interface.gonetann/channel_announcement.gonetann/channel_announcement_test.goInspect captured patch +9 / −9
diff --git a/discovery/gossiper.go b/discovery/gossiper.go
index 967f9ee..894fccf 100644
--- a/discovery/gossiper.go
+++ b/discovery/gossiper.go
@@ -2033,7 +2033,7 @@ func (d *AuthenticatedGossiper) processRejectedEdge(_ context.Context,
}
// fetchPKScript fetches the output script for the given SCID.
-func (d *AuthenticatedGossiper) fetchPKScript(chanID *lnwire.ShortChannelID) (
+func (d *AuthenticatedGossiper) fetchPKScript(chanID lnwire.ShortChannelID) (
[]byte, error) {
return lnwallet.FetchPKScriptWithQuit(d.cfg.ChainIO, chanID, d.quit)
@@ -3737,7 +3737,7 @@ func (d *AuthenticatedGossiper) validateFundingTransaction(_ context.Context,
// Before we can add the channel to the channel graph, we need to obtain
// the full funding outpoint that's encoded within the channel ID.
fundingTx, err := lnwallet.FetchFundingTxWrapper(
- d.cfg.ChainIO, &scid, d.quit,
+ d.cfg.ChainIO, scid, d.quit,
)
if err != nil {
//nolint:ll
diff --git a/lnwallet/interface.go b/lnwallet/interface.go
index 9255c51..f5a717d 100644
--- a/lnwallet/interface.go
+++ b/lnwallet/interface.go
@@ -760,7 +760,7 @@ func SupportedWallets() []string {
// FetchFundingTxWrapper is a wrapper around FetchFundingTx, except that it will
// exit when the supplied quit channel is closed.
-func FetchFundingTxWrapper(chain BlockChainIO, chanID *lnwire.ShortChannelID,
+func FetchFundingTxWrapper(chain BlockChainIO, chanID lnwire.ShortChannelID,
quit chan struct{}) (*wire.MsgTx, error) {
txChan := make(chan *wire.MsgTx, 1)
@@ -795,7 +795,7 @@ func FetchFundingTxWrapper(chain BlockChainIO, chanID *lnwire.ShortChannelID,
// TODO(roasbeef): replace with call to GetBlockTransaction? (would allow to
// later use getblocktxn).
func FetchFundingTx(chain BlockChainIO,
- chanID *lnwire.ShortChannelID) (*wire.MsgTx, error) {
+ chanID lnwire.ShortChannelID) (*wire.MsgTx, error) {
// First fetch the block hash by the block number encoded, then use
// that hash to fetch the block itself.
@@ -826,7 +826,7 @@ func FetchFundingTx(chain BlockChainIO,
// FetchPKScriptWithQuit fetches the output script for the given SCID and exits
// early with an error if the provided quit channel is closed before
// completion.
-func FetchPKScriptWithQuit(chain BlockChainIO, chanID *lnwire.ShortChannelID,
+func FetchPKScriptWithQuit(chain BlockChainIO, chanID lnwire.ShortChannelID,
quit chan struct{}) ([]byte, error) {
tx, err := FetchFundingTxWrapper(chain, chanID, quit)
@@ -835,7 +835,7 @@ func FetchPKScriptWithQuit(chain BlockChainIO, chanID *lnwire.ShortChannelID,
}
outputLocator := chanvalidate.ShortChanIDChanLocator{
- ID: *chanID,
+ ID: chanID,
}
output, _, err := outputLocator.Locate(tx)
diff --git a/netann/channel_announcement.go b/netann/channel_announcement.go
index 3f3e94a..d5c2005 100644
--- a/netann/channel_announcement.go
+++ b/netann/channel_announcement.go
@@ -104,7 +104,7 @@ func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
// FetchPkScript defines a function that can be used to fetch the output script
// for the transaction with the given SCID.
-type FetchPkScript func(*lnwire.ShortChannelID) ([]byte, error)
+type FetchPkScript func(lnwire.ShortChannelID) ([]byte, error)
// ValidateChannelAnn validates the channel announcement.
func ValidateChannelAnn(a lnwire.ChannelAnnouncement,
@@ -249,7 +249,7 @@ func validateChannelAnn2(a *lnwire.ChannelAnnouncement2,
// If bitcoin keys are not provided, then we need to get the
// on-chain output key since this will be the 3rd key in the
// 3-of-3 MuSig2 signature.
- pkScript, err := fetchPkScript(&a.ShortChannelID.Val)
+ pkScript, err := fetchPkScript(a.ShortChannelID.Val)
if err != nil {
return err
}
diff --git a/netann/channel_announcement_test.go b/netann/channel_announcement_test.go
index a4c1f53..390a716 100644
--- a/netann/channel_announcement_test.go
+++ b/netann/channel_announcement_test.go
@@ -223,7 +223,7 @@ func test3of3MuSig2ChanAnnouncement(t *testing.T) {
// We'll pass in a mock tx fetcher that will return the funding output
// containing this key. This is needed since the output key can not be
// determined from the channel announcement itself.
- fetchTx := func(chanID *lnwire.ShortChannelID) ([]byte, error) {
+ fetchTx := func(_ lnwire.ShortChannelID) ([]byte, error) {
return pkScript, nil
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.