<p>The hashed refer to the previous tx the input is consuming, and its vout position in that tx.</p>

<p>You will need to use the electrum API to fetch that transaction's details, and look at the <code>outputs[vin]</code> value for the locking script, and then convert that to an address by encoding it for base58check/bech32.</p>

CC BY-SA 4.0
2018-09-21T13:18:43.967Z
Thanks. But, a bit complicated. I found the information I was looking for in [api.blockcypher.com](https://www.blockcypher.com/dev/bitcoin/) which can be accessed using _wget_ or _curl_ in my scripts.
FedKad
CC BY-SA 4.0
2020-07-07T01:45:45.457Z
it might be wise not to trust an external API especially one your not paying for. Raghav's method might be tedious but its much more trustworthy I believe
Sidharth Ghoshal
CC BY-SA 4.0
2018-09-21T10:22:01.443Z
2018-09-21T10:22:01.443Z
Raghav Sood
<p>They removed <em>input addresses</em> aka <em>from addresses</em> because those were technically incorrect. There are no from addresses in bitcoin so this was misleading to users. I believe even in the GUI it only shows from addresses where the addresses belong to the same wallet. They should remove them entirely.</p>

<p>Whatever are you doing that requires tracking from addresses? I suggest handing out different receive addresses to different users to track who sent you how much and not relying on from addresses. This is the correct way to use bitcoin.</p>

CC BY-SA 4.0
2018-09-22T12:02:23.470Z
Thank you for the clarification! I had a similar feeling along your lines. My case is something like this: Somebody -- who I do not know -- will send some me some _testnet3_ bitcoins; an automatic script will do some calculation; and it will send **back** an amount of testnet bitcoins to the "wallet" that started the transaction. As "wallet" I was trying to use one of the _input addresses_ of the original transaction.
 
Since, the potential senders (i.e., the people or "wallets" who will start a transaction) are not limited, I cannot give a different _receive address_ to each one.
FedKad
CC BY-SA 4.0
2018-09-23T07:38:37.853Z
@FedonKadifeli You can generate unlimited addresses from an extended public key so just install that on your website and have the sender get an address from there. [Mycelium gear](https://gear.mycelium.com/) offers an easy to use donation widget that can solicit information like an email or name and generate a unique address for every individual that requests it. Another option is [this wordpress plugin](https://wordpress.org/plugins/bitcoin-address/) but you'll have to modify it to ask for personally identifying info from the sender. You can get your wallet's xpub via wallet > information.
Abdussamad
CC BY-SA 4.0
2020-07-05T04:33:25.057Z
what about games offfering payouts without creating user objects/user sessions such as satoshidice? paying back to input addresses seems like the only way to make that work.
Sidharth Ghoshal
CC BY-SA 4.0
2020-07-05T11:41:20.943Z
@frogeyedpeas and that has resulted in lost coins. it's specifically listed on the wiki: https://en.bitcoin.it/wiki/From_address
Abdussamad
CC BY-SA 4.0
2018-09-22T02:44:21.507Z
2018-09-22T02:44:21.507Z
Abdussamad
<p>@Raghav Sood deserves credit for outlining the high level plan.</p>
<p>For the lazy person here is an explicitly spelled out guide on how to find input addresses. Keep in mind that for almost all applications its not recommended to re-use input addresses, there are a handful of edge cases where they make sense. I strongly recommend reading: <a href="https://en.bitcoin.it/wiki/Address_reuse" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Address_reuse</a> before proceeding.</p>
<h2>Get a TXID, such as through  transaction history (Skip if you already have TXIDs):</h2>
<p>First we can recover our transaction history (note these assume you have default wallet loaded, if you want to use non default wallets, you will need to pass in -w and -W flags) such as</p>
<pre><code>./electrum onchain_history 
</code></pre>
<p>This will output a history of transactions, its a json blob of the form</p>
<pre><code>{&quot;summary&quot;: {...}, &quot;transactions&quot;: [{...}, {...}, ... {...}] } 
</code></pre>
<p>The transactions field is the array you are interested in, each element (a Json blob) contains a transaction, these transactions have a field: &quot;txid&quot;, if you acquired</p>
<h2>Open Your Transaction (Skip this if you can duplicate the OP's output, i.e. open transactions successfully):</h2>
<p>given the txid HASH you can then find the transaction through the following two steps</p>
<pre><code>./electrum gettransaction HASH
</code></pre>
<p>example:</p>
<pre><code>./electrum gettransaction f85a184b7ff78a6a89337ff2c7a944fca615e571d77e390755b6ffb8563d4583
</code></pre>
<p>This will yield an often-large JSON BLOB that is the serialized-transaction. We now have to open this blob:</p>
<pre><code>./electrum deserialize BLOB
</code></pre>
<p>example:</p>
<pre><code> ./electrum 0100000000101ed1aa1daea82d082e7e5c5cc9ef8b21c08f48e6d961545362d8fc0eb2a067100a000000fffffff317a18100c000000017a914320307f04422094abf47b832c88253e93597d1f68755a4be000000000017a914d68c397348ad2388a71a2966fba32e413ce4ab0879e46530000000001976a91422294ef117cc609b5479e4f884719b6a89e5a5f18c912a000000e00001600149c4c4bc0a4ee905d4333344a31bde95cdddd7ced6a8020000000000197a914386e2c8f36eadb8e2719f3958abba32cda5bfe4b88ac4c4a04b0000000017a914127f34ed64cabe05ec3f0b39268e75f2111f0b48740d10c00000000017a914df24
</code></pre>
<p>In doing so you will find a JSON payload described your transaction now we run into the trouble the question poster found which is: the inputs only give you a &quot;prev_out&quot; hash and a &quot;prev_out_n&quot;. So how to find the address?</p>
<h2>Finding Input Addresses:</h2>
<p>We now use the commands we have already established to take us home.</p>
<pre><code>./electrum gettransaction prev_out_hash
</code></pre>
<p>example:</p>
<pre><code>./electrum &quot;c96274d67e095...74c1af&quot; 
</code></pre>
<p>(the string quotes should be kept but they can dropped in most shells)</p>
<p>The output of this command is a BLOB, to deserialize</p>
<pre><code>./electrum BLOB
</code></pre>
<p>example:</p>
<pre><code>./electrum 0100000000101ed1aa1daea82d082e7e5c5cc9ef8b21c08f48e6d961545362d8fc0eb2a067100a000000fffffff317a18100c000000017a914320307f04422094abf47b832c88253e93597d1f68755a4be00000000
</code></pre>
<p>Now you have opened the transaction that contains in the input. In the &quot;outputs&quot; array find the transaction at index: &quot;prev_out_n&quot;, this transaction will have an address.</p>
<p>That is your from address. But really try not to use this.</p>
<h2>EDIT:</h2>
<p>one can use the &quot;--show_addresses&quot; flag instead, to yield all the addresses saving a tremendous amount of effort:</p>
<pre><code>electrum onchain_history --show_addresses 
</code></pre>

CC BY-SA 4.0
2020-07-09T04:10:40.277Z
2020-07-09T22:23:51.497Z
2020-07-09T22:23:51.497Z
Sidharth Ghoshal
<p>I am using the latest (3.2.3) command line version of Electrum. I want to find the inputs of a transaction by looking at the history. The previous version of Electrum (that I was using 8 months ago) had a field (array) called <em>input_addresses</em> in its history output.</p>

<p>The current version does not have it.</p>

<p>A sample output from history is something like this:</p>

<pre><code>$ electrum --testnet history --show_addresses | tail -40
...
        {
            "balance": "xxx BTC",
            "confirmations": 1,
            "date": "2018-09-21 12:27",
            "height": 1413976,
            "inputs": [
                {
                    "prevout_hash": "c96274d67e095...74c1af",
                    "prevout_n": 1
                },
                {
                    "prevout_hash": "f7e443ade3f0e...fe1eb8",
                    "prevout_n": 0
                }
            ],
            "label": "",
            "outputs": [
                {
                    "address": "myAB...",
                    "value": "0.49794855 BTC"
                },
                {
                    "address": "2N25...",
                    "value": "5.000258 BTC"
                }
            ],
            "timestamp": 1537522037,
            "txid": "3404f9fb96...0d253c",
            "value": "-5.00233525 BTC"
        }
    ]
}
</code></pre>

<p>So I am left with something called <em>inputs</em> containing some hashes. I need to convert these hashes to input addresses from command line.</p>

<p>The GUI version of Electrum will show the input address on the right of the hashes, like this:</p>

<pre><code>c96274d67e095...74c1af:1    mhAhgR...
f7e443ade3f0e...fe1eb8:0    mhAhgR...
</code></pre>

<electrum><command-line-options>
Get input addresses of a transaction using electrum
FedKad
# Get input addresses of a transaction using electrum

(Asked by: username_0 on 2018-09-21)

I am using the latest (3.2.3) command line version of Electrum. I want to find the inputs of a transaction by looking at the history. The previous version of Electrum (that I was using 8 months ago) had a field (array) called *input\_addresses* in its history output.

The current version does not have it.

A sample output from history is something like this:

```
$ electrum --testnet history --show_addresses | tail -40
...
        {
            "balance": "xxx BTC",
            "confirmations": 1,
            "date": "2018-09-21 12:27",
            "height": 1413976,
            "inputs": [
                {
                    "prevout_hash": "c96274d67e095...74c1af",
                    "prevout_n": 1
                },
                {
                    "prevout_hash": "f7e443ade3f0e...fe1eb8",
                    "prevout_n": 0
                }
            ],
            "label": "",
            "outputs": [
                {
                    "address": "myAB...",
                    "value": "0.49794855 BTC"
                },
                {
                    "address": "2N25...",
                    "value": "5.000258 BTC"
                }
            ],
            "timestamp": 1537522037,
            "txid": "3404f9fb96...0d253c",
            "value": "-5.00233525 BTC"
        }
    ]
}

```

So I am left with something called *inputs* containing some hashes. I need to convert these hashes to input addresses from command line.

The GUI version of Electrum will show the input address on the right of the hashes, like this:

```
c96274d67e095...74c1af:1    mhAhgR...
f7e443ade3f0e...fe1eb8:0    mhAhgR...

```

**Tags:** electrum, command-line-options


---

## 3 answers

### Answer by username_1 on 2018-09-21. Score: 2

The hashed refer to the previous tx the input is consuming, and its vout position in that tx.

You will need to use the electrum API to fetch that transaction's details, and look at the `outputs[vin]` value for the locking script, and then convert that to an address by encoding it for base58check/bech32.

> **Comments:**
> **username_0**: Thanks. But, a bit complicated. I found the information I was looking for in [api.blockcypher.com](https://www.blockcypher.com/dev/bitcoin/) which can be accessed using _wget_ or _curl_ in my scripts.  
> **username_2**: it might be wise not to trust an external API especially one your not paying for. username_1's method might be tedious but its much more trustworthy I believe  

---

### Answer by username_3 on 2018-09-22. Score: 0

They removed *input addresses* aka *from addresses* because those were technically incorrect. There are no from addresses in bitcoin so this was misleading to users. I believe even in the GUI it only shows from addresses where the addresses belong to the same wallet. They should remove them entirely.

Whatever are you doing that requires tracking from addresses? I suggest handing out different receive addresses to different users to track who sent you how much and not relying on from addresses. This is the correct way to use bitcoin.

> **Comments:**
> **username_0**: Thank you for the clarification! I had a similar feeling along your lines. My case is something like this: Somebody -- who I do not know -- will send some me some _testnet3_ bitcoins; an automatic script will do some calculation; and it will send **back** an amount of testnet bitcoins to the "wallet" that started the transaction. As "wallet" I was trying to use one of the _input addresses_ of the original transaction.   Since, the potential senders (i.e., the people or "wallets" who will start a transaction) are not limited, I cannot give a different _receive address_ to each one.  
> **username_3**: @FedonKadifeli You can generate unlimited addresses from an extended public key so just install that on your website and have the sender get an address from there. [Mycelium gear](https://gear.mycelium.com/) offers an easy to use donation widget that can solicit information like an email or name and generate a unique address for every individual that requests it. Another option is [this wordpress plugin](https://wordpress.org/plugins/bitcoin-address/) but you'll have to modify it to ask for personally identifying info from the sender. You can get your wallet's xpub via wallet > information.  
> **username_2**: what about games offfering payouts without creating user objects/user sessions such as satoshidice? paying back to input addresses seems like the only way to make that work.  
> **username_3**: @frogeyedpeas and that has resulted in lost coins. it's specifically listed on the wiki: https://en.bitcoin.it/wiki/From_address  

---

### Answer by username_2 on 2020-07-09. Score: 0

@username_1 deserves credit for outlining the high level plan.

For the lazy person here is an explicitly spelled out guide on how to find input addresses. Keep in mind that for almost all applications its not recommended to re-use input addresses, there are a handful of edge cases where they make sense. I strongly recommend reading: <https://en.bitcoin.it/wiki/Address_reuse> before proceeding.

## Get a TXID, such as through transaction history (Skip if you already have TXIDs):

First we can recover our transaction history (note these assume you have default wallet loaded, if you want to use non default wallets, you will need to pass in -w and -W flags) such as

```
./electrum onchain_history 

```

This will output a history of transactions, its a json blob of the form

```
{"summary": {...}, "transactions": [{...}, {...}, ... {...}] } 

```

The transactions field is the array you are interested in, each element (a Json blob) contains a transaction, these transactions have a field: "txid", if you acquired

## Open Your Transaction (Skip this if you can duplicate the OP's output, i.e. open transactions successfully):

given the txid HASH you can then find the transaction through the following two steps

```
./electrum gettransaction HASH

```

example:

```
./electrum gettransaction f85a184b7ff78a6a89337ff2c7a944fca615e571d77e390755b6ffb8563d4583

```

This will yield an often-large JSON BLOB that is the serialized-transaction. We now have to open this blob:

```
./electrum deserialize BLOB

```

example:

```
 ./electrum 0100000000101ed1aa1daea82d082e7e5c5cc9ef8b21c08f48e6d961545362d8fc0eb2a067100a000000fffffff317a18100c000000017a914320307f04422094abf47b832c88253e93597d1f68755a4be000000000017a914d68c397348ad2388a71a2966fba32e413ce4ab0879e46530000000001976a91422294ef117cc609b5479e4f884719b6a89e5a5f18c912a000000e00001600149c4c4bc0a4ee905d4333344a31bde95cdddd7ced6a8020000000000197a914386e2c8f36eadb8e2719f3958abba32cda5bfe4b88ac4c4a04b0000000017a914127f34ed64cabe05ec3f0b39268e75f2111f0b48740d10c00000000017a914df24

```

In doing so you will find a JSON payload described your transaction now we run into the trouble the question poster found which is: the inputs only give you a "prev\_out" hash and a "prev\_out\_n". So how to find the address?

## Finding Input Addresses:

We now use the commands we have already established to take us home.

```
./electrum gettransaction prev_out_hash

```

example:

```
./electrum "c96274d67e095...74c1af" 

```

(the string quotes should be kept but they can dropped in most shells)

The output of this command is a BLOB, to deserialize

```
./electrum BLOB

```

example:

```
./electrum 0100000000101ed1aa1daea82d082e7e5c5cc9ef8b21c08f48e6d961545362d8fc0eb2a067100a000000fffffff317a18100c000000017a914320307f04422094abf47b832c88253e93597d1f68755a4be00000000

```

Now you have opened the transaction that contains in the input. In the "outputs" array find the transaction at index: "prev\_out\_n", this transaction will have an address.

That is your from address. But really try not to use this.

## EDIT:

one can use the "--show\_addresses" flag instead, to yield all the addresses saving a tremendous amount of effort:

```
electrum onchain_history --show_addresses 

```


---

