def initiate(self): """ Called at reactor start to start up hidden service and provide uri string to sender. """ # Note that we don't pass a "failure_callback" to the BIP78 # Protocol; because the only failure is that the payment # HTTP request simply doesn't arrive. Note also that the # "params" argument is None as this is only learnt from request. factory = BIP78ClientProtocolFactory(self, None, self.receive_proposal_from_sender, None, mode="receiver") h = jm_single().config.get("DAEMON", "daemon_host") p = jm_single().config.getint("DAEMON", "daemon_port") - 2000 if jm_single().config.get("DAEMON", "use_ssl") != 'false': reactor.connectSSL(h, p, factory, ClientContextFactory()) else: reactor.connectTCP(h, p, factory)
def send_payjoin(manager, accept_callback=None, info_callback=None, return_deferred=False): """ Given a JMPayjoinManager object `manager`, initialised with the payment request data from the server, use its wallet_service to construct a payment transaction, with coins sourced from mixdepth `manager.mixdepth`, then wait for the server response, parse the PSBT, perform checks and complete sign. The info and accept callbacks are to ask the user to confirm the creation of the original payment transaction (None defaults to terminal/CLI processing), and are as defined in `taker_utils.direct_send`. Returns: (True, None) in case of payment setup successful (response will be delivered asynchronously) - the `manager` object can be inspected for more detail. (False, errormsg) in case of failure. """ success, errmsg = make_payment_psbt(manager, accept_callback, info_callback) if not success: return (False, errmsg) # add delayed call to broadcast this after 1 minute manager.timeout_fallback_dc = reactor.callLater( 60, fallback_nonpayjoin_broadcast, b"timeout", manager) params = make_payjoin_request_params(manager) factory = BIP78ClientProtocolFactory(manager, params, process_payjoin_proposal_from_server, process_error_from_server) h = jm_single().config.get("DAEMON", "daemon_host") p = jm_single().config.getint("DAEMON", "daemon_port") - 2000 if jm_single().config.get("DAEMON", "use_ssl") != 'false': reactor.connectSSL(h, p, factory, ClientContextFactory()) else: reactor.connectTCP(h, p, factory) return (True, None)