Bitcoin Forum
December 13, 2024, 10:38:46 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can someone explain where a transaction size comes from?  (Read 1372 times)
Chris! (OP)
Legendary
*
Offline Offline

Activity: 1382
Merit: 1123



View Profile
October 27, 2016, 03:45:34 PM
 #1

I understand obviously that if a transaction is larger in Kb it's going to need a larger fee to send. But why is it that if you receive a ton of faucet payouts vs one transaction of say 0.01BTC one transaction is bigger than the other?

If I send you 0.01BTC but I received many transactions, will that 0.01BTC always have a huge transaction? Or did I basically just take a roll of pennies to the bank and gave you two quarters?
Will it cost you more in the future to send that same transaction rather than if there was a brand new block mined and from that someone sent you 0.01BTC?

What makes the transaction bigger in Kb and why does it cost more to send? Is it the number of characters in the TXID?

So because you received a ton of faucet transactions you have let's say 50x 50 characters (or whatever a TXID actually is) rather than just 50 characters?

That was kind of long winded but if someone could dumb it down and talk to me like I'm 5 that would be wonderful  Grin.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3570
Merit: 6927


Just writing some code


View Profile WWW
October 27, 2016, 03:51:44 PM
 #2

This gets very technical and is kind of hard to explain.

So Bitcoin works by having transaction outputs (txo), not actually addresses. Addresses are just abstractions for a specific type of transaction output.

When you receive Bitcoin, a new txo is created. When you spend Bitcoin, you spend from a txo. Each txo becomes one input in the transaction. So, if you are sending a transaction which spends from a lot of txos, it will have a lot of inputs. Inputs have a size in bytes. Thus having a lot of inputs from spending from a lot of txos will make your transaction have a lot of bytes.

jonnybravo0311
Legendary
*
Offline Offline

Activity: 1344
Merit: 1024


Mine at Jonny's Pool


View Profile WWW
October 27, 2016, 04:38:29 PM
 #3

Using your analogy of pennies and quarters...

Let's say you want to send $0.25 to somebody.  If you have a quarter, you just hand it to them.  It's a single unit.  If you have pennies, you need to collect 25 of them.

Each of the cases results in the same thing: the receiver got his 25 cents.  The difference is in how you sent it.  In the first case, you had a single input to the transaction: a quarter.  In the second case, you have 25 inputs to your transaction.

It's not the transaction ID, but rather the contents of the transaction that determines the size.

Jonny's Pool - Mine with us and help us grow!  Support a pool that supports Bitcoin, not a hardware manufacturer's pockets!  No SPV cheats.  No empty blocks.
Chris! (OP)
Legendary
*
Offline Offline

Activity: 1382
Merit: 1123



View Profile
October 27, 2016, 05:54:42 PM
 #4

This gets very technical and is kind of hard to explain.

So Bitcoin works by having transaction outputs (txo), not actually addresses. Addresses are just abstractions for a specific type of transaction output.

When you receive Bitcoin, a new txo is created. When you spend Bitcoin, you spend from a txo. Each txo becomes one input in the transaction. So, if you are sending a transaction which spends from a lot of txos, it will have a lot of inputs. Inputs have a size in bytes. Thus having a lot of inputs from spending from a lot of txos will make your transaction have a lot of bytes.

But if I now sent one transaction to you for 0.01BTC does the size still stay the same from now on? Wouldn't it just get bugger and bigger if I kept sending that same 0.01BTC over and over again?

Using your analogy of pennies and quarters...

-snip-

It's not the transaction ID, but rather the contents of the transaction that determines the size.

Well yes I understand that. It's more efficient to send a quarter rather than 25 pennies to someone (again using the same analogy) but if sending 25000 pennies ($250 in pennies) costs me $5.00 to send and they now have 2x$100 and 1x$50 is that transaction that they have of $250 still going to cost the next person $5.00 to send it?

I suppose I could always try this stuff out on testnet.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3570
Merit: 6927


Just writing some code


View Profile WWW
October 27, 2016, 06:00:49 PM
 #5

This gets very technical and is kind of hard to explain.

So Bitcoin works by having transaction outputs (txo), not actually addresses. Addresses are just abstractions for a specific type of transaction output.

