<p>The simple answer is that when the parameter '%U' is missing from the 'Exec' line in a gnome/Ubuntu desktop file, the OS creates a new instance whenever the application is called (in this case by the browser on clicking a bitcoin: link on a web page). That fails when the application can only have one instance running (bitcoin-qt by itself handles the bitcoin database; no other app/instance can be simultaneously doing this).</p>
<p>The 'magic' is that when the '%U' parameter is present, the OS sends the request to the running app and, in this case, that appears as a bitcoin transaction in bitcoin-qt as expected.</p>
<p>Over the years of playing with bitcoin.desktop, i had managed to lose that parameter somehow. Very confusing.</p>

CC BY-SA 4.0
2021-12-29T02:23:31.330Z
2021-12-29T02:23:31.330Z
harrym
<p>I run bitcoin-qt all the time, so I set the browser to handle bitcoin: URI with bitcoin-qt.
Unfortunately that causes a new instance to be started, which fails coz it fails to get a lock on the database.</p>
<p>What's the best way to do this?</p>
<p>I have 'server=1' to enable json-rpc access to bitcoin-qt.</p>
<p>Do I need to set the browser to handle these links with (say) bitcoin-cli?
Or do I need to reconfigure the whole thing and run bitcoind as well?</p>

CC BY-SA 4.0
2021-12-26T22:32:05.423Z
I've duplicated the question on askubuntu as well: https://askubuntu.com/questions/1383898/bitcoin-uri-handling
harrym
CC BY-SA 4.0
2021-12-27T01:50:49.907Z
My question isn't about general URI handling tho. It's only bitcoin that I have the problem with.

Even a mp4 link works when (say) vlc is already running. There's no issue with locking of course, but vlc has an option to run a new instance or start the video in the existing instance.

That's why I'm here. It's very bitcoin specific, but I feel sure there's a 'best' way to handle it.
harrym
CC BY-SA 4.0
2021-12-27T15:10:11.953Z
Ouch! That's what I want.
What is that '-W1' in the title? Is that relevant?
Mine is v22.0.0
harrym
CC BY-SA 4.0
2021-12-27T15:18:06.997Z
Just to confirm: you had bitcoin-qt already running when you clicked that link?
harrym
CC BY-SA 4.0
2021-12-27T16:27:58.270Z
Maybe my desktop file is bad. Does this look like yours?

[Desktop Entry]

Type=Application

Name=Bitcoin

Icon=/home/xxx/.local/share/icons/bitcoin.svg

Exec=/usr/bin/bitcoin-qt -min -testnet=0 -regtest=0

Terminal=false

Hidden=false
harrym
CC BY-SA 4.0
2021-12-27T16:30:36.600Z
Thanks for your time btw. This is looking like a bad configuration on my end somehow.
harrym
CC BY-SA 4.0
2021-12-27T23:15:40.683Z
OK. I got it working! It needed a parameter (%U) in the exec line of the desktop file.
harrym
CC BY-SA 4.0
2021-12-27T23:18:17.290Z
For anyone else trying this, note that the BIP-21 bitcoin wiki page (https://en.bitcoin.it/wiki/BIP_0021) examples of bitcoin:<address> links don't work. They are invalid addresses now for some reason. I needed to get a link from bitrefill to get this thing to behave.
harrym
<bitcoin-core><json-rpc>
Correct way to implement bitcoin:<address> URI handling in Gnome desktop
harrym
# Correct way to implement bitcoin:<address> URI handling in Gnome desktop

(Asked by: username_0 on 2021-12-25)

I run bitcoin-qt all the time, so I set the browser to handle bitcoin: URI with bitcoin-qt.
Unfortunately that causes a new instance to be started, which fails coz it fails to get a lock on the database.

What's the best way to do this?

I have 'server=1' to enable json-rpc access to bitcoin-qt.

Do I need to set the browser to handle these links with (say) bitcoin-cli?
Or do I need to reconfigure the whole thing and run bitcoind as well?

**Tags:** bitcoin-core, json-rpc

> **Comments:**
> **username_0**: I've duplicated the question on askubuntu as well: https://askubuntu.com/questions/1383898/bitcoin-uri-handling  
> **username_0**: My question isn't about general URI handling tho. It's only bitcoin that I have the problem with.  Even a mp4 link works when (say) vlc is already running. There's no issue with locking of course, but vlc has an option to run a new instance or start the video in the existing instance.  That's why I'm here. It's very bitcoin specific, but I feel sure there's a 'best' way to handle it.  
> **username_0**: Ouch! That's what I want. What is that '-W1' in the title? Is that relevant? Mine is v22.0.0  
> **username_0**: Just to confirm: you had bitcoin-qt already running when you clicked that link?  
> **username_0**: Maybe my desktop file is bad. Does this look like yours?  [Desktop Entry]  Type=Application  Name=Bitcoin  Icon=/home/xxx/.local/share/icons/bitcoin.svg  Exec=/usr/bin/bitcoin-qt -min -testnet=0 -regtest=0  Terminal=false  Hidden=false  
> **username_0**: Thanks for your time btw. This is looking like a bad configuration on my end somehow.  
> **username_0**: OK. I got it working! It needed a parameter (%U) in the exec line of the desktop file.  
> **username_0**: For anyone else trying this, note that the BIP-21 bitcoin wiki page (https://en.bitcoin.it/wiki/BIP_0021) examples of bitcoin:<address> links don't work. They are invalid addresses now for some reason. I needed to get a link from bitrefill to get this thing to behave.  

---

## 1 answers

### Answer by username_0 on 2021-12-29. Score: 3 | Accepted answer

The simple answer is that when the parameter '%U' is missing from the 'Exec' line in a gnome/Ubuntu desktop file, the OS creates a new instance whenever the application is called (in this case by the browser on clicking a bitcoin: link on a web page). That fails when the application can only have one instance running (bitcoin-qt by itself handles the bitcoin database; no other app/instance can be simultaneously doing this).

The 'magic' is that when the '%U' parameter is present, the OS sends the request to the running app and, in this case, that appears as a bitcoin transaction in bitcoin-qt as expected.

Over the years of playing with bitcoin.desktop, i had managed to lose that parameter somehow. Very confusing.


---

