diff --git a/client/did.go b/client/did.go index ea51b372..b38eb581 100644 --- a/client/did.go +++ b/client/did.go @@ -48,7 +48,7 @@ func (c *Client) GetAllDIDs() (*model.GetAccountInfo, error) { } func (c *Client) CreateDID(cfg *did.DIDCreate) (string, bool) { - if cfg.Type < did.LiteDIDMode && cfg.Type > did.WalletDIDMode { + if cfg.Type < did.BasicDIDMode && cfg.Type > did.LiteDIDMode { return "Invalid DID mode", false } switch cfg.Type { @@ -186,6 +186,14 @@ func (c *Client) SetupDID(dc *did.DIDCreate) (string, bool) { !strings.Contains(dc.QuorumPrivKeyFile, did.QuorumPvtKeyFileName) { return "Required files are missing", false } + default: + if !strings.Contains(dc.PubImgFile, did.PubShareFileName) || + !strings.Contains(dc.DIDImgFileName, did.DIDImgFileName) || + !strings.Contains(dc.PubKeyFile, did.PubKeyFileName) || + !strings.Contains(dc.QuorumPubKeyFile, did.QuorumPubKeyFileName) || + !strings.Contains(dc.QuorumPrivKeyFile, did.QuorumPvtKeyFileName) { + return "Required files are missing", false + } } jd, err := json.Marshal(&dc) if err != nil { diff --git a/command/did.go b/command/did.go index d139543e..00cb9229 100644 --- a/command/did.go +++ b/command/did.go @@ -120,7 +120,8 @@ func (cmd *Command) CreateDID() { cmd.log.Error("failed to create image", "err", err) return } - } else if cmd.didType != did.BasicDIDMode { + } + if cmd.didType != did.BasicDIDMode && cmd.didType != did.LiteDIDMode { if cmd.privKeyFile == "" || cmd.pubKeyFile == "" { cmd.log.Error("private key & public key file names required") return diff --git a/core/core.go b/core/core.go index f608c287..56c414d8 100644 --- a/core/core.go +++ b/core/core.go @@ -588,7 +588,7 @@ func (c *Core) SetupForienDIDQuorum(didStr string) (did.DIDCrypto, error) { case did.LiteDIDMode: return did.InitDIDQuorum_Lt(didStr, c.didDir, ""), nil default: - return nil, fmt.Errorf("invalid did type") + return did.InitDIDQuorumc(didStr, c.didDir, ""), nil } } @@ -632,6 +632,6 @@ func (c *Core) InitialiseDID(didStr string, didType int) (did.DIDCrypto, error) case did.BasicDIDMode: return did.InitDIDBasic(didStr, c.didDir, nil), nil default: - return nil, fmt.Errorf("invalid did type, couldn't initialise") + return did.InitDIDBasic(didStr, c.didDir, nil), nil } } diff --git a/core/quorum_initiator.go b/core/quorum_initiator.go index 5d539207..ca6af25b 100644 --- a/core/quorum_initiator.go +++ b/core/quorum_initiator.go @@ -215,7 +215,20 @@ func (c *Core) SetupQuorum(didStr string, pwd string, pvtKeyPwd string) error { c.pqc[didStr] = dc } default: - return fmt.Errorf("DID Type is not supported") + dc := did.InitDIDQuorumc(didStr, c.didDir, pwd) + if dc == nil { + c.log.Error("Failed to setup quorum") + return fmt.Errorf("failed to setup quorum") + } + c.qc[didStr] = dc + if pvtKeyPwd != "" { + dc := did.InitDIDBasicWithPassword(didStr, c.didDir, pvtKeyPwd) + if dc == nil { + c.log.Error("Failed to setup quorum") + return fmt.Errorf("failed to setup quorum") + } + c.pqc[didStr] = dc + } } c.up.RunUnpledge() diff --git a/did/did.go b/did/did.go index 7edf5ba7..c123789e 100644 --- a/did/did.go +++ b/did/did.go @@ -260,6 +260,12 @@ func (d *DID) CreateDID(didCreate *DIDCreate) (string, error) { return "", err } + } else if didCreate.Type != LiteDIDMode { + _, err := util.Filecopy(didCreate.PubKeyFile, dirName+"/public/"+PubKeyFileName) + if err != nil { + d.log.Error("failed to copy pub key", "err", err) + return "", err + } } if didCreate.Type == ChildDIDMode {