Does the Bitcoin protocol guarantee that within a valid block, if transaction B spends the outputs of transaction A, A will always precede B?
Or is it possible to have B before A?
Bitcoin Stack Exchange is a question and answer site for Bitcoin users, developers, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
The Bitcoin protocol requires transactions to appear in topological order in the blockchain. Given two transactions A and B where B spends an output of A:
Colloquially, a miner will never include a transaction in a block template until the transaction's requirements are met. Since B spends an output of A, B is not valid until A has created said output. To satisfy this dependency, B can only be included after A was included.