<p>The data you are looking for isn't actually included in the transaction that spends the UTXOs. Addresses are basically shorthand for a <code>scriptPubKey</code>, and <code>scriptPubKey</code>s are associated with outputs, not inputs. So if you want to check if an input spends from a certain address, you have to get the corresponding previous output and look what address it pays to. </p>

<p>For example, I have a transaction in my <code>listtransactions</code>:</p>

<pre><code>{
"account" : "",
"address" : "mmcuav4ZD8EBc8aH5EkoGcKZSPsoHz1UzZ",
"category" : "receive",
...
"txid" : "8cb677f33d2ad2d9d94a4aa5552cd6a09615568abb7e5fd3c34df3c7869105d3",
...
}
</code></pre>

<p>So, I use <code>getrawtransaction</code> to see what my transactions inputs are: </p>

<pre><code>$ bitcoin-cli getrawtransaction 8cb677f33d2ad2d9d94a4aa5552cd6a09615568abb7e5fd3c34df3c7869105d3 1

...
"vin" : [
    {
        "txid" : "33e25fd78c075dff3b0474911ca2244c5246cb40b0b34653e2fe1ca6f7c26d46",
        "vout" : 1,
        "scriptSig" : {
            "asm" : "3044022009ee6ccde46a58d7e5347ed28e8e946b1cbca3518c5066bcf1809abdfef9ef940220254fa3ed7f80831f08f760958d870a575f612aa5bb67add4cd4eb7d135a75b6a01 02a54cf1e2ecaea3e56721af6e90eb8e934597ee77cd03e060bbed47b8db03a754",
            "hex" : "473044022009ee6ccde46a58d7e5347ed28e8e946b1cbca3518c5066bcf1809abdfef9ef940220254fa3ed7f80831f08f760958d870a575f612aa5bb67add4cd4eb7d135a75b6a012102a54cf1e2ecaea3e56721af6e90eb8e934597ee77cd03e060bbed47b8db03a754"
        },
        "sequence" : 4294967295
    }
]
...
</code></pre>

<p>Now I look at the transaction output that funded this input, which is at index 1. </p>

<pre><code>$ bitcoin-cli getrawtransaction 33e25fd78c075dff3b0474911ca2244c5246cb40b0b34653e2fe1ca6f7c26d46 1

...
"vout" : [
    ...
    {
        "value" : 2.39990000,
        "n" : 1,
        "scriptPubKey" : {
            "asm" : "OP_DUP OP_HASH160 1fab219d5483021bd791453e155f7b956f4b3ed4 OP_EQUALVERIFY OP_CHECKSIG",
            "hex" : "76a9141fab219d5483021bd791453e155f7b956f4b3ed488ac",
            "reqSigs" : 1,
            "type" : "pubkeyhash",
            "addresses" : [
                "miQQFQse4DwFE9rkMkZ78CwvTHkg3sTJmc"
            ]
        }
    }
]
...
</code></pre>

<p>So, miQQFQse4DwFE9rkMkZ78CwvTHkg3sTJmc is the addres that funded my original transaction. Obviously, this can be automated so you don't have to make all these calls each time you want to see the address that funded a transaction.</p>

CC BY-SA 3.0
2015-03-30T18:09:29.167Z
I was looking for some kind of indexed operation, but if I must list the transactions, and search one by one, from newest to oldest, that will suffice for my application. Thanks.
lvella
CC BY-SA 3.0
2015-03-30T15:09:24.627Z
2015-03-30T15:09:24.627Z
morsecoder
<p>I have an address from which all unspent <code>txouts</code> were used in a single transaction. How can I find out what transaction was that? In my node instance, <code>listtransactions</code> will not list addresses that spent the coins, only those that received them.</p>

<transactions><json-rpc>
Using bitcoind JSON-RPC, how to get transaction from input address?
lvella
# Using bitcoind JSON-RPC, how to get transaction from input address?

(Asked by: username_0 on 2015-03-30)

I have an address from which all unspent `txouts` were used in a single transaction. How can I find out what transaction was that? In my node instance, `listtransactions` will not list addresses that spent the coins, only those that received them.

**Tags:** transactions, json-rpc


---

## 1 answers

### Answer by username_1 on 2015-03-30. Score: 5

The data you are looking for isn't actually included in the transaction that spends the UTXOs. Addresses are basically shorthand for a `scriptPubKey`, and `scriptPubKey`s are associated with outputs, not inputs. So if you want to check if an input spends from a certain address, you have to get the corresponding previous output and look what address it pays to.

For example, I have a transaction in my `listtransactions`:

```
{
"account" : "",
"address" : "mmcuav4ZD8EBc8aH5EkoGcKZSPsoHz1UzZ",
"category" : "receive",
...
"txid" : "8cb677f33d2ad2d9d94a4aa5552cd6a09615568abb7e5fd3c34df3c7869105d3",
...
}

```

So, I use `getrawtransaction` to see what my transactions inputs are:

```
$ bitcoin-cli getrawtransaction 8cb677f33d2ad2d9d94a4aa5552cd6a09615568abb7e5fd3c34df3c7869105d3 1

...
"vin" : [
    {
        "txid" : "33e25fd78c075dff3b0474911ca2244c5246cb40b0b34653e2fe1ca6f7c26d46",
        "vout" : 1,
        "scriptSig" : {
            "asm" : "3044022009ee6ccde46a58d7e5347ed28e8e946b1cbca3518c5066bcf1809abdfef9ef940220254fa3ed7f80831f08f760958d870a575f612aa5bb67add4cd4eb7d135a75b6a01 02a54cf1e2ecaea3e56721af6e90eb8e934597ee77cd03e060bbed47b8db03a754",
            "hex" : "473044022009ee6ccde46a58d7e5347ed28e8e946b1cbca3518c5066bcf1809abdfef9ef940220254fa3ed7f80831f08f760958d870a575f612aa5bb67add4cd4eb7d135a75b6a012102a54cf1e2ecaea3e56721af6e90eb8e934597ee77cd03e060bbed47b8db03a754"
        },
        "sequence" : 4294967295
    }
]
...

```

Now I look at the transaction output that funded this input, which is at index 1.

```
$ bitcoin-cli getrawtransaction 33e25fd78c075dff3b0474911ca2244c5246cb40b0b34653e2fe1ca6f7c26d46 1

...
"vout" : [
    ...
    {
        "value" : 2.39990000,
        "n" : 1,
        "scriptPubKey" : {
            "asm" : "OP_DUP OP_HASH160 1fab219d5483021bd791453e155f7b956f4b3ed4 OP_EQUALVERIFY OP_CHECKSIG",
            "hex" : "76a9141fab219d5483021bd791453e155f7b956f4b3ed488ac",
            "reqSigs" : 1,
            "type" : "pubkeyhash",
            "addresses" : [
                "miQQFQse4DwFE9rkMkZ78CwvTHkg3sTJmc"
            ]
        }
    }
]
...

```

So, miQQFQse4DwFE9rkMkZ78CwvTHkg3sTJmc is the addres that funded my original transaction. Obviously, this can be automated so you don't have to make all these calls each time you want to see the address that funded a transaction.

> **Comments:**
> **username_0**: I was looking for some kind of indexed operation, but if I must list the transactions, and search one by one, from newest to oldest, that will suffice for my application. Thanks.  

---

