diff --git a/.gitignore b/.gitignore index 6c74786..d3db129 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ .vscode/ +.idea/ *.log .DS_Store -/pisa-btc/venv/* +venv/ conf.py bitcoin.conf* *__pycache__ .pending* -pisa-btc/apps/cli/*.json +apps/cli/*.json +appointments/ +test.py diff --git a/Dockerfile b/Dockerfile index 9424086..98acad5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,11 +10,11 @@ RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py RUN python3 get-pip.py # Add pisa files -ADD pisa-btc /root/pisa-btc -WORKDIR /root/pisa-btc +ADD pisa /root/pisa_btc +WORKDIR /root/pisa_btc # Export pythonpath -RUN echo export PYTHONPATH="$PYTHONPATH:/root/pisa-btc/" >> /root/.bashrc +RUN echo export PYTHONPATH="$PYTHONPATH:/root/pisa_btc/" >> /root/.bashrc # Install dependencies RUN pip3 install -r requirements.txt diff --git a/pisa-btc/apps/__init__.py b/apps/__init__.py similarity index 100% rename from pisa-btc/apps/__init__.py rename to apps/__init__.py diff --git a/pisa-btc/apps/cli/DEPENDENCIES.md b/apps/cli/DEPENDENCIES.md similarity index 100% rename from pisa-btc/apps/cli/DEPENDENCIES.md rename to apps/cli/DEPENDENCIES.md diff --git a/pisa-btc/apps/cli/INSTALL.md b/apps/cli/INSTALL.md similarity index 100% rename from pisa-btc/apps/cli/INSTALL.md rename to apps/cli/INSTALL.md diff --git a/pisa-btc/apps/cli/PISA-API.md b/apps/cli/PISA-API.md similarity index 100% rename from pisa-btc/apps/cli/PISA-API.md rename to apps/cli/PISA-API.md diff --git a/pisa-btc/apps/cli/README.md b/apps/cli/README.md similarity index 100% rename from pisa-btc/apps/cli/README.md rename to apps/cli/README.md diff --git a/pisa-btc/apps/cli/__init__.py b/apps/cli/__init__.py similarity index 100% rename from pisa-btc/apps/cli/__init__.py rename to apps/cli/__init__.py diff --git a/pisa-btc/apps/cli/blob.py b/apps/cli/blob.py similarity index 100% rename from pisa-btc/apps/cli/blob.py rename to apps/cli/blob.py diff --git a/pisa-btc/apps/cli/help.py b/apps/cli/help.py similarity index 100% rename from pisa-btc/apps/cli/help.py rename to apps/cli/help.py diff --git a/pisa-btc/apps/cli/pisa-cli.py b/apps/cli/pisa-cli.py similarity index 100% rename from pisa-btc/apps/cli/pisa-cli.py rename to apps/cli/pisa-cli.py diff --git a/pisa-btc/apps/cli/requirements.txt b/apps/cli/requirements.txt similarity index 100% rename from pisa-btc/apps/cli/requirements.txt rename to apps/cli/requirements.txt diff --git a/pisa-btc/TODO.md b/pisa/TODO.md similarity index 100% rename from pisa-btc/TODO.md rename to pisa/TODO.md diff --git a/pisa-btc/pisa/__init__.py b/pisa/__init__.py similarity index 100% rename from pisa-btc/pisa/__init__.py rename to pisa/__init__.py diff --git a/pisa-btc/pisa/api.py b/pisa/api.py similarity index 90% rename from pisa-btc/pisa/api.py rename to pisa/api.py index af3ac47..4b86259 100644 --- a/pisa-btc/pisa/api.py +++ b/pisa/api.py @@ -7,8 +7,8 @@ import json # FIXME: HERE FOR TESTING (get_block_count). REMOVE WHEN REMOVING THE FUNCTION -from utils.authproxy import AuthServiceProxy -from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT +from pisa.utils.authproxy import AuthServiceProxy +from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT # ToDo: #5-add-async-to-api app = Flask(__name__) @@ -61,13 +61,13 @@ def get_appointment(): locator = request.args.get('locator') response = [] - job_in_watcher = watcher.appointments.get(locator) + appointment_in_watcher = watcher.appointments.get(locator) - if job_in_watcher: - for job in job_in_watcher: - job_data = job.to_json() - job_data['status'] = "being_watched" - response.append(job_data) + if appointment_in_watcher: + for appointment in appointment_in_watcher: + appointment_data = appointment.to_json() + appointment_data['status'] = "being_watched" + response.append(appointment_data) if watcher.responder: responder_jobs = watcher.responder.jobs diff --git a/pisa-btc/pisa/appointment.py b/pisa/appointment.py similarity index 100% rename from pisa-btc/pisa/appointment.py rename to pisa/appointment.py diff --git a/pisa-btc/pisa/encrypted_blob.py b/pisa/encrypted_blob.py similarity index 100% rename from pisa-btc/pisa/encrypted_blob.py rename to pisa/encrypted_blob.py diff --git a/pisa-btc/pisa/errors.py b/pisa/errors.py similarity index 100% rename from pisa-btc/pisa/errors.py rename to pisa/errors.py diff --git a/pisa-btc/pisa/inspector.py b/pisa/inspector.py similarity index 97% rename from pisa-btc/pisa/inspector.py rename to pisa/inspector.py index 3680717..b47b1c2 100644 --- a/pisa-btc/pisa/inspector.py +++ b/pisa/inspector.py @@ -1,9 +1,9 @@ import re from pisa.appointment import Appointment from pisa import errors -from utils.authproxy import AuthServiceProxy, JSONRPCException -from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, MIN_DISPUTE_DELTA, SUPPORTED_CIPHERS, \ - SUPPORTED_HASH_FUNCTIONS +from pisa.utils.authproxy import AuthServiceProxy, JSONRPCException +from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, MIN_DISPUTE_DELTA, \ + SUPPORTED_CIPHERS, SUPPORTED_HASH_FUNCTIONS class Inspector: diff --git a/pisa-btc/pisa/pisad.py b/pisa/pisad.py similarity index 87% rename from pisa-btc/pisa/pisad.py rename to pisa/pisad.py index 2224eed..4ea1ea8 100644 --- a/pisa-btc/pisa/pisad.py +++ b/pisa/pisad.py @@ -1,12 +1,11 @@ import logging from sys import argv from getopt import getopt -from conf import SERVER_LOG_FILE from threading import Thread from pisa.api import start_api from pisa.tools import can_connect_to_bitcoind, in_correct_network -from utils.authproxy import AuthServiceProxy -from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, BTC_NETWORK +from pisa.utils.authproxy import AuthServiceProxy +from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, BTC_NETWORK, SERVER_LOG_FILE if __name__ == '__main__': diff --git a/pisa-btc/requirements.txt b/pisa/requirements.txt similarity index 100% rename from pisa-btc/requirements.txt rename to pisa/requirements.txt diff --git a/pisa-btc/pisa/responder.py b/pisa/responder.py similarity index 98% rename from pisa-btc/pisa/responder.py rename to pisa/responder.py index e607eee..51c7988 100644 --- a/pisa-btc/pisa/responder.py +++ b/pisa/responder.py @@ -5,8 +5,8 @@ from binascii import unhexlify from pisa.zmq_subscriber import ZMQHandler from pisa.rpc_errors import * from pisa.tools import check_tx_in_chain -from utils.authproxy import AuthServiceProxy, JSONRPCException -from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT +from pisa.utils.authproxy import AuthServiceProxy, JSONRPCException +from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT CONFIRMATIONS_BEFORE_RETRY = 6 MIN_CONFIRMATIONS = 6 diff --git a/pisa-btc/pisa/rpc_errors.py b/pisa/rpc_errors.py similarity index 100% rename from pisa-btc/pisa/rpc_errors.py rename to pisa/rpc_errors.py diff --git a/pisa-btc/sample_conf.py b/pisa/sample_conf.py similarity index 93% rename from pisa-btc/sample_conf.py rename to pisa/sample_conf.py index eb107a2..7d00df5 100644 --- a/pisa-btc/sample_conf.py +++ b/pisa/sample_conf.py @@ -16,6 +16,7 @@ MAX_APPOINTMENTS = 100 EXPIRY_DELTA = 6 MIN_DISPUTE_DELTA = 20 SERVER_LOG_FILE = 'pisa.log' +DB_PATH = 'appointments/' # PISA-CLI CLIENT_LOG_FILE = 'pisa.log' diff --git a/pisa-btc/pisa/tools.py b/pisa/tools.py similarity index 97% rename from pisa-btc/pisa/tools.py rename to pisa/tools.py index fa2d555..0155509 100644 --- a/pisa-btc/pisa/tools.py +++ b/pisa/tools.py @@ -1,4 +1,4 @@ -from utils.authproxy import JSONRPCException +from pisa.utils.authproxy import JSONRPCException from pisa.rpc_errors import RPC_INVALID_ADDRESS_OR_KEY from http.client import HTTPException diff --git a/pisa-btc/utils/__init__.py b/pisa/utils/__init__.py similarity index 100% rename from pisa-btc/utils/__init__.py rename to pisa/utils/__init__.py diff --git a/pisa-btc/utils/authproxy.py b/pisa/utils/authproxy.py similarity index 100% rename from pisa-btc/utils/authproxy.py rename to pisa/utils/authproxy.py diff --git a/pisa-btc/pisa/watcher.py b/pisa/watcher.py similarity index 97% rename from pisa-btc/pisa/watcher.py rename to pisa/watcher.py index 04c7b56..c5936d5 100644 --- a/pisa-btc/pisa/watcher.py +++ b/pisa/watcher.py @@ -1,12 +1,11 @@ from binascii import hexlify, unhexlify from queue import Queue from threading import Thread -from conf import EXPIRY_DELTA from pisa.responder import Responder from pisa.zmq_subscriber import ZMQHandler -from utils.authproxy import AuthServiceProxy, JSONRPCException +from pisa.utils.authproxy import AuthServiceProxy, JSONRPCException from hashlib import sha256 -from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, MAX_APPOINTMENTS +from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, MAX_APPOINTMENTS, EXPIRY_DELTA class Watcher: diff --git a/pisa-btc/pisa/zmq_subscriber.py b/pisa/zmq_subscriber.py similarity index 95% rename from pisa-btc/pisa/zmq_subscriber.py rename to pisa/zmq_subscriber.py index 23a411a..90e706c 100644 --- a/pisa-btc/pisa/zmq_subscriber.py +++ b/pisa/zmq_subscriber.py @@ -1,6 +1,6 @@ import zmq import binascii -from conf import FEED_PROTOCOL, FEED_ADDR, FEED_PORT +from pisa.conf import FEED_PROTOCOL, FEED_ADDR, FEED_PORT # ToDo: #7-add-async-back-to-zmq class ZMQHandler: diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pisa-btc/tests/appointment_tests.py b/tests/appointment_tests.py similarity index 95% rename from pisa-btc/tests/appointment_tests.py rename to tests/appointment_tests.py index 43eb520..a35dc59 100644 --- a/pisa-btc/tests/appointment_tests.py +++ b/tests/appointment_tests.py @@ -1,10 +1,10 @@ import logging from pisa.inspector import Inspector from pisa.appointment import Appointment -from conf import TEST_LOG_FILE from pisa import errors -from utils.authproxy import AuthServiceProxy, JSONRPCException -from conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, SUPPORTED_HASH_FUNCTIONS, SUPPORTED_CIPHERS +from pisa.utils.authproxy import AuthServiceProxy, JSONRPCException +from pisa.conf import BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, SUPPORTED_HASH_FUNCTIONS, \ + SUPPORTED_CIPHERS, TEST_LOG_FILE logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO, handlers=[ logging.FileHandler(TEST_LOG_FILE)