mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 01:33:01 +02:00
Merge pull request #3027 from Roasbeef/new-onion-structs
router+build: update to the latest version of lightning-onion
This commit is contained in:
@@ -956,7 +956,7 @@ func (s *Switch) parseFailedPayment(payment *pendingPayment, pkt *htlcPacket,
|
||||
// The payment never cleared the link, so we don't need to
|
||||
// decrypt the error, simply decode it them report back to the
|
||||
// user.
|
||||
case pkt.localFailure:
|
||||
case pkt.localFailure || pkt.convertedError:
|
||||
var userErr string
|
||||
r := bytes.NewReader(htlc.Reason)
|
||||
failureMsg, err := lnwire.DecodeFailure(r, 0)
|
||||
@@ -1172,13 +1172,12 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
||||
fail, isFail := htlc.(*lnwire.UpdateFailHTLC)
|
||||
if isFail && !packet.hasSource {
|
||||
switch {
|
||||
// No message to encrypt, locally sourced payment.
|
||||
case circuit.ErrorEncrypter == nil:
|
||||
// No message to encrypt, locally sourced
|
||||
// payment.
|
||||
|
||||
// If this is a resolution message, then we'll need to
|
||||
// encrypt it as it's actually internally sourced.
|
||||
case packet.isResolution:
|
||||
// If this is a resolution message, then we'll need to encrypt
|
||||
// it as it's actually internally sourced.
|
||||
var err error
|
||||
// TODO(roasbeef): don't need to pass actually?
|
||||
failure := &lnwire.FailPermanentChannelFailure{}
|
||||
@@ -1191,6 +1190,25 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
// Alternatively, if the remote party send us an
|
||||
// UpdateFailMalformedHTLC, then we'll need to convert
|
||||
// this into a proper well formatted onion error as
|
||||
// there's no HMAC currently.
|
||||
case packet.convertedError:
|
||||
log.Infof("Converting malformed HTLC error "+
|
||||
"for circuit for Circuit(%x: "+
|
||||
"(%s, %d) <-> (%s, %d))", packet.circuit.PaymentHash,
|
||||
packet.incomingChanID, packet.incomingHTLCID,
|
||||
packet.outgoingChanID, packet.outgoingHTLCID)
|
||||
|
||||
fail.Reason = circuit.ErrorEncrypter.EncryptMalformedError(
|
||||
fail.Reason,
|
||||
)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("unable to obfuscate "+
|
||||
"error: %v", err)
|
||||
log.Error(err)
|
||||
}
|
||||
default:
|
||||
// Otherwise, it's a forwarded error, so we'll perform a
|
||||
// wrapper encryption as normal.
|
||||
|
Reference in New Issue
Block a user