<p>Whereas it seems, that this is not directly possible, cause bitcoin script does not allow to reference a transaction "within last 30 days", one could think about a "workaround" with a business logic watching the P2SH address. An approach could be the nested "if", which is allowed in bitcoin script. If ever within last 30 days there was a payment, the 30 days need to get "reset" - maybe you would need to play with two P2SH addresses, and shift the funds to a second addresses (and vice versa). If your business logic discovers a transaction in the last 30 days, the funds are transferred to a second address, and then again to the first address. For this second address you'd have the same set of rules, just the tx output script (for it's address) changes. The business logic could have a "known secret", that noone else knows, and then shift the funds between the addresses, just as an idea, like this:</p>

<pre><code>IF
  OP_HASH160  &lt;length 0x14&gt; &lt;SECRET&gt; OP_EQUAL
  &lt;business pubkey&gt; CHECKSIG
ELSE
  IF
    2 &lt;Alice's pubkey&gt; &lt;Bob's pubkey&gt; &lt;Escrow's pubkey&gt; 3 CHECKMULTISIG
  ELSE
    30d CHECKSEQUENCEVERIFY DROP
    &lt;Alice's pubkey&gt; CHECKSIG
  ENDIF
ENDIF
</code></pre>

<p>Obviously it becomes clear, that there are fees involved in such a scenario. It depends on the frequency of transactions within last 30 days, and the value of the funds, that are shifted around. The fees should not eat up your funds... And then again, maybe one might look into using Lightning as "transport mechanism" to shift values around?</p>

CC BY-SA 4.0
2018-05-29T07:52:24.563Z
2018-05-29T07:52:24.563Z
pebwindkraft
<p>One workaround if the multi-sig address is not in cold storage and your usecase allows for it, would be to spend all the coins in the multi-sig address every time you make a new deposit to this address, thereby resetting the timer by "overwriting" it.</p>

<p>So if you have X coins in the multi-sig and want to deposit Y new coins, you make a transaction that also spends those X coins (requiring both signers to sign it) and make a new output of X+Y coins. </p>

<p>The output-script would then always be of the form:</p>

<pre><code>IF
    2
ELSE
    30d CHECKSEQUENCEVERIFY DROP
    1
ENDIF
&lt;Alice's pubkey&gt; &lt;Bob's pubkey&gt; 2 CHECKMULTISIG
</code></pre>

<p>This would result in always exactly one unspent output in the multi-sig address with the current timer running. </p>

CC BY-SA 4.0
2018-05-29T08:53:22.787Z
2018-05-29T09:38:09.680Z
2018-05-29T09:38:09.680Z
Bjarne Magnussen
<blockquote>
  <p>...to use only their single key after a set amount of time after each transaction/update on the address?</p>
</blockquote>

<p>This is not possible as there is no provision in bitcoin script to query past transactions within another transaction, so you cannot check the time of the last transaction to that address.</p>

CC BY-SA 4.0
2018-05-29T06:32:42.907Z
2018-05-29T06:32:42.907Z
Raghav Sood
<p>Is there a way where i can have a multi-sig address which will allow one of the signers to use only their single key after a set amount of time after each transaction/update on the address? </p>

<p>I want to have an address that requires 2 people to sign for outgoing transactions. But if after 30 days nothing has been done with the address at all a single signer can sign a transaction. But if there is ever anything such as an incoming or outgoing transaction the 30 days is reset.</p>

<bitcoin-core><locktime><checksequenceverify>
CHECKSEQUENCEVERIFY After x time of last transaction
PixelPaul
# CHECKSEQUENCEVERIFY After x time of last transaction

(Asked by: username_0 on 2018-05-29)

Is there a way where i can have a multi-sig address which will allow one of the signers to use only their single key after a set amount of time after each transaction/update on the address?

I want to have an address that requires 2 people to sign for outgoing transactions. But if after 30 days nothing has been done with the address at all a single signer can sign a transaction. But if there is ever anything such as an incoming or outgoing transaction the 30 days is reset.

**Tags:** bitcoin-core, locktime, checksequenceverify


---

## 3 answers

### Answer by username_1 on 2018-05-29. Score: 1

Whereas it seems, that this is not directly possible, cause bitcoin script does not allow to reference a transaction "within last 30 days", one could think about a "workaround" with a business logic watching the P2SH address. An approach could be the nested "if", which is allowed in bitcoin script. If ever within last 30 days there was a payment, the 30 days need to get "reset" - maybe you would need to play with two P2SH addresses, and shift the funds to a second addresses (and vice versa). If your business logic discovers a transaction in the last 30 days, the funds are transferred to a second address, and then again to the first address. For this second address you'd have the same set of rules, just the tx output script (for it's address) changes. The business logic could have a "known secret", that noone else knows, and then shift the funds between the addresses, just as an idea, like this:

```
IF
  OP_HASH160  <length 0x14> <SECRET> OP_EQUAL
  <business pubkey> CHECKSIG
ELSE
  IF
    2 <Alice's pubkey> <Bob's pubkey> <Escrow's pubkey> 3 CHECKMULTISIG
  ELSE
    30d CHECKSEQUENCEVERIFY DROP
    <Alice's pubkey> CHECKSIG
  ENDIF
ENDIF

```

Obviously it becomes clear, that there are fees involved in such a scenario. It depends on the frequency of transactions within last 30 days, and the value of the funds, that are shifted around. The fees should not eat up your funds... And then again, maybe one might look into using Lightning as "transport mechanism" to shift values around?


---

### Answer by username_2 on 2018-05-29. Score: 0

One workaround if the multi-sig address is not in cold storage and your usecase allows for it, would be to spend all the coins in the multi-sig address every time you make a new deposit to this address, thereby resetting the timer by "overwriting" it.

So if you have X coins in the multi-sig and want to deposit Y new coins, you make a transaction that also spends those X coins (requiring both signers to sign it) and make a new output of X+Y coins.

The output-script would then always be of the form:

```
IF
    2
ELSE
    30d CHECKSEQUENCEVERIFY DROP
    1
ENDIF
<Alice's pubkey> <Bob's pubkey> 2 CHECKMULTISIG

```

This would result in always exactly one unspent output in the multi-sig address with the current timer running.


---

### Answer by username_3 on 2018-05-29. Score: 0

> ...to use only their single key after a set amount of time after each transaction/update on the address?

This is not possible as there is no provision in bitcoin script to query past transactions within another transaction, so you cannot check the time of the last transaction to that address.


---

