Skip to content

Commit abaef77

Browse files
committed
kvdb: return empty result for a missing scope in ListAccounts
selectScopedManagers mapped a missing key scope to ErrAccountNotFound, diverging from the documented empty-list semantics of the Store contract and from the SQL backend. Treat a missing scope as an empty result.
1 parent d6ef30e commit abaef77

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

wallet/internal/db/kvdb/accountstore_listaccounts.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ func selectScopedManagers(mgr waddrmgr.AddrStore, filter *db.KeyScope) (
198198
}
199199

200200
scopedMgr, err := mgr.FetchScopedKeyManager(scope)
201+
if waddrmgr.IsError(err, waddrmgr.ErrScopeNotFound) {
202+
// List queries return an empty result for an unknown scope,
203+
// matching the Store contract and the SQL backend, rather than
204+
// surfacing ErrAccountNotFound.
205+
return nil, nil
206+
}
207+
201208
if err != nil {
202209
return nil, translateAccountErr(err, db.ErrAccountNotFound)
203210
}

0 commit comments

Comments
 (0)