mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-02 00:52:13 +02:00
routing: invoke htlc ExtraData producer on update_add_htlc
This commit is contained in:
parent
309a1564d0
commit
4c7d2d4e99
@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
@ -688,6 +689,26 @@ func (p *paymentLifecycle) sendAttempt(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If a hook exists that may affect our outgoing message, we call it now
|
||||
// and apply its side effects to the UpdateAddHTLC message.
|
||||
var err error
|
||||
|
||||
p.router.cfg.TrafficShaper.WhenSome(func(ts TlvTrafficShaper) {
|
||||
var newAmt btcutil.Amount
|
||||
var newData []byte
|
||||
|
||||
newAmt, newData, err = ts.ProduceHtlcExtraData(
|
||||
htlcAdd.ExtraData, uint64(htlcAdd.Amount.ToSatoshis()),
|
||||
)
|
||||
|
||||
htlcAdd.ExtraData = newData
|
||||
htlcAdd.Amount = lnwire.MilliSatoshi(newAmt * 1000)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Generate the raw encoded sphinx packet to be included along
|
||||
// with the htlcAdd message that we send directly to the
|
||||
// switch.
|
||||
|
Loading…
x
Reference in New Issue
Block a user