SatoshiPortal / cyphernode

Modular Bitcoin full-node microservices API server architecture and utilities toolkit to build scalable, secure and featureful apps and services without trusted third parties
MIT License
363 stars 68 forks source link

Specter #229

Open BytesTrust opened 2 years ago

BytesTrust commented 2 years ago

Remote specter access from a other specter running on desktop is not working 401 Unauthorized I assume it because of the cyphernode welcome app password

Kexkey commented 2 years ago

Thanks for the report! Last time I tried it was working well, I will have to try again with the latest version of the desktop app.

Also, I'll write a how-to and make sure the needed configuration in Specter is clear.

BytesTrust commented 2 years ago

Let me know asap I am trying to use cyphernode for my project and I also need specter running

BytesTrust commented 2 years ago

@Kexkey any fix i really need to make that work asap???

ghost commented 2 years ago

@BytesTrust specter connects through RPC and the RPC port isn't open by default in docker-compose.yaml. To fix this you can open the port under: cyphernode/dist/docker-compose.yaml

    ports:
      - "8333:8333"
      - "8332:8332"

Keep in mind any security implications depending on where you run your node or if you have port forwarding turned on anywhere.

After editing I just ran ./stop.sh and ./start.sh and then was able to connect the external specter.

Screenshot from 2021-10-04 21-16-28

BytesTrust commented 2 years ago

There is no location called cyphernode/dist/docker-compose.yaml Are you talking about the root docker-compose.yaml if yes i add the port at which location in the file ? or are you talking about the /cyphernode/apps/specte/docker-compose.yaml @radixrat

ghost commented 2 years ago

There is no location called cyphernode/dist/docker-compose.yaml Are you talking about the root docker-compose.yaml if yes i add the port at which location in the file ? or are you talking about the /cyphernode/apps/specte/docker-compose.yaml @radixrat

if you ran setup.sh under dist it would have created a docker-compose.yaml (and other configs), but I think we are both referring to the "root" docker-compose.yaml (where all the container specs are defined). Just go to the section for BITCOIN and you should see a section that looks like:

ports:
      - "8333:8333"

you can add the RPC port to that to expose it on the next ./stop.sh ./start.sh cycle

ports:
      - "8333:8333"
      - "8332:8332"
BytesTrust commented 2 years ago

No section with ports:

ghost commented 2 years ago

@BytesTrust when you are entering the details into specter are you now using the new open port 8332 along with the IP to your cyphernode instead of what was there before? If connecting directly to RPC port and getting 401 the only option would be that your RPC password isn't right.

I would look directly in your bitcoin.conf file to see the password value and make sure it matches.

BytesTrust commented 2 years ago

I am not sure if we are talking about the same thing . I am trying to use the option in preference which is : Yes, I run Specter remotely which give me 401 Unauthorized I am trying to connect from my Specter running on my desktop to Specter running in the cloud as cyphernode. In the specter Preference you can't enter port . I try to enter https://cyphernodeiphost:8333/specter/ or https://cyphernodeiphost:8332/specter/ din't work.

I was not trying to launch Specter desktop and use option: No, run Specter locally to connect to remote RPC port specter desktop

Remote connection to bitcoin core RPC work but that not what i am trying to achieve . I want to connect my hardware wallet but specter is running as cyphernode in the clound @radixrat

BytesTrust commented 2 years ago

Specter cyphernode Docker image server as a lot of defect almost all function don't work /hwi/api/ don't work, tor dont work and it seem remote access also don't work because I did some testing running specter server from original source everything work perfectly . @Kexkey @radixrat

BytesTrust commented 2 years ago

i think the option Yes, I run Specter remotely don't work because there a password to access cyphernode server

ghost commented 2 years ago

Okay I only connect between computers on my internal network and was just connecting to bitcoin RPC port so sounds like you are trying to go directly through cyphernode and get traffic forwarded to RPC port, I didn't know this was possible as an option (I just recently installed)

Kexkey commented 2 years ago

Hi guys,

When I first integrated Specter to Cyphernode, I made sure the remote hwi bridging was working correctly. Indeed, by running a local version of specterd with the remote instance running inside Cyphernode, I was able to get to my hardware wallet when the configuration was correctly set.

Unfortunately, it doesn't seem to work anymore. I managed to find a few hours to test it last week and wasn't successful. I am not yet sure where the problem is and I need to figure it out. There is a problem with the URL context path support in Specter and the fact that we are accessing it with /specter/ in the URL is problematic specifically with the hwi stuff. You can see it when using the browser's inspect -> network, you'll see one of the requests is getting rid of the /specter/ context path and gives a 404 or something like that IIRC.

I've been excessively busy lately but I think it's important to make it work. I will prioritize this.

BytesTrust commented 2 years ago

I did some test I installed a specter server from a docker image into my kubernetes cluster and i am able to connect to it remotely from my desktop without any problem and the ledger wallet work @Kexkey Therefor there a problem with cyphernode specter server

Kexkey commented 2 years ago

What is the URL of the remote specter instance? Is it like https://yourserver/settings/hwi or https://yourserver/specter/settings/hwi ?

The /specter part (context path url or slug) is indeed because of cyphernode. I had to make a PR to Specter for it to support that but I think something changed since then and we lost that support when it comes to deal with remote hwi... when you click on "Test connection", you will find a 404 in the Network panel of the browser's inspector and you can see it's requesting at https://yourserver/hwi/api/ instead of https://yourserver/specter/hwi/api/ ...

BytesTrust commented 2 years ago

