Regtest: address is still at zero after sending some bitcoins

0

I'm trying to send some btc to an address in Regtest mode:

the address where I want to send is: mjeoXvBnD4DtZumeSJEjNJfLb4RrhpbH1H

$  bitcoin-cli -regtest -rpcuser=bitcoinrpc -rpcpassword=Alice -rpcport=16591 sendtoaddress mjeoXvBnD4DtZumeSJEjNJfLb4RrhpbH1H 5.00
9caca4f88c6bf727f6e8599fc1012867561ff7ef34412ef1fc70457fadf08e0b

I generate a new block:

$  bitcoin-cli -regtest -rpcuser=bitcoinrpc -rpcpassword=Alice -rpcport=16591 generate 1
[
    "5851b3adfd810480e53fbb5dab1ce4967a50f072a5a7abe054f114839ea3501e"
]

Then, I check the amount of btc inside the address:

$  bitcoin-cli -regtest -rpcuser=bitcoinrpc -rpcpassword=Alice -rpcport=16591 getreceivedbyaddress mjeoXvBnD4DtZumeSJEjNJfLb4RrhpbH1H 
0.00000000

Nevertheless the transaction is well listed on listtransactions:

$  bitcoin-cli -regtest -rpcuser=bitcoinrpc -rpcpassword=Alice -rpcport=16591 listtransactions
...
    {
        "account" : "",
        "address" : "mjeoXvBnD4DtZumeSJEjNJfLb4RrhpbH1H",
        "category" : "send",
        "amount" : -5.00000000,
        "vout" : 1,
        "fee" : -0.00001860,
        "confirmations" : 1,
        "blockhash" : "5851b3adfd810480e53fbb5dab1ce4967a50f072a5a7abe054f114839ea3501e",
        "blockindex" : 1,
        "blocktime" : 1452096896,
        "txid" : "9caca4f88c6bf727f6e8599fc1012867561ff7ef34412ef1fc70457fadf08e0b",
        "walletconflicts" : [
        ],
        "time" : 1452096887,
        "timereceived" : 1452096887
    },
...

Is there a problem with my address?

I've generated it thanks to pybitcointools , doing:

magickey = '111' # regtest mode

priv = random_key()

addr = privkey_to_address(priv, magickey)

Thanks a lot in advance

ThePhi

Posted 2016-01-06T16:23:56.407

Reputation: 155

Answers

1

getreceivedbyaddress is only able to show the balance for the addresses in the account: it stores only UTXO for these. The addresses generated with Pybitcointools are not stored in the account (contrary to addresses generated with getnewaddress).

To get the balance of any address, a block explorer is needed, which scan ALL UTXOs of the blockchain (like blockexporer.com or blockchain.info).

And for Regtest, it's more complicated since a local server is needed like https://github.com/bitcoin-abe/bitcoin-abe.

Conclusion: I"ve finally switched to Testnet mode, for convenience.

ThePhi

Posted 2016-01-06T16:23:56.407

Reputation: 155

0

By default, getreceivedbyaddress doesn't include unconfirmed transactions. The second parameter is for the minimum number of confirmations.

So either do getreceivedbyaddress 0, or do setgenerate true 6, and the received by should be correct.

morsecoder

Posted 2016-01-06T16:23:56.407

Reputation: 12 624

It's not unconfirmed: you can see in listtransactions: "...confirmations" : 1,.... But I finally solved the riddle. I didn't get properly what getreceivedbyaddress was doing in fact.ThePhi 2016-01-09T07:36:13.387

Glad you figured it out :)morsecoder 2016-01-09T14:07:15.570