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

2 differents parties can't send each other cash in 2 currencies in 1 single tx #4110

Open
foultre opened this Issue Oct 24, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@foultre
Copy link

foultre commented Oct 24, 2018

This is because Cash.verify() checks that there is only one Move command in verifyMoveCommand: val command = commands.requireSingleCommand<T>()

The Cash.verify() function groups inputs,outputs, and keys by Token but commands are not grouped:

for ((inputs, outputs, key) in groups) { 
...
verifyMoveCommand<Commands.Move>(inputs, tx.commands)
}
@joeldudleyr3

This comment has been minimized.

Copy link
Contributor

joeldudleyr3 commented Oct 26, 2018

@foultre Doesn't it work fine if you put in two sets of currencies, but only one Move command?

@joeldudleyr3 joeldudleyr3 added the bug label Oct 26, 2018

@foultre

This comment has been minimized.

Copy link
Author

foultre commented Oct 26, 2018

2 parties send different tokens so they each generate a move command from the Cash.generateSpend() function

@foultre

This comment has been minimized.

Copy link
Author

foultre commented Oct 29, 2018

dirty fix :

fun rebuildMoveCommand(txb:TransactionBuilder): TransactionBuilder {
    val moveCmds: List<Command<*>>  = txb.commands().filter{it.value is MoveCommand}
    val signersOfCashMoveCmd = mutableListOf<PublicKey>()
    for (elem in moveCmds){
        signersOfCashMoveCmd.addAll(elem.signers)
    }
    val moveCmd = Command(Cash().generateMoveCommand(), signersOfCashMoveCmd)
    val otherCmds  = txb.commands().filter{it.value !is MoveCommand}
    val allCmd  = otherCmds.plus(moveCmd)
    return TransactionBuilder(
            notary = txb.notary,
            inputs = ArrayList(txb.inputStates()),
            attachments = ArrayList(txb.attachments()),
            outputs = ArrayList(txb.outputStates()),
            commands = ArrayList(allCmd),
            window = null,
            privacySalt = PrivacySalt()
    )
}
@joeldudleyr3

This comment has been minimized.

Copy link
Contributor

joeldudleyr3 commented Nov 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.