lnwallet: add new method to register our preferred minHTLC value

Before this commit, during a reservation, we wouldn’t ever specify our
minHTL value. We don’t yet fully validate all channel constrains, but
doing this now serves to ensure that once those features are merged,
we’ll actually be setting a valid value for minHTLC.
This commit is contained in:
Olaoluwa Osuntokun 2017-12-13 17:15:36 -08:00
parent a036098e36
commit 5e5cc9b209
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 14 additions and 4 deletions

@ -258,6 +258,16 @@ func (r *ChannelReservation) SetNumConfsRequired(numConfs uint16) {
r.partialState.NumConfsRequired = numConfs
}
// RegisterMinHTLC registers our desired amount for the smallest acceptable
// HTLC we'll accept within this channel. Any HTLC's that are extended which
// are below this value will SHOULD be rejected.
func (r *ChannelReservation) RegisterMinHTLC(minHTLC lnwire.MilliSatoshi) {
r.Lock()
defer r.Unlock()
r.ourContribution.MinHTLC = minHTLC
}
// CommitConstraints takes the constraints that the remote party specifies for
// the type of commitments that we can generate for them. These constraints
// include several parameters that serve as flow control restricting the amount

@ -626,23 +626,23 @@ func (l *LightningWallet) handleFundingCancelRequest(req *fundingReserveCancelMs
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
if !ok {
// TODO(roasbeef): make new error, "unkown funding state" or something
// TODO(roasbeef): make new error, "unknown funding state" or something
req.err <- fmt.Errorf("attempted to cancel non-existent funding state")
return
}
// Grab the mutex on the ChannelReservation to ensure thead-safety
// Grab the mutex on the ChannelReservation to ensure thread-safety
pendingReservation.Lock()
defer pendingReservation.Unlock()
// Mark all previously locked outpoints as usuable for future funding
// Mark all previously locked outpoints as useable for future funding
// requests.
for _, unusedInput := range pendingReservation.ourContribution.Inputs {
delete(l.lockedOutPoints, unusedInput.PreviousOutPoint)
l.UnlockOutpoint(unusedInput.PreviousOutPoint)
}
// TODO(roasbeef): is it even worth it to keep track of unsed keys?
// TODO(roasbeef): is it even worth it to keep track of unused keys?
// TODO(roasbeef): Is it possible to mark the unused change also as
// available?