Created
August 11, 2021 02:38
-
-
Save davidawad/26164babc8449a67137581a2c7c09dae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
progressTracker.setCurrentStep(TX_SIGNING); | |
// We finalise the transaction by signing it, | |
// converting it into a ``SignedTransaction``. | |
SignedTransaction onceSignedTx = getServiceHub().signInitialTransaction(txBuilder); | |
// We can also sign the transaction using a different public key: | |
PartyAndCertificate otherIdentity = getServiceHub().getKeyManagementService().freshKeyAndCert(getOurIdentityAndCert(), false); | |
SignedTransaction onceSignedTx2 = getServiceHub().signInitialTransaction(txBuilder, otherIdentity.getOwningKey()); | |
// If instead this was a ``SignedTransaction`` that we'd received | |
// from a counterparty and we needed to sign it, we would add our | |
// signature using: | |
SignedTransaction twiceSignedTx = getServiceHub().addSignature(onceSignedTx); | |
// Or, if we wanted to use a different public key: | |
PartyAndCertificate otherIdentity2 = getServiceHub().getKeyManagementService().freshKeyAndCert(getOurIdentityAndCert(), false); | |
SignedTransaction twiceSignedTx2 = getServiceHub().addSignature(onceSignedTx, otherIdentity2.getOwningKey()); | |
// We can also generate a signature over the transaction without | |
// adding it to the transaction itself. We may do this when | |
// sending just the signature in a flow instead of returning the | |
// entire transaction with our signature. This way, the receiving | |
// node does not need to check we haven't changed anything in the | |
// transaction. | |
TransactionSignature sig = getServiceHub().createSignature(onceSignedTx); | |
// And again, if we wanted to use a different public key: | |
TransactionSignature sig2 = getServiceHub().createSignature(onceSignedTx, otherIdentity2.getOwningKey()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment