bootnode -writeaddress 命令的输出长度是 64 字节,而不是预期的 128 字节,为什么?

The output length of bootnode -writeaddress command is 64 bytes, not 128 bytes as expected, why?

我想得到enode的第一部分url格式,也就是十六进制的节点ID,通过从ethereum编译源码,我build and 运行 cmd/bootnode/ from goland,提供我的私钥,命令是这样的:

bootnode -nodekeyhex 9069e5f4dd2fdc131c385b78d557b9154b82a0f6fc6f12a0ed0782364528fb1f -writeaddress

输出:

d65a3c0982f62cad6f12b4274faa74e9adade1708064357fcefe19cd3986fc86

只有64字节,不是128字节,根据源码:

if *writeAddr {
        fmt.Printf("%v\n", enode.PubkeyToIDV4(&nodeKey.PublicKey))
        os.Exit(0)
}

我检查了 enode.PubkeyToIDV4 的 return 类型,确实是 32 字节:type ID [32]byte 。通过%v的转换,输出长度为64。 但是根据how-to-produce-enode-from-node-key

,输出长度为128字节,谁能告诉我这是怎么回事。如何获得正确的 128 字节节点 ID 来构造 URL.

的正确格式

发现于此all: new p2p node representation #17643

代码自上次 PR 以来已更改。

它说 "There are other changes in certain packages to deal with the fact that node IDs aren't public keys anymore. I've tried to document those changes in the individual commits." 太好了。