Sign this transaction envelope with a given keypair.

        Note that the signature must not already be in this instance's list of
        signatures.

        :param keypair: The keypair to use for signing this transaction
            envelope.
        :type keypair: :class:`Keypair <stellar_base.keypair.Keypair>`
        :raises: :exc:`SignatureExistError
            <stellar_base.utils.SignatureExistError>`

def sign(self, keypair):
        """Sign this transaction envelope with a given keypair.

        Note that the signature must not already be in this instance's list of
        signatures.

        :param keypair: The keypair to use for signing this transaction
            envelope.
        :type keypair: :class:`Keypair <stellar_base.keypair.Keypair>`
        :raises: :exc:`SignatureExistError
            <stellar_base.utils.SignatureExistError>`

        """
        assert isinstance(keypair, Keypair)
        tx_hash = self.hash_meta()
        sig = keypair.sign_decorated(tx_hash)
        sig_dict = [signature.__dict__ for signature in self.signatures]
        if sig.__dict__ in sig_dict:
            raise SignatureExistError('The keypair has already signed')
        else:
            self.signatures.append(sig)