feat(api): add GetCommunityPublicKeyFromPrivateKey to api (#3828)

This commit is contained in:
Jonathan Rainville 2023-08-02 13:11:26 -04:00 committed by GitHub
parent 0cd140c9b2
commit 9267e58143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -2104,7 +2104,7 @@ func (m *Messenger) findCommunityInfoFromDB(communityID string) (*communities.Co
}
func (m *Messenger) GetCommunityIDFromKey(communityKey string) string {
// Check if the key is a private key
// Check if the key is a private key. strip the 0x at the start
privateKey, err := crypto.HexToECDSA(communityKey[2:])
communityID := ""
if err != nil {

View File

@ -452,6 +452,12 @@ func (api *PublicAPI) ImportCommunity(ctx context.Context, hexPrivateKey string)
return nil, err
}
return api.service.messenger.ImportCommunity(ctx, privateKey)
}
// GetCommunityPublicKeyFromPrivateKey gets the community's public key from its private key
func (api *PublicAPI) GetCommunityPublicKeyFromPrivateKey(ctx context.Context, hexPrivateKey string) string {
publicKey := api.service.messenger.GetCommunityIDFromKey(hexPrivateKey)
return publicKey
}