Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

adcockalexander
Copy link

  • 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)
Copy link
Contributor

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> {
Copy link
Contributor

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()) {
Copy link
Contributor

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()) {
Copy link
Contributor

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)")
Copy link
Contributor

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("")
Copy link
Contributor

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?

Copy link
Contributor

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))
Copy link
Contributor

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))
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what these lines do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants