<p>Despite how it looks on most block explorers, Bitcoin doesn't really have a concept of a &quot;sender address&quot;, at least not on the raw transaction level. What a transaction has is <em>inputs</em> and what block explorers do is go look up those inputs and guess the address that was used to create those UTXOs.</p>
<p>You might find these related questions useful (just search this site for &quot;sender address&quot;):</p>
<p><a href="https://bitcoin.stackexchange.com/questions/3896/how-to-findout-the-sender-of-a-transaction">How to findout the sender of a transaction</a></p>
<p><a href="https://bitcoin.stackexchange.com/questions/40842/sender-address-from-decoderawtransaction-c">Sender address from DecodeRawTransaction (C#)</a></p>

CC BY-SA 4.0
2020-12-14T18:26:01.920Z
2020-12-14T18:26:01.920Z
pinhead
<p>To get the sender address from Bitcoin Core, you will have to track additional information about the blockchain by setting <a href="https://bitcoin.stackexchange.com/questions/35707/what-are-pros-and-cons-of-txindex-option"><code>txindex=1</code></a> in the configuration file. This is because the sending address of the transaction in question is only associated with the previous transaction. Setting <code>txindex=1</code> configures Bitcoin Core to maintain the entire transaction index, beyond what pertains to your wallet or read-only addresses, allowing you to call <code>getrawtransaction</code> on any txid.</p>
<p>Once you have properly configured and synced Bitcoin Core, you can retrieve the sending address(es) of a transaction by looking through each input tx using <code>decoderawtransaction(getrawtransaction(txid))</code> (code pulled from <a href="https://bitcoin.stackexchange.com/questions/3896/how-to-findout-the-sender-of-a-transaction/5982#5982">this answer</a>):</p>
<pre><code>txid = &lt;relevant transaction id&gt;
addresses = []
raw_tx = decoderawtransaction(getrawtransaction(txid))
for(input in raw_tx['vin']) {
  input_raw_tx = decoderawtransaction(getrawtransaction(input['txid']))
  addresses.push(input_raw_tx['vout'][input['vout']]['scriptPubKey']['addresses'][0])
}
</code></pre>
<p>Many blockchain explorers have free low-volume API access and you can just query their data instead of maintaining a full txindex node. Two that come to mind are <a href="https://blockchair.com/api/docs#link_201" rel="nofollow noreferrer">Blockchair</a> and <a href="https://www.blockcypher.com/dev/bitcoin/#transaction-hash-endpoint" rel="nofollow noreferrer">BlockCypher</a> (BlockCypher even includes all the sender addresses in their tx endpoint so you can retrieve these with a single API call instead of querying each input tx from Blockchair like you would need to with Bitcoin Core).</p>

CC BY-SA 4.0
2022-03-10T01:28:24.187Z
2022-03-10T01:35:05.417Z
2022-03-10T01:35:05.417Z
Ron
<p>I'm using JSON-RPC call to connect to local bitcoin node on my clouding server.</p>
<p>I could get all transactions with wallet name by using <code>gettransactions</code>.
Now I need to get sender's address for each transaction but result contains only receivers' address.</p>
<p>Following is response of <code>gettransactions</code> request.</p>
<pre><code>{
    &quot;result&quot;: [
        {
            &quot;address&quot;: &quot;bc1qd9mgd4ynryaw2kp0pzfjdxguhz9dzvs5vh0nfn&quot;,
            &quot;category&quot;: &quot;receive&quot;,
            &quot;amount&quot;: 0.001,
            &quot;label&quot;: &quot;&quot;,
            &quot;vout&quot;: 27,
            &quot;confirmations&quot;: 1322,
            &quot;blockhash&quot;: &quot;000000000000000000074551080f954e790edfe6ad810ecebf4691e881175eaf&quot;,
            &quot;blockheight&quot;: 660029,
            &quot;blockindex&quot;: 106,
            &quot;blocktime&quot;: 1607147554,
            &quot;txid&quot;: &quot;07ab59c8d3a204172887085258460d0058c20a9acdb451daa5ad4290cbd461b0&quot;,
            &quot;walletconflicts&quot;: [],
            &quot;time&quot;: 1607147511,
            &quot;timereceived&quot;: 1607147511,
            &quot;bip125-replaceable&quot;: &quot;no&quot;
        },
        {
            &quot;address&quot;: &quot;bc1q6dh3h5e3qgku8u9s8y664844fj4fkm08n7cnwt&quot;,
            &quot;category&quot;: &quot;receive&quot;,
            &quot;amount&quot;: 0.0011,
            &quot;label&quot;: &quot;&quot;,
            &quot;vout&quot;: 9,
            &quot;confirmations&quot;: 1313,
            &quot;blockhash&quot;: &quot;00000000000000000000960f4476a8552cac203eec6e0f826886b41fae402bec&quot;,
            &quot;blockheight&quot;: 660038,
            &quot;blockindex&quot;: 393,
            &quot;blocktime&quot;: 1607153799,
            &quot;txid&quot;: &quot;af0885e4c1d10e935de525680c6c33d221ab506742b08e34a0322bba90b56fb0&quot;,
            &quot;walletconflicts&quot;: [],
            &quot;time&quot;: 1607152236,
            &quot;timereceived&quot;: 1607152236,
            &quot;bip125-replaceable&quot;: &quot;no&quot;
        },
        {
            &quot;address&quot;: &quot;1L8ZNCibVVpPjJ8VJ1ALLuTjtctA4mzGPw&quot;,
            &quot;category&quot;: &quot;send&quot;,
            &quot;amount&quot;: -0.001,
            &quot;vout&quot;: 0,
            &quot;fee&quot;: -0.00008536,
            &quot;confirmations&quot;: 706,
            &quot;blockhash&quot;: &quot;0000000000000000000c3230522e267980bb990883cc0b36460ad3efc1f8fed4&quot;,
            &quot;blockheight&quot;: 660645,
            &quot;blockindex&quot;: 1049,
            &quot;blocktime&quot;: 1607529332,
            &quot;txid&quot;: &quot;a2056e7a49bc608435713519bc038ed7da2e65f588495f36c6628f5ca6fe2d7d&quot;,
            &quot;walletconflicts&quot;: [],
            &quot;time&quot;: 1607528963,
            &quot;timereceived&quot;: 1607528963,
            &quot;bip125-replaceable&quot;: &quot;no&quot;,
            &quot;comment&quot;: &quot; &quot;,
            &quot;to&quot;: &quot;seans outpost&quot;,
            &quot;abandoned&quot;: false
        },
        {
            &quot;address&quot;: &quot;1L8ZNCibVVpPjJ8VJ1ALLuTjtctA4mzGPw&quot;,
            &quot;category&quot;: &quot;send&quot;,
            &quot;amount&quot;: -0.0005,
            &quot;vout&quot;: 1,
            &quot;fee&quot;: -0.00008536,
            &quot;confirmations&quot;: 705,
            &quot;blockhash&quot;: &quot;0000000000000000000994e21412109847caffa2bd990884f49461d53c047055&quot;,
            &quot;blockheight&quot;: 660646,
            &quot;blockindex&quot;: 844,
            &quot;blocktime&quot;: 1607529675,
            &quot;txid&quot;: &quot;ddbe1dce4537926b6cf5bc1e222e5cd32de224cf346ca89251c127ce32226f30&quot;,
            &quot;walletconflicts&quot;: [],
            &quot;time&quot;: 1607529401,
            &quot;timereceived&quot;: 1607529401,
            &quot;bip125-replaceable&quot;: &quot;no&quot;,
            &quot;comment&quot;: &quot; &quot;,
            &quot;to&quot;: &quot;seans outpost&quot;,
            &quot;abandoned&quot;: false
        }
    ],
    &quot;error&quot;: null,
    &quot;id&quot;: &quot;curltest&quot;
}
</code></pre>
<p>How can I get sender's address?</p>

CC BY-SA 4.0
2020-12-14T19:04:02.557Z
What do you need the sender address for? Bitcoin doesn't really have such a concept. There are approximations but they're often wrong. If the goal is distinguishing multiple payments to determine who paid, the best practice is giving a different receiving address to for every payment.
Pieter Wuille
CC BY-SA 4.0
2022-03-04T00:12:44.983Z
@PieterWuille Certain regulatory reporting schemes require a list of the sending addresses. The sending addresses can definitely be discovered for a given txid and would be considered pertinent information as shown by every blockchain explorer.
Ron
CC BY-SA 4.0
2022-03-04T01:00:51.633Z
What if the transaction is a payjoin/coinjoin? The "apparent" sending addresses would belong to a multitude of unrelated people. If funds are withdrawn from an exchange, the apparent sending address may belong to a different exchange customer. Just because data is visible does not mean it is meaningul.
Pieter Wuille
CC BY-SA 4.0
2022-03-10T01:12:23.893Z
@PieterWuille I agree with your statement that "visible does not mean it is meaningful", but that is irrelevant to the original question about how to achieve this in a technical manner (not what the significance of the result is). It seems you agree that the concept exists by having a conversation about its meaningfulness or usability. If the transaction is coinjoin then the sending addresses can still be enumerated in the same way. The connections between inputs and outputs in coinjoin transactions may still be inferred through certain heuristics.
Ron
<bitcoin-core><transactions><address><json-rpc>
How to get sender address from transaction with JSON RPC?
prodevcn
# How to get sender address from transaction with JSON RPC?

(Asked by: username_0 on 2020-12-14)

I'm using JSON-RPC call to connect to local bitcoin node on my clouding server.

I could get all transactions with wallet name by using `gettransactions`.
Now I need to get sender's address for each transaction but result contains only receivers' address.

Following is response of `gettransactions` request.

```
{
    "result": [
        {
            "address": "bc1qd9mgd4ynryaw2kp0pzfjdxguhz9dzvs5vh0nfn",
            "category": "receive",
            "amount": 0.001,
            "label": "",
            "vout": 27,
            "confirmations": 1322,
            "blockhash": "000000000000000000074551080f954e790edfe6ad810ecebf4691e881175eaf",
            "blockheight": 660029,
            "blockindex": 106,
            "blocktime": 1607147554,
            "txid": "07ab59c8d3a204172887085258460d0058c20a9acdb451daa5ad4290cbd461b0",
            "walletconflicts": [],
            "time": 1607147511,
            "timereceived": 1607147511,
            "bip125-replaceable": "no"
        },
        {
            "address": "bc1q6dh3h5e3qgku8u9s8y664844fj4fkm08n7cnwt",
            "category": "receive",
            "amount": 0.0011,
            "label": "",
            "vout": 9,
            "confirmations": 1313,
            "blockhash": "00000000000000000000960f4476a8552cac203eec6e0f826886b41fae402bec",
            "blockheight": 660038,
            "blockindex": 393,
            "blocktime": 1607153799,
            "txid": "af0885e4c1d10e935de525680c6c33d221ab506742b08e34a0322bba90b56fb0",
            "walletconflicts": [],
            "time": 1607152236,
            "timereceived": 1607152236,
            "bip125-replaceable": "no"
        },
        {
            "address": "1L8ZNCibVVpPjJ8VJ1ALLuTjtctA4mzGPw",
            "category": "send",
            "amount": -0.001,
            "vout": 0,
            "fee": -0.00008536,
            "confirmations": 706,
            "blockhash": "0000000000000000000c3230522e267980bb990883cc0b36460ad3efc1f8fed4",
            "blockheight": 660645,
            "blockindex": 1049,
            "blocktime": 1607529332,
            "txid": "a2056e7a49bc608435713519bc038ed7da2e65f588495f36c6628f5ca6fe2d7d",
            "walletconflicts": [],
            "time": 1607528963,
            "timereceived": 1607528963,
            "bip125-replaceable": "no",
            "comment": " ",
            "to": "seans outpost",
            "abandoned": false
        },
        {
            "address": "1L8ZNCibVVpPjJ8VJ1ALLuTjtctA4mzGPw",
            "category": "send",
            "amount": -0.0005,
            "vout": 1,
            "fee": -0.00008536,
            "confirmations": 705,
            "blockhash": "0000000000000000000994e21412109847caffa2bd990884f49461d53c047055",
            "blockheight": 660646,
            "blockindex": 844,
            "blocktime": 1607529675,
            "txid": "ddbe1dce4537926b6cf5bc1e222e5cd32de224cf346ca89251c127ce32226f30",
            "walletconflicts": [],
            "time": 1607529401,
            "timereceived": 1607529401,
            "bip125-replaceable": "no",
            "comment": " ",
            "to": "seans outpost",
            "abandoned": false
        }
    ],
    "error": null,
    "id": "curltest"
}

```

How can I get sender's address?

**Tags:** bitcoin-core, transactions, address, json-rpc

> **Comments:**
> **username_1**: What do you need the sender address for? Bitcoin doesn't really have such a concept. There are approximations but they're often wrong. If the goal is distinguishing multiple payments to determine who paid, the best practice is giving a different receiving address to for every payment.  
> **username_2**: @username_1 Certain regulatory reporting schemes require a list of the sending addresses. The sending addresses can definitely be discovered for a given txid and would be considered pertinent information as shown by every blockchain explorer.  
> **username_1**: What if the transaction is a payjoin/coinjoin? The "apparent" sending addresses would belong to a multitude of unrelated people. If funds are withdrawn from an exchange, the apparent sending address may belong to a different exchange customer. Just because data is visible does not mean it is meaningul.  
> **username_2**: @username_1 I agree with your statement that "visible does not mean it is meaningful", but that is irrelevant to the original question about how to achieve this in a technical manner (not what the significance of the result is). It seems you agree that the concept exists by having a conversation about its meaningfulness or usability. If the transaction is coinjoin then the sending addresses can still be enumerated in the same way. The connections between inputs and outputs in coinjoin transactions may still be inferred through certain heuristics.  

---

## 2 answers

### Answer by username_3 on 2020-12-14. Score: 2

Despite how it looks on most block explorers, Bitcoin doesn't really have a concept of a "sender address", at least not on the raw transaction level. What a transaction has is *inputs* and what block explorers do is go look up those inputs and guess the address that was used to create those UTXOs.

You might find these related questions useful (just search this site for "sender address"):

[How to findout the sender of a transaction](https://bitcoin.stackexchange.com/questions/3896/how-to-findout-the-sender-of-a-transaction)

[Sender address from DecodeRawTransaction (C#)](https://bitcoin.stackexchange.com/questions/40842/sender-address-from-decoderawtransaction-c)


---

### Answer by username_2 on 2022-03-10. Score: -1

To get the sender address from Bitcoin Core, you will have to track additional information about the blockchain by setting [`txindex=1`](https://bitcoin.stackexchange.com/questions/35707/what-are-pros-and-cons-of-txindex-option) in the configuration file. This is because the sending address of the transaction in question is only associated with the previous transaction. Setting `txindex=1` configures Bitcoin Core to maintain the entire transaction index, beyond what pertains to your wallet or read-only addresses, allowing you to call `getrawtransaction` on any txid.

Once you have properly configured and synced Bitcoin Core, you can retrieve the sending address(es) of a transaction by looking through each input tx using `decoderawtransaction(getrawtransaction(txid))` (code pulled from [this answer](https://bitcoin.stackexchange.com/questions/3896/how-to-findout-the-sender-of-a-transaction/5982#5982)):

```
txid = <relevant transaction id>
addresses = []
raw_tx = decoderawtransaction(getrawtransaction(txid))
for(input in raw_tx['vin']) {
  input_raw_tx = decoderawtransaction(getrawtransaction(input['txid']))
  addresses.push(input_raw_tx['vout'][input['vout']]['scriptPubKey']['addresses'][0])
}

```

Many blockchain explorers have free low-volume API access and you can just query their data instead of maintaining a full txindex node. Two that come to mind are [Blockchair](https://blockchair.com/api/docs#link_201) and [BlockCypher](https://www.blockcypher.com/dev/bitcoin/#transaction-hash-endpoint) (BlockCypher even includes all the sender addresses in their tx endpoint so you can retrieve these with a single API call instead of querying each input tx from Blockchair like you would need to with Bitcoin Core).


---

