From dc5059bc3372941e2908739831188768335ac50b Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 24 Jan 2021 19:45:21 +0100 Subject: entity: more progress on merging and signing --- identity/identity.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'identity/identity.go') diff --git a/identity/identity.go b/identity/identity.go index 65019041..ad5f1efd 100644 --- a/identity/identity.go +++ b/identity/identity.go @@ -519,12 +519,19 @@ func (i *Identity) Keys() []*Key { } // SigningKey return the key that should be used to sign new messages. If no key is available, return nil. -func (i *Identity) SigningKey() *Key { +func (i *Identity) SigningKey(repo repository.RepoKeyring) (*Key, error) { keys := i.Keys() - if len(keys) > 0 { - return keys[0] + for _, key := range keys { + err := key.ensurePrivateKey(repo) + if err == errNoPrivateKey { + continue + } + if err != nil { + return nil, err + } + return key, nil } - return nil + return nil, nil } // ValidKeysAtTime return the set of keys valid at a given lamport time -- cgit