Docs: rename institution to party

This commit is contained in:
Mike Hearn 2015-11-30 17:06:59 +00:00
parent 8ea4ac8b15
commit c4d383bf67
7 changed files with 46 additions and 46 deletions

View File

@ -35,8 +35,8 @@ maximise flexibility for the contract developer.
A transaction has one or more **signatures** attached to it. The signatures do not mean anything by themselves, rather, A transaction has one or more **signatures** attached to it. The signatures do not mean anything by themselves, rather,
their existence is given as input to the contract which can then decide which set of signatures it demands (if any). their existence is given as input to the contract which can then decide which set of signatures it demands (if any).
Signatures may be from an arbitrary, random **public key** that has no identity attached. A public key may be Signatures may be from an arbitrary, random **public key** that has no identity attached. A public key may be
well known, that is, appears in some sort of public identity registry. In this case we say the key is owned by an well known, that is, appears in some sort of public identity registry. In this case we say the key is owned by a
**institution**, which is defined (for now) as being merely a (public key, name) pair. **party**, which is defined (for now) as being merely a (public key, name) pair.
A transaction may also be **timestamped**. A timestamp is a (hash, datetime, signature) triple from a A transaction may also be **timestamped**. A timestamp is a (hash, datetime, signature) triple from a
*timestamping authority* (TSA). The notion of a TSA is not ledger specific and is defined by *timestamping authority* (TSA). The notion of a TSA is not ledger specific and is defined by
@ -125,15 +125,15 @@ two contracts in the repository:
1. Cash 1. Cash
2. Commercial paper 2. Commercial paper
``Cash`` implements the idea of a claim on some quantity of deposits at some institution, denominated in some currency, ``Cash`` implements the idea of a claim on some quantity of deposits at some institutional party, denominated in some currency,
identified by some *deposit reference*. A deposit reference is an opaque byte array which is usable by identified by some *deposit reference*. A deposit reference is an opaque byte array which is usable by
the issuing institution for internal bookkeeping purposes. the issuing party for internal bookkeeping purposes.
Cash states are *fungible* with each other (can be merged and split arbitrarily) if they use the same currency, Cash states are *fungible* with each other (can be merged and split arbitrarily) if they use the same currency,
institution and deposit reference. party and deposit reference.
``CommercialPaper`` implements an asset with a *face value* denominated in a certain currency, which may be redeemed at ``CommercialPaper`` implements an asset with a *face value* denominated in a certain currency, which may be redeemed at
the issuing institution after a certain time. Commercial paper states define the face value (e.g. $1000) and the time the issuing party after a certain time. Commercial paper states define the face value (e.g. $1000) and the time
at which they may be redeemed. The contract allows the paper to be issued, traded and redeemed. The commercial paper at which they may be redeemed. The contract allows the paper to be issued, traded and redeemed. The commercial paper
contract is implemented twice, once in Java and once in a language called Kotlin. contract is implemented twice, once in Java and once in a language called Kotlin.

View File

