WIP/NOMERGE External signing enhancements#209
WIP/NOMERGE External signing enhancements#209adcockalexander wants to merge 8 commits intomasterfrom
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
| 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.
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.
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.
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.
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)") |
| 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.
Should it be implemented too?
There was a problem hiding this comment.
or at least some todo
| 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.
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.
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 |