Skip to content

Commit 793dcec

Browse files
authored
Merge pull request #78 from corda/reissuance
reissuance sample
2 parents cceec9a + 8975c3a commit 793dcec

File tree

33 files changed

+1655
-0
lines changed

33 files changed

+1655
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!groovy
2+
/**
3+
* Jenkins pipeline to build the java CorDapp template
4+
*/
5+
6+
/**
7+
* Kill already started job.
8+
* Assume new commit takes precedence and results from previousunfinished builds are not required.
9+
* This feature doesn't play well with disableConcurrentBuilds() option
10+
*/
11+
@Library('corda-shared-build-pipeline-steps')
12+
import static com.r3.build.BuildControl.killAllExistingBuildsForJob
13+
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
14+
15+
pipeline {
16+
agent {
17+
label 'eight-cores'
18+
}
19+
options {
20+
ansiColor('xterm')
21+
timestamps()
22+
timeout(3*60) // 3 hours
23+
buildDiscarder(logRotator(daysToKeepStr: '7', artifactDaysToKeepStr: '7'))
24+
}
25+
stages {
26+
stage('Build') {
27+
steps {
28+
sh './gradlew --no-daemon -s clean build test deployNodes'
29+
}
30+
}
31+
}
32+
post {
33+
cleanup {
34+
deleteDir()
35+
}
36+
}
37+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Eclipse, ctags, Mac metadata, log files
2+
.classpath
3+
.project
4+
tags
5+
.DS_Store
6+
*.log
7+
*.log.gz
8+
*.orig
9+
10+
.gradle
11+
12+
# General build files
13+
**/build/*
14+
!docs/build/*
15+
16+
lib/dokka.jar
17+
18+
### JetBrains template
19+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
20+
21+
*.iml
22+
23+
## Directory-based project format:
24+
#.idea
25+
26+
# if you remove the above rule, at least ignore the following:
27+
28+
# Specific files to avoid churn
29+
.idea/*.xml
30+
.idea/copyright
31+
.idea/jsLibraryMappings.xml
32+
33+
# User-specific stuff:
34+
.idea/tasks.xml
35+
.idea/dictionaries
36+
37+
# Sensitive or high-churn files:
38+
.idea/dataSources.ids
39+
.idea/dataSources.xml
40+
.idea/sqlDataSources.xml
41+
.idea/dynamic.xml
42+
.idea/uiDesigner.xml
43+
44+
# Gradle:
45+
.idea/libraries
46+
47+
# Mongo Explorer plugin:
48+
.idea/mongoSettings.xml
49+
50+
## File-based project format:
51+
*.ipr
52+
*.iws
53+
54+
## Plugin-specific files:
55+
56+
# IntelliJ
57+
/out/
58+
/workflows/out/
59+
/contracts/out/
60+
clients/out/
61+
*/bin/*
62+
63+
# mpeltonen/sbt-idea plugin
64+
.idea_modules/
65+
66+
# JIRA plugin
67+
atlassian-ide-plugin.xml
68+
69+
# Crashlytics plugin (for Android Studio and IntelliJ)
70+
com_crashlytics_export_strings.xml
71+
crashlytics.properties
72+
crashlytics-build.properties
73+
74+
# docs related
75+
docs/virtualenv/
76+
77+
# if you use the installQuasar task
78+
lib
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate

Features/state-reissuance/LICENCE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016, R3 Limited.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<p align="center">
2+
<img src="https://www.corda.net/wp-content/uploads/2016/11/fg005_corda_b.png" alt="Corda" width="500">
3+
</p>
4+
5+
# State Reissuance Sample CorDapp
6+
7+
This cordapp serves as a sample for state reissuance feature of Corda. This feature enables developers to break long
8+
transaction backchains by reissuing a state with a guaranteed state replacement. This is particularly useful in situations
9+
when an party doesn't want to share state history with other parties for privacy or performance concerns.
10+
11+
This samples demonstrates the feature with the help of a linear state, represented by a land title issued on Corda ledger.
12+
The land title can be transferred multiple times and when the transaction backchain becomes long, the land title could be
13+
reissued and the transaction backchain could be pruned.
14+
15+
# Pre-Requisites
16+
17+
See https://docs.corda.net/getting-set-up.html.
18+
19+
# Usage
20+
21+
## Running the CorDapp
22+
23+
Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper)
24+
25+
`./gradlew clean deployNodes`
26+
27+
Then type: (to run the nodes)
28+
29+
`./build/nodes/runnodes`
30+
31+
## Interacting with the CorDapp
32+
33+
PartyA issues a land title to PartyB, Go to PartyA's terminal and run the below command
34+
35+
`start IssueLandTitleFlow owner: PartyB, dimensions: 40X50, area: 1200sqft`
36+
37+
Verify the land title has been issued correctly by querying the ledgers of PartyA and PartyB using the below command.
38+
PartyA should be issuer and PartyB should be the owner of the land title.
39+
40+
`run vaultQuery contractStateType: net.corda.samples.statereissuance.states.LandTitleState`
41+
42+
Once land title has been issued to PartyB, he could transfer it to PartyC. Go to PartyB's terminal and run the below command
43+
44+
`start TransferLandTitleFlow owner: PartyC, plotIdentifier: <plot-identifier>`
45+
46+
You could find the `plot-identifier` from the result of the vaultQuery command used earlier to query the ledgers.
47+
48+
Verify the land title has been correctly tranferred to PartyC by querying the ledgers of PartyA and PartyC using the below command
49+
50+
`run vaultQuery contractStateType: net.corda.samples.statereissuance.states.LandTitleState`
51+
52+
Note that PartyB is no more able to see the land title, since he is no longer a party to the state as he has transferred
53+
the title to PartyC. It is currently only visible to PartyA and PartyC.
54+
55+
Consider that PartyC now wants to reissue the title to get rid of the backchain. He needs to request a reissuace to the issuer.
56+
Go to PartyA's terminal and run the below command
57+
58+
`start RequestReissueLandStateFlow issuer: PartyA, plotIdentifier: <plot-identifier>`
59+
60+
Now a reissuance request is created on the ledgers of PartyA and PartyC, when can be verified using the below command
61+
62+
`run vaultQuery contractStateType: com.r3.corda.lib.reissuance.states.ReissuanceRequest`
63+
64+
The issuer could either accept or reject the reissuance request. Let's consider the case where the issuer accepts the
65+
reissuance request. To accept the request goto PartyA's (issuer) terminal and run the below command
66+
67+
`start AcceptLandReissuanceFlow issuer: PartyA, stateRef: {index: <output-index>, txhash: <trnx-hash>}`
68+
69+
The `<output-index>` and `<trnx-hash>` are of the transaction which created the state to the reissued. They can be found
70+
in the `ReissuanceRequest` queried earlier.
71+
72+
On successful completion of the above flow, the a duplicate land title would be issued, however it would be currently
73+
locked and it could not be spend. In order to spend it, the older state which was requested to be reissued must be exited
74+
and that would allow the new reissued state to be unlocked and spend.
75+
76+
To exit the older land title run the below command from PartyC's terminal.
77+
78+
`start ExitLandTitleFlow stateRef: {index: <output-index>, txhash: <trnx-hash>}`
79+
80+
Once the previous land title is exited, unlock the reissued land title using the below command from PartyC's terminal
81+
82+
`start UnlockReissuedLandStateFlow reissuedRef: {index: <output-index>, txhash: <tx-hash>}, reissuanceLockRef: {index: <output-index>, txhash: <tx-hash>}, exitTrnxId: <tx-hash>`
83+
84+
The `reissuedRef` is the stateRef of the reissued state, `reissuanceLockRef` is the stateRef of the reissuance lock generated,
85+
which can queried usinf `run vaultQuery contractStateType: com.r3.corda.lib.reissuance.states.ReissuanceLock` and `exitTrnxId` is the
86+
transaction hash of the transaction used to exit the older state.
87+
88+
Note that the lock uses the encumbrance feature of Corda. You can check out the sample on encumbrance [here](https://github.com/corda/samples-java/tree/master/Features/encumbrance-avatar)
89+
90+
Now the reissue process is completed and the reissued state can be spent freely.
91+
92+
93+
94+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Corda and the Corda logo are trademarks of R3CEV LLC and its affiliates. All rights reserved.
2+
3+
For R3CEV LLC's trademark and logo usage information, please consult our Trademark Usage Policy at
4+
https://www.r3.com/trademark-policy/.

0 commit comments

Comments
 (0)