<blockquote>
  <p>but it didn't tell me from which address the transaction was sent from</p>
</blockquote>

<p>Indeed, there is no 'from address' in a bitcoin transaction. (<a href="https://en.bitcoin.it/wiki/From_address#Why_there.E2.80.99s_no_.E2.80.98from.E2.80.99_address" rel="nofollow noreferrer">More info</a>)</p>

<blockquote>
  <p>Am I correct, that when sending a bitcoin transaction, all of the amount from a specific address gets placed in the input, a part of it(the part which I specify) gets sent to the address I wish to send, and the rest gets transfered to a newly created address on the same wallet, from which the send operation was initiated?</p>
</blockquote>

<p>Correct, inputs are spent all at once, there's no way to partially spend it, so you have to send some change back to yourself. The <code>sendtoaddress</code> manages that all for you.</p>

<blockquote>
  <p>How is Blockchain.Info able to retrieve information from any kind of Bitcoin Transaction, while I, using a full Bitcoin Node, can only find transactions which was either initiated by the node, or which has a receiving address which is in the nodes wallet?</p>
</blockquote>

<p>That's a lot of data that bitcoin core doesn't usually need or use, so it's not usually indexed or accessible by bitcoin core. It's possible to use the <code>-txindex</code> configuration option to index all transactions including those not related to your wallet. But blockchain.info and similar block explorers probably run their own databases of information rather than querying it from a bitcoin node every time, allowing them to do more complicated searches in the data.</p>

CC BY-SA 3.0
2017-09-18T11:38:54.520Z
2017-09-18T11:45:19.520Z
2017-09-18T11:45:19.520Z
meshcollider
<blockquote>
  <p>How is Blockchain.Info able to retrieve information from any kind of
  Bitcoin Transaction...</p>
</blockquote>

<p>It is not only blockchain.info who can decompose your transaction. The format of a transaction is layed out on bitcoin.org. So if you take your own transaction, you as well can decompose it into it's pieces. 
You can have a look at the details of your (or any other) tx with</p>

<p><a href="https://blockchain.info/rawtx/" rel="nofollow noreferrer">https://blockchain.info/rawtx/</a></p>

<p>I just did the same with "my" local tools, and got this from the script sig:</p>

<pre><code> TX_IN[0] Script Sig (uchar[])
  4730440220415AE7C712D07CD1F0A98170021FBE3A073DECB569A66F63B28FD2725471EE57022061FE1093885C39D23E1EFE19700D1B8E49619DF526AD0D63CDBF985E2178C34C0121025AB144C5BDD83410487BF2694CA398E3D860D2465E0305DCEC429BA6F1CF8C59 
  ##################################################################
  ### tcls_in_sig_script.sh: decode SIG_script OPCODES from a TX ###
  ##################################################################
    47: OP_DATA_0x47:     push hex 47 (decimal 71) bytes as data
    30: OP_SEQUENCE_0x30: type tag indicating SEQUENCE, begin sigscript
    44: OP_LENGTH_0x44:   length of R + S
    02: OP_INT_0x02:      type tag indicating INTEGER
    20: OP_LENGTH_0x20:   this is SIG R
        415AE7C712D07CD1:F0A98170021FBE3A
        073DECB569A66F63:B28FD2725471EE57
    02: OP_S_INT_0x02
    20: OP_LENGTH_0x20:   this is SIG S
        61FE1093885C39D2:3E1EFE19700D1B8E
        49619DF526AD0D63:CDBF985E2178C34C
    01: OP_SIGHASHALL:    this terminates the ECDSA signature (ASN1-DER structure)
    #########################################################
    ### procedure to strictly check DER-encoded signature ###
    #########################################################
    Minimum and maximum size constraints                        - ok
    scriptsig always starts with 0x30                           - ok
    length 136 chars is less than actual sig length (142 chars) - ok
           (hex 0x44, decimal 68, 136 chars)
    length of R coordinate (64) &gt;= 0                            - ok
    length of S coordinate (64) &gt;= 0                            - ok
    S-Value is within scriptsig boundaries                      - ok
    Make sure the R &amp; S length covers the entire signature      - ok
    S-value must be smaller than N/2                            - ok
    strictly check DER-encoded signature                        - ok
    #########################################################
    21: OP_DATA_0x21:     type tag indicating LENGTH
    02: OP_INT_0x02:      type tag indicating INTEGER
        5AB144C5BDD83410:487BF2694CA398E3
        D860D2465E0305DC:EC429BA6F1CF8C59

    * This terminates the Public Key (X9.63 COMPRESSED form)
    * corresponding bitcoin address is:
   12bFMAPz7dhKmLxsoipfUqmCCjqENCDzKb
</code></pre>

<p>as you can see, it contains your address in the last line. The script sig is part of a transaction, and the tx is stored in the block chain. So as long as one can read the blockchain, one can finally decompose the tx. 
The bitcoin wallet just doesn't show the details you were asking. I think the command "decoderawtransaction" would help to display the structure. </p>