When you receive Bitcoin, a new txo is created. When you spend Bitcoin, you spend from a txo. Each txo becomes one input in the transaction. So, if you are sending a transaction which spends from a lot of txos, it will have a lot of inputs. Inputs have a size in bytes. Thus having a lot of inputs from spending from a lot of txos will make your transaction have a lot of bytes.

But if I now sent one transaction to you for 0.01BTC does the size still stay the same from now on? Wouldn't it just get bugger and bigger if I kept sending that same 0.01BTC over and over again?
No. There is no such thing as an object called a "bitcoin". Rather the Bitcoin are simply values associated with each TXO. When you spend a TXO, you create a new TXO that has at most the value of all of the input TXOs.

Chris! (OP)
Legendary
*
Offline Offline

Activity: 1382
Merit: 1123



View Profile
October 27, 2016, 06:25:16 PM
 #6

This gets very technical and is kind of hard to explain.

So Bitcoin works by having transaction outputs (txo), not actually addresses. Addresses are just abstractions for a specific type of transaction output.

When you receive Bitcoin, a new txo is created. When you spend Bitcoin, you spend from a txo. Each txo becomes one input in the transaction. So, if you are sending a transaction which spends from a lot of txos, it will have a lot of inputs. Inputs have a size in bytes. Thus having a lot of inputs from spending from a lot of txos will make your transaction have a lot of bytes.

But if I now sent one transaction to you for 0.01BTC does the size still stay the same from now on? Wouldn't it just get bugger and bigger if I kept sending that same 0.01BTC over and over again?
No. There is no such thing as an object called a "bitcoin". Rather the Bitcoin are simply values associated with each TXO. When you spend a TXO, you create a new TXO that has at most the value of all of the input TXOs.

So in layman's terms, just because my transaction cost me 100k Satoshis because it was huge doesn't mean that the next person will have to spend 100k Satoshis because the size of the transaction would now be just the one input. Right?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3514
Merit: 4894



View Profile
October 27, 2016, 06:57:44 PM
 #7

I understand obviously that if a transaction is larger in Kb it's going to need a larger fee to send.

Correct.

But why is it that if you receive a ton of faucet payouts vs one transaction of say 0.01BTC one transaction is bigger than the other?

Because each of those payouts need to be listed separately as a transaction input to provide their value to the transaction.

If I send you 0.01BTC but I received many transactions, will that 0.01BTC always have a huge transaction?

No.  Once you spend an unspent output, (by using it as an input to a transaction) you can never spend it again.  Instead, the output provides all of its value to the transaction where it is spent.  Then the transaction creates one or more new unspent outputs (typically one new output for each address that the transaction is sending bitcoins to).

Or did I basically just take a roll of pennies to the bank and gave you two quarters?

Perhaps a better analogy is to think of the payments you've received as nuggets of gold and the transaction as a crucible.  You take several nuggets (unspent outputs) that you've received and toss them all into a crucible (transaction).  The crucible (transaction) now has a total value that has been provided to it.  Melt the nuggets together and now they no longer exist as separate nuggets. Then you pour out some of that melted gold into one or more molds (new unspent outputs) that you will give to pay for something. Once the right amount has been poured out for each person you are paying, you pour the remaining amount out into a mold for yourself that you will keep as "change" from the transaction and will use in the future to provide value to a new transaction.

Will it cost you more in the future to send that same transaction rather than if there was a brand new block mined and from that someone sent you 0.01BTC?

No.  In either case I receive a single 0.01 BTC output wich I can use as an input in the future.

What makes the transaction bigger in Kb

You have to list each input (previously unspent output) that will provide value to the transaction, and each new unspent output that you are creating.

and why does it cost more to send?

Miners have a limit of 1 megabyte per block.  They get to choose which transactions they want to include in their block, and then they get to keep all the transaction fees of all the transactions in their block when they solve it.  If you were a miner trying to be as profitable as you can with a limit of 1 megabyte, would you choose the transactions for your block that pay MORE money per byte? Or would you choose the transactions that pay less money per byte?

Is it the number of characters in the TXID?

No.

