channeldb: drop unused kvdb.RTx parameter from FetchChannelByID

All four call sites pass nil for tx today (server.go, two in
channeldb/db_test.go, funding/manager_test.go). The internal
channelScanner(nil, selector) call inside FetchChannelByID is preserved
verbatim, so runtime behavior is unchanged.

This is a prerequisite for the upcoming chanstate.ChannelStore
interface: keeping the parameter would leak kvdb into a domain
interface.
This commit is contained in:
ziggie 2026-04-28 15:08:41 -03:00
parent 50eb0d1466
commit bb8eeb2304
No known key found for this signature in database
GPG key ID: 1AFF9C4DCED6D666
4 changed files with 7 additions and 10 deletions

View file

@ -729,9 +729,8 @@ func (c *ChannelStateDB) FetchChannel(chanPoint wire.OutPoint) (*OpenChannel,
// FetchChannelByID attempts to locate a channel specified by the passed channel
// ID. If the channel cannot be found, then an error will be returned.
// Optionally an existing db tx can be supplied.
func (c *ChannelStateDB) FetchChannelByID(tx kvdb.RTx, id lnwire.ChannelID) (
*OpenChannel, error) {
func (c *ChannelStateDB) FetchChannelByID(id lnwire.ChannelID) (*OpenChannel,
error) {
selector := func(chainBkt walletdb.ReadBucket) ([]byte, *wire.OutPoint,
error) {
@ -774,7 +773,7 @@ func (c *ChannelStateDB) FetchChannelByID(tx kvdb.RTx, id lnwire.ChannelID) (
return targetChanPointBytes, targetChanPoint, nil
}
return c.channelScanner(tx, selector)
return c.channelScanner(nil, selector)
}
// ChanCount is used by the server in determining access control.

View file

@ -253,7 +253,7 @@ func TestFetchChannel(t *testing.T) {
// Next, attempt to fetch the channel by its channel ID.
chanID := lnwire.NewChanIDFromOutPoint(channelState.FundingOutpoint)
dbChannel, err = cdb.FetchChannelByID(nil, chanID)
dbChannel, err = cdb.FetchChannelByID(chanID)
require.NoError(t, err, "unable to fetch channel")
// The decoded channel state should be identical to what we stored
@ -272,7 +272,7 @@ func TestFetchChannel(t *testing.T) {
require.ErrorIs(t, err, ErrChannelNotFound)
chanID2 := lnwire.NewChanIDFromOutPoint(channelState2.FundingOutpoint)
_, err = cdb.FetchChannelByID(nil, chanID2)
_, err = cdb.FetchChannelByID(chanID2)
require.ErrorIs(t, err, ErrChannelNotFound)
}

View file

@ -1118,7 +1118,7 @@ func assertConfirmationHeight(t *testing.T, node *testNode,
err := wait.NoError(func() error {
pendingChannel, err := node.fundingMgr.cfg.Wallet.Cfg.Database.
FetchChannelByID(nil, chanID)
FetchChannelByID(chanID)
if err != nil {
return fmt.Errorf("unable to fetch pending channel: %w",
err)

View file

@ -1760,9 +1760,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
commitHeight uint64) (*lnwallet.BreachRetribution,
channeldb.ChannelType, error) {
channel, err := s.chanStateDB.FetchChannelByID(
nil, chanID,
)
channel, err := s.chanStateDB.FetchChannelByID(chanID)
if err != nil {
return nil, 0, err
}