Skip to content

Commit a9fe936

Browse files
committed
Add check for counterparty platformVersion
1 parent 2bb2213 commit a9fe936

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

workflows/src/main/kotlin/com/r3/corda/lib/tokens/workflows/internal/flows/FlowVersionUtilities.kt

+18-8
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,22 @@ import java.security.SignatureException
3030
*/
3131
internal const val INITIATING_TOKENS_FLOW = "com.r3.corda.lib.tokens.workflows.flows.rpc."
3232

33+
@Suspendable
34+
internal fun FlowLogic<*>.counterpartyPlatformVersion(session: FlowSession): Int {
35+
val nodeInfo = serviceHub.networkMapCache.getNodeByLegalIdentity(session.counterparty)
36+
return nodeInfo?.platformVersion ?: 0
37+
}
38+
3339
// Internal utilities after introducing new confidential identities. To handle different versions.
3440
@Suspendable
3541
internal fun FlowLogic<*>.provideKeyVersion(session: FlowSession): AbstractParty {
3642
val otherFlowVersion = session.getCounterpartyFlowInfo().flowVersion
3743
val topLevelName = FlowLogic.currentTopLevel?.let { it::class.java.canonicalName } ?: ""
3844
// This will work only for initiating flow
39-
return if (otherFlowVersion == 1) {
45+
return if (otherFlowVersion == 1 || counterpartyPlatformVersion(session) < 5) {
4046
if (!topLevelName.startsWith(INITIATING_TOKENS_FLOW)) {
41-
logger.warn("Your CorDapp is using new confidential identities, but other party flow has version 1. Falling back to old CI." +
47+
logger.warn("Your CorDapp is using new confidential identities, but other party flow has version 1 or runs " +
48+
"on platformVersion less than 5. Falling back to old CI." +
4249
"If this is not intended behaviour version your flows with version >= 2")
4350
}
4451
// Old Confidential Identities case
@@ -54,9 +61,10 @@ internal fun FlowLogic<*>.requestKeyVersion(session: FlowSession): AnonymousPart
5461
val otherFlowVersion = session.getCounterpartyFlowInfo().flowVersion
5562
val topLevelName = FlowLogic.currentTopLevel?.let { it::class.java.canonicalName } ?: ""
5663
// This will work only for initiating flow
57-
return if (otherFlowVersion == 1) {
64+
return if (otherFlowVersion == 1 || counterpartyPlatformVersion(session) < 5) {
5865
if (!topLevelName.startsWith(INITIATING_TOKENS_FLOW)) {
59-
logger.warn("Your CorDapp is using new confidential identities, but other party flow has version 1. Falling back to old CI." +
66+
logger.warn("Your CorDapp is using new confidential identities, but other party flow has version 1 or runs " +
67+
"on platformVersion less than 5. Falling back to old CI." +
6068
"If this is not intended behaviour version your flows with version >= 2")
6169
}
6270
// Old Confidential Identities case
@@ -73,9 +81,10 @@ internal fun FlowLogic<*>.syncKeyVersionHandler(session: FlowSession) {
7381
val otherFlowVersion = session.getCounterpartyFlowInfo().flowVersion
7482
val topLevelName = FlowLogic.currentTopLevel?.let { it::class.java.canonicalName } ?: ""
7583
// This will work only for initiating flow
76-
if (otherFlowVersion == 1) {
84+
if (otherFlowVersion == 1 || counterpartyPlatformVersion(session) < 5) {
7785
if (!topLevelName.startsWith(INITIATING_TOKENS_FLOW)) {
78-
logger.warn("Your CorDapp is using new confidential identities, but other party flow has version 1. Falling back to old CI." +
86+
logger.warn("Your CorDapp is using new confidential identities, but other party flow has version 1 or runs " +
87+
"on platformVersion less than 5. Falling back to old CI." +
7988
"If this is not intended behaviour version your flows with version >= 2")
8089
}
8190
// Old Confidential Identities case
@@ -91,9 +100,10 @@ internal fun FlowLogic<*>.syncKeyVersion(session: FlowSession, txBuilder: Transa
91100
val otherFlowVersion = session.getCounterpartyFlowInfo().flowVersion
92101
val topLevelName = FlowLogic.currentTopLevel?.let { it::class.java.canonicalName } ?: ""
93102
// This will work only for initiating flow
94-
if (otherFlowVersion == 1) {
103+
if (otherFlowVersion == 1 && counterpartyPlatformVersion(session) < 5) {
95104
if (!topLevelName.startsWith(INITIATING_TOKENS_FLOW)) {
96-
logger.warn("Your CorDapp is using new confidential identities, but other party flow has version 1. Falling back to old CI." +
105+
logger.warn("Your CorDapp is using new confidential identities, but other party flow has version 1 and runs " +
106+
"on platformVersion less than 5. Falling back to old CI." +
97107
"If this is not intended behaviour version your flows with version >= 2")
98108
}
99109
// Old Confidential Identities case

0 commit comments

Comments
 (0)