From 5e5cc9b209a7ce941ee340d7a8ee23e97074b8f4 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 13 Dec 2017 17:15:36 -0800 Subject: [PATCH] lnwallet: add new method to register our preferred minHTLC value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lnwallet/reservation.go | 10 ++++++++++ lnwallet/wallet.go | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lnwallet/reservation.go b/lnwallet/reservation.go index 87b77789..e10acd09 100644 --- a/lnwallet/reservation.go +++ b/lnwallet/reservation.go @@ -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 diff --git a/lnwallet/wallet.go b/lnwallet/wallet.go index f4d780ec..42411bd7 100644 --- a/lnwallet/wallet.go +++ b/lnwallet/wallet.go @@ -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?