bitcoin-cli 獲取僅監視地址的所有 tx 雜湊
bitcoin-cli 是否有任何功能來獲取給定地址的所有 tx 雜湊(即從給定地址發送或接收資金的 tx)。
listtransactions
聽起來它應該做我想做的事,但是當我像這樣執行它時,我沒有得到任何結果:# pick a random address to watch from blockchain.info: $ addr=1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk # create a watch-only account for this address, with the account name # being the address itself, for convenience: $ time bitcoin-cli importaddress $addr "$addr" true real 41m59.505s user 0m0.004s sys 0m0.004s $ bitcoin-cli listtransactions "$addr" 100 0 true [ ] $ bitcoin-cli getinfo { "version" : 100200, "protocolversion" : 70002, "walletversion" : 60000, "balance" : 0.00000000, "blocks" : 384809, "timeoffset" : 0, "connections" : 8, "proxy" : "", "difficulty" : 65848255179.70261383, "testnet" : false, "keypoololdest" : 1381701523, "keypoolsize" : 101, "paytxfee" : 0.00000000, "relayfee" : 0.00001000, "errors" : "" }
如您所見,掃描區塊鏈以查找此僅限手錶的地址需要 42 分鐘,所以這不是我經常想做的事情。它只產生一個空列表,而 blockchain.info 顯示有 6 個交易。
為什麼這不起作用?這不是預期的功能
bitcoin-cli listtransactions
嗎?更新
listtransactions
應該顯示來自僅限觀看地址的交易:$ bitcoin-cli help listtransactions listtransactions ( "account" count from includeWatchonly) Returns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'. Arguments: 1. "account" (string, optional) The account name. If not included, it will list all transactions for all accounts. If "" is set, it will list transactions for the default account. 2. count (numeric, optional, default=10) The number of transactions to return 3. from (numeric, optional, default=0) The number of transactions to skip 4. includeWatchonly (bool, optional, default=false) Include transactions to watchonly addresses (see 'importaddress') ... ... ...
幾個月後,這個問題仍然沒有答案……
txindex = 1
您需要bitcoin.conf
根據@Jannes 的建議啟用。如果你想掃描你下載的區塊鏈以獲取另一個錢包的地址交易歷史,那麼你必須在你的機器上建立整個區塊鏈索引。它是否是僅限觀看的地址應該是無關緊要的。
使用比特幣 rpc (gettransaction) 獲取非錢包交易
更新
我想我可能已經解決了你的問題
這是我的比特幣資訊
$ bitcoin-cli getinfo { "version" : 110200, "protocolversion" : 70002, "walletversion" : 60000, "balance" : 0.00000000, "blocks" : 353776, "timeoffset" : -1, "connections" : 55, "proxy" : "", "difficulty" : 47610564513.47126007, "testnet" : false, "keypoololdest" : 1449210293, "keypoolsize" : 101, "paytxfee" : 0.00000000, "relayfee" : 0.00005000, "errors" : "" }
我的區塊鏈不像你的那樣是最新的,所以我收集了這個交易(在塊 353776 內)並使用
1CTVqQSSVTjun32gRxmhJHhVYzzXpR894z
來自該交易的比特幣地址作為我的例子。# Import address WITHOUT rescan; we'll do this later bitcoin-cli importaddress 1CTVqQSSVTjun32gRxmhJHhVYzzXpR894z "Index Test" false # Stop Bitcoin $ bitcoin-cli stop # Verify Bitcoin is stopped, then run: $ bitcoind -rescan # Wait for rescan... mine took 15-20 minutes # Once 'bitcoin-cli getinfo' returns valid info, run: $ bitcoin-cli listtransactions "Index Test" 10 0 true # Result: [ { "involvesWatchonly" : true, "account" : "Index Test", "address" : "1CTVqQSSVTjun32gRxmhJHhVYzzXpR894z", "category" : "receive", "amount" : 3.50000000, "vout" : 0, "confirmations" : 22539, "blockhash" : "00000000000000000548d8ef9a7d14c75b7b18ae5b792d520f44cc5ddd25adfe", "blockindex" : 536, "blocktime" : 1416848183, "txid" : "1db7b0703f441d4cea63a298131f8e766b557329f44c30898847d0fc23573606", "walletconflicts" : [ ], "time" : 1452652576, "timereceived" : 1453438387 }, { "involvesWatchonly" : true, "account" : "Index Test", "address" : "1CTVqQSSVTjun32gRxmhJHhVYzzXpR894z", "category" : "receive", "amount" : 1.89990000, "vout" : 1, "confirmations" : 19031, "blockhash" : "0000000000000000134345f88fb68550d2102d392be6e1635eaa6fb50c37a2cc", "blockindex" : 15, "blocktime" : 1418994502, "txid" : "4cc761b286c23dab5dd07c260726d79e4baee88778a402e36c82a6b9e6ac757f", "walletconflicts" : [ ], "time" : 1452652576, "timereceived" : 1453438430 }, ... snip ... { "involvesWatchonly" : true, "account" : "Index Test", "address" : "1CTVqQSSVTjun32gRxmhJHhVYzzXpR894z", "category" : "receive", "amount" : 13.63000000, "vout" : 0, "confirmations" : 211, "blockhash" : "0000000000000000021df02390f30985f34d871e4cc93c4e349cd3b23574bf76", "blockindex" : 1, "blocktime" : 1430041109, "txid" : "64540e42ec96118d11168d954641dd5390f4a46ba795c7b7588d38141e66117a", "walletconflicts" : [ ], "time" : 1452652576, "timereceived" : 1453438694 } ]
如您所見,輸出中顯示的最後一筆交易是我從區塊 353776 中抓取的交易,所有正確的詳細資訊都顯示在 blockchain.info 上,表明導入地址的成功交易列表(包含地址的帳戶,實際上)。
至於為什麼最初導入地址時重新掃描不起作用,我真的不能說。也許經驗更豐富的比特幣使用者可以對此有所了解。
在這一點上,我建議你停止你的比特幣守護程序並執行
bitcoind -rescan
並等待它發揮它的魔力。之後再試listtransactions
一次。我有興趣了解它是否適合您。請記住,嘗試導入錢包中已經存在的比特幣地址不會啟動重新掃描,即使在命令行中指定這樣做也是如此。— <https://bitcoin.org/en/developer-reference#importaddress>
我也遇到了同樣的問題,不知道樓主解決了沒有。我在 litecoin-cli 中進行操作,但我認為它們應該以相同的方式實現。不加任何參數,直接執行下面的命令。我得到了觀察者地址的相關交易資訊。
litecoin-cli listtransactions "" 10 0 true
一旦我添加了查詢地址,它就會返回一個空列表。我認為這可能是 listtransactions 的一個實現錯誤。
我聲明我的配置。
txindex = 1 and importaddress $address complete.
希望對大家有所幫助。