When i connect from my desktop specter to my specter server running on kubernetes i only have to enter my domain which i have whitelisted in the specter server http://subdomain.domain.com .

USB settings 1 .Access the device bridge settings. Click here. i add http://subdomain.domain.com then in specter desktop i add http://subdomain.domain.com and it work but with cyphernode specter none that work 404 not found when trying to whitelist 1 .Access the device bridge settings. Click here.

Kexkey commented 2 years ago

Ok I got it working.

I first thought the local specter server was making requests to the remote specter server, but that's not how it works. The browser is actually making the requests to both servers and is acting as the bridge between the two specter instances. The problem we were getting is that most browsers nowadays don't want to mix secure and insecure contents... and since the remote specter was accessed via https and the local one via http, the browser just didn't allow it.

After configuring the browser so that it will accept connecting to http://127.0.0.1:25441 from a https://cyphernode/specter page, you need to add the Cyphernode's domain in the local specter's whitelisted domains -- but here again, the mistake was using https://cyphernode/specter/ in the whitelist instead of https://cyphernode/.

I am upgrading to Specter v1.7.0 in the dev branch. It will be in the next release with documentation on how to make it work, step-by-step. :)

btw I tested with v1.7.0-pre1 locally (new server arg instead of --hwibridge) and with v0.7.0-pre1 remote as well as v1.3.1 remote and it worked.

Let me know if this works for you!

BytesTrust commented 2 years ago

Cyphernode specter bridge settings(Access the device bridge settings) are not accesible it always 404 not found when you try click on it to whitelist some domain. In the client side desktop you can whitelist since you need to be connected to the remote specter cyphernode. Also how do you configure the browser? Can you please give more details about the setup @Kexkey

Kexkey commented 2 years ago

I am using it with v1.7.0:

  1. Download release v1.7.0 from https://github.com/cryptoadvance/specter-desktop/releases
  2. Plug in your hardware wallet, enter pin
  3. Run Specter locally: ./specterd server --hwibridge
  4. Go to http://localhost:25441/hwi with any browser
  5. Add https://yourcyphernode/ to the whitelisted domains and click update
  6. Using Chrome or Chromium, go to https://yourcyphernode/specter and enter your Cyphernode's credentials
  7. Go to "Settings/USB Devices", select "Remote Specter USB connection", click "Save Changes" and click "Test connection"

If it doesn't work, right-click on the page, select "Inspect" and "Console" and report the error message, I will try to help.

Notes: Didn't have any success with Safari. Tor Browser tries to go through Tor to access http://localhost and obviously it fails. That's why I suggest using Chrome. Haven't tried with Firefox yet.

BytesTrust commented 2 years ago

chrome and brave hwi.js:23 POST https://x.x.x.x/hwi/api/ 404 cant detect device @Kexkey

Kexkey commented 2 years ago

That is supposed to be localhost or 127.0.0.1 because you should be running specterd locally. Also should be on port 25441 (spectred's default port). This means you haven't configured your Cyphernode's Specter correctly: see step 7.

In your Cyphernode's Specter:

Screen Shot 2021-11-02 at 12 32 48 PM

When choosing "Remote Specter USB connection", it means "remote from the Cyphernode's Specter instance"... it is actually running locally on your browser's computer.

For your locally-running specterd:

Screen Shot 2021-11-02 at 12 40 02 PM

Give me news...

BytesTrust commented 2 years ago

brave and chrome hwi.js:23 POST http://127.0.0.1:25441/hwi/api/ net::ERR_FAILED fetch @ hwi.js:23 enumerate @ hwi.js:47 enumerate @ hwi:1609 testHWIConnection @ hwi:1844 onclick @ hwi:1837 hwi:1590 TypeError: Failed to fetch at HWIBridge.fetch (hwi.js:23) at HWIBridge.enumerate (hwi.js:47) at enumerate (hwi:1609) at testHWIConnection (hwi:1844) at HTMLButtonElement.onclick (hwi:1837)

i understand what you trying to do but for some reason chrome and brave block it @Kexkey

BytesTrust commented 2 years ago

Any fix @Kexkey

Kexkey commented 2 years ago

I can't reproduce what you're seeing. Can you describe step-by-step what you are doing so I can reproduce it and understand where the problem is?

Thanks!

BytesTrust commented 2 years ago

I did exactly what you said @Kexkey

BytesTrust commented 2 years ago

Plug in your hardware wallet, enter pin Run Specter locally: sudo ./specterd server --hwibridge Go to http://localhost:25441/hwi with any browser Go to http://localhost:25441/hwi with try firefox or chrome Add https://yourcyphernode/ to the whitelisted domains and click update (even try to add remove ip many combination) Using Chrome or Chromium, go to https://yourcyphernode/specter and enter your Cyphernode's credentials (try brave chrome firefox) Go to "Settings/USB Devices", select "Remote Specter USB connection", click "Save Changes" and click "Test connection" Fail to detect device chrome error Failed to load resource: net::ERR_BLOCKED_BY_CLIENT hwi:1586 TypeError: Failed to fetch at HWIBridge.fetch (hwi.js:23) at HWIBridge.enumerate (hwi.js:47) at enumerate (hwi:1605) at testHWIConnection (hwi:1840) at HTMLButtonElement.onclick (h

I was able to make it work via firefox . For brave chrome i think the problem as to do with some add blocker stuff!. https://stackoverflow.com/questions/22318119/i-am-getting-failed-to-load-resource-neterr-blocked-by-client-with-google-chr

@Kexkey