How does Bitcoin divisibility work?

5

I come from a programming background and I am trying to figure out how Bitcoin allows for divisibility. An example using high level code would also be nice.

I understand the high level basics of transactions (Bitcoin Transaction Diagram), but I am interested in divisibility specifically.

Zamicol

Posted 2013-09-06T17:27:18.723

Reputation: 285

Answers

8

A bitcoin is divisible to the eighth decimal. The smallest portion of Bitcoin has its own name: satoshi, whereas 1 BTC = 10^8 satoshis = 100,000,000 satoshis

To be completely correct, while in popular conversation the bitcoin is the predominant currency unit, in realitas the protocol uses satoshi. You can see this when looking at raw transactions or the ledger.

Whenever you send a Bitcoin transaction, the inputs are destroyed and new outputs are created. Essentially, what happens with Bitcoin works like this: Imagine you are paying for a $5 ice cream with a $10 bill, and the $10 bill is destroyed and replaced by two $5 bills, of which you get one $5 bill and one $5 bill goes to the ice cream vendor.

I was not able to deduce what you are trying to get code for, but if you want to split up bitcoins for transactions you might be looking for more information on how to create raw transactions, as dannypaz pointed out in the comments, the Bitcoin Wiki's page on transactions may also be illustrative.

Murch

Posted 2013-09-06T17:27:18.723

Reputation: 41 609

Your answer is great @Murch. I wanted to add to this, that you can see another example here: https://en.bitcoin.it/wiki/Transaction which also helped me understand the concept

dannypaz 2018-03-25T05:51:22.023

@dannypaz: Thanks, I've added your link as an additional example.Murch 2018-03-26T16:44:26.183

2

All transactions are actually stored and transmitted in satoshis (one hundred millionths of a bitcoin or bitcoin × 108). So really, it is not divisibility, as much as it is converted by multiplying in the UI. It's always satoshis, but shown as various bigger units.

If you divide the the number of satoshis by 100m you get the value in bitcoin. If instead of dividing by 100m, you divide by 100k, you get mBTC (millibitcoin), if you divide by 100 you get μBTC (microbitcoin).

aantonop

Posted 2013-09-06T17:27:18.723

Reputation: 89

I don't think this is accurate. Bitcoins are divisible to satoshis, but transactions are sent in the desired amount. My understanding is that when a miner signs a block, that becomes the bitcoins, where this one unit was originally equal to 50 bitcoins. There being 50 bitcoins to a block was just an abstraction for the value of a block.Zamicol 2013-09-11T19:33:44.037

2@Zach: aantonop is actually right, in the underlying protocol bitcoin values are always written as satoshis. I will also correct that in my answer.Murch 2013-09-12T12:29:15.373

@Zach: no, you're confusing the monetary unit and blocks. Blocks are lists of transaction and form an authorative history for the network. Blocks are allowed to contain one transaction that conjures new currency out of nothing, under strictly controlled conditions, called the miner subsidy. So blocks do introduce new coins, they are not coins, and the amounts are always internally represented as multiples of a satoshi, even for subsidies.Pieter Wuille 2013-09-13T23:43:47.883

Thanks Pieter and Murch!

If I broke a ten dollar bill into two units, a $2.85 unit and a $7.15 cent unit, amounts are measured in pennies, but these units don't necessarily need to be transmitted or stored in pennies. The only case this would happen is if I actually broke them out into pennies. – Zamicol 2013-09-14T23:25:41.287

Unfortunately, there is no such thing as a $2.85 dollar bill. But in Bitcoin there is. Although we measure in satoshis, the actual units used are variable.Zamicol 2013-09-14T23:33:39.870

Now I get what you were talking about. Yes, units are of variable size in the network and their value is measured in satoshis.Murch 2013-09-15T14:29:39.577