@ -156,7 +156,7 @@ Beyond that it's a freeform object into which we can put anything which can be s
We have four fields in our state: We have four fields in our state:
* ``issuance``: a reference to a specific piece of commercial paper at an institution * ``issuance``: a reference to a specific piece of commercial paper at a party
* ``owner``: the public key of the current owner. This is the same concept as seen in Bitcoin: the public key has no * ``owner``: the public key of the current owner. This is the same concept as seen in Bitcoin: the public key has no
attached identity and is expected to be one-time-use for privacy reasons. However, unlike in Bitcoin, we model attached identity and is expected to be one-time-use for privacy reasons. However, unlike in Bitcoin, we model
ownership at the level of individual contracts rather than as a platform-level concept as we envisage many ownership at the level of individual contracts rather than as a platform-level concept as we envisage many
@ -349,7 +349,7 @@ logic.
requireThat { requireThat {
// Don't allow people to issue commercial paper under other entities identities. // Don't allow people to issue commercial paper under other entities identities.
"the issuance is signed by the claimed issuer of the paper" by "the issuance is signed by the claimed issuer of the paper" by
(command.signers.contains(output.issuance.institution.owningKey)) (command.signers.contains(output.issuance.party.owningKey))
"the face value is not zero" by (output.faceValue.pennies > 0) "the face value is not zero" by (output.faceValue.pennies > 0)
"the maturity date is not in the past" by (time < output.maturityDate ) "the maturity date is not in the past" by (time < output.maturityDate )
// Don't allow an existing CP state to be replaced by this issuance. // Don't allow an existing CP state to be replaced by this issuance.
@ -437,7 +437,7 @@ been changed, save for the public key of the owner.
If the command is a ``Redeem`` command, then the requirements are more complex: If the command is a ``Redeem`` command, then the requirements are more complex:
1. We want to see that the face value of the CP is being moved as a cash claim against some institution, that is, the 1. We want to see that the face value of the CP is being moved as a cash claim against some party, that is, the
issuer of the CP is really paying back the face value. issuer of the CP is really paying back the face value.
2. The transaction must be happening after the maturity date. 2. The transaction must be happening after the maturity date.
3. The commercial paper must *not* be propagated by this transaction: it must be deleted, by the group having no 3. The commercial paper must *not* be propagated by this transaction: it must be deleted, by the group having no
@ -500,7 +500,7 @@ We start by defining a new test class, with a basic CP state:
} }
} }
We start by defining a commercial paper state. It will be owned by a pre-defined unit test institution, affectionately We start by defining a commercial paper state. It will be owned by a pre-defined unit test party, affectionately
called ``MEGA_CORP`` (this constant, along with many others, is defined in ``TestUtils.kt``). Due to Kotin's extensive called ``MEGA_CORP`` (this constant, along with many others, is defined in ``TestUtils.kt``). Due to Kotin's extensive
type inference, many types are not written out explicitly in this code and it has the feel of a scripting language. type inference, many types are not written out explicitly in this code and it has the feel of a scripting language.
But the types are there, and you can ask IntelliJ to reveal them by pressing Alt-Enter on a "val" or "var" and selecting But the types are there, and you can ask IntelliJ to reveal them by pressing Alt-Enter on a "val" or "var" and selecting
@ -658,11 +658,11 @@ a method to wrap up the issuance process:
.. sourcecode:: kotlin .. sourcecode:: kotlin
fun craftIssue(issuance: InstitutionReference, faceValue: Amount, maturityDate: Instant): PartialTransaction { fun craftIssue(issuance: InstitutionReference, faceValue: Amount, maturityDate: Instant): PartialTransaction {
val state = State(issuance, issuance.institution.owningKey, faceValue, maturityDate) val state = State(issuance, issuance.party.owningKey, faceValue, maturityDate)
return PartialTransaction(state, WireCommand(Commands.Issue, issuance.institution.owningKey)) return PartialTransaction(state, WireCommand(Commands.Issue, issuance.party.owningKey))
} }
We take a reference that points to the issuing institution (i.e. the caller) and which can contain any internal We take a reference that points to the issuing party (i.e. the caller) and which can contain any internal
bookkeeping/reference numbers that we may require. Then the face value of the paper, and the maturity date. It bookkeeping/reference numbers that we may require. Then the face value of the paper, and the maturity date. It
returns a ``PartialTransaction``. A ``PartialTransaction`` is one of the few mutable classes the platform provides. returns a ``PartialTransaction``. A ``PartialTransaction`` is one of the few mutable classes the platform provides.
It allows you to add inputs, outputs and commands to it and is designed to be passed around, potentially between It allows you to add inputs, outputs and commands to it and is designed to be passed around, potentially between
@ -675,12 +675,12 @@ multiple contracts.
an issuer should issue the CP (starting out owned by themselves), and then sell it in a separate transaction. an issuer should issue the CP (starting out owned by themselves), and then sell it in a separate transaction.
The function we define creates a ``CommercialPaper.State`` object that mostly just uses the arguments we were given, The function we define creates a ``CommercialPaper.State`` object that mostly just uses the arguments we were given,
but it fills out the owner field of the state to be the same public key as the issuing institution. If the caller wants but it fills out the owner field of the state to be the same public key as the issuing party. If the caller wants
to issue CP onto the ledger that's immediately owned by someone else, they'll have to create the state themselves. to issue CP onto the ledger that's immediately owned by someone else, they'll have to create the state themselves.
The returned partial transaction has a ``WireCommand`` object as a parameter. This is a container for any object The returned partial transaction has a ``WireCommand`` object as a parameter. This is a container for any object
that implements the ``Command`` interface, along with a key that is expected to sign this transaction. In this case, that implements the ``Command`` interface, along with a key that is expected to sign this transaction. In this case,
issuance requires that the issuing institution sign, so we put the key of the institution there. issuance requires that the issuing party sign, so we put the key of the party there.
The ``PartialTransaction`` constructor we used above takes a variable argument list for convenience. You can pass in The ``PartialTransaction`` constructor we used above takes a variable argument list for convenience. You can pass in
any ``ContractStateRef`` (input), ``ContractState`` (output) or ``Command`` objects and it'll build up the transaction any ``ContractStateRef`` (input), ``ContractState`` (output) or ``Command`` objects and it'll build up the transaction

