Skip to content

Commit

Permalink
build: update to version of neutrino w/ BIP 155 support
Browse files Browse the repository at this point in the history
Fixes #4973
  • Loading branch information
Roasbeef committed May 3, 2022
1 parent 54adc69 commit 9ec2632
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 46 deletions.
34 changes: 1 addition & 33 deletions config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/lightningnetwork/lnd/macaroons"
"github.com/lightningnetwork/lnd/rpcperms"
"github.com/lightningnetwork/lnd/signal"
"github.com/lightningnetwork/lnd/tor"
"github.com/lightningnetwork/lnd/walletunlocker"
"github.com/lightningnetwork/lnd/watchtower"
"github.com/lightningnetwork/lnd/watchtower/wtclient"
Expand Down Expand Up @@ -1201,43 +1200,12 @@ func initNeutrinoBackend(cfg *Config, chainDir string,
AddPeers: cfg.NeutrinoMode.AddPeers,
ConnectPeers: cfg.NeutrinoMode.ConnectPeers,
Dialer: func(addr net.Addr) (net.Conn, error) {
dialAddr := addr
if tor.IsOnionFakeIP(addr) {
// Because the Neutrino address manager only
// knows IP addresses, we need to turn any fake
// tcp6 address that actually encodes an Onion
// v2 address back into the hostname
// representation before we can pass it to the
// dialer.
var err error
dialAddr, err = tor.FakeIPToOnionHost(addr)
if err != nil {
return nil, err
}
}

return cfg.net.Dial(
dialAddr.Network(), dialAddr.String(),
addr.Network(), addr.String(),
cfg.ConnectionTimeout,
)
},
NameResolver: func(host string) ([]net.IP, error) {
if tor.IsOnionHost(host) {
// Neutrino internally uses btcd's address
// manager which only operates on an IP level
// and does not understand onion hosts. We need
// to turn an onion host into a fake
// representation of an IP address to make it
// possible to connect to a block filter backend
// that serves on an Onion v2 hidden service.
fakeIP, err := tor.OnionHostToFakeIP(host)
if err != nil {
return nil, err
}

return []net.IP{fakeIP}, nil
}

addrs, err := cfg.net.LookupHost(host)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes/release-notes-0.15.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ releases. Backward compatibility is not guaranteed!
* Add [--socksproxy](https://github.com/lightningnetwork/lnd/pull/6422)
to allow for RPC calls via Tor.

## Neutrino

[Neutrino now suports BIP
155](https://github.com/lightningnetwork/lnd/pull/6468), allowing it to connect
to Bitcoin nodes that advertise a Tor v3 onion service address.

## Bug Fixes

* [Pipelining an UpdateFulfillHTLC message now only happens when the related UpdateAddHTLC is locked-in.](https://github.com/lightningnetwork/lnd/pull/6246)
Expand Down
9 changes: 2 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/lightningnetwork/lnd
require (
github.com/NebulousLabs/go-upnp v0.0.0-20180202185039-29b680b06c82
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344
github.com/btcsuite/btcd v0.22.0-beta.0.20220330201728-074266215c26
github.com/btcsuite/btcd v0.22.0-beta.0.20220413172512-bf64c8bdbbbf
github.com/btcsuite/btcd/btcec/v2 v2.2.0
github.com/btcsuite/btcd/btcutil v1.1.1
github.com/btcsuite/btcd/btcutil/psbt v1.1.3
Expand Down Expand Up @@ -31,7 +31,7 @@ require (
github.com/jessevdk/go-flags v1.4.0
github.com/jrick/logrotate v1.0.0
github.com/kkdai/bstream v1.0.0
github.com/lightninglabs/neutrino v0.13.2
github.com/lightninglabs/neutrino v0.14.1
github.com/lightninglabs/protobuf-hex-display v1.4.3-hex-display
github.com/lightningnetwork/lightning-onion v1.0.2-0.20220211021909-bb84a1ccb0c5
github.com/lightningnetwork/lnd/cert v1.1.1
Expand Down Expand Up @@ -167,11 +167,6 @@ replace github.com/ulikunitz/xz => github.com/ulikunitz/xz v0.5.8
// https://deps.dev/advisory/OSV/GO-2021-0053?from=%2Fgo%2Fgithub.com%252Fgogo%252Fprotobuf%2Fv1.3.1
replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2

// There's a bug in Neutrino that causes our tests to fail. Downgrade to the
// version just before the offending PR. Can remove again once
// https://github.com/lightninglabs/neutrino/pull/247 is merged.
replace github.com/lightninglabs/neutrino => github.com/lightninglabs/neutrino v0.13.2-0.20220209052920-0c79b771272b

// If you change this please also update .github/pull_request_template.md and
// docs/INSTALL.md.
go 1.17
Expand Down
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tj
github.com/btcsuite/btcd v0.22.0-beta.0.20220204213055-eaf0459ff879/go.mod h1:osu7EoKiL36UThEgzYPqdRaxeo0NU8VoXqgcnwpey0g=
github.com/btcsuite/btcd v0.22.0-beta.0.20220207191057-4dc4ff7963b4/go.mod h1:7alexyj/lHlOtr2PJK7L/+HDJZpcGDn/pAU98r7DY08=
github.com/btcsuite/btcd v0.22.0-beta.0.20220316175102-8d5c75c28923/go.mod h1:taIcYprAW2g6Z9S0gGUxyR+zDwimyDMK5ePOX+iJ2ds=
github.com/btcsuite/btcd v0.22.0-beta.0.20220330201728-074266215c26 h1:dgH5afJcotX4eXo7+bXp8Z7lOw0FyVxXQwvtkN+jab4=
github.com/btcsuite/btcd v0.22.0-beta.0.20220330201728-074266215c26/go.mod h1:taIcYprAW2g6Z9S0gGUxyR+zDwimyDMK5ePOX+iJ2ds=
github.com/btcsuite/btcd v0.22.0-beta.0.20220413172512-bf64c8bdbbbf h1:8lTakMpAAOKTe60bNhiEjUDtcZAlrst2MF49ekuA9yI=
github.com/btcsuite/btcd v0.22.0-beta.0.20220413172512-bf64c8bdbbbf/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
github.com/btcsuite/btcd/btcec/v2 v2.1.1/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
Expand Down Expand Up @@ -466,8 +466,9 @@ github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI/f/O0Avg7t8sqkPo78HFzjmeYFl6DPnc=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk=
github.com/lightninglabs/neutrino v0.13.2-0.20220209052920-0c79b771272b h1:E0HzhMQuQN1XrqsS617aRPLYJ8YhyirlyffT0r4j8kc=
github.com/lightninglabs/neutrino v0.13.2-0.20220209052920-0c79b771272b/go.mod h1:Cv/v8oHiPhuGiGvGgO+rIMhwCwEdsQFu6as840i2afw=
github.com/lightninglabs/neutrino v0.13.2/go.mod h1:Cv/v8oHiPhuGiGvGgO+rIMhwCwEdsQFu6as840i2afw=
github.com/lightninglabs/neutrino v0.14.1 h1:ALFckeS3CPmWZmX75vxZaWvz2TUebuASH+CR4cqVo18=
github.com/lightninglabs/neutrino v0.14.1/go.mod h1:SV9ccrw2m6t6UvJX8xB//W0Dv+LEwMTbjg4V/Fb5KwU=
github.com/lightninglabs/protobuf-hex-display v1.4.3-hex-display h1:RZJ8H4ueU/aQ9pFtx5wqsuD3B/DezrewJeVwDKKYY8E=
github.com/lightninglabs/protobuf-hex-display v1.4.3-hex-display/go.mod h1:2oKOBU042GKFHrdbgGiKax4xVrFiZu51lhacUZQ9MnE=
github.com/lightningnetwork/lightning-onion v1.0.2-0.20220211021909-bb84a1ccb0c5 h1:TkKwqFcQTGYoI+VEqyxA8rxpCin8qDaYX0AfVRinT3k=
Expand Down
4 changes: 2 additions & 2 deletions tor/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (p *ProxyNet) Dial(network, address string,
timeout time.Duration) (net.Conn, error) {

switch network {
case "tcp", "tcp4", "tcp6":
case "tcp", "tcp4", "tcp6", "onion":
default:
return nil, errors.New("cannot dial non-tcp network via Tor")
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func (p *ProxyNet) LookupSRV(service, proto,
// addresses over Tor.
func (p *ProxyNet) ResolveTCPAddr(network, address string) (*net.TCPAddr, error) {
switch network {
case "tcp", "tcp4", "tcp6":
case "tcp", "tcp4", "tcp6", "onion":
default:
return nil, errors.New("cannot dial non-tcp network via Tor")
}
Expand Down

0 comments on commit 9ec2632

Please sign in to comment.