Bitcoin miners have the entire record of all transactions, so when they receive a new transaction they check that the inputs to the new transaction are valid outputs of previous transactions and that the inputs have not been spent already
https://t.co/p8ynBpnB5U
