|
@ -17,7 +17,7 @@ |
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import sys, base64, os, re, hashlib, socket, getpass, copy, operator, urllib2, ast |
|
|
import sys, base64, os, re, hashlib, socket, getpass, copy, operator, ast |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
import ecdsa |
|
|
import ecdsa |
|
@ -396,13 +396,14 @@ class Wallet: |
|
|
return conf, unconf |
|
|
return conf, unconf |
|
|
|
|
|
|
|
|
def request(self, request ): |
|
|
def request(self, request ): |
|
|
|
|
|
import urllib |
|
|
|
|
|
|
|
|
if self.port == 80: |
|
|
if self.port == 80: |
|
|
try: |
|
|
request2 = urllib.urlencode({'q':request}) |
|
|
out = urllib2.urlopen('http://'+self.host+'/q/tw', request, timeout=5).read() |
|
|
request = "GET /electrum.php?" + request2 + " HTTP/1.0\r\n\r\n" |
|
|
except: |
|
|
|
|
|
out = '' |
|
|
|
|
|
else: |
|
|
else: |
|
|
|
|
|
request += "#" |
|
|
|
|
|
|
|
|
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM) |
|
|
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM) |
|
|
s.connect(( self.host, self.port)) |
|
|
s.connect(( self.host, self.port)) |
|
|
s.send( request ) |
|
|
s.send( request ) |
|
@ -413,7 +414,9 @@ class Wallet: |
|
|
else: break |
|
|
else: break |
|
|
s.close() |
|
|
s.close() |
|
|
|
|
|
|
|
|
if re.match('[^:]\s*\(', out): out = '' |
|
|
if self.port == 80: |
|
|
|
|
|
out = out.split('\r\n')[-1] |
|
|
|
|
|
|
|
|
return out |
|
|
return out |
|
|
|
|
|
|
|
|
def retrieve_message(self): |
|
|
def retrieve_message(self): |
|
@ -427,10 +430,10 @@ class Wallet: |
|
|
return ast.literal_eval( self.request( repr ( ('h', address ))) ) |
|
|
return ast.literal_eval( self.request( repr ( ('h', address ))) ) |
|
|
|
|
|
|
|
|
def poll(self): |
|
|
def poll(self): |
|
|
return ast.literal_eval( self.request( repr ( ('poll', '' )))) |
|
|
return ast.literal_eval( self.request( repr ( ('poll', self.session_id )))) |
|
|
|
|
|
|
|
|
def new_session(self): |
|
|
def new_session(self): |
|
|
self.message = self.request( repr ( ('watch', repr(self.addresses) ))) |
|
|
self.session_id, self.message = ast.literal_eval( self.request( repr ( ('session', repr(self.addresses) )))) |
|
|
|
|
|
|
|
|
def update(self): |
|
|
def update(self): |
|
|
blocks, changed_addresses = self.poll() |
|
|
blocks, changed_addresses = self.poll() |
|
|