<p>The following scriptPubKey describes the desired contract:</p>

<pre><code>OP_IF
    OP_DUP OP_HASH160 &lt;Bob's pubKeyHash&gt;
OP_ELSE
    &lt;now+30 days&gt; OP_CHECKLOCKTIMEVERIFY OP_DROP
    OP_DUP OP_HASH160 &lt;Victor's pubKeyHash&gt;
OP_ENDIF
OP_EQUALVERIFY OP_CHECKSIG
</code></pre>

<p>Bob can spend the output using the scriptSig <code>&lt;Bob's signature&gt; &lt;Bob's pubKey&gt; OP_TRUE</code><br>
Victor can spend the output after 30 days using the scriptSig <code>&lt;Victor's signature&gt; &lt;Victor's pubKey&gt; OP_FALSE</code>.</p>

CC BY-SA 4.0
2019-03-28T02:38:11.627Z
http://bitcoin.sipa.be/miniscript/miniscript.html. Wouldn’t it rather be https://pastebin.com/pzQKN0ud ?
user2284570
CC BY-SA 4.0
2019-03-28T02:45:51.723Z
no I don't think you need that 1 and 2 there. In my version, Bob could pay by with <signature> <pubkey bob> 1  , and victor with <signature> <pubkey victor> 0 , but I don't doubt there is a better way
Fraggle
CC BY-SA 4.0
2019-03-28T02:47:32.587Z
This is after https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki#Escrow but which is for MultiSig in the case of Victor.
user2284570
CC BY-SA 4.0
2019-03-28T02:50:08.557Z
You don't need 1 and 2. Those are only required for OP_CHECKMULTISIG. This is just an OP_CHECKSIG which does not need a threshold number.
Ava Chow
CC BY-SA 4.0
2019-03-28T02:51:33.303Z
Yeah you don't need multi-sig right. Just bob can spend funds at any time, victor can spend funds after some time as long as bob hasn't already spent them. So no 1,2, multi-sig thing. Just Bob can spend, or Victor can spend after a time has past.
Fraggle
CC BY-SA 4.0
2019-03-28T02:55:09.147Z
@AndrewChow yes, I want to avoid MultiSig. Now just a question : how can I compile this to something ? And how to test the resulting script on bitcoin testnet ?
user2284570
CC BY-SA 4.0
2019-03-28T03:09:47.153Z
Check out https://github.com/kallewoof/btcdeb. That project produces two tools. `btcdeb` lets you give a script and execute it in order to debug the script and learn how it works. `btcc` can take a script written out in english and compile it to the actual bytes for the script.
Ava Chow
CC BY-SA 4.0
2019-03-28T13:56:37.683Z
@AndrewChow I mean something working online. I want to see what this gives in a block explorer, so I definitely need to broadcast on testnet. Like if Bob or Victor address would be changed as result (I mean the transaction would create virtual addresses).
user2284570
CC BY-SA 4.0
2019-03-28T14:28:30.943Z
There is no such thing as "virtual addresses". Bitcoin does not actually use addresses, they are just abstractions for humans. Such a script does not encode addresses and block explorers would not show that a transaction is sending to two addresses with this script. All they would show is a single address corresponding to the P2SH address that has this script as its redeemScript.
Ava Chow
CC BY-SA 4.0
2019-04-04T23:54:40.143Z
@AndrewChow ok… I found out what I was really meaning… I mean is it possible to use this in a pay‑to‑public‑key‑hash instead of a pay‑to‑public‑script‑hash transaction ? I definitely need the payment to appear to be made to at least Victor address or Bob address in the block explorer instead of script hash…
user2284570
CC BY-SA 4.0
2019-04-05T01:33:22.080Z
No, you can't. It is a script, a script is not a key. You cannot make a script be a key.
Ava Chow
CC BY-SA 4.0
2019-04-05T01:53:17.597Z
@AndrewChow I was thinking this because checksig is performed after each address in the similar case of https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki#trustless-payments-for-publishing-data. Of course, this means there’s no way Bob or Victor Balance would be changed in a block explorer.
user2284570
CC BY-SA 4.0
2019-04-16T22:20:39.870Z
@user2284570 so perhaps you want the output to not be a p2sh format, but rather have this script visible (when decoded from hex form) in the output? Anyway I think I answered the original question. Consider opening a new one for further refinements and mark this one as answered.
Fraggle
CC BY-SA 4.0
2019-03-28T02:31:52.250Z
2019-03-29T20:10:29.893Z
2019-03-29T20:10:29.893Z
Fraggle
<p>With a multisig wallet, several public keys are needed to spend an amount. But how to perform the reverse with time ?</p>