View File

@ -169,8 +169,8 @@ maximise flexibility for the contract developer.</p>
<p>A transaction has one or more <strong>signatures</strong> attached to it. The signatures do not mean anything by themselves, rather, <p>A transaction has one or more <strong>signatures</strong> attached to it. The signatures do not mean anything by themselves, rather,
their existence is given as input to the contract which can then decide which set of signatures it demands (if any). their existence is given as input to the contract which can then decide which set of signatures it demands (if any).
Signatures may be from an arbitrary, random <strong>public key</strong> that has no identity attached. A public key may be Signatures may be from an arbitrary, random <strong>public key</strong> that has no identity attached. A public key may be
well known, that is, appears in some sort of public identity registry. In this case we say the key is owned by an well known, that is, appears in some sort of public identity registry. In this case we say the key is owned by a
<strong>institution</strong>, which is defined (for now) as being merely a (public key, name) pair.</p> <strong>party</strong>, which is defined (for now) as being merely a (public key, name) pair.</p>
<p>A transaction may also be <strong>timestamped</strong>. A timestamp is a (hash, datetime, signature) triple from a <p>A transaction may also be <strong>timestamped</strong>. A timestamp is a (hash, datetime, signature) triple from a
<em>timestamping authority</em> (TSA). The notion of a TSA is not ledger specific and is defined by <em>timestamping authority</em> (TSA). The notion of a TSA is not ledger specific and is defined by
<a class="reference external" href="https://www.ietf.org/rfc/rfc3161.txt">IETF RFC 3161</a> which defines the internet standard Timestamping Protocol (TSP). <a class="reference external" href="https://www.ietf.org/rfc/rfc3161.txt">IETF RFC 3161</a> which defines the internet standard Timestamping Protocol (TSP).
@ -257,13 +257,13 @@ two contracts in the repository:</p>
<li>Cash</li> <li>Cash</li>
<li>Commercial paper</li> <li>Commercial paper</li>
</ol> </ol>
<p><code class="docutils literal"><span class="pre">Cash</span></code> implements the idea of a claim on some quantity of deposits at some institution, denominated in some currency, <p><code class="docutils literal"><span class="pre">Cash</span></code> implements the idea of a claim on some quantity of deposits at some institutional party, denominated in some currency,
identified by some <em>deposit reference</em>. A deposit reference is an opaque byte array which is usable by identified by some <em>deposit reference</em>. A deposit reference is an opaque byte array which is usable by
the issuing institution for internal bookkeeping purposes.</p> the issuing party for internal bookkeeping purposes.</p>
<p>Cash states are <em>fungible</em> with each other (can be merged and split arbitrarily) if they use the same currency, <p>Cash states are <em>fungible</em> with each other (can be merged and split arbitrarily) if they use the same currency,
institution and deposit reference.</p> party and deposit reference.</p>
<p><code class="docutils literal"><span class="pre">CommercialPaper</span></code> implements an asset with a <em>face value</em> denominated in a certain currency, which may be redeemed at <p><code class="docutils literal"><span class="pre">CommercialPaper</span></code> implements an asset with a <em>face value</em> denominated in a certain currency, which may be redeemed at
the issuing institution after a certain time. Commercial paper states define the face value (e.g. $1000) and the time the issuing party after a certain time. Commercial paper states define the face value (e.g. $1000) and the time
at which they may be redeemed. The contract allows the paper to be issued, traded and redeemed. The commercial paper at which they may be redeemed. The contract allows the paper to be issued, traded and redeemed. The commercial paper
contract is implemented twice, once in Java and once in a language called Kotlin.</p> contract is implemented twice, once in Java and once in a language called Kotlin.</p>
<p>Each contract comes with unit tests.</p> <p>Each contract comes with unit tests.</p>

File diff suppressed because one or more lines are too long

View File

