How to generate valid BTC address to withdraw coins to I set up bitcoind, and the complete blockchain is synced. I created a wallet, and I loaded the wallet.
How can I generate an address to deposit BTC to? I tried bitcoin-cli getnewaddress and I get this address bc1q4mglxdp28f693lw476fnmcesq25tmfkcsfqnpk, but at the Huobi exchange when I try to withdraw 0.001 BTC to that address as a test, I get the message &quot;Invalid address.&quot;
What am I doing wrong? How can I create a valid BTC address on my loaded wallet to send BTC to?
Your bitcoin client is generating a P2WPKH (bech32 encoded) address, which is a newer address format which has some benefits compared to legacy formats. The address is valid, but for whatever reason, the exchange mentioned has not upgraded it's code to recognize and send to this address type yet.
The fix is easy: you just need to tell bitcoin-core to generate a legacy address. You can use the following command:
$ bitcoin-cli getnewaddress &quot;(address_label)&quot; &quot;legacy&quot;
You can substitute your own label in for the (address_label), this is just for local book-keeping purposes, it can also just be left blank if you'd like:
$ bitcoin-cli getnewaddress &quot;&quot; &quot;legacy&quot;