예제 #1
0
    def __init__(self, processed_transaction):
        bootstrap_util.EnvelopeExractor.__init__(
            self, processed_transaction.transactionEnvelope)

        self.processed_transaction = processed_transaction
        self.tx = transaction_pb2.Transaction()
        self.tx.ParseFromString(self.payload.data)

        self.chaincode_action_payload = transaction_pb2.ChaincodeActionPayload(
        )
        self.chaincode_action_payload.ParseFromString(
            self.tx.actions[0].payload)

        # self.signature_header = common_dot_common_pb2.SignatureHeader()
        # self.signature_header.ParseFromString(self.tx.actions[0].header)

        self.chaincode_proposal_payload = proposal_pb2.ChaincodeProposalPayload(
        )
        self.chaincode_proposal_payload.ParseFromString(
            self.chaincode_action_payload.chaincode_proposal_payload)

        self.chaincode_invocation_spec = chaincode_pb2.ChaincodeInvocationSpec(
        )
        self.chaincode_invocation_spec.ParseFromString(
            self.chaincode_proposal_payload.input)
예제 #2
0
def createInvokeProposalForBDD(ccSpec, chainID, signersCert, Mspid, type):
	"Returns a deployment proposal of chaincode type"
	lc_chaincode_invocation_spec = chaincode_pb2.ChaincodeInvocationSpec(chaincodeSpec = ccSpec)

	# Create
	ccHdrExt = chaincode_proposal_pb2.ChaincodeHeaderExtension(chaincodeID=ccSpec.chaincodeID)

	ccProposalPayload = chaincode_proposal_pb2.ChaincodeProposalPayload(Input=lc_chaincode_invocation_spec.SerializeToString())

	bootstrapHelper = bootstrap_util.BootstrapHelper(chainId=chainID)

	chainHdr = bootstrapHelper.makeChainHeader(type=common_dot_common_pb2.HeaderType.Value(type),
											   txID=bootstrap_util.GetUUID(), extension=ccHdrExt.SerializeToString())
	serializedIdentity = identities_pb2.SerializedIdentity(Mspid=Mspid, IdBytes=crypto.dump_certificate(crypto.FILETYPE_PEM, signersCert))


	sigHdr = bootstrapHelper.makeSignatureHeader(serializedIdentity.SerializeToString(), bootstrap_util.BootstrapHelper.getNonce())

	header = common_dot_common_pb2.Header(chainHeader=chainHdr, signatureHeader=sigHdr)

	# make proposal
	proposal = proposal_pb2.Proposal(header=header.SerializeToString(), payload=ccProposalPayload.SerializeToString())


	return proposal
예제 #3
0
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
예제 #4
0
def createDeploymentProposalForBDD(ccDeploymentSpec):
    "Returns a deployment proposal of chaincode type"
    lc_chaincode_spec = chaincode_pb2.ChaincodeSpec(
        type=chaincode_pb2.ChaincodeSpec.GOLANG,
        chaincodeID=chaincode_pb2.ChaincodeID(name="lccc"),
        ctorMsg=chaincode_pb2.ChaincodeInput(
            args=['deploy', 'default',
                  ccDeploymentSpec.SerializeToString()]))
    lc_chaincode_invocation_spec = chaincode_pb2.ChaincodeInvocationSpec(
        chaincodeSpec=lc_chaincode_spec)
    # make proposal
    proposal = fabric_next_pb2.Proposal(
        type=fabric_next_pb2.Proposal.CHAINCODE, id=createPropsalId())
    proposal.payload = lc_chaincode_invocation_spec.SerializeToString()
    return proposal