<p>I’m talking about this case where Alice performs a transaction where the output is sent to both Bob and Victor. With one point : Bob will be able to spend the transaction output immediately while Victor will only be able to do it after waiting some time if Bob didn’t spend it before Victor is allowed to do so.<br>
It doesn’t matter if Bob is still able to spend the output after Victor can. However Alice can’t get the public keys from Bob and Victor but only their address.</p>

<p>I’m thinking about something using OP_CHECKLOCKTIMEVERIFY or CHECKSEQUENCEVERIFY or nLockTime but I definitely fail to think about what the whole Opcode sequence might looks like. </p>

<transactions><script>
What’s the opcode sequence for doing the reverse of Multisig?
user2284570
# What’s the opcode sequence for doing the reverse of Multisig?

(Asked by: username_0 on 2019-03-28)

With a multisig wallet, several public keys are needed to spend an amount. But how to perform the reverse with time ?

I’m talking about this case where Alice performs a transaction where the output is sent to both Bob and Victor. With one point : Bob will be able to spend the transaction output immediately while Victor will only be able to do it after waiting some time if Bob didn’t spend it before Victor is allowed to do so.  
It doesn’t matter if Bob is still able to spend the output after Victor can. However Alice can’t get the public keys from Bob and Victor but only their address.

I’m thinking about something using OP\_CHECKLOCKTIMEVERIFY or CHECKSEQUENCEVERIFY or nLockTime but I definitely fail to think about what the whole Opcode sequence might looks like.

**Tags:** transactions, script


---

## 1 answers

### Answer by username_1 on 2019-03-28. Score: 2

The following scriptPubKey describes the desired contract:

```
OP_IF
    OP_DUP OP_HASH160 <Bob's pubKeyHash>
OP_ELSE
    <now+30 days> OP_CHECKLOCKTIMEVERIFY OP_DROP
    OP_DUP OP_HASH160 <Victor's pubKeyHash>
OP_ENDIF
OP_EQUALVERIFY OP_CHECKSIG

```

Bob can spend the output using the scriptSig `<Bob's signature> <Bob's pubKey> OP_TRUE`  
Victor can spend the output after 30 days using the scriptSig `<Victor's signature> <Victor's pubKey> OP_FALSE`.

> **Comments:**
> **username_0**: http://bitcoin.sipa.be/miniscript/miniscript.html. Wouldn’t it rather be https://pastebin.com/pzQKN0ud ?  
> **username_1**: no I don't think you need that 1 and 2 there. In my version, Bob could pay by with <signature> <pubkey bob> 1  , and victor with <signature> <pubkey victor> 0 , but I don't doubt there is a better way  
> **username_0**: This is after https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki#Escrow but which is for MultiSig in the case of Victor.  
> **username_2**: You don't need 1 and 2. Those are only required for OP_CHECKMULTISIG. This is just an OP_CHECKSIG which does not need a threshold number.  
> **username_1**: Yeah you don't need multi-sig right. Just bob can spend funds at any time, victor can spend funds after some time as long as bob hasn't already spent them. So no 1,2, multi-sig thing. Just Bob can spend, or Victor can spend after a time has past.  
> **username_0**: @AndrewChow yes, I want to avoid MultiSig. Now just a question : how can I compile this to something ? And how to test the resulting script on bitcoin testnet ?  
> **username_2**: Check out https://github.com/kallewoof/btcdeb. That project produces two tools. `btcdeb` lets you give a script and execute it in order to debug the script and learn how it works. `btcc` can take a script written out in english and compile it to the actual bytes for the script.  
> **username_0**: @AndrewChow I mean something working online. I want to see what this gives in a block explorer, so I definitely need to broadcast on testnet. Like if Bob or Victor address would be changed as result (I mean the transaction would create virtual addresses).  
> **username_2**: There is no such thing as "virtual addresses". Bitcoin does not actually use addresses, they are just abstractions for humans. Such a script does not encode addresses and block explorers would not show that a transaction is sending to two addresses with this script. All they would show is a single address corresponding to the P2SH address that has this script as its redeemScript.  
> **username_0**: @AndrewChow ok… I found out what I was really meaning… I mean is it possible to use this in a pay‑to‑public‑key‑hash instead of a pay‑to‑public‑script‑hash transaction ? I definitely need the payment to appear to be made to at least Victor address or Bob address in the block explorer instead of script hash…  
> **username_2**: No, you can't. It is a script, a script is not a key. You cannot make a script be a key.  
> **username_0**: @AndrewChow I was thinking this because checksig is performed after each address in the similar case of https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki#trustless-payments-for-publishing-data. Of course, this means there’s no way Bob or Victor Balance would be changed in a block explorer.  
> **username_1**: @username_0 so perhaps you want the output to not be a p2sh format, but rather have this script visible (when decoded from hex form) in the output? Anyway I think I answered the original question. Consider opening a new one for further refinements and mark this one as answered.  

---

