def shutdown(self): """ Triggered when processing has completed successfully or failed, receiver side. """ process_shutdown(self.mode) # on receiver side, if we are part of a long running # process (meaning above process_shutdown is a no-op), # we need to abandon the delayed call (this is the normal # success case): tfdc = self.manager.timeout_fallback_dc if tfdc and tfdc.active(): tfdc.cancel() self.info_callback("Hidden service shutdown complete") if self.shutdown_callback: self.shutdown_callback()
def default_end_requests_callback(self, response): process_shutdown()
def process_payjoin_proposal_from_server(response_body, manager): assert isinstance(manager, JMPayjoinManager) try: payjoin_proposal_psbt = \ btc.PartiallySignedTransaction.from_base64(response_body) except Exception as e: log.error("Payjoin tx from server could not be parsed: " + repr(e)) fallback_nonpayjoin_broadcast(b"Server sent invalid psbt", manager) return log.debug("Receiver sent us this PSBT: ") log.debug( manager.wallet_service.human_readable_psbt(payjoin_proposal_psbt)) # we need to add back in our utxo information to the received psbt, # since the servers remove it (not sure why?) for i, inp in enumerate(payjoin_proposal_psbt.unsigned_tx.vin): for j, inp2 in enumerate(manager.initial_psbt.unsigned_tx.vin): if (inp.prevout.hash, inp.prevout.n) == (inp2.prevout.hash, inp2.prevout.n): payjoin_proposal_psbt.set_utxo( manager.initial_psbt.inputs[j].utxo, i, force_witness_utxo=True) signresultandpsbt, err = manager.wallet_service.sign_psbt( payjoin_proposal_psbt.serialize(), with_sign_result=True) if err: log.error("Failed to sign PSBT from the receiver, error: " + err) fallback_nonpayjoin_broadcast(manager, err=b"Failed to sign receiver PSBT") return signresult, sender_signed_psbt = signresultandpsbt assert signresult.is_final success, msg = manager.set_payjoin_psbt(payjoin_proposal_psbt, sender_signed_psbt) if not success: log.error(msg) fallback_nonpayjoin_broadcast(manager, err=b"Receiver PSBT checks failed.") return # All checks have passed. We can use the already signed transaction in # sender_signed_psbt. log.info("Our final signed PSBT is:\n{}".format( manager.wallet_service.human_readable_psbt(sender_signed_psbt))) manager.set_final_payjoin_psbt(sender_signed_psbt) # broadcast the tx extracted_tx = sender_signed_psbt.extract_transaction() log.info("Here is the final payjoin transaction:") log.info(btc.human_readable_transaction(extracted_tx)) if not jm_single().bc_interface.pushtx(extracted_tx.serialize()): log.info("The above transaction failed to broadcast.") else: log.info("Payjoin transaction broadcast successfully.") # if transaction is succesfully broadcast, remove the # timeout fallback to avoid confusing error messages: if manager.timeout_fallback_dc and manager.timeout_fallback_dc.active( ): manager.timeout_fallback_dc.cancel() manager.set_broadcast(True) if manager.mode == "command-line" and reactor.running: process_shutdown()
def quit(): if manager.mode == "command-line" and reactor.running: process_shutdown()
def process_proposals(self, proposals): self.client.process_proposals(proposals) if self.oneshot: process_shutdown()
def shutdown(self): self.tor_connection.protocol.transport.loseConnection() process_shutdown(self.mode) self.info_callback("Hidden service shutdown complete") if self.shutdown_callback: self.shutdown_callback()
def setup_failed(self, arg): errmsg = "Setup failed: " + str(arg) log.error(errmsg) self.info_callback(errmsg) process_shutdown()