<p>It is not possible to make a transaction which is valid in the past invalid in the future (except in specific cases around soft fork activation). The best you can do is to make it more likely that a conflicting transaction is accepted.</p>
<p>What you could do is making a double spending transaction that has a timelock (so it can't be confirmed until the &quot;expiration&quot;) and pays a higher transaction fee rate. So once the timelock is passed, the transaction becomes a RBF transaction for the original, making it much more likely to become confirmed. Once confirmed, it would cause the original to become invalid and thus &quot;expired&quot;.</p>

CC BY-SA 4.0
2021-08-05T07:39:42.973Z
Huh. Bitcoin "stop payment".
chrylis -cautiouslyoptimistic-
CC BY-SA 4.0
2021-08-04T22:17:36.483Z
2021-08-04T22:17:36.483Z
Ava Chow
<p>I want to generate a transaction that spends funds to a wallet controlled by a third party,  but for this transaction to only remain valid for a certain window of time. This could mean a transaction that excecutes successfully if it is accepted within the next three blocks but fails if it is executed after the next three blocks. Let's assume that information such as block height information is known.</p>
<p>I understand that the default response is to say &quot;Bitcoin transactions do not expire [...] so you should just give up.&quot; Any creative solution would be appreciated, consider this a challenge if need be.</p>
<p>A few things that come to my mind that may help you deliver a solution:</p>
<ul>
<li>Spending funds to a wallet that a third party controls is not the same thing as spending to an address that a third-party provides.
<ul>
<li>You could potentially make use of the public key to generate an address with weirdness or make use of bitcoin script.</li>
</ul>
</li>
<li>You could potentially make use of two-way communication between the sender and reciever here.</li>
</ul>

CC BY-SA 4.0
2023-03-27T13:15:33.643Z
Related: https://bitcoin.stackexchange.com/a/116927/5406
Murch
<transactions><public-key>
How can I generate expiring transactions?
SuspiciousTuna
# How can I generate expiring transactions?

(Asked by: username_0 on 2021-08-04)

I want to generate a transaction that spends funds to a wallet controlled by a third party, but for this transaction to only remain valid for a certain window of time. This could mean a transaction that excecutes successfully if it is accepted within the next three blocks but fails if it is executed after the next three blocks. Let's assume that information such as block height information is known.

I understand that the default response is to say "Bitcoin transactions do not expire [...] so you should just give up." Any creative solution would be appreciated, consider this a challenge if need be.

A few things that come to my mind that may help you deliver a solution:

* Spending funds to a wallet that a third party controls is not the same thing as spending to an address that a third-party provides.
  + You could potentially make use of the public key to generate an address with weirdness or make use of bitcoin script.
* You could potentially make use of two-way communication between the sender and reciever here.

**Tags:** transactions, public-key

> **Comments:**
> **username_1**: Related: https://bitcoin.stackexchange.com/a/116927/5406  

---

## 1 answers

### Answer by username_2 on 2021-08-04. Score: 5

It is not possible to make a transaction which is valid in the past invalid in the future (except in specific cases around soft fork activation). The best you can do is to make it more likely that a conflicting transaction is accepted.

What you could do is making a double spending transaction that has a timelock (so it can't be confirmed until the "expiration") and pays a higher transaction fee rate. So once the timelock is passed, the transaction becomes a RBF transaction for the original, making it much more likely to become confirmed. Once confirmed, it would cause the original to become invalid and thus "expired".

> **Comments:**
> **username_3**: Huh. Bitcoin "stop payment".  

---

