lnwallet: modify logging to display mSAT amount if funding constrains invalid

This commit is contained in:
Olaoluwa Osuntokun 2018-02-24 19:09:49 -08:00
parent f83d56c91f
commit 5ecef17e0f
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 12 additions and 16 deletions

View File

@ -288,40 +288,36 @@ func (r *ChannelReservation) CommitConstraints(csvDelay, maxHtlcs uint16,
return ErrCsvDelayTooLarge(csvDelay, maxDelay) return ErrCsvDelayTooLarge(csvDelay, maxDelay)
} }
// Fail if we consider the channel reserve to be too large. // Fail if we consider the channel reserve to be too large. We
// We currently fail if it is greater than 20% of the // currently fail if it is greater than 20% of the channel capacity.
// channel capacity.
maxChanReserve := r.partialState.Capacity / 5 maxChanReserve := r.partialState.Capacity / 5
if chanReserve > maxChanReserve { if chanReserve > maxChanReserve {
return ErrChanReserveTooLarge(chanReserve, maxChanReserve) return ErrChanReserveTooLarge(chanReserve, maxChanReserve)
} }
// Fail if the minimum HTLC value is too large. If this is // Fail if the minimum HTLC value is too large. If this is too large,
// too large, the channel won't be useful for sending small // the channel won't be useful for sending small payments. This limit
// payments. This limit is currently set to maxValueInFlight, // is currently set to maxValueInFlight, effectively letting the remote
// effictively letting the remote setting this as large as // setting this as large as it wants.
// it wants.
// TODO(halseth): set a reasonable/dynamic value.
if minHtlc > maxValueInFlight { if minHtlc > maxValueInFlight {
return ErrMinHtlcTooLarge(minHtlc, maxValueInFlight) return ErrMinHtlcTooLarge(minHtlc, maxValueInFlight)
} }
// Fail if maxHtlcs is above the maximum allowed number of 483. // Fail if maxHtlcs is above the maximum allowed number of 483. This
// This number is specified in BOLT-02. // number is specified in BOLT-02.
if maxHtlcs > uint16(MaxHTLCNumber/2) { if maxHtlcs > uint16(MaxHTLCNumber/2) {
return ErrMaxHtlcNumTooLarge(maxHtlcs, uint16(MaxHTLCNumber/2)) return ErrMaxHtlcNumTooLarge(maxHtlcs, uint16(MaxHTLCNumber/2))
} }
// Fail if we consider maxHtlcs too small. If this is too small // Fail if we consider maxHtlcs too small. If this is too small we
// we cannot offer many HTLCs to the remote. // cannot offer many HTLCs to the remote.
const minNumHtlc = 5 const minNumHtlc = 5
if maxHtlcs < minNumHtlc { if maxHtlcs < minNumHtlc {
return ErrMaxHtlcNumTooSmall(maxHtlcs, minNumHtlc) return ErrMaxHtlcNumTooSmall(maxHtlcs, minNumHtlc)
} }
// Fail if we consider maxValueInFlight too small. We currently // Fail if we consider maxValueInFlight too small. We currently require
// require the remote to at least allow minNumHtlc * minHtlc // the remote to at least allow minNumHtlc * minHtlc in flight.
// in flight.
if maxValueInFlight < minNumHtlc*minHtlc { if maxValueInFlight < minNumHtlc*minHtlc {
return ErrMaxValueInFlightTooSmall(maxValueInFlight, return ErrMaxValueInFlightTooSmall(maxValueInFlight,
minNumHtlc*minHtlc) minNumHtlc*minHtlc)