Bitcoin Forum
September 22, 2018, 03:51:33 PM
 News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 Home Help Search Donate Login Register
 Pages: [1]
 Author Topic: Double spending attack and defense - need an illustration and some pointers  (Read 787 times)
Newbie

Offline

Activity: 9
Merit: 0

 July 11, 2011, 09:44:46 PM

Hey,
Admittedly ultra-noob, but believe me that I've done my research before asking.

1. I understand the cool concept of double-spending prevention by all nodes agreeing on the block (and tx order), but only when it involves discrete, indivisible bitcoins. I fail to understand it when we're talking about fractions of bitcoins. Can you give me an illustration of a double spendning attack with fractions of bitcoins? what does it mean? do I have to spend exactly the same amount? or a fraction of a coin I already spent?

2. Where can I look for the code that scrutinize a newly arrived block? Is it part of the client I downloaded? I want to have a deeper look in it, and maybe that can shed a light on my 1st question.

Thanks, good luck with this amazing technical-economic experiment, Ido
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
vector76
Member

Offline

Activity: 70
Merit: 10

 July 11, 2011, 10:10:56 PM

Each transaction has inputs and outputs.  The sum of the outputs must not be more than the sum of the inputs.

The outputs of a transaction can be used as the inputs to a subsequent transaction.  When an output of a transaction is used, it can never be used again.  The entire value of the output contributes to the subsequent transaction, so if you wish to transfer smaller amount, you must add an additional output on the second transaction to send the remainder back to yourself.

Example:
Tx1 input 1 comes from a previous tx with a value of 1
Tx1 input 2 comes from a previous tx with a value of 2
Tx1 output 1 has a value of 2.5 and requires key A to be claimed.
Tx1 output 2 has a value of 0.5 and requires key B to be claimed.

Person with key A creates a transaction and submits it to the miners:
Tx2 input 1 comes from Tx1/output 1.
Tx2 output 1 has a value of 2.0 and requires key C to be claimed
Tx2 output 2 has a value of 0.5 and requires key A to be claimed

Other nodes observe that Tx1/output 1 has not yet been spent and has a value of 2.5.  They verify that the outputs are not greater than 2.5.  They mark Tx1/output1 as used.

Person with key A creates another (double spend) transaction:
Tx3 input 1 comes from Tx1/output 1
Tx3 output 1 has a value of 1.0 and requires key D to be claimed
Tx3 output 2 has a value of 1.5 and requires key E to be claimed

Other nodes observe that Tx1/output 1 has already been spent, and they reject this transaction.

The value sits in the transaction outputs until another transaction refers to it as an input.  The value at an address (which represents a key) is the total value in all outputs that can be claimed by that key.
Newbie

Offline

Activity: 9
Merit: 0

 July 12, 2011, 08:04:32 AM

Thanks!
so for scrutinizing transactions in a new block, we must reverse trace each of them thru the series of output to input, until we reach a transaction that is acknowledged (sits in an acknowledged block), right?
Where can I see the code for this scrutinizing?
 Pages: [1]