Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
fix: drain alby shared funds calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jul 4, 2024
1 parent f82bd5f commit eebeab8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions alby/alby_oauth_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,18 @@ func (svc *albyOAuthService) DrainSharedWallet(ctx context.Context, lnClient lnc
return err
}

amount := int64(math.Floor(
float64(balance.Balance)*1000* // Alby shared node balance in sats
(1-8/1000)* // Alby service fee (0.8%)
0.99)) - // Maximum potential routing fees (1%)
10000 // Alby fee reserve (10 sats)
balanceSat := float64(balance.Balance)

if amount < 1000 {
amountSat := int64(math.Floor(
balanceSat- // Alby shared node balance in sats
(balanceSat*(8/1000))- // Alby service fee (0.8%)
(balanceSat*0.01))) - // Maximum potential routing fees (1%)
10 // Alby fee reserve (10 sats)

if amountSat < 1 {
return errors.New("Not enough balance remaining")
}
amount := amountSat * 1000

logger.Logger.WithField("amount", amount).WithError(err).Error("Draining Alby shared wallet funds")

Expand Down

0 comments on commit eebeab8

Please sign in to comment.