<p>The Bitcoin system doesn't have a "sender's address".  You can walk the transaction history to find out what destination the coins you were paid was last sent to but that is not a "sender's address".</p>

<p>Imagine if you had a magic wand you could wave over any package you received in the mail that would tell you where it was last mailed before you. You wave the wand over a package and find it was last mailed to a large distribution warehouse in china.  Is this the sender's address?  No. You bought the package from a shop in New York that purchased it for drop shipment from a distributor in Texas that fulfilled it out of a third party operated warehouse in Seattle, who recently pulled it out of a container from transoceanic shipment from the warehouse in china that your wand returned.</p>

<p>The previous to address might be useful information, just like the wand example-- but it is not the sender-- or at least not necessarily so--, it is not a return or refund address.  And this failure to map to the sender is not a fringe situation, just like the wand returning someone other than the party who sold you something would not be fringe: people frequently pay bitcoin's out of third parties wallets.</p>

CC BY-SA 4.0
2018-12-13T06:10:41.380Z
2018-12-13T06:10:41.380Z
G. Maxwell
<p>There is a field named "signature script" in the inputs.Signature script includes the sender's full (unhashed) public key,see:<a href="https://bitcoin.org/en/developer-guide#transactions" rel="nofollow noreferrer">Bitcoin Developer Guide</a>.You can get the sender's wallet address from the public key. In the outputs there is a field named "pubkey script" which contains the receiver's wallet address.</p>

