getbalance and listaddressgroupings inconsistent I imported a private key from my electrum wallet (testnet) to bitcoincore (testnet) as follow:


In my electrum wallet, I copy the private key associated to the address mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr (balance of 0.06 BTC)
Then I import it into bitcoincore:


~# bitcoin-cli importprivkey "the 52 characters private key here" "From Electrum Wallet"


Rescan should be automatic but I ask for a reindex and rescan:


~# bitcoind -rescan -reindex

After a while, I can issue:

~# bitcoin-cli listaddressgroupings

And I successfully get:



[
 [
   [
     "mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr",
     0.06000000,
     "From Electrum Wallet"
   ]
 ],
 [
   [
     "2MwBERpNv7JJaW4nVUbQncXjFjG1nFKLYEp",
     0.05000000,
     "test"
   ],
   [
     "2N4AMdXitdYhNdjafzHG61uUdrErExSdhKs",
     0.00498305
   ]
 ],
 [
   [
     "2N6xTkaeuKsQSHCortgxiNvsVXj2Gv1Qy85",
     0.05000000,
     "test2"
   ]
 ]
]


But when I ask for the balance, it returns 0:

~# bitcoin-cli getbalance mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr

0.00000000

How possible is that, considering that the rescan has been performed and that the balance is correct in listaddressgroupings? As a result, I am not able to spend bitcoins from this address.

Thank you for you input/insight!

My bitcoin.conf:

txindex=1
addrindex=1
listen=1
server=1
daemon=1
testnet=1
You are using getbalance incorrectly. You have specified an account name of the address that you want the balance for. However this is not how getbalance works. Bitcoin does not use accounts and addresses are not accounts. An account here means an account in Bitcoin Core's internal accounts system which has since been removed.

So your command getbalance mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr is asking for the balance of the account named mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr, but no such account exists. The account that has the address mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr is named From Electrum Wallet. Thus the command you should be using is

getbalance "From Electrum Wallet"