htlcswitch+test: send switch back error on lnwallet.ErrInsufficientBalance

This commit fixes a bug related to swallowing an error that should go
to the switch in the case of an insufficient balance error when
attempting to add a new HTLC to the channel state machine. In this
case, an error would never be returned back to the client/switch, and
the internal processing within the channelLink would loop forever,
attempting to add an HTLC that can’t be added due to insufficient
balance to state machine itself.

We fix this issue by only treating the lnwallet.ErrMaxHTLCNumber as the
only error that prompts adding an HTLC to the overflow queue rather
than sending the error directly back to the switch.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-09-25 16:10:20 -07:00
1 parent 97e730cf51
commit 7ae436e30e
3 files changed
+12 -14

No files matched your search

+2
View File
@@ -389,6 +389,8 @@ func (s *Switch) handleLocalDispatch(payment *pendingPayment, packet *htlcPacket
// we're unable to then we'll bail early.
failure, err := payment.deobfuscator.Deobfuscate(htlc.Reason)
if err != nil {
// TODO(roasbeef): can happen in case of local error in
// link pkt handling
userErr = errors.Errorf("unable to de-obfuscate "+
"onion failure, htlc with hash(%x): %v",
payment.paymentHash[:], err)