Introduction to XRB Nano (Previously RaiBlocks) Part 4

Inputs, outputs and transaction ordering on XRB vs Bitcoin

 

Transaction inputs and outputs on the Bitcoin blockchain

The Bitcoin network verifies the transactions that occur on the network by using one blockchain. The blockchain is decentralized and a lot of copies of the blockchain exist, but information about the transactions still goes into one decentralized database.

For the Bitcoin network to start processing a transaction (which is the same as to say “for the network to deem a transaction to be valid”), the transaction needs to have at least one input. An input is a reference to a previous transaction on the network or, more specifically, to an output from that transaction. An output is the amount of money that is or has been sent. In simple language, this means that if you want to give someone, say, 5 bitcoins, the network digitally verifies that you had someone give you in the past an amount that was equal to or larger than 5 bitcoins or several amounts that add up to 5 bitcoins or more. To the Bitcoin network, this means that you can actually send the money because you do have it. Just like in this example, every transaction on the Bitcoin network can have multiple inputs and outputs, which means that the money you have could have come from several transactions and you may want to send the money to not one, but several wallets. On top of that, every input in a Bitcoin transaction must include a digital signature, which is generated in the connection with the private key of the wallet associated with the address that is initiating the transaction.

If a Bitcoin transaction has multiple inputs, it means that the funds that are being sent come from multiple addresses. It is important to note that while a transaction on the Bitcoin network does contain a reference to an input address, Bitcoin addresses are not wallets and they do not store any funds nor do they carry balances. Only wallets have funds in them and can carry balances. You can also use an address only to receive funds. You do not send anyone funds “from” an address because the concept of “from address” does not exist with Bitcoin.

A practical example that illustrates the importance of these differences is a user believing that their address has, say, 4 bitcoins, sending 1 bitcoin to someone and thinking that the address still has three bitcoins (because they had four and sent one).

In reality, when the Bitcoin network takes an output from a previous transaction (which in this case is 4 bitcoins) and uses it as an input, it must spend the output entirely. When the value of an output is higher than the value of an input, just like it is in this case, the network generates a new address and sends the unspent funds to this new address. The new address is also known as a change address. If the user doesn’t have a backup for the change address and something happens to unspent funds, they will be lost forever.

The way the Bitcoin network works may seem strange at first, but in reality what happens when you send funds on the network is very similar to what happens when you buy something in real life and pay with a paper bill. Let’s say that you are buying a $2 ice cream bar and you have a $10 bill. When paying, you will not simply tear one-fifth of the bill and give it to the cashier. You will give the entire bill and will get $8 in change, most likely a $5 and three $1 bills.

If this were a bitcoin transaction, in terms of inputs and outputs it would look in the following way: one input of $10 bill. Outputs, six outputs total: $1 bill to the store, $1 bill to the store (these two outputs equal to $2, the price of the ice cream), $5 bill to you, $1 bill to you, $1 bill to you, $1 bill to you. Obviously, if you are lucky enough to wander into a store that can give change with $2 bills, then the number of outputs will be different. If a store is out of paper bills and only has coins, the number of outputs will be different, too.

What happens with Bitcoin, using the example above, is that the network actually destroys the $10 bill, creates new bills that equal to $10, and makes a record of what happened. Because the Bitcoin network can do it with any amounts, it is actually very practical and convenient. Imagine if you had $10, needed to pay $1 and could instantly turn $10 into two bills, $1 and $9, anytime you wanted. This is exactly what the Bitcoin network does with change addresses, inputs and outputs during the transactions that occur on the network.

 

Transactions on the XRB Nano/RaiBlocks network

As stated before, on the XRB Nano/RaiBlocks network, each user has its own blockchain. The blockchain for a user also arranges transactions independently.

For example, consider these two sequences of transactions: In sequence 1, user A receives 5 coins and sends 5 coins. In sequence 2, user A receives 5 coins and user B sends 5 coins.

What is important to notice here is that, first, there is no need for the entire network to know about all the transactions that happen between users in the way the notifications and confirmations occur on the Bitcoin blockchain.

Second, the order of transactions does matter in sequence 1 (user A receives 5 coins and sends 5 coins) because there is a possibility of the account of user A having a negative balance. If user A has a zero balance, he can’t send 5 coins before receiving 5 coins. However, in the transaction sequence 2, the order doesn’t even matter because the inputs and outputs deal with balances in different accounts.

The XRB Nano/Raiblocks network is able to protect itself from the issue of double-spending and other attacks by using proof-of-stake algorithm instead of proof-of-work. In addition to proof-of-stake, it also uses proof-of-work, but does so differently from Bitcoin.