mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-13 18:10:25 +02:00
lnd: hook up encrypted onion error scaffolding
In this commit daemon have been changed to set the proper hooks in the channel link and switch subsystems so that they could send and receive encrypted onion errors.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
2d378b3280
commit
6bbb7cbfc3
17
server.go
17
server.go
@@ -71,7 +71,7 @@ type server struct {
|
||||
|
||||
utxoNursery *utxoNursery
|
||||
|
||||
sphinx *sphinx.Router
|
||||
sphinx *htlcswitch.OnionProcessor
|
||||
|
||||
connMgr *connmgr.ConnManager
|
||||
|
||||
@@ -126,7 +126,8 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
|
||||
|
||||
// TODO(roasbeef): derive proper onion key based on rotation
|
||||
// schedule
|
||||
sphinx: sphinx.NewRouter(privKey, activeNetParams.Params),
|
||||
sphinx: htlcswitch.NewOnionProcessor(
|
||||
sphinx.NewRouter(privKey, activeNetParams.Params)),
|
||||
lightningID: sha256.Sum256(serializedPubKey),
|
||||
|
||||
persistentPeers: make(map[string]struct{}),
|
||||
@@ -236,11 +237,19 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
|
||||
Chain: cc.chainIO,
|
||||
ChainView: cc.chainView,
|
||||
SendToSwitch: func(firstHop *btcec.PublicKey,
|
||||
htlcAdd *lnwire.UpdateAddHTLC) ([32]byte, error) {
|
||||
htlcAdd *lnwire.UpdateAddHTLC,
|
||||
circuit *sphinx.Circuit) ([32]byte, error) {
|
||||
|
||||
// Initialize the data obfuscator in order to be able to decode the
|
||||
// onion failure and wrap it so that we could process lnwire onion
|
||||
// failures.
|
||||
failureDeobfuscator := &htlcswitch.FailureDeobfuscator{
|
||||
OnionDeobfuscator: sphinx.NewOnionDeobfuscator(circuit),
|
||||
}
|
||||
|
||||
var firstHopPub [33]byte
|
||||
copy(firstHopPub[:], firstHop.SerializeCompressed())
|
||||
return s.htlcSwitch.SendHTLC(firstHopPub, htlcAdd)
|
||||
return s.htlcSwitch.SendHTLC(firstHopPub, htlcAdd, failureDeobfuscator)
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user