mirror of
https://github.com/LBRYFoundation/lbcwallet.git
synced 2025-09-01 17:55:15 +00:00
Revert "waddrmgr+wallet: only watch addresses within default key scopes"
The commit being reverted resulted in the discovery of a bug in which change addresses could at times be created outside of the default key scopes, causing us to not properly determine their spends.
This commit is contained in:
parent
60fce250f4
commit
43e19da868
2 changed files with 8 additions and 35 deletions
|
@ -756,29 +756,6 @@ func (m *Manager) ForEachAccountAddress(ns walletdb.ReadBucket, account uint32,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForEachDefaultScopeActiveAddress calls the given function with each active
|
|
||||||
// address stored in the manager within the default scopes, breaking early on
|
|
||||||
// error.
|
|
||||||
func (m *Manager) ForEachDefaultScopeActiveAddress(ns walletdb.ReadBucket,
|
|
||||||
fn func(addr btcutil.Address) error) error {
|
|
||||||
|
|
||||||
m.mtx.RLock()
|
|
||||||
defer m.mtx.RUnlock()
|
|
||||||
|
|
||||||
for _, keyScope := range DefaultKeyScopes {
|
|
||||||
scopedMgr, ok := m.scopedManagers[keyScope]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("manager for default key scope with "+
|
|
||||||
"purpose %v not found", keyScope.Purpose)
|
|
||||||
}
|
|
||||||
if err := scopedMgr.ForEachActiveAddress(ns, fn); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChainParams returns the chain parameters for this address manager.
|
// ChainParams returns the chain parameters for this address manager.
|
||||||
func (m *Manager) ChainParams() *chaincfg.Params {
|
func (m *Manager) ChainParams() *chaincfg.Params {
|
||||||
// NOTE: No need for mutex here since the net field does not change
|
// NOTE: No need for mutex here since the net field does not change
|
||||||
|
|
|
@ -303,22 +303,18 @@ func (w *Wallet) SetChainSynced(synced bool) {
|
||||||
w.chainClientSyncMtx.Unlock()
|
w.chainClientSyncMtx.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// activeData returns the currently-active receiving addresses that exist within
|
// activeData returns the currently-active receiving addresses and all unspent
|
||||||
// the wallet's default key scopes and all unspent outputs. This is primarily
|
// outputs. This is primarely intended to provide the parameters for a
|
||||||
// intended to provide the parameters for a rescan request.
|
// rescan request.
|
||||||
func (w *Wallet) activeData(dbtx walletdb.ReadTx) ([]btcutil.Address,
|
func (w *Wallet) activeData(dbtx walletdb.ReadTx) ([]btcutil.Address, []wtxmgr.Credit, error) {
|
||||||
[]wtxmgr.Credit, error) {
|
|
||||||
|
|
||||||
addrmgrNs := dbtx.ReadBucket(waddrmgrNamespaceKey)
|
addrmgrNs := dbtx.ReadBucket(waddrmgrNamespaceKey)
|
||||||
txmgrNs := dbtx.ReadBucket(wtxmgrNamespaceKey)
|
txmgrNs := dbtx.ReadBucket(wtxmgrNamespaceKey)
|
||||||
|
|
||||||
var addrs []btcutil.Address
|
var addrs []btcutil.Address
|
||||||
err := w.Manager.ForEachDefaultScopeActiveAddress(
|
err := w.Manager.ForEachActiveAddress(addrmgrNs, func(addr btcutil.Address) error {
|
||||||
addrmgrNs, func(addr btcutil.Address) error {
|
addrs = append(addrs, addr)
|
||||||
addrs = append(addrs, addr)
|
return nil
|
||||||
return nil
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue