From 74ec9147b12f426bef680c1f13ce73edaffb58a3 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 25 Jun 2018 20:15:46 -0700 Subject: [PATCH] htlcswitch: extend the HtlcSatifiesPolicy to also accept timelock/height info In this commit, we extend the existing HtlcSatifiesPolicy method to also accept timelock and height information. This is required as an upcoming commit will fix an existing bug in the forwarding logic wherein we use the time lock policies of the incoming node rather than that of the outgoing node. --- htlcswitch/interfaces.go | 6 ++++-- htlcswitch/link.go | 4 +++- htlcswitch/mock.go | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htlcswitch/interfaces.go b/htlcswitch/interfaces.go index d1afa5683..e5cf4cd8e 100644 --- a/htlcswitch/interfaces.go +++ b/htlcswitch/interfaces.go @@ -81,8 +81,10 @@ type ChannelLink interface { // Otherwise, a valid protocol failure message should be returned in // order to signal to the source of the HTLC, the policy consistency // issue. - HtlcSatifiesPolicy(payHash [32]byte, - incomingAmt, amtToForward lnwire.MilliSatoshi) lnwire.FailureMessage + HtlcSatifiesPolicy(payHash [32]byte, incomingAmt lnwire.MilliSatoshi, + amtToForward lnwire.MilliSatoshi, + incomingTimeout, outgoingTimeout uint32, + heightNow uint32) lnwire.FailureMessage // Bandwidth returns the amount of milli-satoshis which current link // might pass through channel link. The value returned from this method diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 9a933f046..0a5ae9049 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -1741,7 +1741,9 @@ func (l *channelLink) UpdateForwardingPolicy(newPolicy ForwardingPolicy) { // // NOTE: Part of the ChannelLink interface. func (l *channelLink) HtlcSatifiesPolicy(payHash [32]byte, - incomingHtlcAmt, amtToForward lnwire.MilliSatoshi) lnwire.FailureMessage { + incomingHtlcAmt, amtToForward lnwire.MilliSatoshi, + incomingTimeout, outgoingTimeout uint32, + heightNow uint32) lnwire.FailureMessage { l.RLock() policy := l.cfg.FwrdingPolicy diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index dc47730f5..b96fa1e4a 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -613,7 +613,7 @@ func (f *mockChannelLink) HandleChannelUpdate(lnwire.Message) { func (f *mockChannelLink) UpdateForwardingPolicy(_ ForwardingPolicy) { } func (f *mockChannelLink) HtlcSatifiesPolicy([32]byte, lnwire.MilliSatoshi, - lnwire.MilliSatoshi) lnwire.FailureMessage { + lnwire.MilliSatoshi, uint32, uint32, uint32) lnwire.FailureMessage { return nil }