From 00c29c3936bda63f56e76d12283bdbbc997dd4ee Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Mon, 22 Aug 2022 11:08:26 -0700 Subject: [PATCH] multi-account: add forEachKeyScope uitility iterator --- rpc/legacyrpc/methods.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rpc/legacyrpc/methods.go b/rpc/legacyrpc/methods.go index fd7925f..da4caa1 100644 --- a/rpc/legacyrpc/methods.go +++ b/rpc/legacyrpc/methods.go @@ -2110,3 +2110,17 @@ func decodeHexStr(hexStr string) ([]byte, error) { } return decoded, nil } + +// forEachKeyScope calls the given function with each default key scopes +// breaking early on error. +func forEachKeyScope(fn func(scope waddrmgr.KeyScope) error) error { + + for _, scope := range waddrmgr.DefaultKeyScopes { + err := fn(scope) + if err != nil { + return err + } + } + + return nil +}