mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-23 07:11:11 +02:00
routing: add first hop TLVs to ExtraData
This commit is contained in:
parent
cbdcdac213
commit
cf80b7cd9c
@ -1,7 +1,6 @@
|
|||||||
package routing
|
package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
@ -11,6 +10,7 @@ import (
|
|||||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@ -678,18 +678,15 @@ func (p *paymentLifecycle) sendAttempt(
|
|||||||
PaymentHash: *attempt.Hash,
|
PaymentHash: *attempt.Hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer := new(bytes.Buffer)
|
// If we had any first hop TLVs, then we'll encode that here now.
|
||||||
if err := p.firstHopTLVs.Encode(buffer); err != nil {
|
firstHopTLVs := tlv.MapToRecords(p.firstHopTLVs)
|
||||||
return p.failAttempt(attempt.AttemptID, err)
|
wireTLVs := fn.Map(func(r tlv.Record) tlv.RecordProducer {
|
||||||
|
return &r
|
||||||
|
}, firstHopTLVs)
|
||||||
|
if err := htlcAdd.ExtraData.PackRecords(wireTLVs...); err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
recordsBytes := buffer.Bytes()
|
|
||||||
tlvRecord := tlv.NewPrimitiveRecord[lnwire.CustomRecordsBlobTlvType](
|
|
||||||
recordsBytes,
|
|
||||||
)
|
|
||||||
|
|
||||||
htlcAdd.CustomRecordsBlob = tlv.SomeRecordT(tlvRecord)
|
|
||||||
|
|
||||||
// Generate the raw encoded sphinx packet to be included along
|
// Generate the raw encoded sphinx packet to be included along
|
||||||
// with the htlcAdd message that we send directly to the
|
// with the htlcAdd message that we send directly to the
|
||||||
// switch.
|
// switch.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user