def _handle_transaction_signing( self, signing_msg: SigningMessage, signing_dialogue: SigningDialogue ) -> None: """ Handle a transaction for signing. :param signing_msg: the signing message :param signing_dialogue: the signing dialogue :return: None """ performative = self.signing_msg_class.Performative.ERROR kwargs = { "error_code": self.signing_msg_class.ErrorCode.UNSUCCESSFUL_TRANSACTION_SIGNING, } # type: Dict[str, Any] if self._is_acceptable_for_signing(signing_msg): signed_tx = self.wallet.sign_transaction( signing_msg.raw_transaction.ledger_id, signing_msg.raw_transaction.body ) if signed_tx is not None: performative = self.signing_msg_class.Performative.SIGNED_TRANSACTION kwargs.pop("error_code") kwargs["signed_transaction"] = SignedTransaction( signing_msg.raw_transaction.ledger_id, signed_tx ) signing_msg_response = signing_dialogue.reply( performative=performative, target_message=signing_msg, **kwargs, ) self.message_out_queue.put(signing_msg_response)
def _handle_message_signing( self, signing_msg: SigningMessage, signing_dialogue: SigningDialogue ) -> None: """ Handle a message for signing. :param signing_msg: the signing message :param signing_dialogue: the signing dialogue :return: None """ performative = self.signing_msg_class.Performative.ERROR kwargs = { "error_code": self.signing_msg_class.ErrorCode.UNSUCCESSFUL_MESSAGE_SIGNING, } # type: Dict[str, Any] if self._is_acceptable_for_signing(signing_msg): signed_message = self.wallet.sign_message( signing_msg.raw_message.ledger_id, signing_msg.raw_message.body, signing_msg.raw_message.is_deprecated_mode, ) if signed_message is not None: performative = self.signing_msg_class.Performative.SIGNED_MESSAGE kwargs.pop("error_code") kwargs["signed_message"] = SignedMessage( signing_msg.raw_message.ledger_id, signed_message, signing_msg.raw_message.is_deprecated_mode, ) signing_msg_response = signing_dialogue.reply( performative=performative, target_message=signing_msg, **kwargs, ) self.message_out_queue.put(signing_msg_response)