def do_send(self, tx): def on_success(result): window.show_message( _("Your transaction was sent to the cosigning pool.") + '\n' + _("Open your cosigner wallet to retrieve it.")) def on_failure(exc_info): e = exc_info[1] try: traceback.print_exception(*exc_info) except OSError: pass window.show_error( _("Failed to send transaction to cosigning pool") + ':\n' + str(e)) for window, xpub, K, _hash in self.cosigner_list: if not self.cosigner_can_sign(tx, xpub): continue # construct message raw_tx_bytes = bfh(str(tx)) public_key = ecc.ECPubkey(K) message = public_key.encrypt_message(raw_tx_bytes).decode('ascii') # send message task = lambda: server.put(_hash, message) msg = _('Sending transaction to cosigning pool...') WaitingDialog(window, msg, task, on_success, on_failure)
def _send(self, parent, blob): def sender_thread(): with self._audio_interface() as interface: src = BytesIO(blob) dst = interface.player() amodem.main.send(config=self.modem_config, src=src, dst=dst) print_msg('Sending:', repr(blob)) blob = zlib.compress(blob.encode('ascii')) kbps = self.modem_config.modem_bps / 1e3 msg = 'Sending to Audio MODEM ({0:.1f} kbps)...'.format(kbps) WaitingDialog(parent, msg, sender_thread)
def _recv(self, parent): def receiver_thread(): with self._audio_interface() as interface: src = interface.recorder() dst = BytesIO() amodem.main.recv(config=self.modem_config, src=src, dst=dst) return dst.getvalue() def on_finished(blob): if blob: blob = zlib.decompress(blob).decode('ascii') print_msg('Received:', repr(blob)) parent.setText(blob) kbps = self.modem_config.modem_bps / 1e3 msg = 'Receiving from Audio MODEM ({0:.1f} kbps)...'.format(kbps) WaitingDialog(parent, msg, receiver_thread, on_finished)
def do_send(self, tx: Union[Transaction, PartialTransaction]): def on_success(result): window.show_message( _("Your transaction was sent to the cosigning pool.") + '\n' + _("Open your cosigner wallet to retrieve it.")) def on_failure(exc_info): e = exc_info[1] try: self.logger.error("on_failure", exc_info=exc_info) except OSError: pass window.show_error( _("Failed to send transaction to cosigning pool") + ':\n' + repr(e)) buffer = [] some_window = None # construct messages for window, xpub, K, _hash in self.cosigner_list: if not self.cosigner_can_sign(tx, xpub): continue some_window = window raw_tx_bytes = tx.serialize_as_bytes() public_key = ecc.ECPubkey(K) message = public_key.encrypt_message(raw_tx_bytes).decode('ascii') buffer.append((_hash, message)) if not buffer: return # send messages # note: we send all messages sequentially on the same thread def send_messages_task(): for _hash, message in buffer: server.put(_hash, message) msg = _('Sending transaction to cosigning pool...') WaitingDialog(some_window, msg, send_messages_task, on_success, on_failure)