Skip to content

Instantly share code, notes, and snippets.

@davidawad
Created August 11, 2021 19:33
Show Gist options
  • Save davidawad/b8de0a7edb14655393f8da4b362d68ba to your computer and use it in GitHub Desktop.
Save davidawad/b8de0a7edb14655393f8da4b362d68ba to your computer and use it in GitHub Desktop.
progressTracker.setCurrentStep(SIGS_GATHERING);
// The list of parties who need to sign a transaction is dictated
// by the transaction's commands. Once we've signed a transaction
// ourselves, we can automatically gather the signatures of the
// other required signers using ``CollectSignaturesFlow``.
// The responder flow will need to call ``SignTransactionFlow``.
SignedTransaction fullySignedTx = subFlow(new CollectSignaturesFlow(twiceSignedTx, emptySet(), SIGS_GATHERING.childProgressTracker()));
progressTracker.setCurrentStep(VERIFYING_SIGS);
try {
// We can verify that a transaction has all the required
// signatures, and that they're all valid, by running:
fullySignedTx.verifyRequiredSignatures();
// If the transaction is only partially signed, we have to pass in
// a vararg of the public keys corresponding to the missing
// signatures, explicitly telling the system not to check them.
onceSignedTx.verifySignaturesExcept(counterpartyPubKey);
// There is also an overload of ``verifySignaturesExcept`` which accepts
// a ``Collection`` of the public keys corresponding to the missing
// signatures. In the example below, we could also use
// ``Arrays.asList(counterpartyPubKey)`` instead of
// ``Collections.singletonList(counterpartyPubKey)``.
onceSignedTx.verifySignaturesExcept(singletonList(counterpartyPubKey));
// We can also choose to only check the signatures that are
// present. BE VERY CAREFUL - this function provides no guarantees
// that the signatures are correct, or that none are missing.
twiceSignedTx.checkSignaturesAreValid();
} catch (GeneralSecurityException e) {
// Handle this as required.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment