spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.45k stars 3.09k forks source link

Signed payment request view_url returns octet-stream Content-Type #7672

Open sime opened 2 years ago

sime commented 2 years ago

Navigating to the view_url of payment request returns the following headers

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Etag: "16d49b8fa01a621c-13ad"
Last-Modified: Thu, 17 Feb 2022 15:13:26 GMT
Content-Length: 5037
Accept-Ranges: bytes
Date: Thu, 17 Feb 2022 17:12:01 GMT
Server: Python/3.8 aiohttp/3.8.1

The user agent attempts to download the "page".

It should ideally return something like Content-Type: text/html

SomberNight commented 2 years ago

( duplicate of https://github.com/spesmilo/electrum-merchant/issues/7 - although I guess that repo is sort of deprecated... )

sime commented 2 years ago

Hi @SomberNight

If it's a single line change, please point me to the file and I will test it out and offer a PR.

SomberNight commented 2 years ago

I cannot reproduce the issue... this is what I am trying:

$ ./run_electrum -o setconfig --testnet payserver_address 127.0.0.1:9922
$ ./run_electrum daemon --testnet -d

$ ./run_electrum --testnet load_wallet -w ~/.electrum/testnet/wallets/test_segwit_2
$ ./run_electrum --testnet add_request 0.5 -m "test" -w ~/.electrum/testnet/wallets/test_segwit_2
{
    "URI": "bitcoin:tb1qx42l3d7arvf0zf2jvx0f24wz2dkgph2rwfjwkv?amount=0.5&message=test&time=1645205200&exp=3600",
    "address": "tb1qx42l3d7arvf0zf2jvx0f24wz2dkgph2rwfjwkv",
    "amount_BTC": "0.5",
    "amount_sat": 50000000,
    "expiration": 3600,
    "is_lightning": false,
    "message": "test",
    "status": 0,
    "status_str": "Expires in about 1 hour",
    "timestamp": 1645205200,
    "view_url": "http://127.0.0.1:9922/r/pay?id=tb1qx42l3d7arvf0zf2jvx0f24wz2dkgph2rwfjwkv"
}
$ curl -i http://127.0.0.1:9922/r/pay?id=tb1qx42l3d7arvf0zf2jvx0f24wz2dkgph2rwfjwkv
HTTP/1.1 200 OK
Content-Type: text/html
Etag: "d84223e711e5600-13ad"
Last-Modified: Sat, 11 Nov 2000 11:11:11 GMT
Content-Length: 5037
Accept-Ranges: bytes
Date: Fri, 18 Feb 2022 17:31:52 GMT
Server: Python/3.8 aiohttp/3.8.1

<!DOCTYPE HTML>
<html>
[... snip ...]
</html>

For me it seems Content-Type: text/html gets set.

SomberNight commented 2 years ago

http://127.0.0.1:9922/r/pay?id=tb1qx42l3d7arvf0zf2jvx0f24wz2dkgph2rwfjwkv

pay is a symlink to index.html - could you try and see if it behaves any different for you when accessing that directly instead, so e.g. http://127.0.0.1:9922/r/index.html?id=tb1qx42l3d7arvf0zf2jvx0f24wz2dkgph2rwfjwkv ?

btw these files are exposed to the aiohttp webserver here: https://github.com/spesmilo/electrum/blob/11a04c0d72e92089a0ae1443b8ac2ed37b4b9b19/electrum/daemon.py#L383

sime commented 2 years ago

Yes, I was using a real domain on a publicly available VPS.

Will try with 127.0.0.1.

odiferousmint commented 2 years ago

http://127.0.0.1:9922/r/pay?id=tb1qx42l3d7arvf0zf2jvx0f24wz2dkgph2rwfjwkv

pay is a symlink to index.html - could you try and see if it behaves any different for you when accessing that directly instead, so e.g. http://127.0.0.1:9922/r/index.html?id=tb1qx42l3d7arvf0zf2jvx0f24wz2dkgph2rwfjwkv ?

btw these files are exposed to the aiohttp webserver here:

https://github.com/spesmilo/electrum/blob/11a04c0d72e92089a0ae1443b8ac2ed37b4b9b19/electrum/daemon.py#L383

It works with index.html, does not work with pay. Electrum version 4.2.1.