查看外国比特币交易

asv*_*asv 15 bitcoin

我正在尝试使用交易信息

bitcoind gettransaction \
  9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271
Run Code Online (Sandbox Code Playgroud)

但我收到了

error: {"code":-5,"message":"Invalid or non-wallet transaction id"}
Run Code Online (Sandbox Code Playgroud)

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

Ric*_*aca 11

可以使用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
Run Code Online (Sandbox Code Playgroud)

更多.


小智 6

getrawtransaction <txid> 命令甚至从比特币-qt客户端获取任何事务

原始交易

"原始事务API"是在比特币-Qt/bitcoind版本0.7中引入的.它为开发人员或非常复杂的最终用户提供了对事务创建和广播的低级访问.

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

getrawtransaction <txid> 1
Run Code Online (Sandbox Code Playgroud)

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


小智 -1

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

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

  • 我不想在我的服务器上建立对第三方服务的依赖关系。还有其他的可能吗? (6认同)