Is there any way to find out latest bitcoin transaction of a particular address in bit-cli, without knowing the txid?

0

I would like to find out the immediate last transaction of addressA.

But so far, I can only do this, bit-li gettransaction <txid> then bit-cli decoderawtransaction <hex>

But I want to do something like this:

bit-cli lasttransactionto <addressA>

How can I do that, without knowing the tx id??

Rakib Fiha

Posted 2019-02-04T05:04:17.557

Reputation: 9

Answers

0

Bitcoind doesn't index by address, but you can scan the uxto set for outpoints which are spent to the address of interest:

Alternatively, Libbitcoin-server indexes all transactions by address per default:

James C.

Posted 2019-02-04T05:04:17.557

Reputation: 2 183

Thank you, I think, I will download libbitcoin but right now, I am doing it like this, but I am not sure if it is good approach or not,

curl https://localhost/api/addr/&lt;AddressA&gt; | python -m json.tool | grep -A1 transactions | grep -v transactions | tr -d ',\" '

then, as usual like before

bit-cli gettransaction &lt;lastoutput&gt;

then,

bit-cli decoderawtransaction &lt;hex&gt; | grep -A1 addresses | grep -v addresses | tr -d '" -' | grep -v AddressB | tail -1Rakib Fiha 2019-02-04T18:26:22.870

You can also import the address as watch-only into the wallet (using importaddress) in Bitcoin Core, and have the wallet rescan the chain for relevant transactions.Pieter Wuille 2019-02-06T05:42:37.997

@PieterWuille Ah yes, as chris belchers electrum personal server does...James C. 2019-02-06T07:48:46.443

Rescanning the entire chain takes a long time, doesn't it? The problem I am having with my approach is that, if my address (to addr) gets exposed then spammer may flood my address with thousands of small amount of tx. Then, my code will be unable to pick up the right address(from addr). I know there are solutions out there but I dont know how to do it. hahaRakib Fiha 2019-02-11T07:17:34.630