Let's say I have a wallet X with money from 3 unspent outputs (UTXOs) A, B and C.

I make an nlocktime transaction to spend 2 of my 3 UTXOs (A & B) to wallet Y, 1 month in the future, sign it, and give it to someone (actually the owner of wallet Y) so that this person can broadcast it later.

Now, let's say a week later, before the nlocktime's block happens, I go and spend one of the UTXOs of the nlocktime transaction (A), but not the other (B).

Will the person that receives the 1st transaction be able to spend the UTXO B in the end? Or would my 2nd transaction render the entire 1st transaction invalid?



Since one of the inputs of the nLockTime transaction has been spent already, the nLockTime transaction becomes invalid, as not all referenced inputs are available for spending.

This is described in the Bitcoin developers guide explicitly as a way to cancel a locktime transaction:

If any of the signers change their mind, they can create a new non-locktime transaction. The new transaction will use, as one of its inputs, one of the same outputs which was used as an input to the locktime transaction. This makes the locktime transaction invalid if the new transaction is added to the block chain before the time lock expires.

Before the time or block height specified for the nLockTime transaction is reached, the transaction is considered invalid and will not be stored or relayed by (other) nodes. This has been weakened in 0.9.0 so that transactions one block within nLockTime are accepted for relay but not yet for inclusion.

  • Note that if this behaviour (possibility to early spend) is undesired, for example Lightning Network prevents that by locking the the coins in a (2-of-2 multisig OR 1 timelocked signature) script so that early spending is only possible if both parties agree. – Jannes Aug 15 '16 at 16:48

Wallet Y won't receive payment until nLockTime condition passed and transaction included into a block.

AFAIK most peers won't relay nlocktime with 1 month in the future. https://bitcoin.stackexchange.com/a/26983/12049

Once transaction gets included into the blockchain, it can't be undone.

So the second transaction spending B is valid, and the first transaction spending A+B is invalid DOUBLE SPEND!

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.