mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
Merge pull request #6379 from guggero/wallet-default-scopes
btcwallet: always make sure default scopes exist
This commit is contained in:
commit
6275a78c79
2 changed files with 32 additions and 0 deletions
|
@ -68,6 +68,10 @@ then watch it on chain. Taproot script spends are also supported through the
|
|||
|
||||
* [Fixed a bug that would cause lnd to be unable to parse certain PSBT blobs](https://github.com/lightningnetwork/lnd/pull/6383).
|
||||
|
||||
* [Fixed a bug in the `btcwallet` that caused an error to be shown for
|
||||
`lncli walletbalance` in existing wallets after upgrading to
|
||||
Taproot](https://github.com/lightningnetwork/lnd/pull/6379).
|
||||
|
||||
## Misc
|
||||
|
||||
* [An example systemd service file](https://github.com/lightningnetwork/lnd/pull/6033)
|
||||
|
|
|
@ -324,6 +324,34 @@ func (b *BtcWallet) Start() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Because we might add new "default" key scopes over time, they are
|
||||
// created correctly for new wallets. Existing wallets don't
|
||||
// automatically add them, we need to do that manually now.
|
||||
for _, scope := range waddrmgr.DefaultKeyScopes {
|
||||
_, err := b.wallet.Manager.FetchScopedKeyManager(scope)
|
||||
if waddrmgr.IsError(err, waddrmgr.ErrScopeNotFound) {
|
||||
// The default scope wasn't found, that probably means
|
||||
// it was added recently and older wallets don't know it
|
||||
// yet. Let's add it now.
|
||||
addrSchema := waddrmgr.ScopeAddrMap[scope]
|
||||
err := walletdb.Update(
|
||||
b.db, func(tx walletdb.ReadWriteTx) error {
|
||||
addrmgrNs := tx.ReadWriteBucket(
|
||||
waddrmgrNamespaceKey,
|
||||
)
|
||||
|
||||
_, err := b.wallet.Manager.NewScopedKeyManager(
|
||||
addrmgrNs, scope, addrSchema,
|
||||
)
|
||||
return err
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scope, err := b.wallet.Manager.FetchScopedKeyManager(b.chainKeyScope)
|
||||
if err != nil {
|
||||
// If the scope hasn't yet been created (it wouldn't been
|
||||
|
|
Loading…
Add table
Reference in a new issue