Bitcoin Forum
June 14, 2024, 02:18:40 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Query Electrum from website via json-rpc: connection refused  (Read 812 times)
drsnuggles (OP)
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
September 24, 2016, 06:18:48 PM
Last edit: September 25, 2016, 09:02:20 AM by drsnuggles
 #1

For a small webshop I want to enable bitcoin payments. Since the good old blockchain.info wallet doesn't support json-rpc anymore, I would like to use electrum.

I have electrum running on a raspberry pi successfully. Queries run wel locally. My website is on shared hosting somewhere else. I would like to query electron via stratum/json-rpc from the webserver. However, Electrum only accepts connections from localhost, not from 0.0.0.0,  according to netstat.

Two questions that pop up:
1. How can I configure Electrum to accept connections from outside?
2. How safe is opening up a port to the outside world? I want to use ip restrictions in my local router.  Further security would be using ssl, but ssl over json-rpc is not recommended. Ssh tunnels are not available on shared hosting either.
btcbot
Full Member
***
Offline Offline

Activity: 151
Merit: 105



View Profile
September 25, 2016, 02:53:27 PM
 #2

Have you read this?

http://docs.electrum.org/en/latest/merchant.html

Don't tip me... tip the Riseup folks who protect activists around the world.
drsnuggles (OP)
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
September 25, 2016, 03:48:17 PM
 #3

Thanks for the link  Smiley.  I did indeed use it to set up Electrum. I can perform all the given curl queries locally without any problem. If however, instead of 127.0.0.1 I use its network address: 192.16.1.60 I get "connection refused".

This morning I tried to forward all traffic of port 7777 from 192.168.1.60 to 127.0.0.1, but I still get connction refused. I followed this post: http://unix.stackexchange.com/questions/111433/iptables-redirect-outside-requests-to-127-0-0-1  and probably did something wrong, since I am not a debian/raspbian expert.

Either I find a way to forward data correctly, or enable Electrum to listen to port 7777 on 192.168.1.60.
drsnuggles (OP)
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
September 25, 2016, 07:46:55 PM
 #4

Alright, found a workaround to forward data from 192.168.1.60 to 127.0.0.1.

Code:
sudo sysctl -w net.ipv4.conf.eth0.route_localnet=1
sudo iptables -t nat -I PREROUTING -p tcp -d 192.168.1.60/32 --dport 7777 -j DNAT --to-destination 127.0.0.1:7777


Important: to check the result, go to another pc and query:
Code:
 curl --data-binary '{"id":"curltext","method":"getbalance","params":[]}' http://192.168.1.60:7777


I checked on the same pc as Electrum runs, and apparently that doesn't work.

Next step is to secure the line Smiley.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!