def __repr__(self):
     return "CRInfo {" + "\n\t" \
            + "privateKey: {}".format(self.account.private_key()) + "\n\t" \
            + "code: {}".format(self.code) + "\n\t" \
            + "cid : {}".format(keytool.create_address(bytes.fromhex(self.cid))) + "\n\t" \
            + "did : {}".format(keytool.create_address(bytes.fromhex(self.did))) + "\n\t" \
            + "nickname: {}".format(self.nickname) + "\n\t" \
            + "url: {}".format(self.url) + "\n\t" \
            + "location: {}".format(self.location) + "\n\t" \
            + "signature: {}".format(self.signature.hex()) + "\n" \
            + "}"
 def __repr__(self):
     return "Output {" + "\n\t" \
            + "asset_id: " + self.asset_id.hex() + "\n\t" \
            + "value: " + str(self.value) + "\n\t" \
            + "output_lock: " + str(self.output_lock) + "\n\t" \
            + "address: " + keytool.create_address(self.program_hash) + "\n\t" \
            + "output_type: " + str(self.output_type) + "\n\t" \
            + "output_payload: {}".format(self.output_payload) + "\n" \
            + "}"
Example #3
0
 def __repr__(self):
     return "CRCProposalReview {" + "\n\t" \
            + "privateKey: {}".format(self.account.private_key()) + "\n\t" \
            + "proposalHash: {}".format(self.proposal_hash.hex()) + "\n\t" \
            + "voteResult : {}".format(self.vote_result) + "\n\t" \
            + "crOpinionHash: {}".format(self.opinion_hash.hex()) + "\n\t" \
            + "did : {}".format(keytool.create_address(self.did)) + "\n\t" \
            + "sign: {}".format(self.sign.hex()) + "\n\t" \
            + "}"
Example #4
0
 def __repr__(self):
     if self.proposal_type is self.SECRETARY_GENERAL:
         return "CRCProposalSecretaryGeneral {" + "\n\t" \
                + "privateKey: {}".format(self.proposal_type) + "\n\t" \
                + "crCouncilMemberDid: {}".format(self.proposal_type) + "\n\t" \
                + "proposalType: {}".format(self.proposal_type) + "\n\t" \
                + "categoryData : {}".format(self.category_data) + "\n\t" \
                + "sponsorPublicKey : {}".format(self.account.public_key()) + "\n\t" \
                + "draftHash: {}".format(self.draft_hash.hex()) + "\n\t" \
                + "secretaryGeneralPublicKey: {}".format(self.secretary_general_public_key.hex()) + "\n\t" \
                + "secretaryGeneralDid: {}".format(keytool.create_address(self.secretary_general_did)) + "\n\t" \
                + "sign: {}".format(self.sign.hex()) + "\n\t" \
                + "secretaryGeneralSignature: {}".format(self.secretary_general_signature.hex()) + "\n\t" \
                + "crCouncilMemberDid: {}".format(keytool.create_address(self.cr_council_member_did)) + "\n\t" \
                + "crCouncilMemberSign: {}".format(self.cr_council_member_sign.hex()) + "\n\t" \
                + "hash: {}".format(self.hash.hex()) + "\n\t" \
                + "}"
     elif self.proposal_type is self.CHANGE_SPONSOR_OWNER:
         return "CRCProposalChangeSponsor {" + "\n\t" \
                + "proposalType: {}".format(self.proposal_type) + "\n\t" \
                + "categoryData : {}".format(self.category_data) + "\n\t" \
                + "sponsorPublicKey : {}".format(self.account.public_key()) + "\n\t" \
                + "draftHash: {}".format(self.draft_hash.hex()) + "\n\t" \
                + "targetProposalHash: {}".format(self.target_proposal_hash.hex()) + "\n\t" \
                + "newRecipient: {}".format(keytool.create_address(self.new_recipient)) + "\n\t" \
                + "newOwnerPublicKey: {}".format(self.new_owner_public_key.hex()) + "\n\t" \
                + "sign: {}".format(self.sign.hex()) + "\n\t" \
                + "crCouncilMemberDid: {}".format(keytool.create_address(self.cr_council_member_did)) + "\n\t" \
                + "crCouncilMemberSign: {}".format(self.cr_council_member_sign.hex()) + "\n\t" \
                + "hash: {}".format(self.hash.hex()) + "\n\t" \
                + "}"
     elif self.proposal_type is self.CLOSE_PROPOSAL:
         return "CRCProposalCloseProposal {" + "\n\t" \
                + "proposalType: {}".format(self.proposal_type) + "\n\t" \
                + "categoryData : {}".format(self.category_data) + "\n\t" \
                + "sponsorPublicKey : {}".format(self.account.public_key()) + "\n\t" \
                + "draftHash: {}".format(self.draft_hash.hex()) + "\n\t" \
                + "targetProposalHash: {}".format(self.target_proposal_hash.hex) + "\n\t" \
                + "sign: {}".format(self.sign.hex()) + "\n\t" \
                + "crCouncilMemberDid: {}".format(keytool.create_address(self.cr_council_member_did)) + "\n\t" \
                + "crCouncilMemberSign: {}".format(self.cr_council_member_sign.hex()) + "\n\t" \
                + "hash: {}".format(self.hash.hex()) + "\n\t" \
                + "}"
     else:
         return "CRCProposal {" + "\n\t" \
                + "proposalType: {}".format(self.proposal_type) + "\n\t" \
                + "categoryData : {}".format(self.category_data) + "\n\t" \
                + "sponsorPublicKey : {}".format(self.account.public_key()) + "\n\t" \
                + "draftHash: {}".format(self.draft_hash.hex()) + "\n\t" \
                + "budgets: {}".format(self.budget) + "\n\t" \
                + "recipient: {}".format(keytool.create_address(self.recipient)) + "\n\t" \
                + "sign: {}".format(self.sign.hex()) + "\n\t" \
                + "crCouncilMemberDid: {}".format(keytool.create_address(self.cr_council_member_did)) + "\n\t" \
                + "crCouncilMemberSign: {}".format(self.cr_council_member_sign.hex()) + "\n\t" \
                + "hash: {}".format(self.hash.hex()) + "\n\t" \
                + "}"
    def _create_account(self):
        if len(self._private_key) == 0:
            ecc_pair = keytool.create_ecc_pair("P-256")
            self._private_key = ecc_pair.d.to_bytes()

        ecc_pair = keytool.get_ecc_by_private_key(self._private_key.hex())
        self._public_key = keytool.encode_point(ecc_pair.public_key(), True)
        self._redeem_script = keytool.create_redeem_script(self._public_key)
        self._did_redeem_script = keytool.create_did_redeem_script(
            self._public_key)
        self._program_hash = keytool.create_program_hash(self._redeem_script)
        self._cid = keytool.create_id_program_hash(self._redeem_script)
        self._did = keytool.create_id_program_hash(self._did_redeem_script)
        self._address = keytool.create_address(self._program_hash)
 def did_address(self):
     return keytool.create_address(self._did)