Fixes to_dict/to_json for and some fixes

This commit is contained in:
Sergi Delgado Segura
2019-10-17 19:11:32 +01:00
parent 6735aac094
commit c09becd7fa
2 changed files with 10 additions and 4 deletions

View File

@@ -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')