14

Every digital currency has to solve the problem of double-spending somehow. What is Stellar's approach to keeping me from spending my money twice at the same time?

2 Answers 2

7

The digital currency is an Asset on Stellar's public ledger only. You can not download it, clone it and spent it again. It exists as a balance on an account that can be transferred to another account on the net with a transaction. The network makes sure that this happens only once and no assets are lost or duplicated.

In a distributed system this is a fairly complex task as you can have any kind of hardware/ network issues as well as malicious actors (see CAP-Theorem). The Stellar Consensus Protocol (SCP) is the solution for this in the Stellar network. If you want to learn more about it, you can watch Professor Mazières’s talk or just start with the graphic novel.

7

Double spending in Stellar is dealt with at two layers:

  • SCP guarantees that the "blockchain" (ledger chain really) is made of only one chain, and doesn't have forks (in other systems temporary forks can be created which give different opinions of what the "latest block" is). SCP gives similar guarantees at the consensus layer than PBFT in that validators work in lockstep.
  • at the transaction layer, as Stellar is account based, there is also a mechanism to enforce that any given transaction can only be applied once. This is done by using sequence numbers, the gist of it is that to apply a transaction to an account the equivalent of a "test and set" is performed, comparing the counter in the account and the counter in the transaction - if they are compatible (account number + 1 == tx sequence number) the account is updated with the new counter.
4
  • Which of these mechanisms will prevent the classic double-spending (i.e. I connect to different Stellar nodes with two instances of my wallet and spend all my money at exactly the same time?)
    – Helmar
    Commented Jan 19, 2018 at 17:00
  • having different nodes agree with each other is what consensus solves, SCP in this case Commented Jan 19, 2018 at 17:04
  • Well that's exactly the question. How is consensus reached in that case?
    – Helmar
    Commented Jan 19, 2018 at 19:16
  • 1
    I am not sure what you're asking. you can read the SCP paper if you want the details of the protocol for consensus. nodes are "in sync", meaning they won't allow for changes to be done independently on different nodes Commented Jan 19, 2018 at 19:35

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.