Bitcoin Forum
November 05, 2024, 02:50:35 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Stupid question re: "script," "unspent outputs," and the divisibility of bitcoin  (Read 1159 times)
mcgullen (OP)
Newbie
*
Offline Offline

Activity: 57
Merit: 0


View Profile
June 02, 2014, 09:36:59 PM
 #1

Hi All,

I have a stupid question: I don't understand how one bitcoin can be divided into satoshis.

Based on my basic understanding of how bitcoin works, it seems like each bitcoin is associated with an address (a hash of someone's public key?) in the public ledgor (the block chain?).  If this association happens at the coin level, how can a bitcoin be divided into satoshis that can be associated with different addresses?

The whitepaper suggests it has to do with  "script," "inputs" and "outputs."  But my brain explodes when I read this on the Bitcoin wiki:

Quote
Bitcoin uses a scripting system for transactions. Forth-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.

WTF?!

Can someone please point me to resources on bitcoin divisibility that are more easily understandable?  Thanks!

kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1026



View Profile
June 02, 2014, 11:45:04 PM
 #2

"coin" has many meanings.

A transaction creates "coins" as outputs, and the values of these outputs are granular (currently) in lumps of 0.000 000 01 "(bit)coins".

So, skip over the chicken/egg problem for a moment.  Say you have keys to 3 unspent outputs, 1 BTC, 2 BTC and 3 BTC.  You want to pay someone 4.5 BTC.  Your wallet creates a new transaction that spends the 2 BTC and 3 BTC "coins" and creates two new ones: 4.5 (sent to the recipient) and 0.5 (sent back to you).

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
jonald_fyookball
Legendary
*
Offline Offline

Activity: 1302
Merit: 1008


Core dev leaves me neg feedback #abuse #political


View Profile
June 03, 2014, 01:26:44 AM
 #3

Hi All,

I have a stupid question: I don't understand how one bitcoin can be divided into satoshis.

Based on my basic understanding of how bitcoin works, it seems like each bitcoin is associated with an address (a hash of someone's public key?) in the public ledgor (the block chain?).  If this association happens at the coin level, how can a bitcoin be divided into satoshis that can be associated with different addresses?

The whitepaper suggests it has to do with  "script," "inputs" and "outputs."  But my brain explodes when I read this on the Bitcoin wiki:

Quote
Bitcoin uses a scripting system for transactions. Forth-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.

WTF?!

Can someone please point me to resources on bitcoin divisibility that are more easily understandable?  Thanks!



Each bitcoin isn't associated with an address per se....don't think of it that way...
(and Forget about the scripting system for now)

Just think of it as inputs and outputs.   Your inputs and outputs are in decimal form up to
8 decimals in precision, so they never really need to get divided into satoshis.  They sort of already are.
You can initiate a transaction of say 4.3164 BTC and that's the output. Pretty much end of story unless
That wasn't the full unspent output (balance) in the address and you want to send that back to yourself.

Here is an interesting thread when it comes to breaking down the code:

https://bitcointalk.org/index.php?topic=41718.0



DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4801



View Profile
June 03, 2014, 01:35:29 AM
 #4

Just think of it as inputs and outputs.   Your inputs and outputs are in decimal form up to
8 decimals in precision, so they never really need to get divided into satoshis.  They sort of already are.
You can initiate a transaction of say 4.3164 BTC and that's the output. Pretty much end of story unless
That wasn't the full unspent output (balance) in the address and you want to send that back to yourself.

Close, but there are a few important things to keep in mind if we are going to start talking at this detail level about the protocol.

First, as represented in transactions in the blockchain, outputs are not in decimal form.  The concept of 1 BTC is just a way to make it easier for humans to deal with the otherwise really big numbers that would have been involved when bitcoin started out.  The outputs are actually represented as an integer number of satoshis.  So if you want an output to assign 0.0324 BTC to the control of the private key associated with a particular address, then the value that is actually assigned in that output is 2340000.

Second, inputs are just references to a previously received output.  The transaction does not specify values in the inputs (in decimal form or otherwise).  The inputs are simply a SHA-256 hash that can be looked up in the blockchain (or the UTXO set) to identify the transaction with the particular previously unspent output that's being spent, and an index indicating which output from that transaction is being spent (0=first output, 1=second output, 2=third output, etc).
mcgullen (OP)
Newbie
*
Offline Offline

Activity: 57
Merit: 0


View Profile
June 03, 2014, 12:37:48 PM
 #5

Thanks so much!  I think I get it now.
konradp
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
July 23, 2014, 09:51:10 AM
Last edit: July 23, 2014, 10:07:08 AM by konradp
 #6

Quote
First, as represented in transactions in the blockchain, outputs are not in decimal form.  The concept of 1 BTC is just a way to make it easier for humans to deal with the otherwise really big numbers that would have been involved when bitcoin started out.  The outputs are actually represented as an integer number of satoshis.  So if you want an output to assign 0.0324 BTC to the control of the private key associated with a particular address, then the value that is actually assigned in that output is 2340000

@DannyHamilton:
Do you by any chance know why was it implemented this way? What if some day in the year 2400 the value of one satoshi will be greater than a value of a house?
azeteki
Member
**
Offline Offline

Activity: 96
Merit: 10

esotericnonsense


View Profile WWW
July 23, 2014, 12:03:26 PM
 #7

Do you by any chance know why was it implemented this way? What if some day in the year 2400 the value of one satoshi will be greater than a value of a house?

The protocol hits various other limits before that would ever be an issue. However...

The value is stored in an 8-byte field, which is enough to store all values that could be possible (large enough for 21 million * 10**8 satoshis).
I imagine it was just deemed better/safer overall to use an int rather than deal with floating point or some form of odd encoding, for such a crucial field.

I'm not quite sure why it's 8-bytes and not 7-bytes, though. Could simply be that 64bit is a nice size.

TimS
Sr. Member
****
Offline Offline

Activity: 250
Merit: 253


View Profile WWW
July 23, 2014, 12:11:43 PM
 #8

Quote
First, as represented in transactions in the blockchain, outputs are not in decimal form.  The concept of 1 BTC is just a way to make it easier for humans to deal with the otherwise really big numbers that would have been involved when bitcoin started out.  The outputs are actually represented as an integer number of satoshis.  So if you want an output to assign 0.0324 BTC to the control of the private key associated with a particular address, then the value that is actually assigned in that output is 2340000

@DannyHamilton:
Do you by any chance know why was it implemented this way? What if some day in the year 2400 the value of one satoshi will be greater than a value of a house?
Bitcoins could be divided further. E.g. let's say we wanted to add 7 more zeroes to the end. From people's perspective, this would mean that instead of 0.000 000 01 being the smallest possible value, 0.000 000 000 000 001 is. From the technical perspective, this would mean that each old unit (satoshi) is now worth 10^7 units, so an old output of 20 satoshi (0.000 000 20 BTC) can be spent as up to 2*10^8 units (probably with a new transaction version number, to help prevent software from confusing things).

This increased divisibility would not be a hard thing to agree on.

I think this would be implemented if a satoshi approached the value of US$0.01 today, and/or transaction fees approached a satoshi; both long before the value of a house is a satoshi.
konradp
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
July 23, 2014, 01:19:46 PM
 #9

@azeteki @TimS:

Thanks!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!