@ -279,7 +279,7 @@ the bytecode of the contract itself. For now this is a dummy value and isn&#8217
Beyond that it&#8217;s a freeform object into which we can put anything which can be serialized.</p> Beyond that it&#8217;s a freeform object into which we can put anything which can be serialized.</p>
<p>We have four fields in our state:</p> <p>We have four fields in our state:</p>
<ul class="simple"> <ul class="simple">
<li><code class="docutils literal"><span class="pre">issuance</span></code>: a reference to a specific piece of commercial paper at an institution</li> <li><code class="docutils literal"><span class="pre">issuance</span></code>: a reference to a specific piece of commercial paper at a party</li>
<li><code class="docutils literal"><span class="pre">owner</span></code>: the public key of the current owner. This is the same concept as seen in Bitcoin: the public key has no <li><code class="docutils literal"><span class="pre">owner</span></code>: the public key of the current owner. This is the same concept as seen in Bitcoin: the public key has no
attached identity and is expected to be one-time-use for privacy reasons. However, unlike in Bitcoin, we model attached identity and is expected to be one-time-use for privacy reasons. However, unlike in Bitcoin, we model
ownership at the level of individual contracts rather than as a platform-level concept as we envisage many ownership at the level of individual contracts rather than as a platform-level concept as we envisage many
@ -447,7 +447,7 @@ logic.</p>
<span class="n">requireThat</span> <span class="p">{</span> <span class="n">requireThat</span> <span class="p">{</span>
<span class="c1">// Don&#39;t allow people to issue commercial paper under other entities identities.</span> <span class="c1">// Don&#39;t allow people to issue commercial paper under other entities identities.</span>
<span class="s">&quot;the issuance is signed by the claimed issuer of the paper&quot;</span> <span class="k">by</span> <span class="s">&quot;the issuance is signed by the claimed issuer of the paper&quot;</span> <span class="k">by</span>
<span class="p">(</span><span class="n">command</span><span class="p">.</span><span class="n">signers</span><span class="p">.</span><span class="n">contains</span><span class="p">(</span><span class="n">output</span><span class="p">.</span><span class="n">issuance</span><span class="p">.</span><span class="n">institution</span><span class="p">.</span><span class="n">owningKey</span><span class="p">))</span> <span class="p">(</span><span class="n">command</span><span class="p">.</span><span class="n">signers</span><span class="p">.</span><span class="n">contains</span><span class="p">(</span><span class="n">output</span><span class="p">.</span><span class="n">issuance</span><span class="p">.</span><span class="n">party</span><span class="p">.</span><span class="n">owningKey</span><span class="p">))</span>
<span class="s">&quot;the face value is not zero&quot;</span> <span class="k">by</span> <span class="p">(</span><span class="n">output</span><span class="p">.</span><span class="n">faceValue</span><span class="p">.</span><span class="n">pennies</span> <span class="p">&gt;</span> <span class="m">0</span><span class="p">)</span> <span class="s">&quot;the face value is not zero&quot;</span> <span class="k">by</span> <span class="p">(</span><span class="n">output</span><span class="p">.</span><span class="n">faceValue</span><span class="p">.</span><span class="n">pennies</span> <span class="p">&gt;</span> <span class="m">0</span><span class="p">)</span>
<span class="s">&quot;the maturity date is not in the past&quot;</span> <span class="k">by</span> <span class="p">(</span><span class="n">time</span> <span class="p">&lt;</span> <span class="n">output</span><span class="p">.</span><span class="n">maturityDate</span> <span class="p">)</span> <span class="s">&quot;the maturity date is not in the past&quot;</span> <span class="k">by</span> <span class="p">(</span><span class="n">time</span> <span class="p">&lt;</span> <span class="n">output</span><span class="p">.</span><span class="n">maturityDate</span> <span class="p">)</span>
<span class="c1">// Don&#39;t allow an existing CP state to be replaced by this issuance.</span> <span class="c1">// Don&#39;t allow an existing CP state to be replaced by this issuance.</span>
@ -532,7 +532,7 @@ allowed to delete the CP from the ledger. The grouping logic already ensured tha
been changed, save for the public key of the owner.</p> been changed, save for the public key of the owner.</p>
<p>If the command is a <code class="docutils literal"><span class="pre">Redeem</span></code> command, then the requirements are more complex:</p> <p>If the command is a <code class="docutils literal"><span class="pre">Redeem</span></code> command, then the requirements are more complex:</p>
<ol class="arabic simple"> <ol class="arabic simple">
<li>We want to see that the face value of the CP is being moved as a cash claim against some institution, that is, the <li>We want to see that the face value of the CP is being moved as a cash claim against some party, that is, the
issuer of the CP is really paying back the face value.</li> issuer of the CP is really paying back the face value.</li>
<li>The transaction must be happening after the maturity date.</li> <li>The transaction must be happening after the maturity date.</li>
<li>The commercial paper must <em>not</em> be propagated by this transaction: it must be deleted, by the group having no <li>The commercial paper must <em>not</em> be propagated by this transaction: it must be deleted, by the group having no
@ -588,7 +588,7 @@ benefit from the DSL and would write them by hand).</p>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<p>We start by defining a commercial paper state. It will be owned by a pre-defined unit test institution, affectionately <p>We start by defining a commercial paper state. It will be owned by a pre-defined unit test party, affectionately
called <code class="docutils literal"><span class="pre">MEGA_CORP</span></code> (this constant, along with many others, is defined in <code class="docutils literal"><span class="pre">TestUtils.kt</span></code>). Due to Kotin&#8217;s extensive called <code class="docutils literal"><span class="pre">MEGA_CORP</span></code> (this constant, along with many others, is defined in <code class="docutils literal"><span class="pre">TestUtils.kt</span></code>). Due to Kotin&#8217;s extensive
type inference, many types are not written out explicitly in this code and it has the feel of a scripting language. type inference, many types are not written out explicitly in this code and it has the feel of a scripting language.
But the types are there, and you can ask IntelliJ to reveal them by pressing Alt-Enter on a &#8220;val&#8221; or &#8220;var&#8221; and selecting But the types are there, and you can ask IntelliJ to reveal them by pressing Alt-Enter on a &#8220;val&#8221; or &#8220;var&#8221; and selecting
@ -726,13 +726,13 @@ like a module), the basic concept is the same: preparation of a transaction usin
a method to wrap up the issuance process:</p> a method to wrap up the issuance process:</p>
<div class="codeset container"> <div class="codeset container">
<div class="highlight-kotlin"><div class="highlight"><pre><span class="k">fun</span> <span class="nf">craftIssue</span><span class="p">(</span><span class="n">issuance</span><span class="p">:</span> <span class="n">InstitutionReference</span><span class="p">,</span> <span class="n">faceValue</span><span class="p">:</span> <span class="n">Amount</span><span class="p">,</span> <span class="n">maturityDate</span><span class="p">:</span> <span class="n">Instant</span><span class="p">):</span> <span class="n">PartialTransaction</span> <span class="p">{</span> <div class="highlight-kotlin"><div class="highlight"><pre><span class="k">fun</span> <span class="nf">craftIssue</span><span class="p">(</span><span class="n">issuance</span><span class="p">:</span> <span class="n">InstitutionReference</span><span class="p">,</span> <span class="n">faceValue</span><span class="p">:</span> <span class="n">Amount</span><span class="p">,</span> <span class="n">maturityDate</span><span class="p">:</span> <span class="n">Instant</span><span class="p">):</span> <span class="n">PartialTransaction</span> <span class="p">{</span>
<span class="k">val</span> <span class="py">state</span> <span class="p">=</span> <span class="n">State</span><span class="p">(</span><span class="n">issuance</span><span class="p">,</span> <span class="n">issuance</span><span class="p">.</span><span class="n">institution</span><span class="p">.</span><span class="n">owningKey</span><span class="p">,</span> <span class="n">faceValue</span><span class="p">,</span> <span class="n">maturityDate</span><span class="p">)</span> <span class="k">val</span> <span class="py">state</span> <span class="p">=</span> <span class="n">State</span><span class="p">(</span><span class="n">issuance</span><span class="p">,</span> <span class="n">issuance</span><span class="p">.</span><span class="n">party</span><span class="p">.</span><span class="n">owningKey</span><span class="p">,</span> <span class="n">faceValue</span><span class="p">,</span> <span class="n">maturityDate</span><span class="p">)</span>
<span class="k">return</span> <span class="n">PartialTransaction</span><span class="p">(</span><span class="n">state</span><span class="p">,</span> <span class="n">WireCommand</span><span class="p">(</span><span class="n">Commands</span><span class="p">.</span><span class="n">Issue</span><span class="p">,</span> <span class="n">issuance</span><span class="p">.</span><span class="n">institution</span><span class="p">.</span><span class="n">owningKey</span><span class="p">))</span> <span class="k">return</span> <span class="n">PartialTransaction</span><span class="p">(</span><span class="n">state</span><span class="p">,</span> <span class="n">WireCommand</span><span class="p">(</span><span class="n">Commands</span><span class="p">.</span><span class="n">Issue</span><span class="p">,</span> <span class="n">issuance</span><span class="p">.</span><span class="n">party</span><span class="p">.</span><span class="n">owningKey</span><span class="p">))</span>
<span class="p">}</span> <span class="p">}</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<p>We take a reference that points to the issuing institution (i.e. the caller) and which can contain any internal <p>We take a reference that points to the issuing party (i.e. the caller) and which can contain any internal
bookkeeping/reference numbers that we may require. Then the face value of the paper, and the maturity date. It bookkeeping/reference numbers that we may require. Then the face value of the paper, and the maturity date. It
returns a <code class="docutils literal"><span class="pre">PartialTransaction</span></code>. A <code class="docutils literal"><span class="pre">PartialTransaction</span></code> is one of the few mutable classes the platform provides. returns a <code class="docutils literal"><span class="pre">PartialTransaction</span></code>. A <code class="docutils literal"><span class="pre">PartialTransaction</span></code> is one of the few mutable classes the platform provides.
It allows you to add inputs, outputs and commands to it and is designed to be passed around, potentially between It allows you to add inputs, outputs and commands to it and is designed to be passed around, potentially between
@ -746,11 +746,11 @@ would just introduce complexity that isn&#8217;t likely to be worth it, so we re
an issuer should issue the CP (starting out owned by themselves), and then sell it in a separate transaction.</p> an issuer should issue the CP (starting out owned by themselves), and then sell it in a separate transaction.</p>
</div> </div>
<p>The function we define creates a <code class="docutils literal"><span class="pre">CommercialPaper.State</span></code> object that mostly just uses the arguments we were given, <p>The function we define creates a <code class="docutils literal"><span class="pre">CommercialPaper.State</span></code> object that mostly just uses the arguments we were given,
but it fills out the owner field of the state to be the same public key as the issuing institution. If the caller wants but it fills out the owner field of the state to be the same public key as the issuing party. If the caller wants
to issue CP onto the ledger that&#8217;s immediately owned by someone else, they&#8217;ll have to create the state themselves.</p> to issue CP onto the ledger that&#8217;s immediately owned by someone else, they&#8217;ll have to create the state themselves.</p>
<p>The returned partial transaction has a <code class="docutils literal"><span class="pre">WireCommand</span></code> object as a parameter. This is a container for any object <p>The returned partial transaction has a <code class="docutils literal"><span class="pre">WireCommand</span></code> object as a parameter. This is a container for any object
that implements the <code class="docutils literal"><span class="pre">Command</span></code> interface, along with a key that is expected to sign this transaction. In this case, that implements the <code class="docutils literal"><span class="pre">Command</span></code> interface, along with a key that is expected to sign this transaction. In this case,
issuance requires that the issuing institution sign, so we put the key of the institution there.</p> issuance requires that the issuing party sign, so we put the key of the party there.</p>
<p>The <code class="docutils literal"><span class="pre">PartialTransaction</span></code> constructor we used above takes a variable argument list for convenience. You can pass in <p>The <code class="docutils literal"><span class="pre">PartialTransaction</span></code> constructor we used above takes a variable argument list for convenience. You can pass in
any <code class="docutils literal"><span class="pre">ContractStateRef</span></code> (input), <code class="docutils literal"><span class="pre">ContractState</span></code> (output) or <code class="docutils literal"><span class="pre">Command</span></code> objects and it&#8217;ll build up the transaction any <code class="docutils literal"><span class="pre">ContractStateRef</span></code> (input), <code class="docutils literal"><span class="pre">ContractState</span></code> (output) or <code class="docutils literal"><span class="pre">Command</span></code> objects and it&#8217;ll build up the transaction
for you.</p> for you.</p>