CC BY-SA 4.0
2018-05-18T18:57:40.647Z
On   [BTC](https://btc.com/api-doc):  signature script field --- "script_hex" ,  
pubkey script field --- addresses:
Bill
CC BY-SA 4.0
2018-05-18T21:20:40.387Z
*THIS IS NOT THE SENDER'S ADDRESS!* Suppose Alice deposits bitcoins into an exchange and then Bill asks the exchange to pay Charley, if the exchange uses the coins Alice deposited, the "sender's address" will be Alice's deposit address even though Bill is the sender. Sending to that address will credit Alice, not Bill.
David Schwartz
CC BY-SA 4.0
2018-05-18T21:33:04.703Z
What do you mean "THIS"?
Bill
CC BY-SA 4.0
2018-05-18T22:27:43.667Z
The address you get if you follow the procedure above. It is actually the receiving address of the transaction that funded the wallet that made the payment, which is not always the sender's address. See my example above.
David Schwartz
CC BY-SA 4.0
2018-05-21T10:03:20.743Z
Thanks for insights so far:
"You can get the sender's wallet address from the public key"
 - any suggested method or example?
Maz
CC BY-SA 4.0
2018-09-04T22:11:36.047Z
@Maz Bitcoin does not have a concept of a "sender address". If you want to know who paid you, give a different address for each invoice/expected payment. If you want to be able to refund people, ask them for a refund address before they pay you. Do **not** guess the sender's address based on the transaction; the information is not there.
Pieter Wuille
CC BY-SA 4.0
2018-05-18T18:54:13.403Z
2018-05-18T18:54:13.403Z
Bill
<p>You have to crawl the transactions,which will give you <strong>Vout addresses</strong> i.e <strong>receiver address</strong> </p>

<p>and to know the <strong>sender address</strong> you have to Crawl Vin txid and match the  Vout address  with "vout"and "n" parameter of <strong>raw transaction</strong> which will be you sender address. You can check the <a href="https://bitcoin.stackexchange.com/questions/25540/how-to-get-the-input-address-from-vin-where-only-a-txid-is-given-insight-api/74721#74721">link</a> which will show you how this is done in python 2.7</p>

CC BY-SA 4.0
2018-06-25T12:08:51.643Z
2018-06-25T12:08:51.643Z
Parishilan Rayamajhi
<p>Various block explorers exist, which offer REST APIs. So far been using blockchain.info and btc.com</p>

<p><strong>Here is what we have:</strong><br>
- List of bitcoin addresses</p>

<p><strong>Here is what can easily be got with that info:</strong><br>
 - Historic list of transactions (hashes, or IDs) for the given addresses<br>
 - I can also discover which input or output was OUR address, and therefore:<br>
 - value, and whether the transaction was being sent or received<br></p>

<p>Now, <strong>here's what we need to obtain</strong>:<br>
 - the <strong>OTHER (to/from)</strong> address!<br></p>

<p><strong>So:</strong><br>
How can you use a transaction ID to obtain BOTH the sender's and receiver's wallet address - with some kind of REST API preferably?<br></p>

<p>(...knowing that sometimes transaction IDs are associated with multiple inputs and multiple outputs)<br></p>

<p><em>Endpoint references</em>:<br>
<a href="https://blockchain.info/q" rel="nofollow noreferrer">https://blockchain.info/q</a><br>
<a href="https://btc.com/api-doc" rel="nofollow noreferrer">https://btc.com/api-doc</a></p>

<transactions><address><blockchain.info><api><hash>
Bitcoin API(s) - how to pair (or obtain) BOTH sender and receiver addresses with a transaction ID (hash)
Maz
# Bitcoin API(s) - how to pair (or obtain) BOTH sender and receiver addresses with a transaction ID (hash)

(Asked by: username_0 on 2018-05-18)

Various block explorers exist, which offer REST APIs. So far been using blockchain.info and btc.com

**Here is what we have:**  
- List of bitcoin addresses

**Here is what can easily be got with that info:**  
- Historic list of transactions (hashes, or IDs) for the given addresses  
- I can also discover which input or output was OUR address, and therefore:  
- value, and whether the transaction was being sent or received

Now, **here's what we need to obtain**:  
- the **OTHER (to/from)** address!

**So:**  
How can you use a transaction ID to obtain BOTH the sender's and receiver's wallet address - with some kind of REST API preferably?

(...knowing that sometimes transaction IDs are associated with multiple inputs and multiple outputs)

*Endpoint references*:  
<https://blockchain.info/q>  
<https://btc.com/api-doc>

**Tags:** transactions, address, blockchain.info, api, hash


---

## 3 answers

### Answer by username_1 on 2018-12-13. Score: 1

The Bitcoin system doesn't have a "sender's address". You can walk the transaction history to find out what destination the coins you were paid was last sent to but that is not a "sender's address".

Imagine if you had a magic wand you could wave over any package you received in the mail that would tell you where it was last mailed before you. You wave the wand over a package and find it was last mailed to a large distribution warehouse in china. Is this the sender's address? No. You bought the package from a shop in New York that purchased it for drop shipment from a distributor in Texas that fulfilled it out of a third party operated warehouse in Seattle, who recently pulled it out of a container from transoceanic shipment from the warehouse in china that your wand returned.

The previous to address might be useful information, just like the wand example-- but it is not the sender-- or at least not necessarily so--, it is not a return or refund address. And this failure to map to the sender is not a fringe situation, just like the wand returning someone other than the party who sold you something would not be fringe: people frequently pay bitcoin's out of third parties wallets.


---

### Answer by username_2 on 2018-05-18. Score: -1

There is a field named "signature script" in the inputs.Signature script includes the sender's full (unhashed) public key,see:[Bitcoin Developer Guide](https://bitcoin.org/en/developer-guide#transactions).You can get the sender's wallet address from the public key. In the outputs there is a field named "pubkey script" which contains the receiver's wallet address.

> **Comments:**
> **username_2**: On   [BTC](https://btc.com/api-doc):  signature script field --- "script_hex" ,   pubkey script field --- addresses:  
> **username_3**: *THIS IS NOT THE SENDER'S ADDRESS!* Suppose Alice deposits bitcoins into an exchange and then username_2 asks the exchange to pay Charley, if the exchange uses the coins Alice deposited, the "sender's address" will be Alice's deposit address even though username_2 is the sender. Sending to that address will credit Alice, not username_2.  
> **username_2**: What do you mean "THIS"?  
> **username_3**: The address you get if you follow the procedure above. It is actually the receiving address of the transaction that funded the wallet that made the payment, which is not always the sender's address. See my example above.  
> **username_0**: Thanks for insights so far: "You can get the sender's wallet address from the public key"  - any suggested method or example?  
> **username_4**: @username_0 Bitcoin does not have a concept of a "sender address". If you want to know who paid you, give a different address for each invoice/expected payment. If you want to be able to refund people, ask them for a refund address before they pay you. Do **not** guess the sender's address based on the transaction; the information is not there.  

---

### Answer by username_5 on 2018-06-25. Score: -2

You have to crawl the transactions,which will give you **Vout addresses** i.e **receiver address**

and to know the **sender address** you have to Crawl Vin txid and match the Vout address with "vout"and "n" parameter of **raw transaction** which will be you sender address. You can check the [link](https://bitcoin.stackexchange.com/questions/25540/how-to-get-the-input-address-from-vin-where-only-a-txid-is-given-insight-api/74721#74721) which will show you how this is done in python 2.7


---

