htlcswitch: set packet obfuscator for failures through switch
Set obfuscator for use in blinded error handling when we forward failures through the switch.
This commit is contained in:
2 files changed
+15
-1
No files matched your search
@@ -738,6 +738,7 @@ func (m *memoryMailBox) FailAdd(pkt *htlcPacket) {
|
|||||||
sourceRef: pkt.sourceRef,
|
sourceRef: pkt.sourceRef,
|
||||||
hasSource: true,
|
hasSource: true,
|
||||||
localFailure: localFailure,
|
localFailure: localFailure,
|
||||||
|
obfuscator: pkt.obfuscator,
|
||||||
linkFailure: linkError,
|
linkFailure: linkError,
|
||||||
htlc: &lnwire.UpdateFailHTLC{
|
htlc: &lnwire.UpdateFailHTLC{
|
||||||
Reason: reason,
|
Reason: reason,
|
||||||
|
|||||||
+14
-1
@@ -1297,6 +1297,11 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
|||||||
|
|
||||||
fail, isFail := htlc.(*lnwire.UpdateFailHTLC)
|
fail, isFail := htlc.(*lnwire.UpdateFailHTLC)
|
||||||
if isFail && !packet.hasSource {
|
if isFail && !packet.hasSource {
|
||||||
|
// HTLC resolutions and messages restored from disk
|
||||||
|
// don't have the obfuscator set from the original htlc
|
||||||
|
// add packet - set it here for use in blinded errors.
|
||||||
|
packet.obfuscator = circuit.ErrorEncrypter
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
// No message to encrypt, locally sourced payment.
|
// No message to encrypt, locally sourced payment.
|
||||||
case circuit.ErrorEncrypter == nil:
|
case circuit.ErrorEncrypter == nil:
|
||||||
@@ -1485,6 +1490,7 @@ func (s *Switch) failAddPacket(packet *htlcPacket, failure *LinkError) error {
|
|||||||
incomingTimeout: packet.incomingTimeout,
|
incomingTimeout: packet.incomingTimeout,
|
||||||
outgoingTimeout: packet.outgoingTimeout,
|
outgoingTimeout: packet.outgoingTimeout,
|
||||||
circuit: packet.circuit,
|
circuit: packet.circuit,
|
||||||
|
obfuscator: packet.obfuscator,
|
||||||
linkFailure: failure,
|
linkFailure: failure,
|
||||||
htlc: &lnwire.UpdateFailHTLC{
|
htlc: &lnwire.UpdateFailHTLC{
|
||||||
Reason: reason,
|
Reason: reason,
|
||||||
@@ -1841,6 +1847,10 @@ out:
|
|||||||
// resolution message on restart.
|
// resolution message on restart.
|
||||||
resolutionMsg.errChan <- nil
|
resolutionMsg.errChan <- nil
|
||||||
|
|
||||||
|
// Create a htlc packet for this resolution. We do
|
||||||
|
// not have some of the information that we'll need
|
||||||
|
// for blinded error handling here , so we'll rely on
|
||||||
|
// our forwarding logic to fill it in later.
|
||||||
pkt := &htlcPacket{
|
pkt := &htlcPacket{
|
||||||
outgoingChanID: resolutionMsg.SourceChan,
|
outgoingChanID: resolutionMsg.SourceChan,
|
||||||
outgoingHTLCID: resolutionMsg.HtlcIndex,
|
outgoingHTLCID: resolutionMsg.HtlcIndex,
|
||||||
@@ -2065,6 +2075,8 @@ func (s *Switch) reforwardResolutions() error {
|
|||||||
|
|
||||||
// The circuit is still open, so we can assume that the link or
|
// The circuit is still open, so we can assume that the link or
|
||||||
// switch (if we are the source) hasn't cleaned it up yet.
|
// switch (if we are the source) hasn't cleaned it up yet.
|
||||||
|
// We rely on our forwarding logic to fill in details that
|
||||||
|
// are not currently available to us.
|
||||||
resPkt := &htlcPacket{
|
resPkt := &htlcPacket{
|
||||||
outgoingChanID: resMsg.SourceChan,
|
outgoingChanID: resMsg.SourceChan,
|
||||||
outgoingHTLCID: resMsg.HtlcIndex,
|
outgoingHTLCID: resMsg.HtlcIndex,
|
||||||
@@ -2214,7 +2226,8 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
|
|||||||
// we can continue to propagate it. This
|
// we can continue to propagate it. This
|
||||||
// failure originated from another node, so
|
// failure originated from another node, so
|
||||||
// the linkFailure field is not set on this
|
// the linkFailure field is not set on this
|
||||||
// packet.
|
// packet. We rely on the link to fill in
|
||||||
|
// additional circuit information for us.
|
||||||
failPacket := &htlcPacket{
|
failPacket := &htlcPacket{
|
||||||
outgoingChanID: fwdPkg.Source,
|
outgoingChanID: fwdPkg.Source,
|
||||||
outgoingHTLCID: pd.ParentIndex,
|
outgoingHTLCID: pd.ParentIndex,
|
||||||
|
|||||||
Reference in new issue
Block a user