Merge pull request #29 from rkfg/deprecate-allow-unbalance

pull/33/head
rkfg 2 years ago committed by GitHub
commit 19a61db973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -68,8 +68,7 @@ func (r *regolancer) getChannelCandidates(fromPerc, toPerc, amount int64) error
} }
if _, ok := r.excludeIn[c.ChanId]; !ok { if _, ok := r.excludeIn[c.ChanId]; !ok {
if _, ok := r.toChannelId[c.ChanId]; ok || len(r.toChannelId) == 0 { if _, ok := r.toChannelId[c.ChanId]; ok || len(r.toChannelId) == 0 {
if c.LocalBalance < c.Capacity*toPerc/100 && (params.AllowUnbalanceTo || if c.LocalBalance < c.Capacity*toPerc/100 {
c.LocalBalance+amount < c.Capacity/2) {
r.toChannels = append(r.toChannels, c) r.toChannels = append(r.toChannels, c)
} }
} }
@ -77,9 +76,7 @@ func (r *regolancer) getChannelCandidates(fromPerc, toPerc, amount int64) error
} }
if _, ok := r.excludeOut[c.ChanId]; !ok { if _, ok := r.excludeOut[c.ChanId]; !ok {
if _, ok := r.fromChannelId[c.ChanId]; ok || len(r.fromChannelId) == 0 { if _, ok := r.fromChannelId[c.ChanId]; ok || len(r.fromChannelId) == 0 {
if c.RemoteBalance < c.Capacity*fromPerc/100 && if c.RemoteBalance < c.Capacity*fromPerc/100 {
(params.AllowUnbalanceFrom ||
c.RemoteBalance+amount < c.Capacity/2) {
r.fromChannels = append(r.fromChannels, c) r.fromChannels = append(r.fromChannels, c)
} }
} }
@ -136,17 +133,11 @@ func (r *regolancer) pickChannelPair(amount, minAmount int64,
} }
fromChan = pair[0] fromChan = pair[0]
toChan = pair[1] toChan = pair[1]
maxFrom := fromChan.Capacity/2 - fromChan.RemoteBalance maxFrom := fromChan.LocalBalance
if params.AllowUnbalanceFrom {
maxFrom = fromChan.LocalBalance
}
if relFromAmount > 0 { if relFromAmount > 0 {
maxFrom = min(maxFrom, int64(float64(fromChan.Capacity)*relFromAmount)-fromChan.RemoteBalance) maxFrom = min(maxFrom, int64(float64(fromChan.Capacity)*relFromAmount)-fromChan.RemoteBalance)
} }
maxTo := toChan.Capacity/2 - toChan.LocalBalance maxTo := toChan.RemoteBalance
if params.AllowUnbalanceTo {
maxTo = toChan.RemoteBalance
}
if relToAmount > 0 { if relToAmount > 0 {
maxTo = min(maxTo, int64(float64(toChan.Capacity)*relToAmount)-toChan.LocalBalance) maxTo = min(maxTo, int64(float64(toChan.Capacity)*relToAmount)-toChan.LocalBalance)
} }

@ -391,6 +391,9 @@ func preflightChecks(params *configParams) error {
(params.RelAmountFrom > 0 || params.RelAmountTo > 0) { (params.RelAmountFrom > 0 || params.RelAmountTo > 0) {
return fmt.Errorf("use either precise amount or relative amounts but not both") return fmt.Errorf("use either precise amount or relative amounts but not both")
} }
if params.Amount == 0 && params.RelAmountFrom == 0 && params.RelAmountTo == 0 {
return fmt.Errorf("no amount specified, use either --amount, --rel-amount-from, or --rel-amount-to")
}
if params.FailTolerance == 0 { if params.FailTolerance == 0 {
params.FailTolerance = 1000 params.FailTolerance = 1000
} }
@ -410,6 +413,10 @@ func preflightChecks(params *configParams) error {
} }
} }
if params.AllowUnbalanceFrom || params.AllowUnbalanceTo {
log.Print(infoColor("--allow-unbalance-from/to are deprecated and enabled by default, please remove them from your config or command line parameters"))
}
return nil return nil
} }

Loading…
Cancel
Save