<p>You are looking at transactions the wrong way. Bitcoin does not actually use addresses and their balances. The protocol has no concept of what an address is, nor does it need to. It also has no idea of an address or an account balance.</p>

<p>Rather how Bitcoin works is with transaction outputs. Transaction outputs are spent as the inputs to other transactions, and created as the outputs of transactions. Addresses are merely a human abstraction to quickly specify the locking conditions (the conditions that need to be met in order to spend) of a transaction output. They are not an identifier, just shorthand for an output script.</p>

<p>Since addresses are just shorthand for an output script rather than identifiers, nodes do not care about the contents of the scripts except when verifying that an input has met the conditions to spend the output it specifies. Other than that, a transaction output can contain whatever the user wants in the script, including invalid scripts. Outputs with such scripts just cannot be spent.</p>

<p>So these self loops exist because people can create a transaction which spends an output with a particular script, and then they create a new output which has the same script. Because nodes don't check the scripts, this is perfectly fine and valid.</p>

CC BY-SA 4.0
2019-10-08T13:25:22.307Z
So, correct if I am wrong, but the protocol can be used to send anything in a anonymized (or pseudo-anonymized) way. That may include pictures, videos, etc.?

However, I don't understand the last paragraph. Could you elaborate more? If not, can you recommend sources to study the bitcoin protocol/blockchain?
Andreas
CC BY-SA 4.0
2019-10-08T19:58:08.277Z
Arbitrary data can be sent only by abusing the fact that output scripts aren't checked for any form of validity in the transaction that creates the output. There isn't anything that explicitly allows or disallows arbitrary data, just that people have realized they can abuse the laxness in order to embed aribitrary data in the blockchain. The point of the last paragraph is just that because you can have anything as a script, having the same script as the output that is being spent is allowed and that causes your "self-loops".
Ava Chow
CC BY-SA 4.0
2019-10-08T03:03:31.627Z
2019-10-08T03:03:31.627Z
Ava Chow
<p>I have obtained bitcoin data from block explorer and created the transaction graph. The graph consists of millions of nodes and edges.</p>

<p>i wrote a query that creates a relationship from source address to destination address and visualized a portion of the network; approx. 4500 nodes along with 50000 edges. What this means is that I omit the nodes depicting the blocks txs belong to, nodes depicting txs etc.</p>

<p>The nodes in the graph illustrate addresses connected by a relationship " sent_money_to "</p>

<p>There are many self-loops. In several instances a node u has n out-links to node w, while the same node u has n self-loops.</p>

<p>By no means I am an expert on the graph properties or protocol of the bitcoin network.</p>

<p>Any possible explanations? Trivial or non-trivial.</p>

<p>Thanks.</p>

CC BY-SA 4.0
2019-10-07T15:58:37.187Z
What do you mean by self loops?
Raghav Sood
CC BY-SA 4.0
2019-10-07T16:06:03.620Z
You must be confused. Loops are not possible.
Pieter Wuille
CC BY-SA 4.0
2019-10-07T16:24:32.007Z
Do you mean transactions sending funds that were previously received to an address back to the same address?
Murch
CC BY-SA 4.0
2019-10-07T16:38:48.393Z
I edited the post, I hope it s more insightful now. Possible answer: A transaction with change, source: https://hal.inria.fr/hal-01449078/document . Search for key word: " self ", result number 2.
Andreas
CC BY-SA 4.0
2019-10-07T16:40:06.267Z
Possible duplicate of [How does change work in a bitcoin transaction?](https://bitcoin.stackexchange.com/questions/736/how-does-change-work-in-a-bitcoin-transaction)
Raghav Sood
CC BY-SA 4.0
2019-10-07T16:40:39.153Z
Those transactions are simply sending change back to the same address as one (or more) of the inputs, it is normal behaviour for certain types of wallet systems.
Raghav Sood
<address-reuse>
Why do self-loops exist in the bitcoin transaction graph?
Andreas
# Why do self-loops exist in the bitcoin transaction graph?

(Asked by: username_0 on 2019-10-07)

I have obtained bitcoin data from block explorer and created the transaction graph. The graph consists of millions of nodes and edges.

i wrote a query that creates a relationship from source address to destination address and visualized a portion of the network; approx. 4500 nodes along with 50000 edges. What this means is that I omit the nodes depicting the blocks txs belong to, nodes depicting txs etc.

The nodes in the graph illustrate addresses connected by a relationship " sent\_money\_to "

There are many self-loops. In several instances a node u has n out-links to node w, while the same node u has n self-loops.

By no means I am an expert on the graph properties or protocol of the bitcoin network.

Any possible explanations? Trivial or non-trivial.

Thanks.

**Tags:** address-reuse

> **Comments:**
> **username_1**: What do you mean by self loops?  
> **username_2**: You must be confused. Loops are not possible.  
> **username_3**: Do you mean transactions sending funds that were previously received to an address back to the same address?  
> **username_0**: I edited the post, I hope it s more insightful now. Possible answer: A transaction with change, source: https://hal.inria.fr/hal-01449078/document . Search for key word: " self ", result number 2.  
> **username_1**: Possible duplicate of [How does change work in a bitcoin transaction?](https://bitcoin.stackexchange.com/questions/736/how-does-change-work-in-a-bitcoin-transaction)  
> **username_1**: Those transactions are simply sending change back to the same address as one (or more) of the inputs, it is normal behaviour for certain types of wallet systems.  

---

## 1 answers

### Answer by username_4 on 2019-10-08. Score: 4 | Accepted answer

You are looking at transactions the wrong way. Bitcoin does not actually use addresses and their balances. The protocol has no concept of what an address is, nor does it need to. It also has no idea of an address or an account balance.

Rather how Bitcoin works is with transaction outputs. Transaction outputs are spent as the inputs to other transactions, and created as the outputs of transactions. Addresses are merely a human abstraction to quickly specify the locking conditions (the conditions that need to be met in order to spend) of a transaction output. They are not an identifier, just shorthand for an output script.

Since addresses are just shorthand for an output script rather than identifiers, nodes do not care about the contents of the scripts except when verifying that an input has met the conditions to spend the output it specifies. Other than that, a transaction output can contain whatever the user wants in the script, including invalid scripts. Outputs with such scripts just cannot be spent.

So these self loops exist because people can create a transaction which spends an output with a particular script, and then they create a new output which has the same script. Because nodes don't check the scripts, this is perfectly fine and valid.

> **Comments:**
> **username_0**: So, correct if I am wrong, but the protocol can be used to send anything in a anonymized (or pseudo-anonymized) way. That may include pictures, videos, etc.?  However, I don't understand the last paragraph. Could you elaborate more? If not, can you recommend sources to study the bitcoin protocol/blockchain?  
> **username_4**: Arbitrary data can be sent only by abusing the fact that output scripts aren't checked for any form of validity in the transaction that creates the output. There isn't anything that explicitly allows or disallows arbitrary data, just that people have realized they can abuse the laxness in order to embed aribitrary data in the blockchain. The point of the last paragraph is just that because you can have anything as a script, having the same script as the output that is being spent is allowed and that causes your "self-loops".  

---

