How to get the account of a neuron?

Operations on neurons.
1, generate address(382…45) and memo(167…14) by a tool.
2, Stake ICP to create a neuron.
3, query the neuron information by get_full_neuron method and return:

(
  variant {
    Ok = record {
      id = opt record { id = xxxxxxxxxx : nat64 };
      ......
      account = blob "\ab....8b";
      .....
    }
  },
)

My problem is that the “account” of this neuron is Ledger Account?
I want to transfer ICP to this neuron, but it returns that the Checksum of this account is not correct. How do I get Ledger account of the neuron?

1 Like

It is not the ledger account, it is the subaccount relative to the governance canister’s state. But I’ve faced the problem before as well, and here’s how you can convert it: convert the blob string into a plain hex string (note that it’s a combination of escaped hex and ASCII characters, so it’s not trivial), and then run:

echo $HEX | for line in $(cat); do RAW=`(echo -n 0a | xxd -p -r; echo -n account-id; echo -n 00000000000000010101 | xxd -r -p; echo -n $line | xxd -r -p) | shasum -a 224 | sed -e 's/ *-//'`; CRC=`echo $RAW | xxd -r -p | crc32 /dev/stdin`; echo $CRC$RAW; done

and that should output the account hex string.
The script can handle multiple lines at once that’s why it’s a bit more complicated.

2 Likes