15

我正在尝试使用

bitcoind gettransaction \
  9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271

但我收到

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

如何使用比特币 API 查看交易?

4

4 回答 4

12

可以使用 bitcoind 查看国外交易。

  1. 在你的 bitcoin.conf 文件中设置 txindex=1。
  2. 使用 -reindex 重新启动 bitcoind(您需要重新构建整个索引)

在你索引了几个块之后,你可以使用这样的东西:

$ 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

有关更多信息,请参阅

于 2013-12-14T23:04:51.940 回答
7

getrawtransaction <txid>命令甚至从 Bitcoin-qt 客户端获取任何交易

原始交易

Bitcoin-Qt/bitcoind 0.7 版引入了“原始交易 API”。它为开发人员或非常复杂的最终用户提供了对事务创建和广播的低级访问权限。

这将返回十六进制的字节字符串,这不是很有用。但是如果你输入

getrawtransaction <txid> 1

您将获得格式良好的 JSON 表示

于 2015-07-03T16:15:22.463 回答
3

znort987 的blockparser 程序看起来很有希望。我还没有机会玩它,所以我不确定它是否具有指定要检查的单个交易的本机支持,但是 doco 说如果您知道接收地址,那么您可以获得所有交易详细信息那个地址是这样的:

./parser transactions the_receiving_address
于 2013-10-14T06:14:26.970 回答
-1

正如错误所说,您正在尝试查看不属于您钱包的交易。Bitcoind 仅允许您探索与您的钱包相关的交易。

如果您想探索“外国”交易,您应该使用其他工具,例如http://blockexplorer.com/

于 2012-01-04T22:37:26.747 回答