Search code examples
go-ethereumgeth

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


I want to get the first part of enode url format, which is hexadecimal node ID, by compiling the source code from ethereum, I build and run cmd/bootnode/ from the goland, with my priviate key supplied, the command is like this:

bootnode -nodekeyhex 9069e5f4dd2fdc131c385b78d557b9154b82a0f6fc6f12a0ed0782364528fb1f -writeaddress

the output:

d65a3c0982f62cad6f12b4274faa74e9adade1708064357fcefe19cd3986fc86

only 64 bytes, not 128 bytes, according to the source code:

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

I checked the return type of enode.PubkeyToIDV4, which is 32 bytes indeed:type ID [32]byte . With conversion of %v, the length of output will be 64. But according to how-to-produce-enode-from-node-key

,the output length is 128 bytes, someone please tell me what's going wrong. How can I get the right 128 bytes of node id to construct the proper format of URL.


Solution

  • Found in this all: new p2p node representation #17643

    The code has been changed since last PR.

    changed codes

    And it says "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." Goodness.