Skip to content
Open
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
21 changes: 7 additions & 14 deletions accounts/checkers.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ func filterInvoices(ctx context.Context,
// after filtering.
var filteredInvoices []*lnrpc.Invoice
for _, invoice := range t.Invoices {
invoice := invoice

hash, err := lntypes.MakeHash(invoice.RHash)
if err != nil {
Expand Down Expand Up @@ -523,7 +522,6 @@ func filterPayments(ctx context.Context,
// after filtering.
var filteredPayments []*lnrpc.Payment
for _, payment := range t.Payments {
payment := payment

hash, err := lntypes.MakeHashFromStr(payment.PaymentHash)
if err != nil {
Expand All @@ -549,10 +547,7 @@ func checkSend(ctx context.Context, chainParams *chaincfg.Params,
return err
}

sendAmt := lnwire.NewMSatFromSatoshis(btcutil.Amount(amt))
if lnwire.MilliSatoshi(amtMsat) > sendAmt {
sendAmt = lnwire.MilliSatoshi(amtMsat)
}
sendAmt := max(lnwire.MilliSatoshi(amtMsat), lnwire.NewMSatFromSatoshis(btcutil.Amount(amt)))

// We require that a payment hash is set, which we either read from the
// payment hash from the invoice or from the request.
Expand Down Expand Up @@ -697,10 +692,9 @@ func checkSendToRoute(ctx context.Context, service Service, paymentHash []byte,
return fmt.Errorf("invalid route")
}

sendAmt := lnwire.NewMSatFromSatoshis(btcutil.Amount(route.TotalAmt)) // nolint
if lnwire.MilliSatoshi(route.TotalAmtMsat) > sendAmt {
sendAmt = lnwire.MilliSatoshi(route.TotalAmtMsat)
}
sendAmt := max(
// nolint
lnwire.MilliSatoshi(route.TotalAmtMsat), lnwire.NewMSatFromSatoshis(btcutil.Amount(route.TotalAmt)))

log.Tracef("Handling send request for payment with hash: %s and "+
"amount: %d", hash, sendAmt)
Expand All @@ -709,10 +703,9 @@ func checkSendToRoute(ctx context.Context, service Service, paymentHash []byte,
// not every single satoshi of an account can be used up. But it
// prevents an account from going into a negative balance if we only
// check for the amount to send but then later debit the full amount.
fee := lnwire.NewMSatFromSatoshis(btcutil.Amount(route.TotalFees)) // nolint
if lnwire.MilliSatoshi(route.TotalFeesMsat) > fee {
fee = lnwire.MilliSatoshi(route.TotalFeesMsat)
}
fee := max(
// nolint
lnwire.MilliSatoshi(route.TotalFeesMsat), lnwire.NewMSatFromSatoshis(btcutil.Amount(route.TotalFees)))
sendAmt += fee

err = service.CheckBalance(ctx, acct.ID, sendAmt)
Expand Down
1 change: 0 additions & 1 deletion accounts/checkers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ func TestAccountCheckers(t *testing.T) {
}}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(tt *testing.T) {
tt.Parallel()
Expand Down
4 changes: 2 additions & 2 deletions accounts/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var (
// caveatPrefix is the prefix that is used for custom caveats that are
// used by the account system. This prefix is used to identify the
// custom caveat and extract the condition (the AccountID) from it.
caveatPrefix = []byte(fmt.Sprintf(
caveatPrefix = fmt.Appendf(nil,
"%s %s ", macaroons.CondLndCustom, CondAccount,
))
)
)

// Name returns the name of the interceptor.
Expand Down
1 change: 0 additions & 1 deletion accounts/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ func (s *RPCServer) ListAccounts(ctx context.Context,
// Map the response into the proper response type and return it.
rpcAccounts := make([]*litrpc.Account, len(accts))
for i, acct := range accts {
acct := acct

rpcAccounts[i] = marshalAccount(acct)
}
Expand Down
3 changes: 0 additions & 3 deletions accounts/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,13 @@ func (s *InterceptorService) Start(ctx context.Context,
"accounts: %w", err)
}
for _, acct := range existingAccounts {
acct := acct
for invoice := range acct.Invoices {
invoice := invoice
s.invoiceToAccount[invoice] = acct.ID
}

// Let's also resume tracking payments that have a last recorded
// state of being in-flight.
for hash, entry := range acct.Payments {
entry := entry
if !successState(entry.Status) {
err := s.TrackPayment(
ctx, acct.ID, hash, entry.FullAmount,
Expand Down
5 changes: 2 additions & 3 deletions firewalldb/privacy_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"maps"
"math/big"
"strconv"
"strings"
Expand Down Expand Up @@ -340,9 +341,7 @@ func (p *PrivacyMapPairs) Add(pairs map[string]string) error {
}

// In our second pass, we can add the new pairs to our set.
for realStr, pseudoStr := range pairs {
p.pairs[realStr] = pseudoStr
}
maps.Copy(p.pairs, pairs)

return nil
}
1 change: 0 additions & 1 deletion rules/channel_restrictions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ func TestChannelRestrictRealToPseudo(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion rules/peer_restrictions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ func TestPeerRestrictRealToPseudo(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion session/tlv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func TestSerializeDeserializeSession(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()

Expand Down