lnwire: add IncorrectValue as HTLC error type, fix typos

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-01-07 19:24:40 -08:00
parent 219c79e726
commit 81767eb8fd
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
3 changed files with 17 additions and 10 deletions

@ -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"
}

@ -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.

@ -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