<p>Oh, there is no need to ask twice or more in different forums (<a href="https://bitcointalk.org/index.php?topic=2187720.0" rel="nofollow noreferrer">https://bitcointalk.org/index.php?topic=2187720.0</a>). This is meaningless bloat...</p>

CC BY-SA 3.0
2017-09-18T12:03:21.837Z
2017-09-18T12:11:03.070Z
2017-09-18T12:11:03.070Z
pebwindkraft
<p>I was playing around with my Bitcoin Node, to try and understand how does Bitcoin Transactions work.</p>

<p>For this purpose, I used the <code>sendtoaddress</code> API call for bitcoin-cli, to send some XBT to my own Bitcoin Blockchain.Info wallet. The transaction was processed, and I was trying to understand the information that I get from <code>gettransaction</code> bitcoin-cli command, and the information that the Blockchain.info website shows about the transaction.</p>

<p>So, here is what I did:</p>

<ol>
<li><p>I've generated a receiving address for myself in Blockchain.Info (<code>17tzZwAi722L7V8V27bUGEKwJpRYVNRKVW</code>)</p></li>
<li><p>In my Bitcoin node, I used the following command: <code>bitcoin-cli sendtoaddress 17tzZwAi722L7V8V27bUGEKwJpRYVNRKVW 0.001</code> </p></li>
</ol>

<p>This gave me back a transaction id: <code>4f299e7313af7e4e091ea519bbf5983526d18fe4765b679ce1827bd9f75dbaff</code></p>

<ol start="3">
<li>I then checked the information that the bitcoin node gives about that transaction with: <code>bitcoin-cli gettransaction 4f299e7313af7e4e091ea519bbf5983526d18fe4765b679ce1827bd9f75dbaff</code></li>
</ol>

<p>What I noticed here is that the bitcoin-cli command gave me back the address I sent the money to, the fee it took to get the address, but it didn't tell me from which address the transaction was sent from.</p>

<p>Then I checked the information that Blockchain.info provides about the transaction: <a href="https://blockchain.info/tx/4f299e7313af7e4e091ea519bbf5983526d18fe4765b679ce1827bd9f75dbaff" rel="nofollow noreferrer">https://blockchain.info/tx/4f299e7313af7e4e091ea519bbf5983526d18fe4765b679ce1827bd9f75dbaff</a></p>

<p>Here, it can be clearly seen that an amount of <code>0.06611392 BTC</code> was sent from <code>12bFMAPz7dhKmLxsoipfUqmCCjqENCDzKb</code> XBT address, to two different outputs. One of the output is the address, Blockchain.Info gave me to receive the Bitcoin. The other output is an address unknown to me.</p>

<p>So I started thinking:
Am I correct, that when sending a bitcoin transaction, all of the amount from a specific address gets placed in the input, a part of it(the part which I specify) gets sent to the address I wish to send, and the rest gets transfered to a newly created address on the same wallet, from which the send operation was initiated? </p>

<p>Some other questions which arise to me:
How is Blockchain.Info able to retrieve information from any kind of Bitcoin Transaction, while I, using a full Bitcoin Node, can only find transactions which was either initiated by the node, or which has a receiving address which is in the nodes wallet?</p>

<bitcoin-core><blockchain.info>
Questions about Bitcoin Transactions
Adam Baranyai
# Questions about Bitcoin Transactions

(Asked by: username_0 on 2017-09-18)

I was playing around with my Bitcoin Node, to try and understand how does Bitcoin Transactions work.

For this purpose, I used the `sendtoaddress` API call for bitcoin-cli, to send some XBT to my own Bitcoin Blockchain.Info wallet. The transaction was processed, and I was trying to understand the information that I get from `gettransaction` bitcoin-cli command, and the information that the Blockchain.info website shows about the transaction.

So, here is what I did:

1. I've generated a receiving address for myself in Blockchain.Info (`17tzZwAi722L7V8V27bUGEKwJpRYVNRKVW`)
2. In my Bitcoin node, I used the following command: `bitcoin-cli sendtoaddress 17tzZwAi722L7V8V27bUGEKwJpRYVNRKVW 0.001`

This gave me back a transaction id: `4f299e7313af7e4e091ea519bbf5983526d18fe4765b679ce1827bd9f75dbaff`

3. I then checked the information that the bitcoin node gives about that transaction with: `bitcoin-cli gettransaction 4f299e7313af7e4e091ea519bbf5983526d18fe4765b679ce1827bd9f75dbaff`

What I noticed here is that the bitcoin-cli command gave me back the address I sent the money to, the fee it took to get the address, but it didn't tell me from which address the transaction was sent from.

Then I checked the information that Blockchain.info provides about the transaction: <https://blockchain.info/tx/4f299e7313af7e4e091ea519bbf5983526d18fe4765b679ce1827bd9f75dbaff>

Here, it can be clearly seen that an amount of `0.06611392 BTC` was sent from `12bFMAPz7dhKmLxsoipfUqmCCjqENCDzKb` XBT address, to two different outputs. One of the output is the address, Blockchain.Info gave me to receive the Bitcoin. The other output is an address unknown to me.

So I started thinking:
Am I correct, that when sending a bitcoin transaction, all of the amount from a specific address gets placed in the input, a part of it(the part which I specify) gets sent to the address I wish to send, and the rest gets transfered to a newly created address on the same wallet, from which the send operation was initiated?

Some other questions which arise to me:
How is Blockchain.Info able to retrieve information from any kind of Bitcoin Transaction, while I, using a full Bitcoin Node, can only find transactions which was either initiated by the node, or which has a receiving address which is in the nodes wallet?

**Tags:** bitcoin-core, blockchain.info


---

## 2 answers

### Answer by username_1 on 2017-09-18. Score: 1 | Accepted answer

> but it didn't tell me from which address the transaction was sent from

Indeed, there is no 'from address' in a bitcoin transaction. ([More info](https://en.bitcoin.it/wiki/From_address#Why_there.E2.80.99s_no_.E2.80.98from.E2.80.99_address))

> Am I correct, that when sending a bitcoin transaction, all of the amount from a specific address gets placed in the input, a part of it(the part which I specify) gets sent to the address I wish to send, and the rest gets transfered to a newly created address on the same wallet, from which the send operation was initiated?

Correct, inputs are spent all at once, there's no way to partially spend it, so you have to send some change back to yourself. The `sendtoaddress` manages that all for you.

> How is Blockchain.Info able to retrieve information from any kind of Bitcoin Transaction, while I, using a full Bitcoin Node, can only find transactions which was either initiated by the node, or which has a receiving address which is in the nodes wallet?

That's a lot of data that bitcoin core doesn't usually need or use, so it's not usually indexed or accessible by bitcoin core. It's possible to use the `-txindex` configuration option to index all transactions including those not related to your wallet. But blockchain.info and similar block explorers probably run their own databases of information rather than querying it from a bitcoin node every time, allowing them to do more complicated searches in the data.


---

### Answer by username_2 on 2017-09-18. Score: 0

> How is Blockchain.Info able to retrieve information from any kind of
> Bitcoin Transaction...

It is not only blockchain.info who can decompose your transaction. The format of a transaction is layed out on bitcoin.org. So if you take your own transaction, you as well can decompose it into it's pieces.
You can have a look at the details of your (or any other) tx with

<https://blockchain.info/rawtx/>

I just did the same with "my" local tools, and got this from the script sig:

```
 TX_IN[0] Script Sig (uchar[])
  4730440220415AE7C712D07CD1F0A98170021FBE3A073DECB569A66F63B28FD2725471EE57022061FE1093885C39D23E1EFE19700D1B8E49619DF526AD0D63CDBF985E2178C34C0121025AB144C5BDD83410487BF2694CA398E3D860D2465E0305DCEC429BA6F1CF8C59 
  ##################################################################
  ### tcls_in_sig_script.sh: decode SIG_script OPCODES from a TX ###
  ##################################################################
    47: OP_DATA_0x47:     push hex 47 (decimal 71) bytes as data
    30: OP_SEQUENCE_0x30: type tag indicating SEQUENCE, begin sigscript
    44: OP_LENGTH_0x44:   length of R + S
    02: OP_INT_0x02:      type tag indicating INTEGER
    20: OP_LENGTH_0x20:   this is SIG R
        415AE7C712D07CD1:F0A98170021FBE3A
        073DECB569A66F63:B28FD2725471EE57
    02: OP_S_INT_0x02
    20: OP_LENGTH_0x20:   this is SIG S
        61FE1093885C39D2:3E1EFE19700D1B8E
        49619DF526AD0D63:CDBF985E2178C34C
    01: OP_SIGHASHALL:    this terminates the ECDSA signature (ASN1-DER structure)
    #########################################################
    ### procedure to strictly check DER-encoded signature ###
    #########################################################
    Minimum and maximum size constraints                        - ok
    scriptsig always starts with 0x30                           - ok
    length 136 chars is less than actual sig length (142 chars) - ok
           (hex 0x44, decimal 68, 136 chars)
    length of R coordinate (64) >= 0                            - ok
    length of S coordinate (64) >= 0                            - ok
    S-Value is within scriptsig boundaries                      - ok
    Make sure the R & S length covers the entire signature      - ok
    S-value must be smaller than N/2                            - ok
    strictly check DER-encoded signature                        - ok
    #########################################################
    21: OP_DATA_0x21:     type tag indicating LENGTH
    02: OP_INT_0x02:      type tag indicating INTEGER
        5AB144C5BDD83410:487BF2694CA398E3
        D860D2465E0305DC:EC429BA6F1CF8C59

    * This terminates the Public Key (X9.63 COMPRESSED form)
    * corresponding bitcoin address is:
   12bFMAPz7dhKmLxsoipfUqmCCjqENCDzKb

```

as you can see, it contains your address in the last line. The script sig is part of a transaction, and the tx is stored in the block chain. So as long as one can read the blockchain, one can finally decompose the tx.
The bitcoin wallet just doesn't show the details you were asking. I think the command "decoderawtransaction" would help to display the structure.

Oh, there is no need to ask twice or more in different forums (<https://bitcointalk.org/index.php?topic=2187720.0>). This is meaningless bloat...


---

