Browse Source

Merge #966: Obwatcher fidelity bonds fix

ce08a0c Fix year 2038 problem in ob-watcher /fidelitybonds (chris-belcher)
58d3e59 Fix Export Orders page on ob-watcher (chris-belcher)

Tree-SHA512: 77db761eb325d8bda363015414aa8b8c947f4c809be8ce06f730fbe7bff17c92c66ac31d54d820b48df8ff52efb6a324a6c0640bd155dfbb3426102526fa07ab
master
chris-belcher 4 years ago
parent
commit
05a81f221a
No known key found for this signature in database
GPG Key ID: EF734EA677F31129
  1. 30
      scripts/obwatch/ob-watcher.py

30
scripts/obwatch/ob-watcher.py

@ -210,11 +210,28 @@ class OrderbookPageRequestHeader(http.server.SimpleHTTPRequestHandler):
if not rows or not fbonds:
return []
fidelitybonds = []
if jm_single().bc_interface != None:
(fidelity_bond_data, fidelity_bond_values, bond_outpoint_conf_times) =\
get_fidelity_bond_data(self.taker)
fidelity_bond_values_dict = dict([(bond_data["counterparty"], bond_value)
fidelity_bond_values_dict = dict([(bond_data.maker_nick, bond_value)
for (bond_data, _), bond_value in zip(fidelity_bond_data, fidelity_bond_values)])
for ((parsed_bond, bond_utxo_data), fidelity_bond_value, bond_outpoint_conf_time)\
in zip(fidelity_bond_data, fidelity_bond_values, bond_outpoint_conf_times):
fb = {
"counterparty": parsed_bond.maker_nick,
"utxo": {"txid": bintohex(parsed_bond.utxo[0]),
"vout": parsed_bond.utxo[1]},
"bond_value": fidelity_bond_value,
"locktime": parsed_bond.locktime,
"amount": bond_utxo_data["value"],
"address": bond_utxo_data["address"],
"utxo_confirmations": bond_utxo_data["confirms"],
"utxo_confirmation_timestamp": bond_outpoint_conf_time,
"utxo_pub": bintohex(parsed_bond.utxo_pub),
"cert_expiry": parsed_bond.cert_expiry
}
fidelitybonds.append(fb)
else:
fidelity_bond_values_dict = {}
@ -230,15 +247,6 @@ class OrderbookPageRequestHeader(http.server.SimpleHTTPRequestHandler):
o["fidelity_bond_value"] = fidelity_bond_values_dict.get(o["counterparty"], 0)
offers.append(o)
BIN_KEYS = ["txid", "utxopubkey"]
fidelitybonds = []
for fbond in fbonds:
o = dict(fbond)
for k in BIN_KEYS:
o[k] = bintohex(o[k])
o["fidelity_bond_value"] = fidelity_bond_values_dict.get(o["counterparty"], 0)
fidelitybonds.append(o)
return {"offers": offers, "fidelitybonds": fidelitybonds}
def create_depth_chart(self, cj_amount, args=None):
@ -358,7 +366,7 @@ class OrderbookPageRequestHeader(http.server.SimpleHTTPRequestHandler):
+ elem(bond_data.maker_nick)
+ elem(bintohex(bond_data.utxo[0]) + ":" + str(bond_data.utxo[1]))
+ elem(bond_value_str)
+ elem(datetime.utcfromtimestamp(bond_data.locktime).strftime("%Y-%m-%d"))
+ elem((datetime.utcfromtimestamp(0) + timedelta(seconds=bond_data.locktime)).strftime("%Y-%m-%d"))
+ elem(utxo_value_str)
+ elem(conf_time_str)
+ elem(str(bond_data.cert_expiry*RETARGET_INTERVAL))

Loading…
Cancel
Save