<p>I would parse the blockchain. There are libraries for almost any programming language. You can in a 5-liner scan through all transactions and see which input they spent. You need to do this with a local parser and not via an remote api as remote api calls would take way too much time. 
If the input txid is an element of your funding txset wich you collected before it is a channel close (for now while we don't have Splicing)</p>

<p>On the other side 1ml.com has a history of channels with the closing tx. So you might be able to get the data you seek from them. </p>

CC BY-SA 4.0
2019-05-02T05:05:21.780Z
2019-05-02T05:05:21.780Z
Rene Pickhardt
<p>I am wondering how I can find the transaction that spends a specific output (for a large number of transactions). So for example, I have a transaction like the following: <a href="https://www.blockchain.com/btc/tx/ebd4a554faff31dd2a07135913fa073012a4495b195c1a5d5a9a7bca3e88de61" rel="nofollow noreferrer">https://www.blockchain.com/btc/tx/ebd4a554faff31dd2a07135913fa073012a4495b195c1a5d5a9a7bca3e88de61</a>. It has two outputs which are both spent. I would like to find the transaction that spends that output. Blockchain.com has a link to the spending transaction via the tx index (<a href="https://www.blockchain.com/btc/tx-index/355543195" rel="nofollow noreferrer">https://www.blockchain.com/btc/tx-index/355543195</a>). However, they do not offer this an API endpoint and just in the GUI. I was wondering if there exists an API that offers to find the transaction via either the tx-index or other means.</p>

<p><strong>Background</strong>
I just started doing research on the lightning network and I was interested in the closing of channels. In particular, I took a snapshot of the lightning network in January from <a href="https://graph.lndexplorer.com/api/graph" rel="nofollow noreferrer">https://graph.lndexplorer.com/api/graph</a> and scan all the channel transactions to see if the channel is closed. If the channel is closed I want to know if it was a mutual close, unilateral close, or a disputed unilateral close (an old commitment tx which should have a revocation tx following the commitment tx on the chain). Since the dataset has around 16.000 channels, I need an automated way of parsing through the transactions.</p>

<transactions><lightning-network><output>
How can I find the transaction that spends a specific output via an API?
Dominik Harz
# How can I find the transaction that spends a specific output via an API?

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

I am wondering how I can find the transaction that spends a specific output (for a large number of transactions). So for example, I have a transaction like the following: <https://www.blockchain.com/btc/tx/ebd4a554faff31dd2a07135913fa073012a4495b195c1a5d5a9a7bca3e88de61>. It has two outputs which are both spent. I would like to find the transaction that spends that output. Blockchain.com has a link to the spending transaction via the tx index (<https://www.blockchain.com/btc/tx-index/355543195>). However, they do not offer this an API endpoint and just in the GUI. I was wondering if there exists an API that offers to find the transaction via either the tx-index or other means.

**Background**
I just started doing research on the lightning network and I was interested in the closing of channels. In particular, I took a snapshot of the lightning network in January from <https://graph.lndexplorer.com/api/graph> and scan all the channel transactions to see if the channel is closed. If the channel is closed I want to know if it was a mutual close, unilateral close, or a disputed unilateral close (an old commitment tx which should have a revocation tx following the commitment tx on the chain). Since the dataset has around 16.000 channels, I need an automated way of parsing through the transactions.

**Tags:** transactions, lightning-network, output


---

## 1 answers

### Answer by username_1 on 2019-05-02. Score: 2

I would parse the blockchain. There are libraries for almost any programming language. You can in a 5-liner scan through all transactions and see which input they spent. You need to do this with a local parser and not via an remote api as remote api calls would take way too much time.
If the input txid is an element of your funding txset wich you collected before it is a channel close (for now while we don't have Splicing)

On the other side 1ml.com has a history of channels with the closing tx. So you might be able to get the data you seek from them.


---

