Repository: spesmilo/electrum

Issue:
Bitcoin URIs don't work on Mac
Not completely sure why they aren't supported.
Bitcoin URIs are becoming more and more popular, and Electrum is by far my favorite client. However, its one downfall is that it lacks support for these convenient URIs on computers running OSX.



Discussion:
:+1: This would be a useful feature for Electrum. MultiBit has had it for a while.

Agreed this could be helpful; I will see if I can make the OS X binaries support this.

I got it to work on my system. I've [build this binary](https://dl.dropboxusercontent.com/u/374/electrum-master.dmg) for you to test it out. Please let me know if it works for you. (Tested it on Chrome and Safari)

I tried the binary and had mixed results. It did not seem to register the URI scheme; clicking bitcoin: links still opened MultiBit and Chrome did not give an option for Electrum. From the command line, running `open -a Electrum bitcoin:...` works, opening and populating the send interface, but only if the Electrum application is not already running.

I think in your case Electrum and MultiBit are fighting for the rights to open URI scheme. I don't have multibit installed and Safari just opens up my links in Electrum now. Without having to register it for the bitcoin URI scheme first. Chrome might have asked me what to open it with but I can't be sure. 

I think the way OS X works is checking if an app is already running; if it's not it will boot it with the given arguments (bitcoin:.....) but if it's already running it just won't do anything, since it won't boot the application twice. I need to ascertain if this indeed the case or something else goes wrong.

I'm sorry but I can't find a way to make this work when Electrum is already running. I will leave this open to see if anybody else steps up. 

This still doesn't seem to work with the latest release (1.8.1).

Any update on this topic?


Resolving patch:
diff --git a/gui/gui_classic.py b/gui/gui_classic.py
--- a/gui/gui_classic.py
+++ b/gui/gui_classic.py
@@ -2247,18 +2247,28 @@ def closeEvent(self, event):
         self.config.set_key("console-history",self.console.history[-50:])
         event.accept()
 
-
-
-
+class OpenFileEventFilter(QObject):
+    def __init__(self, windows):
+        self.windows = windows
+        super(OpenFileEventFilter, self).__init__()
+
+    def eventFilter(self, obj, event):
+        if event.type() == QtCore.QEvent.FileOpen:
+            if len(self.windows) >= 1:
+                self.windows[0].set_url(event.url().toString())
+                return True
+        return False
 
 class ElectrumGui:
 
     def __init__(self, wallet, config, app=None):
         self.wallet = wallet
         self.config = config
+        self.windows = []
+        self.efilter = OpenFileEventFilter(self.windows)
         if app is None:
             self.app = QApplication(sys.argv)
-
+        self.app.installEventFilter(self.efilter)
 
     def restore_or_create(self):
         msg = _("Wallet file not found.")+"\n"+_("Do you want to create a new wallet, or to restore an existing one?")
@@ -2373,6 +2383,7 @@ def main(self,url):
         s = Timer()
         s.start()
         w = ElectrumWindow(self.wallet, self.config)
+        self.windows.append(w)
         if url: w.set_url(url)
         w.app = self.app
         w.connect_slots(s)


Test patch: