-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP/NOMERGE External signing enhancements #209
base: master
Are you sure you want to change the base?
Conversation
adcockalexander
commented
Aug 27, 2020
- Moves Corda version to 4.6
- Adds 'haltForExternalSigning' parameter to flows for moving tokens, which can be set to true to make these flows halt while awaiting a transaction signature (intended for calls to external services)
- External calls will timeout after 30 minutes
@@ -49,7 +50,7 @@ abstract class AbstractTokenContract<AT : AbstractToken> : Contract { | |||
// Issuances should only contain one issue command. | |||
is IssueTokenCommand -> verifyIssue(commands.single(), inputs, outputs, attachments, references) | |||
// Moves may contain more than one move command. | |||
is MoveTokenCommand -> verifyMove(commands, inputs, outputs, attachments, references) | |||
is MoveTokenCommand -> verifyMove(commands, inputs, outputs, attachments, references, summary) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redeem doesn't need summary? It should be signed by token holder too
inputs: List<TransactionState<ContractState>>, | ||
outputs: List<TransactionState<ContractState>>, | ||
commands: List<CommandData>, | ||
attachments: List<SecureHash>): List<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are references not needed?
outputs: List<TransactionState<ContractState>>, | ||
commands: List<CommandData>, | ||
attachments: List<SecureHash>): List<String> { | ||
return when(commands.first()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if this throws on empty list? add edge cases
outputs: List<TransactionState<ContractState>>, | ||
commands: List<CommandData>, | ||
attachments: List<SecureHash>): List<String> { | ||
return when(commands.first()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we check only first? what if we have more command data?
// Moves may contain more than one move command. | ||
is MoveTokenCommand -> constructMoveDescription(inputs, outputs) | ||
// Redeems must only contain one redeem command. | ||
is RedeemTokenCommand -> listOf("I AM A REDEPMPTION SONG)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂
return when(commands.first()) { | ||
//verify the type jar presence and correctness | ||
// Issuances should only contain one issue command. | ||
is IssueTokenCommand -> listOf("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be implemented too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or at least some todo
@@ -38,6 +41,6 @@ constructor( | |||
participantSessions.forEach { it.send(TransactionRole.PARTICIPANT) } | |||
observerSessions.forEach { it.send(TransactionRole.OBSERVER) } | |||
val confidentialOutput = subFlow(ConfidentialTokensFlow(listOf(output), participantSessions)).single() | |||
return subFlow(MoveTokensFlow(input, confidentialOutput, participantSessions, observerSessions)) | |||
return subFlow(MoveTokensFlow(listOf(input), listOf(confidentialOutput), participantSessions, observerSessions, haltForExternalSigning)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to change it to listOf(input) etc
?: throw IllegalArgumentException("Didn't provide transactionBuilder nor signedTransaction to the flow.") | ||
|
||
val stx = if (haltForExternalSigning) { | ||
await(SignTransactionOperation(transactionBuilder!!, ourSigningKeys, serviceHub)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove !! because it throws null pointer exception without explaining what happened. Have meaningful error handling if the transaction builder is null
val moveFrom = inputs.first().asFungibleToken().holder.owningKey | ||
val moveTo = (outputs.map { it.asFungibleToken().holder }).firstOrNull { p -> p.owningKey != moveFrom }?.owningKey ?: throw IllegalArgumentException("") | ||
val amountToMove = outputs.filter { p -> p.asFungibleToken().holder.owningKey != moveFrom }.first().asFungibleToken().amount | ||
amountToMove.displayTokenSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what these lines do?