<p>Bitcoin does not have the concept of account balance. Anyone who can provide a valid signature to the locking script of a particular transaction output can spend those bitcoins. As a result when you spend your bitcoins in a transaction, you have to include the transaction id and the output no. from which you earned those bitcoins. The nodes maintain a set of unspent transaction outputs (UTXOs) in the memory to check that this transaction output that has been referenced in the input has not been spent previously (this prevents double spending.)</p>

<p>If you want to send X BTC to a particular address, you will need to reference enough transactions in the input so that sum of all those unspent bitcoins >= X. This referenced transactions can come from different addresses. You just need to provide valid signature with your private key to show that you are the owner of those bitcoins. </p>

CC BY-SA 4.0
2019-04-16T07:19:06.447Z
2019-04-16T07:19:06.447Z
Ugam Kamat
<p>A node will receive many transactions from other nodes through <a href="https://en.bitcoin.it/wiki/Network" rel="nofollow noreferrer">network propagation</a>. If it determines that a transaction it has received is not valid, it will not relay the transaction to other nodes on the network (essentially preventing it from "spreading").</p>

<p>A node individually verifies each transaction by comparing its attributes against a set of defined <a href="https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages" rel="nofollow noreferrer">protocol rules</a>.</p>

<p>In your case, <a href="https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages" rel="nofollow noreferrer">rule #14</a> states:</p>

<blockquote>
  <p>Reject if the sum of input values &lt; sum of output values</p>
</blockquote>

<p>The code for this behavior can be found in <a href="https://github.com/bitcoin/bitcoin/blob/6a135fbe5b30c3603616589b4779b1ce602c9392/src/consensus/tx_verify.cpp#L187" rel="nofollow noreferrer">tx_verify.cpp</a></p>

<pre><code>const CAmount value_out = tx.GetValueOut();

if (nValueIn &lt; value_out) {
    return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-belowout", false,
        strprintf("value in (%s) &lt; value out (%s)", FormatMoney(nValueIn), FormatMoney(value_out)));
}
</code></pre>

<p>While new Bitcoin addresses can be generated at any time, only an address capable of unlocking the output's <a href="http://learnmeabitcoin.com/glossary/scriptPubKey" rel="nofollow noreferrer">scriptPubKey</a> can be used to spend these funds.</p>

CC BY-SA 4.0
2019-04-15T23:48:17.707Z
2019-04-16T00:28:54.427Z
2019-04-16T00:28:54.427Z
Mason Ticehurst
<p>How do miners verify the blockchain transaction history to check if the sender has enough money if the address can be changed at any time?</p>

<transactions><blockchain><transaction-verification>
Checking if a receiver has enough coins
Leon Trotsky
# Checking if a receiver has enough coins

(Asked by: username_0 on 2019-04-15)

How do miners verify the blockchain transaction history to check if the sender has enough money if the address can be changed at any time?

**Tags:** transactions, blockchain, transaction-verification


---

## 2 answers

### Answer by username_1 on 2019-04-16. Score: 1 | Accepted answer

Bitcoin does not have the concept of account balance. Anyone who can provide a valid signature to the locking script of a particular transaction output can spend those bitcoins. As a result when you spend your bitcoins in a transaction, you have to include the transaction id and the output no. from which you earned those bitcoins. The nodes maintain a set of unspent transaction outputs (UTXOs) in the memory to check that this transaction output that has been referenced in the input has not been spent previously (this prevents double spending.)

If you want to send X BTC to a particular address, you will need to reference enough transactions in the input so that sum of all those unspent bitcoins >= X. This referenced transactions can come from different addresses. You just need to provide valid signature with your private key to show that you are the owner of those bitcoins.


---

### Answer by username_2 on 2019-04-15. Score: 0

A node will receive many transactions from other nodes through [network propagation](https://en.bitcoin.it/wiki/Network). If it determines that a transaction it has received is not valid, it will not relay the transaction to other nodes on the network (essentially preventing it from "spreading").

A node individually verifies each transaction by comparing its attributes against a set of defined [protocol rules](https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages).

In your case, [rule #14](https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages) states:

> Reject if the sum of input values < sum of output values

The code for this behavior can be found in [tx\_verify.cpp](https://github.com/bitcoin/bitcoin/blob/6a135fbe5b30c3603616589b4779b1ce602c9392/src/consensus/tx_verify.cpp#L187)

```
const CAmount value_out = tx.GetValueOut();

if (nValueIn < value_out) {
    return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-belowout", false,
        strprintf("value in (%s) < value out (%s)", FormatMoney(nValueIn), FormatMoney(value_out)));
}

```

While new Bitcoin addresses can be generated at any time, only an address capable of unlocking the output's [scriptPubKey](http://learnmeabitcoin.com/glossary/scriptPubKey) can be used to spend these funds.


---

