Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix download-blockchain-wallet.py #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.pyc
*.pyo
/addresses.db

\.idea/
15 changes: 10 additions & 5 deletions extract-scripts/download-blockchain-wallet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python

# download-blockchain-wallet.py -- Blockchain.info wallet file downloader
# Copyright (C) 2016, 2017 Christopher Gurnee
Expand Down Expand Up @@ -26,10 +26,15 @@
# Thank You!

from __future__ import print_function
import sys, os.path, atexit, uuid, urllib2, json, time
import sys, os.path, atexit, uuid, urllib2, json, time, ssl

# Context to ignore SSL Errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

# The base URL
BASE_URL = "https://blockchain.info/"
BASE_URL = "https://login.blockchain.com/"
# The api_code (as of Feb 2 2017)
API_CODE = "1770d5d9-bcea-4d28-ad21-6cbd5be018a8"

Expand Down Expand Up @@ -63,9 +68,9 @@ def do_request(query, body = None):
if auth_token:
req.add_header("authorization", "Bearer " + auth_token)
try:
return urllib2.urlopen(req, cadefault=True) # calls ssl.create_default_context() (despite what the docs say)
return urllib2.urlopen(req, context=ctx) # fixed because otherwise SSL errors abound
except TypeError:
return urllib2.urlopen(req) # Python < 2.7.9 doesn't support the cadefault argument
return urllib2.urlopen(req, context=ctx) # Python < 2.7.9 doesn't support the cadefault argument
#
# Performs a do_request(), decoding the result as json
def do_request_json(query, body = None):
Expand Down