From 01d54c29af9f66b98c4320a2dea64ddbb531df2e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 4 Jul 2017 15:58:14 -0700 Subject: [PATCH] htlcswitch: restore the ability to properly handle debughtlc recv's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a regression introduce in the prior commit which added full verification of the per-hop payloads to the ChannelLink interface. When this was initially implemented, the added checks weren’t guarded on the existence of debughtlc’s. As a result, debughtlc’s would be rejected as they don’t match the expected invoice value. This commit fixes that issue by only checking the hop payload if debug HTLC mode isn’t on. --- htlcswitch/link.go | 8 ++++++-- htlcswitch/switch.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index eb94cffc8..3272969f3 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -928,7 +928,9 @@ func (l *channelLink) processLockedInHtlcs( // extended. Additionally, we'll ensure that // our time-lock value has been computed // correctly. - if fwdInfo.AmountToForward != invoice.Terms.Value { + if !l.cfg.DebugHTLC && + fwdInfo.AmountToForward != invoice.Terms.Value { + log.Errorf("Onion payload of incoming "+ "htlc(%x) has incorrect value: "+ "expected %v, got %v", pd.RHash, @@ -940,7 +942,9 @@ func (l *channelLink) processLockedInHtlcs( needUpdate = true continue } - if fwdInfo.OutgoingCTLV != l.cfg.FwrdingPolicy.TimeLockDelta { + if !l.cfg.DebugHTLC && + fwdInfo.OutgoingCTLV != l.cfg.FwrdingPolicy.TimeLockDelta { + log.Errorf("Onion payload of incoming "+ "htlc(%x) has incorrect time-lock: "+ "expected %v, got %v", diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 41c0fee49..ad927f05d 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -628,7 +628,7 @@ func (s *Switch) htlcForwarder() { // Otherwise, we'll log this diff, then accumulate the // new stats into the running total. log.Infof("Sent %v satoshis received %v satoshi "+ - " in the last 10 seconds (%v tx/sec)", + "in the last 10 seconds (%v tx/sec)", diffSatSent, diffSatRecv, float64(diffNumUpdates)/10) totalNumUpdates += diffNumUpdates