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:
parent
219c79e726
commit
81767eb8fd
@ -26,18 +26,22 @@ const (
|
|||||||
// absolute HTLC timeout, removing the HTLC.
|
// absolute HTLC timeout, removing the HTLC.
|
||||||
UpstreamTimeout = 1
|
UpstreamTimeout = 1
|
||||||
|
|
||||||
// UnkownPaymentHash indicates that the destination did not recognize
|
// UnknownPaymentHash indicates that the destination did not recognize
|
||||||
// the payment hash.
|
// 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
|
// Sphinx packet at a point in the route contained an unknown or
|
||||||
// invalid "next hop".
|
// invalid "next hop".
|
||||||
UnkownDestination = 3
|
UnknownDestination = 3
|
||||||
|
|
||||||
// SphinxParseError indicates that an intermediate node was unable
|
// SphinxParseError indicates that an intermediate node was unable
|
||||||
// properly parse the HTLC.
|
// properly parse the HTLC.
|
||||||
SphinxParseError = 4
|
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.
|
// String returns a human-readable version of the CancelReason type.
|
||||||
@ -50,16 +54,19 @@ func (c CancelReason) String() string {
|
|||||||
case UpstreamTimeout:
|
case UpstreamTimeout:
|
||||||
return "UpstreamTimeout: HTLC has timed out upstream"
|
return "UpstreamTimeout: HTLC has timed out upstream"
|
||||||
|
|
||||||
case UnkownPaymentHash:
|
case UnknownPaymentHash:
|
||||||
return "UnkownPaymentHash: the destination did not know the " +
|
return "UnknownPaymentHash: the destination did not know the " +
|
||||||
"preimage"
|
"preimage"
|
||||||
|
|
||||||
case UnkownDestination:
|
case UnknownDestination:
|
||||||
return "UnkownDestination: next hop unknown"
|
return "UnknownDestination: next hop unknown"
|
||||||
|
|
||||||
case SphinxParseError:
|
case SphinxParseError:
|
||||||
return "SphinxParseError: unable to parse sphinx packet"
|
return "SphinxParseError: unable to parse sphinx packet"
|
||||||
|
|
||||||
|
case IncorrectValue:
|
||||||
|
return "IncorrectValue: htlc value was wrong"
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "unknown reason"
|
return "unknown reason"
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ func TestCancelHTLCEncodeDecode(t *testing.T) {
|
|||||||
cancelMsg := &CancelHTLC{
|
cancelMsg := &CancelHTLC{
|
||||||
ChannelPoint: outpoint1,
|
ChannelPoint: outpoint1,
|
||||||
HTLCKey: 22,
|
HTLCKey: 22,
|
||||||
Reason: UpstreamTimeout,
|
Reason: UnknownPaymentHash,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next encode the HTLCTR message into an empty bytes buffer.
|
// Next encode the HTLCTR message into an empty bytes buffer.
|
||||||
|
@ -41,7 +41,7 @@ type SingleFundingRequest struct {
|
|||||||
// channel is open.
|
// channel is open.
|
||||||
FeePerKb btcutil.Amount
|
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.
|
// to commit to the channel.
|
||||||
FundingAmount btcutil.Amount
|
FundingAmount btcutil.Amount
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user