def modify_signing_requirements(self, public_keys_signers, signature_count, low_treshold=0, high_treshold=2, master_weight=2): """modify_signing_requirements sets the signing requirements for a multisig account. It also adds the public keys of the signer to this account. :param public_keys_signers: list of public keys of signers. :type public_keys_signers: list :param signature_count: amount of signatures required to transfer funds. :type signature_count: int :param low_treshold: weight required for low security operations (transaction processing, allow trust, bump sequence) :type low_treshold: int :param high_treshold: weight required for high security operations (set options, account merge) :type high_treshold: int :param master_weight: A number from 0-255 (inclusive) representing the weight of the master key. If the weight of the master key is updated to 0, it is effectively disabled. :type master_weight: int """ account = self.load_account() source_keypair = Keypair.from_secret(self.secret) horizon_server = self._get_horizon_server() base_fee = horizon_server.fetch_base_fee() transaction_builder = TransactionBuilder( account, network_passphrase=_NETWORK_PASSPHRASES[str(self.network)], base_fee=base_fee) # set the signing options transaction_builder.append_set_options_op( low_threshold=low_treshold, med_threshold=signature_count, high_threshold=high_treshold, master_weight=master_weight) # For every public key given, add it as a signer to this account for public_key_signer in public_keys_signers: transaction_builder.append_ed25519_public_key_signer( public_key_signer, 1) transaction_builder.set_timeout(30) tx = transaction_builder.build() tx.sign(source_keypair) try: response = horizon_server.submit_transaction(tx) self._log_info(response) self._log_info( "Set the signers of {address} to require {signature_count} signers" .format(address=self.address, signature_count=signature_count)) except BadRequestError: self._log_info( "Transaction need additional signatures in order to send") return tx.to_xdr()
def modify_signing_requirements(self, public_keys_signers, signature_count, low_treshold=1, high_treshold=2): """modify_signing_requirements sets to amount of signatures required for the creation of multisig account. It also adds the public keys of the signer to this account :param public_keys_signers: list of public keys of signers. :type public_keys_signers: list :param signature_count: amount of signatures requires to transfer funds. :type signature_count: str :param low_treshold: amount of signatures required for low security operations (transaction processing, allow trust, bump sequence) :type low_treshold: str :param high_treshold: amount of signatures required for high security operations (set options, account merge) :type: str """ if len(public_keys_signers) != signature_count - 1: raise Exception( "Number of public_keys must be 1 less than the signature count in order to set the signature count" ) account = self.load_account() source_keypair = Keypair.from_secret(self.secret) transaction_builder = TransactionBuilder(account) # set the signing options transaction_builder.append_set_options_op( low_threshold=low_treshold, med_threshold=signature_count, high_threshold=high_treshold ) # For every public key given, add it as a signer to this account for public_key_signer in public_keys_signers: transaction_builder.append_ed25519_public_key_signer(public_key_signer, 1) transaction_builder.set_timeout(30) tx = transaction_builder.build() tx.sign(source_keypair) horizon_server = self._get_horizon_server() try: response = horizon_server.submit_transaction(tx) self._log_info(response) self._log_info( "Set the signers of {address} to require {signature_count} signers".format( address=self.address, signature_count=signature_count ) ) except BadRequestError: self._log_info("Transaction need additional signatures in order to send") return tx.to_xdr()