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?


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.


A node will receive many transactions from other nodes through network propagation. 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.

In your case, rule #14 states:

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

The code for this behavior can be found in tx_verify.cpp

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 can be used to spend these funds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.