View File

@ -35,8 +35,8 @@ maximise flexibility for the contract developer.
A transaction has one or more **signatures** attached to it. The signatures do not mean anything by themselves, rather, A transaction has one or more **signatures** attached to it. The signatures do not mean anything by themselves, rather,
their existence is given as input to the contract which can then decide which set of signatures it demands (if any). their existence is given as input to the contract which can then decide which set of signatures it demands (if any).
Signatures may be from an arbitrary, random **public key** that has no identity attached. A public key may be Signatures may be from an arbitrary, random **public key** that has no identity attached. A public key may be
well known, that is, appears in some sort of public identity registry. In this case we say the key is owned by an well known, that is, appears in some sort of public identity registry. In this case we say the key is owned by a
**institution**, which is defined (for now) as being merely a (public key, name) pair. **party**, which is defined (for now) as being merely a (public key, name) pair.
A transaction may also be **timestamped**. A timestamp is a (hash, datetime, signature) triple from a A transaction may also be **timestamped**. A timestamp is a (hash, datetime, signature) triple from a
*timestamping authority* (TSA). The notion of a TSA is not ledger specific and is defined by *timestamping authority* (TSA). The notion of a TSA is not ledger specific and is defined by
@ -125,15 +125,15 @@ two contracts in the repository:
1. Cash 1. Cash
2. Commercial paper 2. Commercial paper
``Cash`` implements the idea of a claim on some quantity of deposits at some institution, denominated in some currency, ``Cash`` implements the idea of a claim on some quantity of deposits at some institutional party, denominated in some currency,
identified by some *deposit reference*. A deposit reference is an opaque byte array which is usable by identified by some *deposit reference*. A deposit reference is an opaque byte array which is usable by
the issuing institution for internal bookkeeping purposes. the issuing party for internal bookkeeping purposes.
Cash states are *fungible* with each other (can be merged and split arbitrarily) if they use the same currency, Cash states are *fungible* with each other (can be merged and split arbitrarily) if they use the same currency,
institution and deposit reference. party and deposit reference.
``CommercialPaper`` implements an asset with a *face value* denominated in a certain currency, which may be redeemed at ``CommercialPaper`` implements an asset with a *face value* denominated in a certain currency, which may be redeemed at
the issuing institution after a certain time. Commercial paper states define the face value (e.g. $1000) and the time the issuing party after a certain time. Commercial paper states define the face value (e.g. $1000) and the time
at which they may be redeemed. The contract allows the paper to be issued, traded and redeemed. The commercial paper at which they may be redeemed. The contract allows the paper to be issued, traded and redeemed. The commercial paper
contract is implemented twice, once in Java and once in a language called Kotlin. contract is implemented twice, once in Java and once in a language called Kotlin.

