SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 80db7f981596c54870995aa38bda19a6816e974c
parent 1c561c5c7a6351521f87cc7603868ad5efdd587c
Author: Martin Habovstiak <martin.habovstiak@gmail.com>
Date:   Sun, 28 Mar 2021 08:32:12 +0200

Use single source of truth for API key path

This will avoid problems in the future and makes the key path configurable.

Diffstat:
Mconfig.py | 3+++
Mserver.py | 4++--
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/config.py b/config.py @@ -9,6 +9,9 @@ rpcport = "8332" username = "bitcoinrpc" password = "RPAPASSWORD" +# File in which API key will be stored +api_key_path = "BTCPyment_API_key" + # SSH tunnel to node (raspberry pi!) # Make sure this command works `ssh HOST@IP -q -N -L 8332:localhost:8332` # This forwards the ports required to talk to the node via RPC (or gRPC in the case of lightning) diff --git a/server.py b/server.py @@ -16,10 +16,10 @@ app = Flask(__name__) # Load an API key or create a new one if os.path.exists("BTCPyment_API_key"): - with open("BTCPyment_API_key", "r") as f: + with open(config.api_key_path, "r") as f: app.config["SECRET_KEY"] = f.read().strip() else: - with open("BTCPyment_API_key", "w") as f: + with open(config.api_key_path, "w") as f: app.config["SECRET_KEY"] = os.urandom(64).hex() f.write(app.config["SECRET_KEY"])