環境
bitcoind 0.17
getrawtransaction
(bitcoin coreドキュメント)でtransactionの情報をとろうとすると以下のエラー
$ bitcoin-cli getrawtransaction 5d55ed7b2e4e0d8896359ee457ca05ac6265914cfa712c4b695e279a5ceb893d true
error code: -5
error message:
No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.
getrawtransactionコマンド
ドキュメントによれば、
getrawtransaction
はmempoolのtransactionに対するコマンドです。
ブロックに入ったあとのtransactionに対しても使うためには、bitcoindを-txindex
オプション付きで動作させる必要があります。
txindexを有効にするには
- 設定ファイルに書く(方法調べてないし実証もしていないm(__)m)
- 起動時にオプション付きで、
$ bitcoind -txindex
すでに起動している場合は、それまでのtransactionをインデックスし直す必要があるようで
$ bitcoind -reindex -txindex
とします。
reindexには時間がかかります。
参考
bitcoin core 0.17
What are pros and cons of txindex option?
Bitcoin wiki