1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2025-03-13 12:17:27 +00:00

remove test setup

This commit is contained in:
Darren 2020-01-23 03:44:19 +02:00
parent ac3a40417e
commit d8bd807ee4
2 changed files with 1 additions and 76 deletions

View file

@ -65,7 +65,6 @@ phone_required = yes
api_key = YOUR_API_HERE_
secret = YOUR_SECRET_HERE_
network_confirmations = 2
test_setup = False
# Bot appearance settings
[Appearance]

76
core.py
View file

@ -173,82 +173,8 @@ def callback():
else:
return "Incorrect secret"
# Add test setup button to index page
@app.route('/', methods=['GET'])
def home():
if configloader.config["Bitcoin"]["test_setup"] == str(True):
return '<a href="/test_setup"><button>Test Setup</button></a>'
else:
return "No access, enable test_setup in config.ini"
@app.route('/test_setup', methods=['GET', 'POST'])
def test_setup():
if configloader.config["Bitcoin"]["test_setup"] == str(True):
response = Blockonomics.get_callbacks()
error_str = ''
response_body = response.json()
if response_body[0]:
response_callback = response_body[0]['callback']
response_address = response_body[0]['address']
else :
response_callback = ''
response_address = ''
callback_secret = configloader.config["Bitcoin"]["secret"]
api_url = flask.url_for('callback', _external=True)
callback_url = api_url + "?secret=" + callback_secret
callback_string = "Blockonomics Callback URL: " + callback_url
# Remove http:# or https:# from urls
api_url_without_schema = api_url.replace("https://","")
api_url_without_schema = api_url_without_schema.replace("http://","")
callback_url_without_schema = callback_url.replace("https://","")
callback_url_without_schema = callback_url_without_schema.replace("http://","")
response_callback_without_schema = response_callback.replace("https://","")
response_callback_without_schema = response_callback_without_schema.replace("http://","")
# TODO: Check This: WE should actually check code for timeout
if response == False:
error_str = 'Your server is blocking outgoing HTTPS calls'
elif response.status_code==401:
error_str = 'API Key is incorrect'
elif response.status_code!=200:
error_str = response.text
elif response_body == None or len(response_body) == 0:
error_str = 'You have not entered an xpub'
elif len(response_body) == 1:
if response_callback == "":
# No callback URL set, set one
Blockonomics.update_callback(callback_url, response_address)
elif response_callback_without_schema != callback_url_without_schema:
base_url = api_url_without_schema
# Check if only secret differs
if base_url in response_callback:
# Looks like the user regenrated callback by mistake
# Just force Update_callback on server
Blockonomics.update_callback(callback_url, response_address)
else:
error_str = "You have an existing callback URL. Refer instructions on integrating multiple websites"
else:
error_str = "You have an existing callback URL. Refer instructions on integrating multiple websites"
# Check if callback url is set
for res_obj in response_body:
res_url = res_obj['callback'].replace("https://","")
res_url = res_url.replace("https://","")
if res_url == callback_url_without_schema:
error_str = ""
if error_str == "":
# Everything OK ! Test address generation
response = Blockonomics.new_address(True)
if response.status_code != 200:
error_str = response.text
if error_str:
error_str = error_str + '<p>For more information, please consult <a href="https://blockonomics.freshdesk.com/support/solutions/articles/33000215104-troubleshooting-unable-to-generate-new-address" target="_blank">this troubleshooting article</a></p>'
return error_str
# No errors
return 'Congrats ! Setup is all done<br>'+callback_string
else:
return "No access, enable test_setup in config.ini"
# Run the main bot function in thread
threading.Thread(target=main).start()
# Run the flask app in the main process
if __name__ == "__main__":
app.run()
app.run()