public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Daniel Robinson <danrobinson010@gmail.com>
To: Praveen Baratam <praveen.baratam@gmail.com>,
	 Bitcoin Protocol Discussion
	<bitcoin-dev@lists.linuxfoundation.org>
Subject: Re: [bitcoin-dev] Multi CSV Transaction
Date: Wed, 21 Feb 2018 00:59:45 +0000	[thread overview]
Message-ID: <CAD438Hvb2k4iCwJ91x5j+tgx-d_eLdBKvLWZfea87HPdKeYgAA@mail.gmail.com> (raw)
In-Reply-To: <CAAQs3wucifHfjZ6VJJ2tWL-vzERzL=341aCL666MY+6_vKC-yQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1818 bytes --]

Yes, although it's a functionality of Bitcoin Script generally, not OP_CSV
in particular. Bitcoin Script allows you to use nested IF statements, and
enforce whatever different conditions you want in each branch.

Here's your contract in Ivy <https://ivy-lang.org/bitcoin/>:

contract MultiCSV(
  bob: PublicKey,
  carol: PublicKey,
  bobDelay: Duration,
  carolDelay: Duration,
  val: Value
) {
  clause bobSpend(sig: Signature) {
    verify checkSig(bob, sig)
    verify older(bobDelay)
    unlock val
  }
  clause carolSpend(sig: Signature) {
    verify checkSig(carol, sig)
    verify older(carolDelay)
    unlock val
  }
  clause bothSpend(bobSig: Signature, carolSig: Signature) {
    verify checkMultiSig([bob, carol], [bobSig, carolSig])
    unlock val
  }
}

It compiles to the following Bitcoin Script:

PUSH(carolKey) PUSH(bobKey) 2 PICK 2 EQUAL IF ROT DROP 0 4 ROLL 4 ROLL 2
2ROT 2 CHECKMULTISIG ELSE ROT IF DROP CHECKSIGVERIFY PUSH(carolDelay)
CHECKSEQUENCEVERIFY DROP 1 ELSE NIP CHECKSIGVERIFY PUSH(bobDelay)
CHECKSEQUENCEVERIFY DROP 1 ENDIF ENDIF

On Tue, Feb 20, 2018 at 5:32 PM Praveen Baratam via bitcoin-dev <
bitcoin-dev@lists.linuxfoundation.org> wrote:

> Hello Everybody,
>
> I need a little clarity about how OP_CHECKSEQUENCEVERIFY (CSV) works in
> transactions.
>
> Can I use multiple CSV end points as depicted in the figure below? I
> basically want to allow different conditions at different delays.
>
> [image: Multi CSV.png]
>
> I just want to know if OP_CHECKSEQUENCEVERIFY can be used to achieve the
> above.
>
> Thank you.
>
> Praveen
> ᐧ
> _______________________________________________
> bitcoin-dev mailing list
> bitcoin-dev@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>

[-- Attachment #1.2: Type: text/html, Size: 3768 bytes --]

[-- Attachment #2: Multi CSV.png --]
[-- Type: image/png, Size: 119739 bytes --]

  reply	other threads:[~2018-02-21  0:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 16:53 [bitcoin-dev] Multi CSV Transaction Praveen Baratam
2018-02-21  0:59 ` Daniel Robinson [this message]
2018-02-21  2:36   ` Praveen Baratam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAD438Hvb2k4iCwJ91x5j+tgx-d_eLdBKvLWZfea87HPdKeYgAA@mail.gmail.com \
    --to=danrobinson010@gmail.com \
    --cc=bitcoin-dev@lists.linuxfoundation.org \
    --cc=praveen.baratam@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox