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:
parent
a036098e36
commit
5e5cc9b209
@ -258,6 +258,16 @@ func (r *ChannelReservation) SetNumConfsRequired(numConfs uint16) {
|
|||||||
r.partialState.NumConfsRequired = numConfs
|
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
|
// CommitConstraints takes the constraints that the remote party specifies for
|
||||||
// the type of commitments that we can generate for them. These constraints
|
// the type of commitments that we can generate for them. These constraints
|
||||||
// include several parameters that serve as flow control restricting the amount
|
// 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]
|
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
|
||||||
if !ok {
|
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")
|
req.err <- fmt.Errorf("attempted to cancel non-existent funding state")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the mutex on the ChannelReservation to ensure thead-safety
|
// Grab the mutex on the ChannelReservation to ensure thread-safety
|
||||||
pendingReservation.Lock()
|
pendingReservation.Lock()
|
||||||
defer pendingReservation.Unlock()
|
defer pendingReservation.Unlock()
|
||||||
|
|
||||||
// Mark all previously locked outpoints as usuable for future funding
|
// Mark all previously locked outpoints as useable for future funding
|
||||||
// requests.
|
// requests.
|
||||||
for _, unusedInput := range pendingReservation.ourContribution.Inputs {
|
for _, unusedInput := range pendingReservation.ourContribution.Inputs {
|
||||||
delete(l.lockedOutPoints, unusedInput.PreviousOutPoint)
|
delete(l.lockedOutPoints, unusedInput.PreviousOutPoint)
|
||||||
l.UnlockOutpoint(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
|
// TODO(roasbeef): Is it possible to mark the unused change also as
|
||||||
// available?
|
// available?
|
||||||
|
Loading…
Reference in New Issue
Block a user