Merge pull request #67 from meshplus/feat/add-get-pubkey

feat: add get public key
This commit is contained in:
Aiden X 2020-04-29 16:25:56 +08:00 committed by GitHub
commit 4a167cf715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -370,6 +370,18 @@ func (x *Interchain) GetIBTPByID(id string) *boltvm.Response {
return boltvm.Success(hash.Bytes())
}
// GetPubKeyByChainID can get aim chain's public key using aim chain ID
func (x *Interchain) GetPubKeyByChainID(id string) *boltvm.Response {
ok := x.Has(x.appchainKey(id))
if !ok {
return boltvm.Error("chain is not existed")
} else {
chain := &appchain{}
x.GetObject(x.appchainKey(id), chain)
return boltvm.Success([]byte(chain.PublicKey))
}
}
func (x *Interchain) appchainKey(id string) string {
return prefix + id
}