View File

@ -156,7 +156,7 @@ Beyond that it's a freeform object into which we can put anything which can be s
We have four fields in our state: We have four fields in our state:
* ``issuance``: a reference to a specific piece of commercial paper at an institution * ``issuance``: a reference to a specific piece of commercial paper at a party
* ``owner``: the public key of the current owner. This is the same concept as seen in Bitcoin: the public key has no * ``owner``: the public key of the current owner. This is the same concept as seen in Bitcoin: the public key has no
attached identity and is expected to be one-time-use for privacy reasons. However, unlike in Bitcoin, we model attached identity and is expected to be one-time-use for privacy reasons. However, unlike in Bitcoin, we model
ownership at the level of individual contracts rather than as a platform-level concept as we envisage many ownership at the level of individual contracts rather than as a platform-level concept as we envisage many
@ -349,7 +349,7 @@ logic.
requireThat { requireThat {
// Don't allow people to issue commercial paper under other entities identities. // Don't allow people to issue commercial paper under other entities identities.
"the issuance is signed by the claimed issuer of the paper" by "the issuance is signed by the claimed issuer of the paper" by
(command.signers.contains(output.issuance.institution.owningKey)) (command.signers.contains(output.issuance.party.owningKey))
"the face value is not zero" by (output.faceValue.pennies > 0) "the face value is not zero" by (output.faceValue.pennies > 0)
"the maturity date is not in the past" by (time < output.maturityDate ) "the maturity date is not in the past" by (time < output.maturityDate )
// Don't allow an existing CP state to be replaced by this issuance. // Don't allow an existing CP state to be replaced by this issuance.
@ -437,7 +437,7 @@ been changed, save for the public key of the owner.
If the command is a ``Redeem`` command, then the requirements are more complex: If the command is a ``Redeem`` command, then the requirements are more complex:
1. We want to see that the face value of the CP is being moved as a cash claim against some institution, that is, the 1. We want to see that the face value of the CP is being moved as a cash claim against some party, that is, the
issuer of the CP is really paying back the face value. issuer of the CP is really paying back the face value.
2. The transaction must be happening after the maturity date. 2. The transaction must be happening after the maturity date.
3. The commercial paper must *not* be propagated by this transaction: it must be deleted, by the group having no 3. The commercial paper must *not* be propagated by this transaction: it must be deleted, by the group having no
@ -500,7 +500,7 @@ We start by defining a new test class, with a basic CP state:
} }
} }
We start by defining a commercial paper state. It will be owned by a pre-defined unit test institution, affectionately We start by defining a commercial paper state. It will be owned by a pre-defined unit test party, affectionately
called ``MEGA_CORP`` (this constant, along with many others, is defined in ``TestUtils.kt``). Due to Kotin's extensive called ``MEGA_CORP`` (this constant, along with many others, is defined in ``TestUtils.kt``). Due to Kotin's extensive
type inference, many types are not written out explicitly in this code and it has the feel of a scripting language. type inference, many types are not written out explicitly in this code and it has the feel of a scripting language.
But the types are there, and you can ask IntelliJ to reveal them by pressing Alt-Enter on a "val" or "var" and selecting But the types are there, and you can ask IntelliJ to reveal them by pressing Alt-Enter on a "val" or "var" and selecting
@ -658,11 +658,11 @@ a method to wrap up the issuance process:
.. sourcecode:: kotlin .. sourcecode:: kotlin
fun craftIssue(issuance: InstitutionReference, faceValue: Amount, maturityDate: Instant): PartialTransaction { fun craftIssue(issuance: InstitutionReference, faceValue: Amount, maturityDate: Instant): PartialTransaction {
val state = State(issuance, issuance.institution.owningKey, faceValue, maturityDate) val state = State(issuance, issuance.party.owningKey, faceValue, maturityDate)
return PartialTransaction(state, WireCommand(Commands.Issue, issuance.institution.owningKey)) return PartialTransaction(state, WireCommand(Commands.Issue, issuance.party.owningKey))
} }
We take a reference that points to the issuing institution (i.e. the caller) and which can contain any internal We take a reference that points to the issuing party (i.e. the caller) and which can contain any internal
bookkeeping/reference numbers that we may require. Then the face value of the paper, and the maturity date. It bookkeeping/reference numbers that we may require. Then the face value of the paper, and the maturity date. It
returns a ``PartialTransaction``. A ``PartialTransaction`` is one of the few mutable classes the platform provides. returns a ``PartialTransaction``. A ``PartialTransaction`` is one of the few mutable classes the platform provides.
It allows you to add inputs, outputs and commands to it and is designed to be passed around, potentially between It allows you to add inputs, outputs and commands to it and is designed to be passed around, potentially between
@ -675,12 +675,12 @@ multiple contracts.
an issuer should issue the CP (starting out owned by themselves), and then sell it in a separate transaction. an issuer should issue the CP (starting out owned by themselves), and then sell it in a separate transaction.
The function we define creates a ``CommercialPaper.State`` object that mostly just uses the arguments we were given, The function we define creates a ``CommercialPaper.State`` object that mostly just uses the arguments we were given,
but it fills out the owner field of the state to be the same public key as the issuing institution. If the caller wants but it fills out the owner field of the state to be the same public key as the issuing party. If the caller wants
to issue CP onto the ledger that's immediately owned by someone else, they'll have to create the state themselves. to issue CP onto the ledger that's immediately owned by someone else, they'll have to create the state themselves.
The returned partial transaction has a ``WireCommand`` object as a parameter. This is a container for any object The returned partial transaction has a ``WireCommand`` object as a parameter. This is a container for any object
that implements the ``Command`` interface, along with a key that is expected to sign this transaction. In this case, that implements the ``Command`` interface, along with a key that is expected to sign this transaction. In this case,
issuance requires that the issuing institution sign, so we put the key of the institution there. issuance requires that the issuing party sign, so we put the key of the party there.
The ``PartialTransaction`` constructor we used above takes a variable argument list for convenience. You can pass in The ``PartialTransaction`` constructor we used above takes a variable argument list for convenience. You can pass in
any ``ContractStateRef`` (input), ``ContractState`` (output) or ``Command`` objects and it'll build up the transaction any ``ContractStateRef`` (input), ``ContractState`` (output) or ``Command`` objects and it'll build up the transaction