accounts: rename store IncreaseAccountBalance

In preparation for the upcoming credit/debit accounts feature, rename
the store `IncreaseAccountBalance` method to `CreditAccount` to better
reflect its purpose.
This commit is contained in:
Viktor Tigerström 2025-02-11 17:32:42 +01:00
parent 1a389d1a0d
commit cc003ab7a7
No known key found for this signature in database
GPG key ID: B984570980684DCC
4 changed files with 8 additions and 8 deletions

View file

@ -225,9 +225,9 @@ type Store interface {
AddAccountInvoice(ctx context.Context, id AccountID,
hash lntypes.Hash) error
// IncreaseAccountBalance increases the balance of the account with the
// CreditAccount increases the balance of the account with the
// given ID by the given amount.
IncreaseAccountBalance(ctx context.Context, id AccountID,
CreditAccount(ctx context.Context, id AccountID,
amount lnwire.MilliSatoshi) error
// UpsertAccountPayment updates or inserts a payment entry for the given

View file

@ -563,7 +563,7 @@ func (s *InterceptorService) invoiceUpdate(ctx context.Context,
// If we get here, the current account has the invoice associated with
// it that was just paid. Credit the amount to the account and update it
// in the DB.
err := s.store.IncreaseAccountBalance(ctx, acctID, invoice.AmountPaid)
err := s.store.CreditAccount(ctx, acctID, invoice.AmountPaid)
if err != nil {
return s.disableAndErrorfUnsafe("error increasing account "+
"balance account: %w", err)

View file

@ -223,11 +223,11 @@ func (s *BoltStore) AddAccountInvoice(_ context.Context, id AccountID,
return s.updateAccount(id, update)
}
// IncreaseAccountBalance increases the balance of the account with the given ID
// CreditAccount increases the balance of the account with the given ID
// by the given amount.
//
// NOTE: This is part of the Store interface.
func (s *BoltStore) IncreaseAccountBalance(_ context.Context, id AccountID,
func (s *BoltStore) CreditAccount(_ context.Context, id AccountID,
amount lnwire.MilliSatoshi) error {
update := func(account *OffChainBalanceAccount) error {

View file

@ -262,12 +262,12 @@ func TestAccountUpdateMethods(t *testing.T) {
assertInvoices(hash1, hash2)
})
t.Run("IncreaseAccountBalance", func(t *testing.T) {
t.Run("CreditAccount", func(t *testing.T) {
store := NewTestDB(t, clock.NewTestClock(time.Now()))
// Increasing the balance of an account that doesn't exist
// should error out.
err := store.IncreaseAccountBalance(ctx, AccountID{}, 100)
err := store.CreditAccount(ctx, AccountID{}, 100)
require.ErrorIs(t, err, ErrAccNotFound)
acct, err := store.NewAccount(ctx, 123, time.Time{}, "foo")
@ -284,7 +284,7 @@ func TestAccountUpdateMethods(t *testing.T) {
// Increase the balance by 100 and assert that the new balance
// is 223.
err = store.IncreaseAccountBalance(ctx, acct.ID, 100)
err = store.CreditAccount(ctx, acct.ID, 100)
require.NoError(t, err)
assertBalance(223)