So because you received a ton of faucet transactions you have let's say 50x 50 characters (or whatever a TXID actually is) rather than just 50 characters?

No.

That was kind of long winded

I don't mind you being long winded as long as you don't mind me creating this really long response.

but if someone could dumb it down and talk to me like I'm 5 that would be wonderful  Grin.

I did the best I could.

if I now sent one transaction to you for 0.01BTC does the size still stay the same from now on?

It shrinks down to a single unspent output.  Then if I spend it, it could grow if I create many new outputs or it could stay the same if I only create a single output.

Wouldn't it just get bugger and bigger if I kept sending that same 0.01BTC over and over again?

No.  All the inputs to the transaction become spent and never get listed again.  Only the new unspent outputs need to be listed in the future transaction where they get spent.

So in layman's terms, just because my transaction cost me 100k Satoshis because it was huge doesn't mean that the next person will have to spend 100k Satoshis because the size of the transaction would now be just the one input. Right?

Correct!
Chris! (OP)
Legendary
*
Offline Offline

Activity: 1382
Merit: 1123



View Profile
October 27, 2016, 07:11:35 PM
 #8

-snip-

Wonderful answer! Thanks so much.

I do have one more question but I'm sure it's too hard to dumb down like achow101 said.

What makes up the actual size of a transaction? What I mean by that is, are there more characters to create that transaction because there are more... inputs (if that's right?)

So example: I have 0.02BTC. The first 0.01BTC was from faucets and will have a high fee and the second was just 0.01BTC paid to me in one transaction. Does the first transaction consist of a whole bunch of TXIDs? So those very long IDs but for each input? Is that not where the large size in a transaction comes from?

So the first transaction contains all of this information (inputs? Or are they now considered outputs when spent?) that takes up room on the Blockchain:

tRaNSaCtioN12341
tRaNSaCtioN12342
tRaNSaCtioN12343
tRaNSaCtioN12344
tRaNSaCtioN12345
tRaNSaCtioN12346
tRaNSaCtioN12347
tRaNSaCtioN12348
tRaNSaCtioN12349

Whereas one input (or I guess now it's an output) looks like:

tRaNSaCtioN1234

Ok and another question (yes I know I said I only had one more. Don't you sass me boay!!) what is an input vs an output? Output is when you send your inputs right? So I just received 0.01BTC. I now have 1 0.01BTC input. What is an unspent output though?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3514
Merit: 4894



View Profile
October 27, 2016, 07:57:10 PM
 #9

Ok and another question (yes I know I said I only had one more. Don't you sass me boay!!)


I'm going to answer these questions in reverse order.  It just feels easier that way.

what is an input vs an output? Output is when you send your inputs right? So I just received 0.01BTC. I now have 1 0.01BTC input. What is an unspent output though?

Think back to my gold analogy.

Each transaction creates unspent transaction outputs.  These are the values that have been assigned to the control of a private key, and which are waiting to be spent. These are what are added up and shown as a balance by the wallet that has access to the associated private keys.

When you want to transfer control over value from yourself to someone else...
  • Your wallet chooses enough of the unspent outputs that it has control over such that the sum of the values is equal at least as much value as you want to transfer.
  • Each of these unspent outputs is listed in the transaction as an input to the transaction.
  • Then a list of new unspent outputs is created that assign that total value from the transaction.
  • Any value that was provided as inputs to the transaction which is not accounted for when you sum up the value of all the newly created unspent outputs becomes a transaction fee
  • Once an output is used as an input to a transaction (and that transaction is confirmed), that output is considered to be "spent" and can never be used as an input to any another transaction

What makes up the actual size of a transaction?

Transactions have a few parts that are ALWAYS there, and a few parts that the user (or wallet) chooses.

Every transaction starts with a 4 byte version number.
Then there is anywhere from 1 to 9 bytes (typically 1 byte) that indicate how many inputs there will be in the transaction.
Then each input is listed along with its scriptSig (typically the signature that was generated with the proper private key for the address where that output was previously "sent").
The size of the input will depend on they type of bitcoin address that was used to previously receive that output (P2SH, P2PKH, P2PK, etc).
A typical output received at an address that starts with a '1' will be about 148 bytes.
Next there is anywhere from 1 to 9 bytes (typically 1 byte) that indicate how many outputs there will be in the transaction.
Next each output is listed.
Each output consists of two pieces.  An 8 byte "value" indicating the integer number of satoshis that are being assigned to the output and a Txout-script that sets up the requirements that must be met to spend the output.  In the case of an address that starts with a '1', this would be a P2PKH script and would be 26 bytes.
Finally, there is a 4 byte "lock_time" that prevents the transaction from being included into a block until a specified block height.

So, there are typically about 10 bytes (and potentially up to 26 bytes) of transaction overhead in every transaction, and typically an additional 144 bytes per input and 34 bytes per output.

What I mean by that is, are there more characters to create that transaction because there are more... inputs (if that's right?)

There are more bytes because there are more inputs.  Don't think of them as characters.  Think of them as sequences of 0's and 1's where every 8 binary digits is a byte.

So example: I have 0.02BTC. The first 0.01BTC was from faucets and will have a high fee and the second was just 0.01BTC paid to me in one transaction. Does the first transaction consist of a whole bunch of TXIDs? So those very long IDs but for each input? Is that not where the large size in a transaction comes from?

Effectively, yes, except that the transactionID isn't stored as a sequence of alphanumeric characters.  It's just a 256 bit (32 byte) number.

It isn't enough to just indicate which transaction (since transactions can have more than one output).  You also need to indicate which (first, second, third, etc) output from that transaction is being spent. This is done with a 4 byte index.

Finally, you need to prove that you have the right to use that output as an input in this transaction.  This is typically done with a script that includes an ECDSA signature generated with the private key that is associated with the "address" that the output was previously received at. This script is typically about 108 bytes long.

So the first transaction contains all of this information (inputs? Or are they now considered outputs when spent?) that takes up room on the Blockchain:

tRaNSaCtioN12341
tRaNSaCtioN12342
tRaNSaCtioN12343
tRaNSaCtioN12344
tRaNSaCtioN12345
tRaNSaCtioN12346
tRaNSaCtioN12347
tRaNSaCtioN12348
tRaNSaCtioN12349

Whereas one input (or I guess now it's an output) looks like:

tRaNSaCtioN1234

They are unspent outputs when they are created by a transaction. They are spent outputs when they are spent by listing them in the list of inputs to a transaction.
jonnybravo0311
Legendary
*
Offline Offline

Activity: 1344
Merit: 1024


Mine at Jonny's Pool


View Profile WWW
October 27, 2016, 08:42:14 PM
 #10

Perhaps a better analogy is to think of the payments you've received as nuggets of gold and the transaction as a crucible.  You take several nuggets (unspent outputs) that you've received and toss them all into a crucible (transaction).  The crucible (transaction) now has a total value that has been provided to it.  Melt the nuggets together and now they no longer exist as separate nuggets. Then you pour out some of that melted gold into one or more molds (new unspent outputs) that you will give to pay for something. Once the right amount has been poured out for each person you are paying, you pour the remaining amount out into a mold for yourself that you will keep as "change" from the transaction and will use in the future to provide value to a new transaction.
Great analogy Mr. Hamilton!

To continue that analogy, the fees would be calculated based upon the number of nuggets you initially dump into the crucible and into how many molds the melted gold must be distributed from the crucible.

Once you've determined everything (number of nuggets, number of molds and how much of the gold you're willing to pay for the smelting services) you broadcast that work order to a network of workers.  If you offer a lot of gold for the smelting, a lot of smelters will pick up that work order and try to complete it as soon as possible.  If, on the other hand you don't offer a lot of gold for the smelting services, very few, if any, smelters will bother with it.

Jonny's Pool - Mine with us and help us grow!  Support a pool that supports Bitcoin, not a hardware manufacturer's pockets!  No SPV cheats.  No empty blocks.
Chris! (OP)
Legendary
*
Offline Offline

Activity: 1382
Merit: 1123



View Profile
October 31, 2016, 03:00:50 AM
 #11

Oops I thought I had already posted it but thanks everyone so much for all of this information. It's hard to sift through all of the information online and find something that just clearly explains these basic things in plain English.

For my future reference:

Input = Credit
Output = Debit
Unspent output = 'spendable'
or balance in your bitcoin address equal to the inputs added up or possible bitcoins you can spend. The number of inputs will determine how high the fee is. Ex: 5 inputs of 0.002 will have a higher fee than 1 input (now an unspent output) of 0.01BTC.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3514
Merit: 4894



View Profile
October 31, 2016, 06:57:20 PM
Last edit: October 31, 2016, 07:46:25 PM by DannyHamilton
 #12

Oops I thought I had already posted it but thanks everyone so much for all of this information. It's hard to sift through all of the information online and find something that just clearly explains these basic things in plain English.

For my future reference:

Input = Credit
Output = Debit
Unspent output = 'spendable'
or balance in your bitcoin address equal to the inputs added up or possible bitcoins you can spend. The number of inputs will determine how high the fee is. Ex: 5 inputs of 0.002 will have a higher fee than 1 input (now an unspent output) of 0.01BTC.

You're getting close, but your use of words like "credit" and "debit" indicates that you are still thinking of addresses like accounts, and they really aren't.  Also, either I'm mis-understanding what you've written, or you are still getting a bit confused with the concept of the relationship between inputs and unspent outputs.

Lets start by trying to clear up some common confusions.  You may not be confused about some of these things (I'm not sure), so this might not be directed at you, but it still could be helpful to others reading this thread:

There are no accounts.  Do not think of bitcoin addresses as accounts, it will only cause you confusion in the long run.  If you need an analogy, think of them as invoice numbers, but remember that at the protocol level, there aren't even any bitcoin addresses at all.  Addresses are an abstraction that we humans use to make it easier to talk about transferring control of value.

When talking about bitcoin transactions, the word "input" refers to value being put into the transaction, not value being put into an address, or wallet, or account.  Again, if you really need an analogy, you can think about an input as being a removal (or subtraction) from your control and an addition to the transaction's control.

When talking about bitcoin transactions, the word "output" refers to value coming out of the transaction, not value coming out of an address, or wallet, or account.  If you really need an analogy, you can think about an output as being a removal (or subtraction) from the transaction's control and an addition to the control of a private key.

An unspent output is simply an output that hasn't been used as an input yet.  Each output in the blockchain can only be used as an input once.  After that, it is considered to have been spent and isn't allowed to be used as an input into any other transactions ever.




Now that we've cleared up some common confusions, lets take a look at how this all works...

You receive three separate payments.  Each payment is a transaction output that is associated with a private key that you control, and you haven't spent any of it yet.  Therefore, you are in control over 3 unspent transaction outputs. Lets call these outputs A, B, and C. A is valued at 1 BTC, B at 0.5 BTC, and C is 2 BTC.  You are using wallet software that has all the associated private keys, so that wallet sees these 3 outputs in the blockchain, and understands that it has the ability to spend all three of them.  The wallet therefore adds them all up and shows you a total of 3.5 BTC under your control.

Now, you want to send 2.25 BTC to Jack.  Jack gives you a bitcoin address that is associated with a private key that he has.  You tell your wallet software to create a transaction sending 2.25 BTC to Jack.

Your wallet searches through the list of outputs that it has the ability to spend, and chooses outputs B & C.  The wallet then creates a transaction by listing as inputs the outputs that it wants to spend and listing as outputs the new outputs that it wants to create:

Transaction Inputs:
B
C

Transaction Outputs:
D has a script that puts it under the control of Jack's private key (valued at 2.25 BTC)
E has a script that puts it under the control of a private key that your wallet has (valued at 0.24 BTC)

The wallet uses the private keys that it controls to generate digital signatures for B and C to prove to the entire network that it is authorized to spend those outputs, broadcasts the transaction to the network, and a miner eventually mines a block confirming this transaction into the blockchain.

Now, since this transaction just spent B & C, those are "spent outputs" and can never be used as inputs to any other transaction. Your wallet still has control over A and it hasn't been spent yet, so it is still an unspent output.  Your wallet also now has control over E. Since E hasn't shown up in a list of transaction inputs anywhere yet, it is also an unspent output.  Your wallet adds up the values of A and E and shows you a total of 1.24 BTC under your control.

Jack's wallet sees that it has control over output D. Since D hasn't been listed as an input to any other transactions yet, it is an unspent output. Jack's wallet shows him a total of 2.25 BTC under his control.

You'll notice if you add up the values of B & C that they total 2.50 BTC. So, in the list of transaction inputs, you transferred a total of 2.50 BTC to the control of the transaction. If you add up the values of D & E they total 2.49 BTC.  So, the transaction transferred a total of 2.49 BTC to the control of Jack and yourself. The extra 0.01 BTC that is not accounted for in the transaction outputs is the transaction fee that the miner gets to assign to himself in the block reward of the block he solved.  This is how transaction fees are paid to miners. If your wallet had instead given output E a value of 0.25 BTC, then this transaction would have paid no fee at all.  If the sum of the values of the transaction outputs is higher than the sum of the values of the transaction inputs, then the transaction is invalid and every node on the network will reject the transaction and refuse to relay it or add it to any blocks.

Now, lets say Jack decides to pay 3 people in a single transaction.  He's going to send 1 BTC to Bob, 0.75 BTC to you, and 0.3 BTC to Sally. Jack receives a bitcoin address from each of you and tells his wallet software what he wants to do.

Jack's wallet searches through the list of outputs that it has the ability to spend, and discovers that D is the ONLY unspent output Jack has.  The wallet then creates a transaction by listing D as an input and listing as outputs the new outputs that it wants to create:

Transaction Inputs:
D

Transaction Outputs:
F has a script that puts it under the control of a private key that Bob's wallet has (valued at 1.00 BTC)
G has a script that puts it under the control of a private key that Sally's wallet has (valued at 0.30 BTC)
H has a script that puts it under the control of a private key that your wallet has (valued at 0.75 BTC)
I has a script that puts it under the control of Jack's private key (valued at 0.11 BTC)

The wallet uses the private keys that it controls to generate a digital signature for D to prove to the entire network that it is authorized to spend that output, broadcasts the transaction to the network, and a miner eventually mines a block confirming this transaction into the blockchain.

As you can hopefully see:
As a transaction has more inputs it gets bigger, because the list gets longer.
As a transaction has more outputs it gets bigger because the list gets longer.

Since the fee that is paid is typically chosen as an amount "per byte", each additional input and each additional output adds to the total fee the transaction is likely to pay.  Each input adds about 148 bytes to the size of the transaction.  Each output adds about 34 bytes to the size of the transaction.

Hopefully you can see that the value of the transaction has nothing to do with it's size.  A single input is 148 bytes regardless of whether that input is 0.0001 BTC or 5000.00 BTC.  A single output is 34 bytes regardless of whether that output is 0.0001 BTC or 5000.00 BTC.


Looking at the blockchain, there are now a total of 9 outputs.
  • 3 of them (B, C, and D) have been used as inputs and are therefore now spent.
  • 3 of them (A, E, and H) have not been spent yet and are all under your control
  • 1 of them (F) has not been spent yet and is under the control of Bob
  • 1 of them (G) has not been spent yet and is under the control of Sally
  • 1 of them (I) has not been spent yet and is under the control of Jack

If we add up the values of the unspent outputs we see that you have control over 1.99 BTC, Bob has control over 1.0 BTC, Sally has control over 0.3 BTC and Jack has control over 0.11 BTC.

The blockchain is nothing more than a list of all the blocks that have been created by miners.

Blocks are nothing more than a header record that proves that the miner did the work he was supposed to, and a list of transactions.  So, the blockchain is a LONG list of EVERY transaction ever confirmed.

Any new wallet can start at the first block and follow through all the transactions. The wallet can keep track of a list of ALL the unspent transactions.  Each time the wallet sees a transaction, it can add all the outputs of that transaction to its list of unspent outputs. It can also remove all the inputs of that transaction from its list of unspent outputs.  This process of going step-by-step through every transaction that has ever existed is called "synchronizing" the wallet.  When the wallet is done, it will have a complete list of EVERY output that has ever been created and not yet spent.  This list of unspent outputs is called the "UTXO".  The wallet can now compare the list of private keys that it has to the UTXO to see exactly how many bitcoins it has control over. It can also use the UTXO to make sure that every new transaction that is broadcast on the network ONLY has inputs that are in the UTXO.  If any transaction tries to list as an input something that is not in the UTXO, then the transaction is rejected as invalid, and the wallet refuses to accept or relay the transaction. Every time the wallet receives a new solved block it goes through all the transactions in the block, adding all the outputs of all the transactions to its UTXO and removing all the inputs of all the transactions from its UTXO.

See that there are no "accounts".  There is just a list of inputs and outputs.  That's it.  Each transaction simply spends outputs that were created earlier (by listing them as inputs), and creates new outputs.  Each wallet simply keeps track of all the outputs that it has control over, and displays to the user a sum of those outputs.
Chris! (OP)
Legendary
*
Offline Offline

Activity: 1382
Merit: 1123



View Profile
November 02, 2016, 03:35:07 PM
 #13


If you need an analogy, think of them as invoice numbers, but remember that at the protocol level, there aren't even any bitcoin addresses at all.  Addresses are an abstraction that we humans use to make it easier to talk about transferring control of value.


Ok I definitely understand that. So basically an address is just for us to see a consolidation of how may unspent outputs (or chunks of gold in different sizes, or invoices in different amounts) we have.


When talking about bitcoin transactions, the word "input" refers to value being put into the transaction, not value being put into an address, or wallet, or account.  Again, if you really need an analogy, you can think about an input as being a removal (or subtraction) from your control and an addition to the transaction's control.


I think I understand it a bit better. If I add a transaction to the Blockchain that's an input to said transaction. It now becomes a spent output for me and can never be used again.


When talking about bitcoin transactions, the word "output" refers to value coming out of the transaction, not value coming out of an address, or wallet, or account.  If you really need an analogy, you can think about an output as being a removal (or subtraction) from the transaction's control and an addition to the control of a private key.


So I just received an output from someone else. I didn't get a credit to my bitcoin address but instead the transaction now is controlled by my private key (or I guess I should say my private key controls that unspent output now).


Each wallet simply keeps track of all the outputs that it has control over, and displays to the user a sum of those outputs.

Got it... I think.

Can you correct me if I'm wrong?:

I have 1BTC.

I send the 1BTC (minus fees) to Charlie with transaction A so I did an input onto the Blockchain of .99 +.01 in fees.

Charlie now receives the output. He has an unspent output until he sends the .99BTC (minus fees) to Alice. He sends an input of .98 + .01 in fees to the Blockchain with transaction B.

Alice now sees her .98BTC show up as an output. Again, it'll be an unspent output until she spends it in the future. Her private key has control of the unspent output.

So:

When your private key 'loses control' of an output it  = input
When your private key 'gains control' of an input = output

Outputs are unspent outputs until they're an input, then your private key loses control of that transaction.

So basically every portion of a bitcoin that you have is an output and once you input it onto the Blockchain it's now an output for the other private key it was sent to.

Is that all right?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3514
Merit: 4894



View Profile
November 02, 2016, 05:03:46 PM
Last edit: November 02, 2016, 05:14:39 PM by DannyHamilton
 #14

Ok I definitely understand that. So basically an address is just for us to see a consolidation of how may unspent outputs (or chunks of gold in different sizes, or invoices in different amounts) we have.

Wallets are for us to see a consolidation of how may unspent outputs we have.  They add up all the unspent outputs regardless of whether they are associated with the same addresses or different addresses.

Addresses are an easy way to say the following:
"Please create and broadcast a bitcoin transaction that creates an output valued at X satoshis. Please generate a script for the output that encumbers it with a requirement that it can't be used as an input in any other transaction unless a digital signature of the transaction is supplied from the private key that is associated with the public key that hashes to a hexadecimal value of b887364d67e651a39e0647ab08d591ec54fd0966."

Clearly it is much easier to just say:
"Please send X BTC to 1HphJzyKGfnCiTDqzcFTQt5idNfaAiBSob"

But both of those statements literally mean exactly the same thing.
 
I think I understand it a bit better. If I add an transaction output to the Blockchain transaction that's as an input to said transaction. It now becomes a spent output for me and can never be used again.

See the corrections I made in your quote. I fixed that for you.

So I just received an output from someone else. I didn't get a credit to my bitcoin address but instead the transaction output now is controlled by my private key (or I guess I should say my private key controls that unspent output now).

You missed the word "output".  I've added it to your quote.  As long as that's what you meant to say, you are correct.

Got it... I think.

Can you correct me if I'm wrong?:

I have 1BTC.

So far so good.  I assume that 1 BTC is a single output that you received from a single transaction?

I send the 1BTC (minus fees) to Charlie with transaction A so I did an input onto the Blockchain of .99 +.01 in fees.

No.  You created an input of 1 BTC.  More specifically, you listed your one output valued at 1 BTC as an input in the transaction that you created. You can't break up the 1 BTC output that you have control over.  You either spend it as an input, or you keep it as an unspent output to use in some other transaction some other time.

Charlie now receives the output.

Correct.  You will create an output under the control of Charlie's private key and list it in the transaction that you broadcast. If you create that output as a 1 BTC output, then he will get the whole thing, and there will be no transaction fee.  If you create a 0.99 BTC output, then there is 0.01 BTC unaccounted for (you supplied 1 BTC in value as inputs, but only accounted for 0.99 BTC as outputs)  The unaccounted for 0.01 BTC is added to the block reward by the miner when he solves the block that first confirms your transaction.

He has an unspent output until he sends the .99BTC (minus fees) to Alice.

This is correct as long as you created a 0.99 BTC output under the control of Charlie in the transaction that you broadcast to the network.

He sends an input of .98 + .01 in fees to the Blockchain with transaction B.

No.  He only has a 0.99 BTC output.  If he is going to create transaction B, then he can list that 0.99 BTC output as an input.  He can create a new 0.98 BTC output in the list of outputs that he creates in that transaction, and if he does, then the unaccounted for 0.01 BTC is added to the block reward by the miner when he solves the block that first confirms your transaction.

Alice now sees her .98BTC show up as an output.

This is correct as long as Charlie created a 0.98 BTC output under the control of Alice in the transaction that he broadcast to the network.

Again, it'll be an unspent output until she spends it in the future. Her private key has control of the unspent output.

Correct.

So:

When your private key 'loses control' of an output it  = input

I think that's a close enough understanding for our discussion.  Another way to phrase it would be that when an output is listed in the "inputs" half of a transaction, it is an input.  If that transaction is confirmed, then the output is called "spent" and can never again be used.

When your private key 'gains control' of an input = output

No.  You never gain control of an input.  The inputs provide value to a transaction.  The transaction then has a separate list of outputs that it creates. Any of those newly created outputs can be used as inputs to other transactions in the future by anyone that can provide the correct input script (typically a digital signature).

Outputs are unspent outputs until they're an input,

Correct.

then your private key loses control of that transaction.

I assume you meant to say that your private key loses control of that output?  If so, then that becomes effectively true once the transaction is confirmed.  More specifically:
Once an output is used as an input to a transaction, and that transaction is confirmed in the blockchain, that output can never again be used as an input to any other transaction.

So basically every portion of a bitcoin that you have is an output

Correct.

and once you input it onto the Blockchain it's now an output for the other private key it was sent to.

No.  Once you input it into a transaction, and that transaction is confirmed onto the blockchain, the output is "spent" and can never again be used by anyone.  The transaction can create new outputs for other private keys, but the sum of the values of the new outputs is not allowed to exceed the sum of the values of the inputs.
 
Is that all right?

You're almost there.  See if my corrections make sense, and let me know if any of them confuse you.
Chris! (OP)
Legendary
*
Offline Offline

Activity: 1382
Merit: 1123



View Profile
November 06, 2016, 08:51:10 PM
 #15

Ok I definitely understand it much better now. I know my terminology is a little mixed up sometimes but I definitely understand how it works. No wonder I didn't just 'pick it up' haha it's a lot more complicated than you would think when you first start with bitcoins and you 'send bitcoin from one address to another.'

Thanks for all of you help DannyHamilton. I'm looking to include an input into a transaction but I need an address to send it to so you can have an unspent output. Would you happen to have one that you would prefer?
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!