3

I've just started toying around with the bitcoind Python wrapper (bitcoin-python) and have run into some issues when trying to move funds around.

On the client side, I have generated a new address, via

new_addr = conn.getnewaddress(ACCT)

Upon calling

conn.getaddressesbyaccount(ACCT)

I see new_addr within the addresses listed.

I now send a test transaction (~1mBTC) on blockchain.info to new_addr, and have waited for some period of time, so that there is at least one confirmation in the chain.

However, upon calling

amount_received = btc_conn.getreceivedbyaddress(new_addr)

I have not received any coins at that address.

Furthermore, when attempting to find out more information about the transaction via

btc_conn.gettransaction(tx_id)

where tx_id is given in blockchain.info/tx/tx_id, I'm getting an InvalidAddressOrKey error.

Is there there anything I'm doing wrong?

1

There's also another possibility, that's that you haven't yet downloaded all the block chain with bitcoind.

If you haven't yet started the daemon you must use this command:

bitcoind -daemon

Then, you can use the command:

bitcoind getblockcount

To check the number of blocks that the daemon has already downloaded, and compare it with the lastest block number

Your transaction is on the lastest blocks, so you must wait it to be completed, and this can take many hours.

  • This was indeed the issue -- after a week I checked back and everything was fine. If only I had gigabit back then :) – mzhang Nov 12 '15 at 4:58
0

It might just be that your transaction has still zero confirmations, that might be the reason it doesn't show in getreceivedbyaddress(), which by default only returns transactions that have at least one confirmation. To override this, call it like this: getreceivedbyaddress(address, 0).

Also note that gettransaction() will only work for in-wallet transactions, for other transactions it will just throw an exception. Try calling it for an older transaction of yours and see if it works.

0

Can you see in block.io or blockchain.info that your transaction goes through?

Furthermore gettransaction() doesn't work unless you have txindex=1in your bitcoin.conf settings.

Look here for inspiration:

http://cryptoassetscore.readthedocs.org/en/latest/backends.html#module-cryptoassets.core.backend.bitcoind

Also if you are accepting Bitcoin payments in Python, check out cryptoassets.core library for Bitcoin cryptocurrencies in Python. (disclaimer: I am the author)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.