0
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.
http://bitcoin.sipa.be/miniscript/miniscript.html. Wouldn’t it rather be https://pastebin.com/pzQKN0ud ? – user2284570 – 2019-03-28T02:38:11.627
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 – 2019-03-28T02:45:51.723
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 – 2019-03-28T02:47:32.5871You 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. – Andrew Chow – 2019-03-28T02:50:08.557
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 – 2019-03-28T02:51:33.303
@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 – 2019-03-28T02:55:09.147
Check out https://github.com/kallewoof/btcdeb. That project produces two tools.
– Andrew Chow – 2019-03-28T03:09:47.153btcdeblets you give a script and execute it in order to debug the script and learn how it works.btcccan take a script written out in english and compile it to the actual bytes for the script.@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 – 2019-03-28T13:56:37.683
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. – Andrew Chow – 2019-03-28T14:28:30.943
@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 – 2019-04-04T23:54:40.143
No, you can't. It is a script, a script is not a key. You cannot make a script be a key. – Andrew Chow – 2019-04-05T01:33:22.080
@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 – 2019-04-05T01:53:17.597@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 – 2019-04-16T22:20:39.870