def createInvokeProposalForBDD(context, ccSpec, chainID, signersCert, Mspid, type): import binascii "Returns a deployment proposal of chaincode type" lc_chaincode_invocation_spec = chaincode_pb2.ChaincodeInvocationSpec(chaincode_spec = ccSpec) # Create ccHdrExt = proposal_pb2.ChaincodeHeaderExtension(chaincode_id=ccSpec.chaincode_id) ccProposalPayload = proposal_pb2.ChaincodeProposalPayload(input=lc_chaincode_invocation_spec.SerializeToString()) bootstrapHelper = ContextHelper.GetHelper(context=context).getBootrapHelper(chainId=chainID) serializedIdentity = identities_pb2.SerializedIdentity(Mspid=Mspid, IdBytes=crypto.dump_certificate(crypto.FILETYPE_PEM, signersCert)) nonce = bootstrap_util.BootstrapHelper.getNonce() sigHdr = bootstrapHelper.makeSignatureHeader(serializedIdentity.SerializeToString(), nonce) # Calculate the transaction ID tx_id = binascii.hexlify(bootstrap_util.computeCryptoHash(nonce + serializedIdentity.SerializeToString())) chainHdr = bootstrapHelper.makeChainHeader(type=common_dot_common_pb2.HeaderType.Value(type), txID=tx_id, extension=ccHdrExt.SerializeToString()) header = common_dot_common_pb2.Header(channel_header=chainHdr.SerializeToString(), signature_header=sigHdr.SerializeToString()) # make proposal proposal = proposal_pb2.Proposal(header=header.SerializeToString(), payload=ccProposalPayload.SerializeToString()) return proposal
def createInvokeProposalForBDD(context, ccSpec, chainID, signersCert, Mspid, type): import binascii "Returns a deployment proposal of chaincode type" lc_chaincode_invocation_spec = chaincode_pb2.ChaincodeInvocationSpec(chaincode_spec = ccSpec) # Create ccHdrExt = proposal_pb2.ChaincodeHeaderExtension(chaincode_id=ccSpec.chaincode_id) ccProposalPayload = proposal_pb2.ChaincodeProposalPayload(input=lc_chaincode_invocation_spec.SerializeToString()) serializedIdentity = identities_pb2.SerializedIdentity(mspid=Mspid, id_bytes=crypto.dump_certificate(crypto.FILETYPE_PEM, signersCert)) nonce = bootstrap_util.BootstrapHelper.getNonce() sigHdr = bootstrap_util.make_signature_header(serializedIdentity.SerializeToString(), nonce) # Calculate the transaction ID tx_id = binascii.hexlify(bootstrap_util.computeCryptoHash(nonce + serializedIdentity.SerializeToString())) chainHdr = bootstrap_util.make_chain_header(type=common_dot_common_pb2.HeaderType.Value(type), channel_id=chainID, txID=tx_id, extension=ccHdrExt.SerializeToString()) header = common_dot_common_pb2.Header(channel_header=chainHdr.SerializeToString(), signature_header=sigHdr.SerializeToString()) # make proposal proposal = proposal_pb2.Proposal(header=header.SerializeToString(), payload=ccProposalPayload.SerializeToString()) return proposal