multi: let FetchPkScript take SCID by value

Instead of a pointer.
This commit is contained in:
Elle Mouton
2025-03-24 10:14:28 +02:00
parent b77b698b9d
commit 06bf0c28b6
4 changed files with 9 additions and 9 deletions

View File

@@ -2033,7 +2033,7 @@ func (d *AuthenticatedGossiper) processRejectedEdge(_ context.Context,
} }
// fetchPKScript fetches the output script for the given SCID. // 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) { []byte, error) {
return lnwallet.FetchPKScriptWithQuit(d.cfg.ChainIO, chanID, d.quit) 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 // 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. // the full funding outpoint that's encoded within the channel ID.
fundingTx, err := lnwallet.FetchFundingTxWrapper( fundingTx, err := lnwallet.FetchFundingTxWrapper(
d.cfg.ChainIO, &scid, d.quit, d.cfg.ChainIO, scid, d.quit,
) )
if err != nil { if err != nil {
//nolint:ll //nolint:ll

View File

@@ -760,7 +760,7 @@ func SupportedWallets() []string {
// FetchFundingTxWrapper is a wrapper around FetchFundingTx, except that it will // FetchFundingTxWrapper is a wrapper around FetchFundingTx, except that it will
// exit when the supplied quit channel is closed. // 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) { quit chan struct{}) (*wire.MsgTx, error) {
txChan := make(chan *wire.MsgTx, 1) 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 // TODO(roasbeef): replace with call to GetBlockTransaction? (would allow to
// later use getblocktxn). // later use getblocktxn).
func FetchFundingTx(chain BlockChainIO, 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 // First fetch the block hash by the block number encoded, then use
// that hash to fetch the block itself. // 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 // FetchPKScriptWithQuit fetches the output script for the given SCID and exits
// early with an error if the provided quit channel is closed before // early with an error if the provided quit channel is closed before
// completion. // completion.
func FetchPKScriptWithQuit(chain BlockChainIO, chanID *lnwire.ShortChannelID, func FetchPKScriptWithQuit(chain BlockChainIO, chanID lnwire.ShortChannelID,
quit chan struct{}) ([]byte, error) { quit chan struct{}) ([]byte, error) {
tx, err := FetchFundingTxWrapper(chain, chanID, quit) tx, err := FetchFundingTxWrapper(chain, chanID, quit)
@@ -835,7 +835,7 @@ func FetchPKScriptWithQuit(chain BlockChainIO, chanID *lnwire.ShortChannelID,
} }
outputLocator := chanvalidate.ShortChanIDChanLocator{ outputLocator := chanvalidate.ShortChanIDChanLocator{
ID: *chanID, ID: chanID,
} }
output, _, err := outputLocator.Locate(tx) output, _, err := outputLocator.Locate(tx)

View File

@@ -104,7 +104,7 @@ func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
// FetchPkScript defines a function that can be used to fetch the output script // FetchPkScript defines a function that can be used to fetch the output script
// for the transaction with the given SCID. // 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. // ValidateChannelAnn validates the channel announcement.
func ValidateChannelAnn(a lnwire.ChannelAnnouncement, 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 // 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 // on-chain output key since this will be the 3rd key in the
// 3-of-3 MuSig2 signature. // 3-of-3 MuSig2 signature.
pkScript, err := fetchPkScript(&a.ShortChannelID.Val) pkScript, err := fetchPkScript(a.ShortChannelID.Val)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -223,7 +223,7 @@ func test3of3MuSig2ChanAnnouncement(t *testing.T) {
// We'll pass in a mock tx fetcher that will return the funding output // 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 // containing this key. This is needed since the output key can not be
// determined from the channel announcement itself. // determined from the channel announcement itself.
fetchTx := func(chanID *lnwire.ShortChannelID) ([]byte, error) { fetchTx := func(_ lnwire.ShortChannelID) ([]byte, error) {
return pkScript, nil return pkScript, nil
} }