From e184bbcb5496cb2f098aeaec9bbf711e79b63c13 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 9 Mar 2018 14:22:23 -0800 Subject: [PATCH] funding: don't case to a net.TCPAddr to support tor stream isolation In this commit, we fix an existing bug in the funding manager, that can be triggered if the user is connecting to a node over Tor, and then attempts to open a channel. An existing fix was added for the case that the receiving node established the channel, but this now makes that case symmetric. --- fundingmanager.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index ecae47b1..d56dec28 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/binary" "fmt" - "net" "sync" "sync/atomic" "time" @@ -881,10 +880,12 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) { // TODO(roasbeef): assuming this was an inbound connection, replace // port with default advertised port chainHash := chainhash.Hash(msg.ChainHash) - reservation, err := f.cfg.Wallet.InitChannelReservation(amt, 0, - msg.PushAmount, lnwallet.SatPerKWeight(msg.FeePerKiloWeight), 0, + reservation, err := f.cfg.Wallet.InitChannelReservation( + amt, 0, msg.PushAmount, + lnwallet.SatPerKWeight(msg.FeePerKiloWeight), 0, fmsg.peerAddress.IdentityKey, fmsg.peerAddress.Address, - &chainHash, msg.ChannelFlags) + &chainHash, msg.ChannelFlags, + ) if err != nil { fndgLog.Errorf("Unable to initialize reservation: %v", err) f.failFundingFlow(fmsg.peerAddress.IdentityKey, @@ -2407,10 +2408,11 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) { // Initialize a funding reservation with the local wallet. If the // wallet doesn't have enough funds to commit to this channel, then the // request will fail, and be aborted. - reservation, err := f.cfg.Wallet.InitChannelReservation(capacity, - localAmt, msg.pushAmt, commitFeePerKw, msg.fundingFeePerVSize, - peerKey, msg.peerAddress.Address.(*net.TCPAddr), - &msg.chainHash, channelFlags) + reservation, err := f.cfg.Wallet.InitChannelReservation( + capacity, localAmt, msg.pushAmt, commitFeePerKw, + msg.fundingFeePerVSize, peerKey, msg.peerAddress.Address, + &msg.chainHash, channelFlags, + ) if err != nil { msg.err <- err return