运营商地址是如何成为Cosmos账户地址的?
时间:2024-02-10
浏览:480
作者:佚名
珍惜时间,勤奋学习!今天给大家带来《运营商地址是如何成为Cosmos账户地址的?》,正文内容主要涉及到等等,如果你正在学习Golang,或者是对Golang有疑问,欢迎大家关注我!后面我会持续更新相关内容的,希望都能帮到正在学习的大家!
问题内容
我的任务是列出所有验证者及其帐户地址。这里是 rpc,它可以列出所有验证器,https://buf.build/cosmos/cosmos-sdk/docs/main:cosmos.stake.v1beta1#cosmos.stake.v1beta1.query.validators。验证器消息原型如下。我的问题是我如何获得验证者的帐户地址,它没有帐户地址。有什么建议吗?
message Validator {
// operator_address defines the address of the validator's operator; bech encoded in JSON.
string operator_address = 1;
// consensus_pubkey is the consensus public key of the validator, as a Protobuf Any.
google.protobuf.Any consensus_pubkey = 2;
// jailed defined whether the validator has been jailed from bonded status or not.
bool jailed = 3;
// status is the validator status (bonded/unbonding/unbonded).
BondStatus status = 4;
// tokens define the delegated tokens (incl. self-delegation).
string tokens = 5;
// delegator_shares defines total shares issued to a validator's delegators.
string delegator_shares = 6;
// description defines the description terms for the validator.
Description description = 7;
// unbonding_height defines, if unbonding, the height at which this validator has begun unbonding.
int64 unbonding_height = 8;
// unbonding_time defines, if unbonding, the min time for the validator to complete unbonding.
google.protobuf.Timestamp unbonding_time = 9;
// commission defines the commission parameters.
Commission commission = 10;
// min_self_delegation is the validator's self declared minimum self delegation.
string min_self_delegation = 11;
}正确答案
经过几个小时的挖掘,我在 cosmos 地址文档中找到了答案,它说:https://docs.cosmos.network/main/basics/accounts#addresses。
每个帐户都使用地址来标识,地址是从公钥派生的字节序列。
然后我就知道运营商地址是从公钥导出的。但是可以将其转换为公钥吗?答案是肯定的,因为它们都是公共信息,只是表示/格式不同。
valAddr, _ := sdk.ValAddressFromBech32(v.OperatorAddress) accAddr, _ := sdk.AccAddressFromHex(hex.EncodeToString(valAddr.Bytes())) fmt.Println(accAddr.String()) // output: cosmos1q...
今天关于《运营商地址是如何成为Cosmos账户地址的?》的内容介绍就到此结束,如果有什么疑问或者建议,可以在golang学习网公众号下多多回复交流;文中若有不正之处,也希望回复留言以告知!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.20
11.20
11.20
11.20
热门专题
