Edit: Answer to the question: How to get private keys out of Bitcoin Core
After you found your addresses (by using the commands I listed below, for example) you can execute the folllowing command:
dumpprivatekey 1ofYourAddresses
If your wallet is password protected and locked run:
walletpassphrase "your password or passphrase" 600
And 'walletlock' when you're done to re-lock it.
You can easily recognize addresses from Private Keys because addresses start always with one (1), Private Keys instead start with 5, K or L. You don't need to manage public keys at all. Also you just need the Private key to export/import a "wallet", in fact a private key is a wallet, and from that ypthe software can find out the address(es) that correspond to it, so you need just to export that.
Answer to the original question: How to get public address in Bitcoin Core
Warning: The 'account' API which is used below has been removed since v0.18 *
Your main (first) bitcoin account in Bitcoin Core and bitcoin-qt is the empty-string account, '""'.
To get your bitcoin addresses via bitcoin-cli or via the bitcoin-qt console, for your main account, use:
getaccountaddress ""
That will return your first address of the main account, and:
getaddressesbyaccount ""
Will return (at first launch two addresses and in general) the list of all your addresses associated with your main account.
This is an example output of the getaddressesbyaccount
call on a newly installed bitcoin-qt:
> bitcoin-cli getaddressesbyaccount ""
[
"1AA37Akj16aj9nU4NYgx2cRwjgmuwpxR6Z",
"1CbkkAbB7ootHHu9Fhbh8TtRR2iiCoNCZD"
]
This is the minimal ~/.bitcoin/bitcoin.conf
you want to have to be able to run bitcoin-qt
with the CLI enabled, this way you can understand which accounts and addresses you own and their balances etc. from the UI.
rpcuser=bitcoin
rpcpassword=TYPE_A_STRONG_PASS_HERE
# enables deamon in bitcoin-qt
server=1