From 81767eb8fd9e36a728bd103a38404ec7d863453d Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 7 Jan 2017 19:24:40 -0800 Subject: [PATCH] lnwire: add IncorrectValue as HTLC error type, fix typos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a new HTLC error type: IncorrectValue. This error type is to be used when an HTLC that’s extended to the final destination does not match the expectation of the destination. --- lnwire/htlc_cancel.go | 23 +++++++++++++++-------- lnwire/htlc_cancel_test.go | 2 +- lnwire/single_funding_request.go | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lnwire/htlc_cancel.go b/lnwire/htlc_cancel.go index 8fa7dbe03..447fea236 100644 --- a/lnwire/htlc_cancel.go +++ b/lnwire/htlc_cancel.go @@ -26,18 +26,22 @@ const ( // absolute HTLC timeout, removing the HTLC. UpstreamTimeout = 1 - // UnkownPaymentHash indicates that the destination did not recognize + // UnknownPaymentHash indicates that the destination did not recognize // the payment hash. - UnkownPaymentHash = 2 + UnknownPaymentHash = 2 - // UnkownDestination indicates that the specified next hop within the + // UnknownDestination indicates that the specified next hop within the // Sphinx packet at a point in the route contained an unknown or // invalid "next hop". - UnkownDestination = 3 + UnknownDestination = 3 // SphinxParseError indicates that an intermediate node was unable // properly parse the HTLC. SphinxParseError = 4 + + // IncorrectValue indicates that the HTLC ultimately extended to the + // destination did not match the value that was expected. + IncorrectValue = 5 ) // String returns a human-readable version of the CancelReason type. @@ -50,16 +54,19 @@ func (c CancelReason) String() string { case UpstreamTimeout: return "UpstreamTimeout: HTLC has timed out upstream" - case UnkownPaymentHash: - return "UnkownPaymentHash: the destination did not know the " + + case UnknownPaymentHash: + return "UnknownPaymentHash: the destination did not know the " + "preimage" - case UnkownDestination: - return "UnkownDestination: next hop unknown" + case UnknownDestination: + return "UnknownDestination: next hop unknown" case SphinxParseError: return "SphinxParseError: unable to parse sphinx packet" + case IncorrectValue: + return "IncorrectValue: htlc value was wrong" + default: return "unknown reason" } diff --git a/lnwire/htlc_cancel_test.go b/lnwire/htlc_cancel_test.go index 416fc52f9..538bab84e 100644 --- a/lnwire/htlc_cancel_test.go +++ b/lnwire/htlc_cancel_test.go @@ -11,7 +11,7 @@ func TestCancelHTLCEncodeDecode(t *testing.T) { cancelMsg := &CancelHTLC{ ChannelPoint: outpoint1, HTLCKey: 22, - Reason: UpstreamTimeout, + Reason: UnknownPaymentHash, } // Next encode the HTLCTR message into an empty bytes buffer. diff --git a/lnwire/single_funding_request.go b/lnwire/single_funding_request.go index 2dc9a3337..a60f0c6f4 100644 --- a/lnwire/single_funding_request.go +++ b/lnwire/single_funding_request.go @@ -41,7 +41,7 @@ type SingleFundingRequest struct { // channel is open. FeePerKb btcutil.Amount - // FundingAmount is the number of satoshis the the initiator would like + // FundingAmount is the number of satoshis the initiator would like // to commit to the channel. FundingAmount btcutil.Amount