Bitcoin Explained #3 - The Nuts and Bolts of Transactions

Greetings guys! Last time, we went through the basics of transactions in Bitcoin – we spoke of the blockchain, of the many different types of transactions, of inputs and outputs… feel free to take a look if you missed it!

Now, let’s dive in deeper – let’s see what happens in the machine when you make a transaction! If you’re a programmer, you’ll feel right at home here! And if you’re not, don’t worry, I’ll try to make this as simple as I can!

I’m gonna be showing you what happens in a series of steps.

Let’s get started, shall we?

Step 1 – All the information gets registered

First thing’s first – your wallet needs you to give it all the info about the transaction you are about to do before it can do so. Luckily, it doesn’t need much info – a destination (in the form of a wallet address, more on that later) and the amount you want to send is all the info it needs.

Your wallet can create these offline, but, of course, it can’t perform these transactions offline as well – it needs an online connection before the transaction can be issued to the blockchain and validated by miners.

Back on track though – you supply the right info, you go online, then what?

Step 2 – Finding the right inputs

For those that didn’t read my latest article, an input is the part of a transaction where the bitcoin gets sent. If the wallet was a credit card, an input would be a debit on it.

In addition to that, most transactions aren’t exact – instead of you just receiving the right amount in a transaction, you receive too much and give the rest back as change. As such, your bitcoin wallet, if it was a real life wallet, would be full of change.

This next step then, is simple – the wallet has to pick up the right change, put it all together, and prepare to send it. This can be done in many ways, and depends on how the wallet works.

I will cover wallets in a later chapter, but for now, know this – there are different types of wallets, that do things differently.

A full-index client type wallet would simply go through the entire blockchain history and find out Bitcoin transfers into your account, in order to find the right inputs.

A lightweight client would only go through your own records to determine how much unspent money you have, and it would run faster.

Alternatively, it can use APIs to ask the blockchain network for help in determining the right inputs, or ask a full-index node using a JSON RPC API.

Once the wallet knows for sure how much money you have, it clumps the necessary sum together to make the transfer. Then, the next part begins.

Step 3 – Making the output

The output takes this form – it’s a program, that basically says “the person who has the key of [person you sent the money to] can receive this money”. The person who is to receive the money certainly has the private key to his wallet, and can then collect his money.

(If you didn’t understand, I briefly explained the concept of private keys in another article, feel free to check it out. It’s basically the “signature” of your wallet, and every transaction you make has that signature. It’s how the network knows you, so to speak.)

Don’t forget that for every transaction made in the blockchain, there is a fee – the miner who mined the block that validates the transaction gets a small piece of it.

Any change resulting from the transaction is then sent back to you, in the same process.

Only one step remains before this transaction is truly done – it needs to be transmitted to the blockchain.

Step 4 – The transaction is validated

The blockchain has it’s own peer-to-peer network. Unlike most networks with centralized servers, every client participates in this process. Its’ purpose is to spread newly-made transactions and blocks so that they get acknowledged by everyone on the network.

A normal transaction can get transmitted in many ways. WiFi, Ethernet…. You name it. Once a transaction gets sent onto a node, it spreads, and spreads, and spreads, until eventually, it reaches the entire network. But for it to truly be a part of the blockchain, it needs to be part of a block…. And we’ll see how that happens next time!

That wraps this up!

If you feel like this ending is abrupt, it is – a work complication just came up and needs my immediate attention. I’m gonna have to split this article into 2, and I’ll speak of the mining process in the next chapter.

Again, I give full credit for the information in this article to the book “Mastering Bitcoin”, by Andreas Antonopoulos. Check it out, it’s a great book!

Feel free to sound off in the comments below if you have some question or criticism!

Till the next one guys! Steem on!

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now