# validation – How is a bitcoin transaction validated?

w.r.t. a bitcoin transaction, I really have trouble understanding how the bitcoin network validates the fact that 1) Have the bitcoin I want to send, and 2) Have not sent it to anyone else yet.

If the balance of my account had been followed, it would have been easy. The nodes would do a simple test if I check that the balance of my account is sufficient before spending money. But as I learned, a bitcoin transaction destroys bitcoins and generates new ones (UTXO). So a transaction looks like:

``````FromAddress, ToAddress, Id_of_Bitcoin_being_destroyed, Id_of_bitcoin_being_created
``````

The above assumes that I have the exact amount I want to pay, which is sufficient for the purposes of my question.

So now, before validating this transaction, the nodes must check:

``````isDestroyed (Id_of_Bitcoin_being_destroyed) == false; that is, the room has not been spent yet

Owner (Id_of_Bitcoin_being_destroyed) == me; it is to say that the piece belongs to me
``````

Could someone please explain in detail how this is going?

Does a node make a reverse table scan (that is, scan the blockchain starting from the most recent transaction to the oldest one) to the location `Id_of_Bitcoin_being_destroyed`? Then he can answer the two questions above. However, this algorithm can not evolve at all and is the node of what I seek to understand.

To make it happen, let's say `Id_of_Bitcoin_being_destroyed = 1234`. An inverted table analysis takes place and the following record is located:

``````From: me, to: Brian, 1234, 5678
``````

The node detects that I have already spent the coin and that the transaction fails.

Another example. In this case, an inverted table analysis finds:

``````From: Brian, to: me, 5678, 1234
``````

The knot can say with confidence that I own the piece and that it has not been spent.

I've sincerely tried to understand this and find the answer online, including looking at [1, 2] but failed. For example, I just said this:

This transaction can be validated – that is, it can be confirmed that
I own the bitcoins that I transfer to you and that I do not have
already sent to someone else – by plugging the signature and my
public key (that everyone knows) in the Bitcoin program.

But that leaves a lot unexplained for me.