|
|
@ -40,9 +40,10 @@ from functools import wraps |
|
|
|
from decimal import Decimal |
|
|
|
|
|
|
|
from .import util |
|
|
|
from .util import print_msg, format_satoshis, print_stderr |
|
|
|
from .util import bfh, bh2u, format_satoshis |
|
|
|
from .import bitcoin |
|
|
|
from .bitcoin import is_address, hash_160, COIN, TYPE_ADDRESS |
|
|
|
from .i18n import _ |
|
|
|
from .transaction import Transaction |
|
|
|
from .import paymentrequest |
|
|
|
from .paymentrequest import PR_PAID, PR_UNPAID, PR_UNKNOWN, PR_EXPIRED |
|
|
@ -658,12 +659,12 @@ class Commands: |
|
|
|
def notify(self, address, URL): |
|
|
|
"""Watch an address. Everytime the address changes, a http POST is sent to the URL.""" |
|
|
|
def callback(x): |
|
|
|
import urllib2 |
|
|
|
import urllib.request |
|
|
|
headers = {'content-type':'application/json'} |
|
|
|
data = {'address':address, 'status':x.get('result')} |
|
|
|
try: |
|
|
|
req = urllib2.Request(URL, json.dumps(data), headers) |
|
|
|
response_stream = urllib2.urlopen(req, timeout=5) |
|
|
|
req = urllib.request.Request(URL, json.dumps(data), headers) |
|
|
|
response_stream = urllib.request.urlopen(req, timeout=5) |
|
|
|
util.print_error('Got Response for %s' % address) |
|
|
|
except BaseException as e: |
|
|
|
util.print_error(str(e)) |
|
|
|