Skip to content

Commit

Permalink
remove source field from interceptor output
Browse files Browse the repository at this point in the history
Next step in isolating per-node logic.
  • Loading branch information
joostjager committed Nov 8, 2022
1 parent 3be8194 commit c19e992
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ func (i *interceptor) htlcReceiveLoop(ctx context.Context,

select {
case i.htlcChan <- &interceptedHtlc{
source: i.pubKey,
circuitKey: circuitKey,
hash: hash,
onionBlob: htlc.OnionBlob,
Expand Down
19 changes: 11 additions & 8 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"sync"

"github.com/bottlepay/lnmux/common"
"github.com/bottlepay/lnmux/lnd"
"github.com/bottlepay/lnmux/types"
"github.com/btcsuite/btcd/chaincfg"
Expand All @@ -29,6 +28,8 @@ type Mux struct {

settledHandler *SettledHandler
routingPolicy RoutingPolicy

virtualChannel uint64
}

type MuxConfig struct {
Expand Down Expand Up @@ -74,18 +75,23 @@ func New(cfg *MuxConfig) (*Mux,

sphinx := hop.NewOnionProcessor(sphinxRouter)

connectedNode := cfg.Lnd.PubKey()
logger := cfg.Logger.With("node", connectedNode)

virtualChannel := virtualChannelFromNode(connectedNode)

return &Mux{
registry: cfg.Registry,
sphinx: sphinx,
lnd: cfg.Lnd,
logger: cfg.Logger,
logger: logger,
settledHandler: cfg.SettledHandler,
routingPolicy: cfg.RoutingPolicy,
virtualChannel: virtualChannel,
}, nil
}

type interceptedHtlc struct {
source common.PubKey
circuitKey types.CircuitKey
hash lntypes.Hash
onionBlob []byte
Expand Down Expand Up @@ -153,10 +159,8 @@ func (p *Mux) Run(mainCtx context.Context) error {
}

case htlc := <-htlcChan:
virtualChannel := virtualChannelFromNode(htlc.source)

// Only intercept htlcs for the virtual channel.
if htlc.outgoingChanID != virtualChannel {
if htlc.outgoingChanID != p.virtualChannel {
err := htlc.reply(&interceptedHtlcResponse{
action: routerrpc.ResolveHoldForwardAction_RESUME,
})
Expand Down Expand Up @@ -209,7 +213,6 @@ func (p *Mux) ProcessHtlc(

logger := p.logger.With(
"hash", htlc.hash,
"source", htlc.source,
"circuitKey", htlc.circuitKey,
)

Expand Down Expand Up @@ -354,7 +357,7 @@ func (p *Mux) ProcessHtlc(
htlcKey := types.HtlcKey{
ChanID: htlc.circuitKey.ChanID,
HtlcID: htlc.circuitKey.HtlcID,
Node: htlc.source,
Node: p.lnd.PubKey(),
}

p.registry.NotifyExitHopHtlc(
Expand Down

0 comments on commit c19e992

Please sign in to comment.