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

<ul>
<li><p>See <code>scanutxoset</code> in the documentation:
<a href="https://bitcoincore.org/en/doc/0.17.0/rpc/blockchain/scantxoutset/" rel="nofollow noreferrer">https://bitcoincore.org/en/doc/0.17.0/rpc/blockchain/scantxoutset/</a></p></li>
<li><p>However, it is not clear to how it will be supported in the future: <a href="https://bitcoincore.org/en/meetings/2018/05/24/" rel="nofollow noreferrer">https://bitcoincore.org/en/meetings/2018/05/24/</a></p></li>
<li>Also note, that the utxo set may not return any result for your address, if the last transaction output associated with that address has been spent (not member of the uxto set anymore).</li>
</ul>

<p>Alternatively, Libbitcoin-server indexes all transactions by address per default:</p>

<ul>
<li>See the CLI command <code>bx fetch-history &lt;address&gt;</code>: <a href="https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-fetch-history" rel="nofollow noreferrer">https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-fetch-history</a></li>
<li>Which makes <code>fetch_history</code> server request: <a href="https://github.com/libbitcoin/libbitcoin-server/wiki/Query-Service#blockchainfetch_history3" rel="nofollow noreferrer">https://github.com/libbitcoin/libbitcoin-server/wiki/Query-Service#blockchainfetch_history3</a></li>
<li>Above commands/requests will return ALL transactions in order of confirmation height related to any standard address and indicate whether the outpoint was spent or not.</li>
</ul>

CC BY-SA 4.0
2019-02-04T18:26:22.870Z
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/<AddressA> | python -m json.tool | grep -A1 transactions | grep -v transactions | tr -d ',\" '```

then, as usual like before 

```bit-cli gettransaction <lastoutput>```

then,

```bit-cli decoderawtransaction <hex> | grep -A1 addresses | grep -v addresses | tr -d '" -' | grep -v AddressB | tail -1```
Rakib Fiha
CC BY-SA 4.0
2019-02-06T05:42:37.997Z
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
CC BY-SA 4.0
2019-02-06T07:48:46.443Z
@PieterWuille Ah yes, as chris belchers electrum personal server does...
James C.
CC BY-SA 4.0
2019-02-11T07:17:34.630Z
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. haha
Rakib Fiha
CC BY-SA 4.0
2019-02-04T05:45:59.233Z
2019-02-04T05:45:59.233Z
James C.
<p>I have written a program in Python3 that allows you to search for any address on bitcoin core whether it belongs to your wallet or not.</p>
<p>Here is the github link:</p>
<p><a href="https://github.com/ORP967/Bitcoin_Core_RPC_par_address" rel="nofollow noreferrer">https://github.com/ORP967/Bitcoin_Core_RPC_par_address</a></p>
<p>Let me know what you think or if you have any improvements you might have.</p>

CC BY-SA 4.0
2022-01-23T22:56:31.150Z
2022-01-23T22:56:31.150Z
ORP967
<p>I would like to find out the immediate last transaction of addressA.</p>

<p>But so far, I can only do this, <code>bit-li gettransaction &lt;txid&gt;</code> then <code>bit-cli decoderawtransaction &lt;hex&gt;</code></p>

<p>But I want to do something like this:</p>

<p><code>bit-cli lasttransactionto &lt;addressA&gt;</code></p>

<p>How can I do that, without knowing the tx id??</p>

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

(Asked by: username_0 on 2019-02-04)

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??

**Tags:** blockchain


---

## 2 answers

### Answer by username_1 on 2019-02-04. Score: 0 | Accepted answer

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

* See `scanutxoset` in the documentation:
  <https://bitcoincore.org/en/doc/0.17.0/rpc/blockchain/scantxoutset/>
* However, it is not clear to how it will be supported in the future: <https://bitcoincore.org/en/meetings/2018/05/24/>
* Also note, that the utxo set may not return any result for your address, if the last transaction output associated with that address has been spent (not member of the uxto set anymore).

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

* See the CLI command `bx fetch-history <address>`: <https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-fetch-history>
* Which makes `fetch_history` server request: <https://github.com/libbitcoin/libbitcoin-server/wiki/Query-Service#blockchainfetch_history3>
* Above commands/requests will return ALL transactions in order of confirmation height related to any standard address and indicate whether the outpoint was spent or not.

> **Comments:**
> **username_0**: 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/<AddressA> | python -m json.tool | grep -A1 transactions | grep -v transactions | tr -d ',\" '```  then, as usual like before   ```bit-cli gettransaction <lastoutput>```  then,  ```bit-cli decoderawtransaction <hex> | grep -A1 addresses | grep -v addresses | tr -d '" -' | grep -v AddressB | tail -1```  
> **username_2**: 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.  
> **username_1**: @username_2 Ah yes, as chris belchers electrum personal server does...  
> **username_0**: 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. haha  

---

### Answer by username_3 on 2022-01-23. Score: 0

I have written a program in Python3 that allows you to search for any address on bitcoin core whether it belongs to your wallet or not.

Here is the github link:

<https://github.com/username_3/Bitcoin_Core_RPC_par_address>

Let me know what you think or if you have any improvements you might have.


---

