diff --git a/pisa/api.py b/pisa/api.py index cd05e02..44fcb8c 100644 --- a/pisa/api.py +++ b/pisa/api.py @@ -102,7 +102,7 @@ def get_all_appointments(): if watcher.responder: for uuid, job in watcher.responder.jobs.items(): - responder_jobs[uuid] = job.to_json() + responder_jobs[uuid] = job.to_dict() response = jsonify({"watcher_appointments": watcher_appointments, "responder_jobs": responder_jobs}) diff --git a/pisa/responder.py b/pisa/responder.py index 0b948e0..dcce0a6 100644 --- a/pisa/responder.py +++ b/pisa/responder.py @@ -1,6 +1,7 @@ +import json from queue import Queue -from threading import Thread from hashlib import sha256 +from threading import Thread from binascii import unhexlify from pisa.logger import Logger @@ -29,11 +30,14 @@ class Job: # can be directly got from DB self.locator = sha256(unhexlify(dispute_txid)).hexdigest() - def to_json(self): + def to_dict(self): job = {"locator": self.locator, "justice_rawtx": self.justice_rawtx, "appointment_end": self.appointment_end} return job + def to_json(self): + return json.dumps(self.to_dict()) + class Responder: def __init__(self): @@ -62,6 +66,8 @@ class Responder: # TODO: Add the missing reasons (e.g. RPC_VERIFY_REJECTED) pass + return receipt + def create_job(self, uuid, dispute_txid, justice_txid, justice_rawtx, appointment_end, confirmations=0, retry=False): @@ -155,7 +161,7 @@ class Responder: for uuid, job in self.jobs.items(): if job.appointment_end <= height: - tx = Carrier.get_transaction(job.dispute_txid) + tx = Carrier.get_transaction(job.justice_txid) # FIXME: Should be improved with the librarian confirmations = tx.get('confirmations')