user138736: I tried using mkp224o to generate a Tor vanity address for my Bitcoin Core node. It output something like this:
./mkp224o -y satosh

hostname: satoshf47rudte4hkkhhpz7sndbizctnvh3qcmdsaegjaprobb5mt6id.onion 
hs_ed25519_public_key: PT0gZWQyNTUxOXYxLXB1YmxpYzogdHlwZTAgPT0AAACQJukcvPxoOZOHUo535/JowoyKban3ATByAQyQPi4Ieg== 
hs_ed25519_secret_key: PT0gZWQyNTUxOXYxLXNlY3JldDogdHlwZTAgPT0AAADwgEV7/yRWZksAC7dZCHRWx0GQVn7q3Wki2rEmQd1DaBtwbyaym1Ohy+572xy49hnGgJyh2eWdEaaOs/ko0nkw

I assumed I could just edit onion_v3_private_key and put the secret key in there after "ED25519-V3:", but it didn't work, and the generated key also looks longer than the one originally in the file. The error in debug.log was:
tor: Add onion failed; error code 512


user48884: The normal -y yaml output of mkp224o includes a fixed prefix string in the public and private keys. These are part of what Tor expects in its private key files when it looks them up. However Bitcoin Core uses the Tor Control protocol to setup the hidden service. It reads the private key from the onion_v3_private_key file and sends it to Tor via the control protocol. Private keys sent this way use a different format. You should be able to get private keys in this other format by passing --rawyaml to mkp224o.

138736: <p>I tried using <a href="https://github.com/cathugger/mkp224o" rel="nofollow noreferrer">mkp224o</a> to generate a Tor vanity address for my Bitcoin Core node. It output something like this:</p>
<pre><code>./mkp224o -y satosh

hostname: satoshf47rudte4hkkhhpz7sndbizctnvh3qcmdsaegjaprobb5mt6id.onion 
hs_ed25519_public_key: PT0gZWQyNTUxOXYxLXB1YmxpYzogdHlwZTAgPT0AAACQJukcvPxoOZOHUo535/JowoyKban3ATByAQyQPi4Ieg== 
hs_ed25519_secret_key: PT0gZWQyNTUxOXYxLXNlY3JldDogdHlwZTAgPT0AAADwgEV7/yRWZksAC7dZCHRWx0GQVn7q3Wki2rEmQd1DaBtwbyaym1Ohy+572xy49hnGgJyh2eWdEaaOs/ko0nkw
</code></pre>
<p>I assumed I could just edit <code>onion_v3_private_key</code> and put the secret key in there after &quot;ED25519-V3:&quot;, but it didn't work, and the generated key also looks longer than the one originally in the file. The error in debug.log was:</p>
<pre><code>tor: Add onion failed; error code 512
</code></pre>
 48884: <p>The normal <code>-y</code> yaml output of <code>mkp224o</code> includes a fixed prefix string in the public and private keys. These are part of what Tor expects in its private key files when it looks them up. However Bitcoin Core uses the Tor Control protocol to setup the hidden service. It reads the private key from the <code>onion_v3_private_key</code> file and sends it to Tor via the control protocol. Private keys sent this way use a different format. You should be able to get private keys in this other format by passing <code>--rawyaml</code> to <code>mkp224o</code>.</p>
