Skip to content

Commit

Permalink
Merge pull request #7017 from Roasbeef/v0-15-3-branch
Browse files Browse the repository at this point in the history
release: create release branch for v0.15.3
  • Loading branch information
Roasbeef committed Oct 14, 2022
2 parents 08a957f + 34cd2f5 commit f674960
Show file tree
Hide file tree
Showing 39 changed files with 1,575 additions and 886 deletions.
100 changes: 66 additions & 34 deletions aliasmgr/aliasmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,22 @@ type Manager struct {
// negotiated option-scid-alias feature bit.
aliasToBase map[lnwire.ShortChannelID]lnwire.ShortChannelID

// peerAlias is a cache for the alias SCIDs that our peers send us in
// the funding_locked TLV. The keys are the ChannelID generated from
// the FundingOutpoint and the values are the remote peer's alias SCID.
// The values should match the ones stored in the "invoice-alias-bucket"
// bucket.
peerAlias map[lnwire.ChannelID]lnwire.ShortChannelID

sync.RWMutex
}

// NewManager initializes an alias Manager from the passed database backend.
func NewManager(db kvdb.Backend) (*Manager, error) {
m := &Manager{backend: db}
m.baseToSet = make(
map[lnwire.ShortChannelID][]lnwire.ShortChannelID,
)
m.aliasToBase = make(
map[lnwire.ShortChannelID]lnwire.ShortChannelID,
)
m.baseToSet = make(map[lnwire.ShortChannelID][]lnwire.ShortChannelID)
m.aliasToBase = make(map[lnwire.ShortChannelID]lnwire.ShortChannelID)
m.peerAlias = make(map[lnwire.ChannelID]lnwire.ShortChannelID)

err := m.populateMaps()
return m, err
Expand All @@ -115,6 +119,10 @@ func (m *Manager) populateMaps() error {
// populate the Manager's actual maps.
aliasMap := make(map[lnwire.ShortChannelID]lnwire.ShortChannelID)

// This map caches the ChannelID/alias SCIDs stored in the database and
// is used to populate the Manager's cache.
peerAliasMap := make(map[lnwire.ChannelID]lnwire.ShortChannelID)

err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error {
baseConfBucket, err := tx.CreateTopLevelBucket(confirmedBucket)
if err != nil {
Expand Down Expand Up @@ -152,12 +160,34 @@ func (m *Manager) populateMaps() error {
aliasMap[aliasScid] = baseScid
return nil
})
if err != nil {
return err
}

invAliasBucket, err := tx.CreateTopLevelBucket(
invoiceAliasBucket,
)
if err != nil {
return err
}

err = invAliasBucket.ForEach(func(k, v []byte) error {
var chanID lnwire.ChannelID
copy(chanID[:], k)
alias := lnwire.NewShortChanIDFromInt(
byteOrder.Uint64(v),
)

peerAliasMap[chanID] = alias

return nil
})

return err
}, func() {
baseConfMap = make(map[lnwire.ShortChannelID]struct{})
aliasMap = make(
map[lnwire.ShortChannelID]lnwire.ShortChannelID,
)
aliasMap = make(map[lnwire.ShortChannelID]lnwire.ShortChannelID)
peerAliasMap = make(map[lnwire.ChannelID]lnwire.ShortChannelID)
})
if err != nil {
return err
Expand All @@ -176,6 +206,9 @@ func (m *Manager) populateMaps() error {
m.aliasToBase[aliasSCID] = baseSCID
}

// Populate the peer alias cache.
m.peerAlias = peerAliasMap

return nil
}

Expand Down Expand Up @@ -242,7 +275,9 @@ func (m *Manager) AddLocalAlias(alias, baseScid lnwire.ShortChannelID,

// GetAliases fetches the set of aliases stored under a given base SCID from
// write-through caches.
func (m *Manager) GetAliases(base lnwire.ShortChannelID) []lnwire.ShortChannelID {
func (m *Manager) GetAliases(
base lnwire.ShortChannelID) []lnwire.ShortChannelID {

m.RLock()
defer m.RUnlock()

Expand Down Expand Up @@ -310,7 +345,10 @@ func (m *Manager) DeleteSixConfs(baseScid lnwire.ShortChannelID) error {
func (m *Manager) PutPeerAlias(chanID lnwire.ChannelID,
alias lnwire.ShortChannelID) error {

return kvdb.Update(m.backend, func(tx kvdb.RwTx) error {
m.Lock()
defer m.Unlock()

err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error {
bucket, err := tx.CreateTopLevelBucket(invoiceAliasBucket)
if err != nil {
return err
Expand All @@ -320,36 +358,30 @@ func (m *Manager) PutPeerAlias(chanID lnwire.ChannelID,
byteOrder.PutUint64(scratch[:], alias.ToUint64())
return bucket.Put(chanID[:], scratch[:])
}, func() {})
}

// GetPeerAlias retrieves a peer's alias SCID by the channel's ChanID.
func (m *Manager) GetPeerAlias(chanID lnwire.ChannelID) (
lnwire.ShortChannelID, error) {
if err != nil {
return err
}

var alias lnwire.ShortChannelID
// Now that the database state has been updated, we can update it in
// our cache.
m.peerAlias[chanID] = alias

err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error {
bucket, err := tx.CreateTopLevelBucket(invoiceAliasBucket)
if err != nil {
return err
}
return nil
}

aliasBytes := bucket.Get(chanID[:])
if aliasBytes == nil {
return nil
}
// GetPeerAlias retrieves a peer's alias SCID by the channel's ChanID.
func (m *Manager) GetPeerAlias(chanID lnwire.ChannelID) (lnwire.ShortChannelID,
error) {

alias = lnwire.NewShortChanIDFromInt(
byteOrder.Uint64(aliasBytes),
)
return nil
}, func() {})
m.RLock()
defer m.RUnlock()

if alias == hop.Source {
return alias, errNoPeerAlias
alias, ok := m.peerAlias[chanID]
if !ok || alias == hop.Source {
return lnwire.ShortChannelID{}, errNoPeerAlias
}

return alias, err
return alias, nil
}

// RequestAlias returns a new ALIAS ShortChannelID to the caller by allocating
Expand Down
4 changes: 2 additions & 2 deletions build/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ const (
AppMinor uint = 15

// AppPatch defines the application patch for this binary.
AppPatch uint = 2
AppPatch uint = 3

// AppPreRelease MUST only contain characters from semanticAlphabet
// per the semantic versioning spec.
AppPreRelease = "beta"
AppPreRelease = "beta.rc1"
)

func init() {
Expand Down
4 changes: 3 additions & 1 deletion cmd/lncli/walletrpc_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ func parseAddrType(addrTypeStr string) (walletrpc.AddressType, error) {
return walletrpc.AddressType_NESTED_WITNESS_PUBKEY_HASH, nil
case "np2wkh-p2wkh":
return walletrpc.AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH, nil
case "p2tr":
return walletrpc.AddressType_TAPROOT_PUBKEY, nil
default:
return 0, errors.New("invalid address type, supported address " +
"types are: p2wkh, np2wkh, and np2wkh-p2wkh")
"types are: p2wkh, p2tr, np2wkh, and np2wkh-p2wkh")
}
}

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 @@ -34,6 +34,12 @@ were created after introducing the Taproot key
derivation](https://github.com/lightningnetwork/lnd/pull/6524) to simplify
detecting Taproot compatibility of a seed.

**NOTE** for users running a remote signing setup: A manual account import is
necessary when upgrading from `lnd v0.14.x-beta` to `lnd v0.15.x-beta`, see [the
remote signing documentation for more
details](../remote-signing.md#migrating-a-remote-signing-setup-from-014x-to-015x).
Please upgrade to `lnd v0.15.3-beta` or later directly!

## MuSig2

The [`signrpc.Signer` RPC service now supports EXPERIMENTAL MuSig2
Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes/release-notes-0.15.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ supports the feature.](https://github.com/lightningnetwork/lnd/pull/6633)
The [wallet also creates P2TR change addresses by
default](https://github.com/lightningnetwork/lnd/pull/6810) in most cases.

**NOTE** for users running a remote signing setup: A manual account import is
necessary when upgrading from `lnd v0.14.x-beta` to `lnd v0.15.x-beta`, see [the
remote signing documentation for more
details](../remote-signing.md#migrating-a-remote-signing-setup-from-014x-to-015x).
Please upgrade to `lnd v0.15.3-beta` or later directly!

## `lncli`

* [Add `payment_addr` flag to
Expand Down
39 changes: 39 additions & 0 deletions docs/release-notes/release-notes-0.15.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Release Notes

## RPC/REST Server

- A `POST` URL mapping [was added to the REST version of the `QueryRoutes` call
(`POST /v1/graph/routes`)](https://github.com/lightningnetwork/lnd/pull/6926)
to make it possible to specify `route_hints` over REST.

## Bug Fixes

* [A bug has been fixed where the responder of a zero-conf channel could forget
about the channel after a hard-coded 2016 blocks.](https://github.com/lightningnetwork/lnd/pull/6998)

* [A bug where LND wouldn't send a ChannelUpdate during a channel open has
been fixed.](https://github.com/lightningnetwork/lnd/pull/6892)

* [A bug has been fixed that caused fee estimation to be incorrect for taproot
inputs when using the `SendOutputs` call.](https://github.com/lightningnetwork/lnd/pull/6941)

* [A bug has been fixed that could cause lnd to underpay for co-op close
transaction when or both of the outputs used a P2TR
addresss.](https://github.com/lightningnetwork/lnd/pull/6957)

## Taproot

* [Add `p2tr` address type to account
import](https://github.com/lightningnetwork/lnd/pull/6966).

**NOTE** for users running a remote signing setup: A manual account import is
necessary when upgrading from `lnd v0.14.x-beta` to `lnd v0.15.x-beta`, see [the
remote signing documentation for more
details](../remote-signing.md#migrating-a-remote-signing-setup-from-014x-to-015x).

# Contributors (Alphabetical Order)

* Eugene Siegel
* Jordi Montes
* Olaoluwa Osuntokun
* Oliver Gugger
22 changes: 22 additions & 0 deletions docs/remote-signing.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,28 @@ To migrate an existing node, follow these steps:
a watch-only one (by purging all private key material from it) by adding the
`remotesigner.migrate-wallet-to-watch-only=true` configuration entry.

## Migrating a remote signing setup from 0.14.x to 0.15.x

If you were running a remote signing setup with `lnd v0.14.x-beta` and want to
upgrade to `lnd v0.15.x-beta`, you need to manually import the newly added
Taproot account to the watch-only node, otherwise you will encounter errors such
as `account 0 not found` when doing on-chain operations that require creating
(change) P2TR addresses.

**NOTE**: For this to work, you need to upgrade to at least `lnd v0.15.3-beta`
or later!

The upgrade process should look like this:
1. Upgrade the "signer" node to `lnd v0.15.x-beta` and unlock it.
2. Run `lncli wallet accounts list | grep -A5 TAPROOT` on the **"signer"** node
and copy the `xpub...` value from `extended_public_key`.
3. Upgrade the "watch-only" node to `lnd v0.15.x-beta` and unlock it.
4. Run `lncli wallet accounts import --address_type p2tr <xpub...> default` on
the **"watch-only"** node (notice the `default` account name at the end,
that's important).
5. Run `lncli newaddress p2tr` on the "watch-only" node to test that everything
works as expected.

## Example initialization script

This section shows an example script that initializes the watch-only wallet of
Expand Down
6 changes: 2 additions & 4 deletions funding/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@ func (f *Manager) waitForFundingWithTimeout(
// If we are not the initiator, we have no money at stake and will
// timeout waiting for the funding transaction to confirm after a
// while.
if !ch.IsInitiator {
if !ch.IsInitiator && !ch.IsZeroConf() {
f.wg.Add(1)
go f.waitForTimeout(ch, cancelChan, timeoutChan)
}
Expand Down Expand Up @@ -3200,9 +3200,7 @@ func (f *Manager) waitForZeroConfChannel(c *channeldb.OpenChannel,
// is already confirmed, the chainntnfs subsystem will return with the
// confirmed tx. Otherwise, we'll wait here until confirmation occurs.
confChan, err := f.waitForFundingWithTimeout(c)
if err == ErrConfirmationTimeout {
return f.fundingTimeout(c, pendingID)
} else if err != nil {
if err != nil {
return fmt.Errorf("error waiting for zero-conf funding "+
"confirmation for ChannelPoint(%v): %v",
c.FundingOutpoint, err)
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/btcsuite/btcd/btcutil/psbt v1.1.5
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
github.com/btcsuite/btcwallet v0.15.1
github.com/btcsuite/btcwallet/wallet/txauthor v1.2.3
github.com/btcsuite/btcwallet v0.16.1
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2
github.com/btcsuite/btcwallet/wallet/txrules v1.2.0
github.com/btcsuite/btcwallet/walletdb v1.4.0
github.com/btcsuite/btcwallet/wtxmgr v1.5.0
Expand Down Expand Up @@ -66,7 +66,7 @@ require (
github.com/aead/siphash v1.0.1 // indirect
github.com/andybalholm/brotli v1.0.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcwallet/wallet/txsizes v1.1.0 // indirect
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.3 // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/btcsuite/winsvc v1.0.0 // indirect
Expand Down
11 changes: 7 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,17 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtyd
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcwallet v0.15.1 h1:SKfh/l2Bgz9sJwHZvfiVbZ8Pl3N/8fFcWWXzsAPz9GU=
github.com/btcsuite/btcwallet v0.15.1/go.mod h1:7OFsQ8ypiRwmr67hE0z98uXgJgXGAihE79jCib9x6ag=
github.com/btcsuite/btcwallet/wallet/txauthor v1.2.3 h1:M2yr5UlULvpqtxUqpMxTME/pA92Z9cpqeyvAFk9lAg0=
github.com/btcsuite/btcwallet v0.16.1 h1:nD8qXJeAU8c7a0Jlx5jwI2ufbf/9ouy29XGapRLTmos=
github.com/btcsuite/btcwallet v0.16.1/go.mod h1:NCO8+5rIcbUm5CtVNSQM0xrtK4iYprlyuvpGzhkejaM=
github.com/btcsuite/btcwallet/wallet/txauthor v1.2.3/go.mod h1:T2xSiKGpUkSLCh68aF+FMXmKK9mFqNdHl9VaqOr+JjU=
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2 h1:etuLgGEojecsDOYTII8rYiGHjGyV5xTqsXi+ZQ715UU=
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2/go.mod h1:Zpk/LOb2sKqwP2lmHjaZT9AdaKsHPSbNLm2Uql5IQ/0=
github.com/btcsuite/btcwallet/wallet/txrules v1.2.0 h1:BtEN5Empw62/RVnZ0VcJaVtVlBijnLlJY+dwjAye2Bg=
github.com/btcsuite/btcwallet/wallet/txrules v1.2.0/go.mod h1:AtkqiL7ccKWxuLYtZm8Bu8G6q82w4yIZdgq6riy60z0=
github.com/btcsuite/btcwallet/wallet/txsizes v1.1.0 h1:wZnOolEAeNOHzHTnznw/wQv+j35ftCIokNrnOTOU5o8=
github.com/btcsuite/btcwallet/wallet/txsizes v1.1.0/go.mod h1:pauEU8UuMFiThe5PB3EO+gO5kx87Me5NvdQDsTuq6cs=
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.2/go.mod h1:q08Rms52VyWyXcp5zDc4tdFRKkFgNsMQrv3/LvE1448=
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.3 h1:PszOub7iXVYbtGybym5TGCp9Dv1h1iX4rIC3HICZGLg=
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.3/go.mod h1:q08Rms52VyWyXcp5zDc4tdFRKkFgNsMQrv3/LvE1448=
github.com/btcsuite/btcwallet/walletdb v1.3.5/go.mod h1:oJDxAEUHVtnmIIBaa22wSBPTVcs6hUp5NKWmI8xDwwU=
github.com/btcsuite/btcwallet/walletdb v1.3.6-0.20210803004036-eebed51155ec/go.mod h1:oJDxAEUHVtnmIIBaa22wSBPTVcs6hUp5NKWmI8xDwwU=
github.com/btcsuite/btcwallet/walletdb v1.4.0 h1:/C5JRF+dTuE2CNMCO/or5N8epsrhmSM4710uBQoYPTQ=
Expand Down
2 changes: 0 additions & 2 deletions lnrpc/autopilotrpc/autopilot.pb.json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions lnrpc/chainrpc/chainnotifier.pb.json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions lnrpc/devrpc/dev.pb.json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lnrpc/gen_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function generate() {
# Generate the JSON/WASM client stubs.
falafel=$(which falafel)
pkg="lnrpc"
opts="package_name=$pkg,js_stubs=1,build_tags=// +build js"
opts="package_name=$pkg,js_stubs=1"
protoc -I/usr/local/include -I. -I.. \
--plugin=protoc-gen-custom=$falafel\
--custom_out=. \
Expand All @@ -61,7 +61,7 @@ function generate() {
manual_import="github.com/lightningnetwork/lnd/lnrpc"
fi

opts="package_name=$package,manual_import=$manual_import,js_stubs=1,build_tags=// +build js"
opts="package_name=$package,manual_import=$manual_import,js_stubs=1"
pushd $package
protoc -I/usr/local/include -I. -I.. \
--plugin=protoc-gen-custom=$falafel\
Expand Down
Loading

0 comments on commit f674960

Please sign in to comment.