@@ -679,23 +679,13 @@ func (p *paymentLifecycle) sendAttempt(
679679 CustomRecords : lnwire .CustomRecords (p .firstHopTLVs ),
680680 }
681681
682- // If we had custom records in the HTLC, then we'll encode that here
683- // now. We allow the traffic shaper (if there is one) to overwrite the
684- // custom records below. But if there is no traffic shaper, we still
685- // want to forward these custom records.
686- encodedRecords , err := htlcAdd .CustomRecords .Serialize ()
687- if err != nil {
688- return nil , fmt .Errorf ("unable to encode first hop TLVs: %w" ,
689- err )
690- }
691-
692682 // If a hook exists that may affect our outgoing message, we call it now
693683 // and apply its side effects to the UpdateAddHTLC message.
694- err = fn .MapOptionZ (
684+ err : = fn .MapOptionZ (
695685 p .router .cfg .TrafficShaper ,
696686 func (ts TlvTrafficShaper ) error {
697687 newAmt , newData , err := ts .ProduceHtlcExtraData (
698- rt .TotalAmount , encodedRecords ,
688+ rt .TotalAmount , htlcAdd . CustomRecords ,
699689 )
700690 if err != nil {
701691 return err
@@ -706,8 +696,12 @@ func (p *paymentLifecycle) sendAttempt(
706696 return err
707697 }
708698
699+ log .Debugf ("TLV traffic shaper returned custom " +
700+ "records %v and amount %d msat for HTLC" ,
701+ spew .Sdump (customRecords ), newAmt )
702+
709703 htlcAdd .CustomRecords = customRecords
710- htlcAdd .Amount = lnwire . NewMSatFromSatoshis ( newAmt )
704+ htlcAdd .Amount = newAmt
711705
712706 return nil
713707 },
0 commit comments