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.
This commit is contained in:
Olaoluwa Osuntokun
2018-06-25 20:15:46 -07:00
parent 6e051a80ff
commit 74ec9147b1
3 changed files with 8 additions and 4 deletions

View File

@@ -81,8 +81,10 @@ type ChannelLink interface {
// Otherwise, a valid protocol failure message should be returned in // Otherwise, a valid protocol failure message should be returned in
// order to signal to the source of the HTLC, the policy consistency // order to signal to the source of the HTLC, the policy consistency
// issue. // issue.
HtlcSatifiesPolicy(payHash [32]byte, HtlcSatifiesPolicy(payHash [32]byte, incomingAmt lnwire.MilliSatoshi,
incomingAmt, amtToForward lnwire.MilliSatoshi) lnwire.FailureMessage amtToForward lnwire.MilliSatoshi,
incomingTimeout, outgoingTimeout uint32,
heightNow uint32) lnwire.FailureMessage
// Bandwidth returns the amount of milli-satoshis which current link // Bandwidth returns the amount of milli-satoshis which current link
// might pass through channel link. The value returned from this method // might pass through channel link. The value returned from this method

View File

@@ -1741,7 +1741,9 @@ func (l *channelLink) UpdateForwardingPolicy(newPolicy ForwardingPolicy) {
// //
// NOTE: Part of the ChannelLink interface. // NOTE: Part of the ChannelLink interface.
func (l *channelLink) HtlcSatifiesPolicy(payHash [32]byte, 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() l.RLock()
policy := l.cfg.FwrdingPolicy policy := l.cfg.FwrdingPolicy

View File

@@ -613,7 +613,7 @@ func (f *mockChannelLink) HandleChannelUpdate(lnwire.Message) {
func (f *mockChannelLink) UpdateForwardingPolicy(_ ForwardingPolicy) { func (f *mockChannelLink) UpdateForwardingPolicy(_ ForwardingPolicy) {
} }
func (f *mockChannelLink) HtlcSatifiesPolicy([32]byte, lnwire.MilliSatoshi, func (f *mockChannelLink) HtlcSatifiesPolicy([32]byte, lnwire.MilliSatoshi,
lnwire.MilliSatoshi) lnwire.FailureMessage { lnwire.MilliSatoshi, uint32, uint32, uint32) lnwire.FailureMessage {
return nil return nil
} }