asv
asv

Reputation: 181

See foreign bitcoin transactions

I'm trying to get a transaction info using

bitcoind gettransaction \
  9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271

but I'm receiving

error: {"code":-5,"message":"Invalid or non-wallet transaction id"}

How to see a transaction using bitcoin API?

Upvotes: 15

Views: 3493

Answers (4)

Dmytro Sandu
Dmytro Sandu

Reputation: 71

getrawtransaction <txid> command gets any transaction even from Bitcoin-qt client

Raw Transactions

The "raw transaction API" was introduced with Bitcoin-Qt/bitcoind version 0.7. It gives developers or very sophisticated end-users low-level access to transaction creation and broadcast.

This will return hexadecimal string of bytes, which is not very useful. But if you type

getrawtransaction <txid> 1

you'll get nicely formatted JSON representation

Upvotes: 7

Rich Apodaca
Rich Apodaca

Reputation: 29014

You can view foreign transactions using bitcoind.

  1. Set txindex=1 in your bitcoin.conf file.
  2. restart bitcoind with -reindex (you need to re-build your entire index)

After you've indexed a few blocks you can use something like this:

$ bitcoind getblockcount
122735

$ bitcoind getblockhash 67543
0000000004e213266ccd388df12896412c1a70e647b48004f7d6894b9d6f63b9

$ bitcoind getblock 0000000004e213266ccd388df12896412c1a70e647b48004f7d6894b9d6f63b9
// JSON containing tx "a93a668d9332e21d51380c7251bbf5ad47295ca9795e0ad6f2fe8d63b76af9aa"

$ bitcoind getrawtransaction a93a668d9332e21d51380c7251bbf5ad47295ca9795e0ad6f2fe8d63b76af9aa 1
// json of transaction - note that "1" at the end tells bitcoind to decode into json

See this for more.

Upvotes: 12

mulllhausen
mulllhausen

Reputation: 4435

znort987's blockparser program looks promising. i haven't had a chance to play with it yet so i'm not sure if it has native support for specifying an individual transaction to inspect, but the doco says that if you know the receiving address then you can get all transaction details for that address like so:

./parser transactions the_receiving_address

Upvotes: 3

ploum
ploum

Reputation: 242

As the error said, you are trying to see a transaction which is not part of your wallet. Bitcoind only allows you to explore transactions that are related to your wallet.

If you want to explore "foreign" transactions, you should use other tools like http://blockexplorer.com/

Upvotes: -1

Related Questions