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

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.

  • Thanks. But, a bit complicated. I found the information I was looking for in api.blockcypher.com which can be accessed using wget or curl in my scripts. Sep 21 '18 at 13:18
  • 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 Jul 7 '20 at 1:45

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.

  • 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. Sep 22 '18 at 12:02
  • @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 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 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
    Sep 23 '18 at 7:38
  • 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. Jul 5 '20 at 4:33
  • @frogeyedpeas and that has resulted in lost coins. it's specifically listed on the wiki: en.bitcoin.it/wiki/From_address
    – Abdussamad
    Jul 5 '20 at 11:41

@Raghav Sood 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


./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


 ./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


./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


./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.


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

electrum onchain_history --show_addresses 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.