try fixing email plugin

This commit is contained in:
SomberNight 2020-06-13 19:12:22 +02:00
parent 0b224ba685
commit eb39aa143b
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -180,21 +180,24 @@ class Plugin(BasePlugin):
window = get_parent_main_window(menu) window = get_parent_main_window(menu)
menu.addAction(_("Send via e-mail"), lambda: self.send(window, addr)) menu.addAction(_("Send via e-mail"), lambda: self.send(window, addr))
def send(self, window: ElectrumWindow, addr): # FIXME this is broken def send(self, window: ElectrumWindow, addr):
from electrum import paymentrequest from electrum import paymentrequest
r = window.wallet.receive_requests.get(addr) req = window.wallet.receive_requests.get(addr)
message = r.get('memo', '') if not isinstance(req, OnchainInvoice):
if r.get('signature'): window.show_error("Only on-chain requests are supported.")
pr = paymentrequest.serialize_request(r) return
message = req.message
if req.bip70:
payload = bytes.fromhex(req.bip70)
else: else:
pr = paymentrequest.make_request(self.config, r) pr = paymentrequest.make_request(self.config, req)
if not pr: payload = pr.SerializeToString()
if not payload:
return return
recipient, ok = QInputDialog.getText(window, 'Send request', 'Email invoice to:') recipient, ok = QInputDialog.getText(window, 'Send request', 'Email invoice to:')
if not ok: if not ok:
return return
recipient = str(recipient) recipient = str(recipient)
payload = pr.SerializeToString()
self.logger.info(f'sending mail to {recipient}') self.logger.info(f'sending mail to {recipient}')
try: try:
# FIXME this runs in the GUI thread and blocks it... # FIXME this runs in the GUI thread and blocks it...