mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
Revert "funding+lnwallet: ensure max_htlc_value_in_flight smaller than capacity"
This reverts commit 4aa52d267f
.
It turns out that the other implementations set values for this field
which aren't based on the actual capacity of the channel. As a result,
we'll no reject most of their channel offerings, since they may offer a
value of a max `uint64` or something else hard coded that's above the
size of the channel. As a result, we're reverting this check for now to
maintain proper compatibility.
This commit is contained in:
parent
fd1bbe63cf
commit
b220c47ce7
4 changed files with 8 additions and 38 deletions
|
@ -1090,7 +1090,7 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
|
|||
MaxAcceptedHtlcs: msg.MaxAcceptedHTLCs,
|
||||
CsvDelay: msg.CsvDelay,
|
||||
}
|
||||
err = reservation.CommitConstraints(channelConstraints, amt)
|
||||
err = reservation.CommitConstraints(channelConstraints)
|
||||
if err != nil {
|
||||
fndgLog.Errorf("Unacceptable channel constraints: %v", err)
|
||||
f.failFundingFlow(fmsg.peer, fmsg.msg.PendingChannelID, err)
|
||||
|
@ -1254,9 +1254,7 @@ func (f *fundingManager) handleFundingAccept(fmsg *fundingAcceptMsg) {
|
|||
MaxAcceptedHtlcs: msg.MaxAcceptedHTLCs,
|
||||
CsvDelay: msg.CsvDelay,
|
||||
}
|
||||
err = resCtx.reservation.CommitConstraints(
|
||||
channelConstraints, resCtx.chanAmt,
|
||||
)
|
||||
err = resCtx.reservation.CommitConstraints(channelConstraints)
|
||||
if err != nil {
|
||||
fndgLog.Warnf("Unacceptable channel constraints: %v", err)
|
||||
f.failFundingFlow(fmsg.peer, fmsg.msg.PendingChannelID, err)
|
||||
|
|
|
@ -132,16 +132,6 @@ func ErrNumConfsTooLarge(numConfs, maxNumConfs uint32) error {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrMaxValueInFlightTooLarge returns an error indicating that the 'max HTLC
|
||||
// value in flight' the remote required is too large to be accepted.
|
||||
func ErrMaxValueInFlightTooLarge(maxValInFlight,
|
||||
maxMaxValInFlight lnwire.MilliSatoshi) ReservationError {
|
||||
return ReservationError{
|
||||
fmt.Errorf("maxValueInFlight too large: %v, max is %v",
|
||||
maxValInFlight, maxMaxValInFlight),
|
||||
}
|
||||
}
|
||||
|
||||
// ErrChanTooSmall returns an error indicating that an incoming channel request
|
||||
// was too small. We'll reject any incoming channels if they're below our
|
||||
// configured value for the min channel size we'll accept.
|
||||
|
|
|
@ -437,9 +437,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
|||
MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2,
|
||||
CsvDelay: csvDelay,
|
||||
}
|
||||
err = aliceChanReservation.CommitConstraints(
|
||||
channelConstraints, fundingAmount*2,
|
||||
)
|
||||
err = aliceChanReservation.CommitConstraints(channelConstraints)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to verify constraints: %v", err)
|
||||
}
|
||||
|
@ -473,9 +471,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
|||
if err != nil {
|
||||
t.Fatalf("bob unable to init channel reservation: %v", err)
|
||||
}
|
||||
err = bobChanReservation.CommitConstraints(
|
||||
channelConstraints, fundingAmount*2,
|
||||
)
|
||||
err = bobChanReservation.CommitConstraints(channelConstraints)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to verify constraints: %v", err)
|
||||
}
|
||||
|
@ -873,9 +869,7 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
|||
MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2,
|
||||
CsvDelay: csvDelay,
|
||||
}
|
||||
err = aliceChanReservation.CommitConstraints(
|
||||
channelConstraints, fundingAmt,
|
||||
)
|
||||
err = aliceChanReservation.CommitConstraints(channelConstraints)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to verify constraints: %v", err)
|
||||
}
|
||||
|
@ -909,9 +903,7 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
|||
if err != nil {
|
||||
t.Fatalf("unable to create bob reservation: %v", err)
|
||||
}
|
||||
err = bobChanReservation.CommitConstraints(
|
||||
channelConstraints, fundingAmt,
|
||||
)
|
||||
err = bobChanReservation.CommitConstraints(channelConstraints)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to verify constraints: %v", err)
|
||||
}
|
||||
|
|
|
@ -286,9 +286,7 @@ func (r *ChannelReservation) SetNumConfsRequired(numConfs uint16) {
|
|||
// of satoshis that can be transferred in a single commitment. This function
|
||||
// will also attempt to verify the constraints for sanity, returning an error
|
||||
// if the parameters are seemed unsound.
|
||||
func (r *ChannelReservation) CommitConstraints(c *channeldb.ChannelConstraints,
|
||||
capacity btcutil.Amount) error {
|
||||
|
||||
func (r *ChannelReservation) CommitConstraints(c *channeldb.ChannelConstraints) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
|
@ -343,15 +341,7 @@ func (r *ChannelReservation) CommitConstraints(c *channeldb.ChannelConstraints,
|
|||
)
|
||||
}
|
||||
|
||||
// Fail if the maxValueInFlight is greater than the channel capacity.
|
||||
capacityMsat := lnwire.NewMSatFromSatoshis(capacity)
|
||||
if c.MaxPendingAmount > capacityMsat {
|
||||
return ErrMaxValueInFlightTooLarge(
|
||||
c.MaxPendingAmount, capacityMsat,
|
||||
)
|
||||
}
|
||||
|
||||
// Our dust limit should always be less than or equal our proposed
|
||||
// Our dust limit should always be less than or equal to our proposed
|
||||
// channel reserve.
|
||||
if r.ourContribution.DustLimit > c.ChanReserve {
|
||||
r.ourContribution.DustLimit = c.ChanReserve
|
||||
|
|
Loading…
Add table
Reference in a new issue