Misc documentation fixes

This commit is contained in:
rick.parker 2017-09-27 14:29:44 +01:00
parent 1b349214ff
commit 592896fb73
3 changed files with 50 additions and 47 deletions

View File

@ -41,7 +41,8 @@ In ``IOUFlow.java``/``IOUFlow.kt``, update ``IOUFlow.call`` as follows:
val signedTx = serviceHub.signInitialTransaction(txBuilder) val signedTx = serviceHub.signInitialTransaction(txBuilder)
// Obtaining the counterparty's signature // Obtaining the counterparty's signature
val fullySignedTx = subFlow(CollectSignaturesFlow(signedTx, CollectSignaturesFlow.tracker())) val otherSession = initiateFlow(otherParty)
val fullySignedTx = subFlow(CollectSignaturesFlow(signedTx, setOf(otherSession), CollectSignaturesFlow.tracker()))
// Finalising the transaction. // Finalising the transaction.
subFlow(FinalityFlow(fullySignedTx)) subFlow(FinalityFlow(fullySignedTx))
@ -52,6 +53,7 @@ In ``IOUFlow.java``/``IOUFlow.kt``, update ``IOUFlow.call`` as follows:
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.security.PublicKey; import java.security.PublicKey;
import java.util.Collections;
import java.util.List; import java.util.List;
... ...
@ -69,7 +71,8 @@ In ``IOUFlow.java``/``IOUFlow.kt``, update ``IOUFlow.call`` as follows:
final SignedTransaction signedTx = getServiceHub().signInitialTransaction(txBuilder); final SignedTransaction signedTx = getServiceHub().signInitialTransaction(txBuilder);
// Obtaining the counterparty's signature // Obtaining the counterparty's signature
final SignedTransaction fullySignedTx = subFlow(new CollectSignaturesFlow(signedTx, CollectSignaturesFlow.Companion.tracker())); final FlowSession otherSession = initiateFlow(otherParty)
final SignedTransaction fullySignedTx = subFlow(new CollectSignaturesFlow(signedTx, Collections.singleton(otherSession), CollectSignaturesFlow.Companion.tracker()));
// Finalising the transaction. // Finalising the transaction.
subFlow(new FinalityFlow(fullySignedTx)); subFlow(new FinalityFlow(fullySignedTx));
@ -98,10 +101,10 @@ In a new ``IOUFlowResponder.java`` file in Java, or within the ``App.kt`` file i
... ...
@InitiatedBy(IOUFlow::class) @InitiatedBy(IOUFlow::class)
class IOUFlowResponder(val otherParty: Party) : FlowLogic<Unit>() { class IOUFlowResponder(val otherPartySession: FlowSession) : FlowLogic<Unit>() {
@Suspendable @Suspendable
override fun call() { override fun call() {
val signTransactionFlow = object : SignTransactionFlow(otherParty, SignTransactionFlow.tracker()) { val signTransactionFlow = object : SignTransactionFlow(otherPartySession, SignTransactionFlow.tracker()) {
override fun checkTransaction(stx: SignedTransaction) = requireThat { override fun checkTransaction(stx: SignedTransaction) = requireThat {
val output = stx.tx.outputs.single().data val output = stx.tx.outputs.single().data
"This must be an IOU transaction." using (output is IOUState) "This must be an IOU transaction." using (output is IOUState)
@ -123,9 +126,9 @@ In a new ``IOUFlowResponder.java`` file in Java, or within the ``App.kt`` file i
import net.corda.core.contracts.ContractState; import net.corda.core.contracts.ContractState;
import net.corda.core.flows.FlowException; import net.corda.core.flows.FlowException;
import net.corda.core.flows.FlowLogic; import net.corda.core.flows.FlowLogic;
import net.corda.core.flows.FlowSession;
import net.corda.core.flows.InitiatedBy; import net.corda.core.flows.InitiatedBy;
import net.corda.core.flows.SignTransactionFlow; import net.corda.core.flows.SignTransactionFlow;
import net.corda.core.identity.Party;
import net.corda.core.transactions.SignedTransaction; import net.corda.core.transactions.SignedTransaction;
import net.corda.core.utilities.ProgressTracker; import net.corda.core.utilities.ProgressTracker;
@ -133,18 +136,18 @@ In a new ``IOUFlowResponder.java`` file in Java, or within the ``App.kt`` file i
@InitiatedBy(IOUFlow.class) @InitiatedBy(IOUFlow.class)
public class IOUFlowResponder extends FlowLogic<Void> { public class IOUFlowResponder extends FlowLogic<Void> {
private final Party otherParty; private final FlowSession otherPartySession;
public IOUFlowResponder(Party otherParty) { public IOUFlowResponder(FlowSession otherPartySession) {
this.otherParty = otherParty; this.otherPartySession = otherPartySession;
} }
@Suspendable @Suspendable
@Override @Override
public Void call() throws FlowException { public Void call() throws FlowException {
class signTxFlow extends SignTransactionFlow { class SignTxFlow extends SignTransactionFlow {
private signTxFlow(Party otherParty, ProgressTracker progressTracker) { private signTxFlow(FlowSession otherPartySession, ProgressTracker progressTracker) {
super(otherParty, progressTracker); super(otherPartySession, progressTracker);
} }
@Override @Override
@ -159,7 +162,7 @@ In a new ``IOUFlowResponder.java`` file in Java, or within the ``App.kt`` file i
} }
} }
subFlow(new signTxFlow(otherParty, SignTransactionFlow.Companion.tracker())); subFlow(new SignTxFlow(otherPartySession, SignTransactionFlow.Companion.tracker()));
return null; return null;
} }

View File

@ -249,7 +249,7 @@ We can continue to build the transaction until it ``verifies``:
input(inState) input(inState)
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() }
this `fails with` "the state is propagated" this `fails with` "the state is propagated"
output("alice's paper") { inState `owned by` ALICE_PUBKEY } output(CommercialPaper.CP_PROGRAM_ID, "alice's paper") { inState `owned by` ALICE_PUBKEY }
this.verifies() this.verifies()
} }
} }
@ -265,7 +265,7 @@ We can continue to build the transaction until it ``verifies``:
tx.input(inState); tx.input(inState);
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move());
tx.failsWith("the state is propagated"); tx.failsWith("the state is propagated");
tx.output("alice's paper", inState.withOwner(getALICE_PUBKEY())); tx.output(CommercialPaper.CP_PROGRAM_ID, "alice's paper", inState.withOwner(getALICE_PUBKEY()));
return tx.verifies(); return tx.verifies();
}); });
return Unit.INSTANCE; return Unit.INSTANCE;
@ -289,7 +289,7 @@ What should we do if we wanted to test what happens when the wrong party signs t
fun `simple issuance with tweak`() { fun `simple issuance with tweak`() {
ledger { ledger {
transaction { transaction {
output("paper") { getPaper() } // Some CP is issued onto the ledger by MegaCorp. output(CommercialPaper.CP_PROGRAM_ID, "paper") { getPaper() } // Some CP is issued onto the ledger by MegaCorp.
tweak { tweak {
command(DUMMY_PUBKEY_1) { CommercialPaper.Commands.Issue() } command(DUMMY_PUBKEY_1) { CommercialPaper.Commands.Issue() }
timestamp(TEST_TX_TIME) timestamp(TEST_TX_TIME)
@ -308,7 +308,7 @@ What should we do if we wanted to test what happens when the wrong party signs t
public void simpleIssuanceWithTweak() { public void simpleIssuanceWithTweak() {
ledger(l -> { ledger(l -> {
l.transaction(tx -> { l.transaction(tx -> {
tx.output("paper", getPaper()); // Some CP is issued onto the ledger by MegaCorp. tx.output(CommercialPaper.CP_PROGRAM_ID, "paper", getPaper()); // Some CP is issued onto the ledger by MegaCorp.
tx.tweak(tw -> { tx.tweak(tw -> {
tw.command(getDUMMY_PUBKEY_1(), new JavaCommercialPaper.Commands.Issue()); tw.command(getDUMMY_PUBKEY_1(), new JavaCommercialPaper.Commands.Issue());
tw.timestamp(getTEST_TX_TIME()); tw.timestamp(getTEST_TX_TIME());
@ -337,7 +337,7 @@ ledger with a single transaction:
@Test @Test
fun `simple issuance with tweak and top level transaction`() { fun `simple issuance with tweak and top level transaction`() {
transaction { transaction {
output("paper") { getPaper() } // Some CP is issued onto the ledger by MegaCorp. output(CommercialPaper.CP_PROGRAM_ID, "paper") { getPaper() } // Some CP is issued onto the ledger by MegaCorp.
tweak { tweak {
command(DUMMY_PUBKEY_1) { CommercialPaper.Commands.Issue() } command(DUMMY_PUBKEY_1) { CommercialPaper.Commands.Issue() }
timestamp(TEST_TX_TIME) timestamp(TEST_TX_TIME)
@ -354,7 +354,7 @@ ledger with a single transaction:
@Test @Test
public void simpleIssuanceWithTweakTopLevelTx() { public void simpleIssuanceWithTweakTopLevelTx() {
transaction(tx -> { transaction(tx -> {
tx.output("paper", getPaper()); // Some CP is issued onto the ledger by MegaCorp. tx.output(CommercialPaper.CP_PROGRAM_ID, "paper", getPaper()); // Some CP is issued onto the ledger by MegaCorp.
tx.tweak(tw -> { tx.tweak(tw -> {
tw.command(getDUMMY_PUBKEY_1(), new JavaCommercialPaper.Commands.Issue()); tw.command(getDUMMY_PUBKEY_1(), new JavaCommercialPaper.Commands.Issue());
tw.timestamp(getTEST_TX_TIME()); tw.timestamp(getTEST_TX_TIME());
@ -381,12 +381,12 @@ Now that we know how to define a single transaction, let's look at how to define
ledger { ledger {
unverifiedTransaction { unverifiedTransaction {
output("alice's $900", 900.DOLLARS.CASH `issued by` issuer `owned by` ALICE_PUBKEY) output(Cash.CP_PROGRAM_ID, "alice's $900", 900.DOLLARS.CASH `issued by` issuer `owned by` ALICE_PUBKEY)
} }
// Some CP is issued onto the ledger by MegaCorp. // Some CP is issued onto the ledger by MegaCorp.
transaction("Issuance") { transaction("Issuance") {
output("paper") { getPaper() } output(CommercialPaper.CP_PROGRAM_ID, "paper") { getPaper() }
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() }
timestamp(TEST_TX_TIME) timestamp(TEST_TX_TIME)
this.verifies() this.verifies()
@ -396,8 +396,8 @@ Now that we know how to define a single transaction, let's look at how to define
transaction("Trade") { transaction("Trade") {
input("paper") input("paper")
input("alice's $900") input("alice's $900")
output("borrowed $900") { 900.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP_PUBKEY } output(Cash.CP_PROGRAM_ID, "borrowed $900") { 900.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP_PUBKEY }
output("alice's paper") { "paper".output<ICommercialPaperState>() `owned by` ALICE_PUBKEY } output(CommercialPaper.CP_PROGRAM_ID, "alice's paper") { "paper".output<ICommercialPaperState>() `owned by` ALICE_PUBKEY }
command(ALICE_PUBKEY) { Cash.Commands.Move() } command(ALICE_PUBKEY) { Cash.Commands.Move() }
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() }
this.verifies() this.verifies()
@ -412,14 +412,14 @@ Now that we know how to define a single transaction, let's look at how to define
PartyAndReference issuer = getMEGA_CORP().ref(defaultRef); PartyAndReference issuer = getMEGA_CORP().ref(defaultRef);
ledger(l -> { ledger(l -> {
l.unverifiedTransaction(tx -> { l.unverifiedTransaction(tx -> {
tx.output("alice's $900", tx.output(Cash.CP_PROGRAM_ID, "alice's $900",
new Cash.State(issuedBy(DOLLARS(900), issuer), getALICE_PUBKEY(), null)); new Cash.State(issuedBy(DOLLARS(900), issuer), getALICE_PUBKEY(), null));
return Unit.INSTANCE; return Unit.INSTANCE;
}); });
// Some CP is issued onto the ledger by MegaCorp. // Some CP is issued onto the ledger by MegaCorp.
l.transaction("Issuance", tx -> { l.transaction("Issuance", tx -> {
tx.output("paper", getPaper()); tx.output(CommercialPaper.CP_PROGRAM_ID, "paper", getPaper());
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Issue()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Issue());
tx.timestamp(getTEST_TX_TIME()); tx.timestamp(getTEST_TX_TIME());
return tx.verifies(); return tx.verifies();
@ -428,9 +428,9 @@ Now that we know how to define a single transaction, let's look at how to define
l.transaction("Trade", tx -> { l.transaction("Trade", tx -> {
tx.input("paper"); tx.input("paper");
tx.input("alice's $900"); tx.input("alice's $900");
tx.output("borrowed $900", new Cash.State(issuedBy(DOLLARS(900), issuer), getMEGA_CORP_PUBKEY(), null)); tx.output(Cash.CP_PROGRAM_ID, "borrowed $900", new Cash.State(issuedBy(DOLLARS(900), issuer), getMEGA_CORP_PUBKEY(), null));
JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper"); JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper");
tx.output("alice's paper", inputPaper.withOwner(getALICE_PUBKEY())); tx.output(CommercialPaper.CP_PROGRAM_ID, "alice's paper", inputPaper.withOwner(getALICE_PUBKEY()));
tx.command(getALICE_PUBKEY(), new Cash.Commands.Move()); tx.command(getALICE_PUBKEY(), new Cash.Commands.Move());
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move());
return tx.verifies(); return tx.verifies();
@ -462,12 +462,12 @@ To do so let's create a simple example that uses the same input twice:
val issuer = MEGA_CORP.ref(123) val issuer = MEGA_CORP.ref(123)
ledger { ledger {
unverifiedTransaction { unverifiedTransaction {
output("alice's $900", 900.DOLLARS.CASH `issued by` issuer `owned by` ALICE_PUBKEY) output(Cash.CP_PROGRAM_ID, "alice's $900", 900.DOLLARS.CASH `issued by` issuer `owned by` ALICE_PUBKEY)
} }
// Some CP is issued onto the ledger by MegaCorp. // Some CP is issued onto the ledger by MegaCorp.
transaction("Issuance") { transaction("Issuance") {
output("paper") { getPaper() } output(CommercialPaper.CP_PROGRAM_ID, "paper") { getPaper() }
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() }
timestamp(TEST_TX_TIME) timestamp(TEST_TX_TIME)
this.verifies() this.verifies()
@ -476,8 +476,8 @@ To do so let's create a simple example that uses the same input twice:
transaction("Trade") { transaction("Trade") {
input("paper") input("paper")
input("alice's $900") input("alice's $900")
output("borrowed $900") { 900.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP_PUBKEY } output(Cash.CP_PROGRAM_ID, "borrowed $900") { 900.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP_PUBKEY }
output("alice's paper") { "paper".output<ICommercialPaperState>() `owned by` ALICE_PUBKEY } output(CommercialPaper.CP_PROGRAM_ID, "alice's paper") { "paper".output<ICommercialPaperState>() `owned by` ALICE_PUBKEY }
command(ALICE_PUBKEY) { Cash.Commands.Move() } command(ALICE_PUBKEY) { Cash.Commands.Move() }
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() }
this.verifies() this.verifies()
@ -486,7 +486,7 @@ To do so let's create a simple example that uses the same input twice:
transaction { transaction {
input("paper") input("paper")
// We moved a paper to another pubkey. // We moved a paper to another pubkey.
output("bob's paper") { "paper".output<ICommercialPaperState>() `owned by` BOB_PUBKEY } output(CommercialPaper.CP_PROGRAM_ID, "bob's paper") { "paper".output<ICommercialPaperState>() `owned by` BOB_PUBKEY }
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() }
this.verifies() this.verifies()
} }
@ -502,14 +502,14 @@ To do so let's create a simple example that uses the same input twice:
PartyAndReference issuer = getMEGA_CORP().ref(defaultRef); PartyAndReference issuer = getMEGA_CORP().ref(defaultRef);
ledger(l -> { ledger(l -> {
l.unverifiedTransaction(tx -> { l.unverifiedTransaction(tx -> {
tx.output("alice's $900", tx.output(Cash.CP_PROGRAM_ID, "alice's $900",
new Cash.State(issuedBy(DOLLARS(900), issuer), getALICE_PUBKEY(), null)); new Cash.State(issuedBy(DOLLARS(900), issuer), getALICE_PUBKEY(), null));
return Unit.INSTANCE; return Unit.INSTANCE;
}); });
// Some CP is issued onto the ledger by MegaCorp. // Some CP is issued onto the ledger by MegaCorp.
l.transaction("Issuance", tx -> { l.transaction("Issuance", tx -> {
tx.output("paper", getPaper()); tx.output(CommercialPaper.CP_PROGRAM_ID, "paper", getPaper());
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Issue()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Issue());
tx.timestamp(getTEST_TX_TIME()); tx.timestamp(getTEST_TX_TIME());
return tx.verifies(); return tx.verifies();
@ -518,9 +518,9 @@ To do so let's create a simple example that uses the same input twice:
l.transaction("Trade", tx -> { l.transaction("Trade", tx -> {
tx.input("paper"); tx.input("paper");
tx.input("alice's $900"); tx.input("alice's $900");
tx.output("borrowed $900", new Cash.State(issuedBy(DOLLARS(900), issuer), getMEGA_CORP_PUBKEY(), null)); tx.output(Cash.CP_PROGRAM_ID, "borrowed $900", new Cash.State(issuedBy(DOLLARS(900), issuer), getMEGA_CORP_PUBKEY(), null));
JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper"); JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper");
tx.output("alice's paper", inputPaper.withOwner(getALICE_PUBKEY())); tx.output(CommercialPaper.CP_PROGRAM_ID, "alice's paper", inputPaper.withOwner(getALICE_PUBKEY()));
tx.command(getALICE_PUBKEY(), new Cash.Commands.Move()); tx.command(getALICE_PUBKEY(), new Cash.Commands.Move());
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move());
return tx.verifies(); return tx.verifies();
@ -530,7 +530,7 @@ To do so let's create a simple example that uses the same input twice:
tx.input("paper"); tx.input("paper");
JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper"); JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper");
// We moved a paper to other pubkey. // We moved a paper to other pubkey.
tx.output("bob's paper", inputPaper.withOwner(getBOB_PUBKEY())); tx.output(CommercialPaper.CP_PROGRAM_ID, "bob's paper", inputPaper.withOwner(getBOB_PUBKEY()));
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move());
return tx.verifies(); return tx.verifies();
}); });
@ -551,12 +551,12 @@ verification (``this.fails()`` at the end). As in previous examples we can use `
val issuer = MEGA_CORP.ref(123) val issuer = MEGA_CORP.ref(123)
ledger { ledger {
unverifiedTransaction { unverifiedTransaction {
output("alice's $900", 900.DOLLARS.CASH `issued by` issuer `owned by` ALICE_PUBKEY) output(Cash.CP_PROGRAM_ID, "alice's $900", 900.DOLLARS.CASH `issued by` issuer `owned by` ALICE_PUBKEY)
} }
// Some CP is issued onto the ledger by MegaCorp. // Some CP is issued onto the ledger by MegaCorp.
transaction("Issuance") { transaction("Issuance") {
output("paper") { getPaper() } output(CommercialPaper.CP_PROGRAM_ID, "paper") { getPaper() }
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Issue() }
timestamp(TEST_TX_TIME) timestamp(TEST_TX_TIME)
this.verifies() this.verifies()
@ -565,8 +565,8 @@ verification (``this.fails()`` at the end). As in previous examples we can use `
transaction("Trade") { transaction("Trade") {
input("paper") input("paper")
input("alice's $900") input("alice's $900")
output("borrowed $900") { 900.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP_PUBKEY } output(Cash.CP_PROGRAM_ID, "borrowed $900") { 900.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP_PUBKEY }
output("alice's paper") { "paper".output<ICommercialPaperState>() `owned by` ALICE_PUBKEY } output(CommercialPaper.CP_PROGRAM_ID, "alice's paper") { "paper".output<ICommercialPaperState>() `owned by` ALICE_PUBKEY }
command(ALICE_PUBKEY) { Cash.Commands.Move() } command(ALICE_PUBKEY) { Cash.Commands.Move() }
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() }
this.verifies() this.verifies()
@ -576,7 +576,7 @@ verification (``this.fails()`` at the end). As in previous examples we can use `
transaction { transaction {
input("paper") input("paper")
// We moved a paper to another pubkey. // We moved a paper to another pubkey.
output("bob's paper") { "paper".output<ICommercialPaperState>() `owned by` BOB_PUBKEY } output(CommercialPaper.CP_PROGRAM_ID, "bob's paper") { "paper".output<ICommercialPaperState>() `owned by` BOB_PUBKEY }
command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() } command(MEGA_CORP_PUBKEY) { CommercialPaper.Commands.Move() }
this.verifies() this.verifies()
} }
@ -594,14 +594,14 @@ verification (``this.fails()`` at the end). As in previous examples we can use `
PartyAndReference issuer = getMEGA_CORP().ref(defaultRef); PartyAndReference issuer = getMEGA_CORP().ref(defaultRef);
ledger(l -> { ledger(l -> {
l.unverifiedTransaction(tx -> { l.unverifiedTransaction(tx -> {
tx.output("alice's $900", tx.output(Cash.CP_PROGRAM_ID, "alice's $900",
new Cash.State(issuedBy(DOLLARS(900), issuer), getALICE_PUBKEY(), null)); new Cash.State(issuedBy(DOLLARS(900), issuer), getALICE_PUBKEY(), null));
return Unit.INSTANCE; return Unit.INSTANCE;
}); });
// Some CP is issued onto the ledger by MegaCorp. // Some CP is issued onto the ledger by MegaCorp.
l.transaction("Issuance", tx -> { l.transaction("Issuance", tx -> {
tx.output("paper", getPaper()); tx.output(CommercialPaper.CP_PROGRAM_ID, "paper", getPaper());
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Issue()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Issue());
tx.timestamp(getTEST_TX_TIME()); tx.timestamp(getTEST_TX_TIME());
return tx.verifies(); return tx.verifies();
@ -610,9 +610,9 @@ verification (``this.fails()`` at the end). As in previous examples we can use `
l.transaction("Trade", tx -> { l.transaction("Trade", tx -> {
tx.input("paper"); tx.input("paper");
tx.input("alice's $900"); tx.input("alice's $900");
tx.output("borrowed $900", new Cash.State(issuedBy(DOLLARS(900), issuer), getMEGA_CORP_PUBKEY(), null)); tx.output(Cash.CP_PROGRAM_ID, "borrowed $900", new Cash.State(issuedBy(DOLLARS(900), issuer), getMEGA_CORP_PUBKEY(), null));
JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper"); JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper");
tx.output("alice's paper", inputPaper.withOwner(getALICE_PUBKEY())); tx.output(CommercialPaper.CP_PROGRAM_ID, "alice's paper", inputPaper.withOwner(getALICE_PUBKEY()));
tx.command(getALICE_PUBKEY(), new Cash.Commands.Move()); tx.command(getALICE_PUBKEY(), new Cash.Commands.Move());
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move());
return tx.verifies(); return tx.verifies();
@ -623,7 +623,7 @@ verification (``this.fails()`` at the end). As in previous examples we can use `
tx.input("paper"); tx.input("paper");
JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper"); JavaCommercialPaper.State inputPaper = l.retrieveOutput(JavaCommercialPaper.State.class, "paper");
// We moved a paper to another pubkey. // We moved a paper to another pubkey.
tx.output("bob's paper", inputPaper.withOwner(getBOB_PUBKEY())); tx.output(CommercialPaper.CP_PROGRAM_ID, "bob's paper", inputPaper.withOwner(getBOB_PUBKEY()));
tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move()); tx.command(getMEGA_CORP_PUBKEY(), new JavaCommercialPaper.Commands.Move());
return tx.verifies(); return tx.verifies();
}); });

View File

@ -64,7 +64,7 @@ Defining plugins
---------------- ----------------
Your CorDapp may need to define two types of plugins: Your CorDapp may need to define two types of plugins:
* ``CordaPluginRegistry`` subclasses, which define additional serializable classes and vault schemas * ``CordaPluginRegistry`` subclasses, which define additional serializable classes
* ``WebServerPluginRegistry`` subclasses, which define the APIs and static web content served by your CorDapp * ``WebServerPluginRegistry`` subclasses, which define the APIs and static web content served by your CorDapp
The fully-qualified class path of each ``CordaPluginRegistry`` subclass must then be added to the The fully-qualified class path of each ``CordaPluginRegistry`` subclass must then be added to the