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.


  • What do you mean by self loops? Commented Oct 7, 2019 at 15:58
  • 2
    You must be confused. Loops are not possible. Commented Oct 7, 2019 at 16:06
  • Do you mean transactions sending funds that were previously received to an address back to the same address?
    – Murch
    Commented Oct 7, 2019 at 16:24
  • 3
    Possible duplicate of How does change work in a bitcoin transaction? Commented Oct 7, 2019 at 16:40
  • 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. Commented Oct 7, 2019 at 16:40

1 Answer 1


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.

  • 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
    Commented Oct 8, 2019 at 13:25
  • 1
    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
    Commented Oct 8, 2019 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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