htlcswitch+router: add onion error obfuscation

Within the network, it's important that when an HTLC forwarding failure
occurs, the recipient is notified in a timely manner in order to ensure
that errors are graceful and not unknown. For that reason with
accordance to BOLT №4 onion failure obfuscation have been added.
This commit is contained in:
Andrey Samokhvalov
2017-06-29 16:40:45 +03:00
committed by Olaoluwa Osuntokun
parent ef73062c14
commit 2d378b3280
13 changed files with 639 additions and 212 deletions

View File

@ -38,17 +38,23 @@ type paymentCircuit struct {
// request back.
Dest lnwire.ShortChannelID
// Obfuscator is used to obfuscate the onion failure before sending it
// back to the originator of the payment.
Obfuscator Obfuscator
// RefCount is used to count the circuits with the same circuit key.
RefCount int
}
// newPaymentCircuit creates new payment circuit instance.
func newPaymentCircuit(src, dest lnwire.ShortChannelID, key circuitKey) *paymentCircuit {
func newPaymentCircuit(src, dest lnwire.ShortChannelID, key circuitKey,
obfuscator Obfuscator) *paymentCircuit {
return &paymentCircuit{
Src: src,
Dest: dest,
PaymentHash: key,
RefCount: 1,
Obfuscator: obfuscator,
}
}