Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 31 additions & 35 deletions scripts/obwatch/ob-watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,37 @@ def cjfee_display(cjfee: Union[Decimal, float, int],
btc_unit: str,
rel_unit: str) -> str:
if order['ordertype'] in ['swabsoffer', 'sw0absoffer']:
val = sat_to_unit(cjfee, html.unescape(btc_unit))
if btc_unit == "BTC":
return "%.8f" % val
else:
return str(val)
# Display absolute fee in satoshis with commas
return f"{int(cjfee):,} sats"
elif order['ordertype'] in ['reloffer', 'swreloffer', 'sw0reloffer']:
return str(Decimal(cjfee) * Decimal(rel_unit_to_factor[rel_unit])) + rel_unit
# For relative fee, keep using percentage but format with commas if needed
rel_fee = Decimal(cjfee) * Decimal(rel_unit_to_factor[rel_unit])
if rel_fee >= 1000:
return f"{int(rel_fee):,}{rel_unit}"
else:
return f"{rel_fee}{rel_unit}"


def order_str(s, order, btc_unit, rel_unit):
return str(s)


def bond_value_to_str(bond_value: Decimal, btc_unit: str) -> str:
if btc_unit == "BTC":
return "%.16f" % bond_value
elif btc_unit == "mBTC":
return "%.10f" % bond_value
else:
return str(bond_value)
# Convert to integer and format with commas
try:
# Convert to satoshis if needed (multiply by 10^8 if in BTC)
if btc_unit == "BTC":
satoshis = int(bond_value * 100000000)
elif btc_unit == "mBTC":
satoshis = int(bond_value * 100000)
elif btc_unit == "μBTC":
satoshis = int(bond_value * 100)
else:
satoshis = int(bond_value)

return f"{satoshis:,} sats"
except (ValueError, TypeError):
return str(bond_value) + " sats"


def create_offerbook_table_heading(btc_unit, rel_unit):
Expand All @@ -119,10 +130,10 @@ def create_offerbook_table_heading(btc_unit, rel_unit):
col.format('counterparty', 'Counterparty'),
col.format('oid', 'Order ID'),
col.format('cjfee', 'Fee'),
col.format('txfee', 'Miner Fee Contribution / ' + btc_unit),
col.format('minsize', 'Minimum Size / ' + btc_unit),
col.format('maxsize', 'Maximum Size / ' + btc_unit),
col.format('bondvalue', 'Bond value / ' + btc_unit + '<sup>' + bond_exponent + '</sup>')
col.format('txfee', 'Miner Fee Contribution (sats)'),
col.format('minsize', 'Minimum Size (sats)'),
col.format('maxsize', 'Maximum Size (sats)'),
col.format('bondvalue', 'Bond value (sats)')
]) + ' </tr>'
return tableheading

Expand All @@ -141,20 +152,8 @@ def create_bonds_table_heading(btc_unit):
return tableheading

def create_choose_units_form(selected_btc, selected_rel):
choose_units_form = (
'<form method="get" action="">' +
'<select name="btcunit" onchange="this.form.submit();">' +
''.join(('<option>' + u + ' </option>' for u in sorted_units)) +
'</select><select name="relunit" onchange="this.form.submit();">' +
''.join(('<option>' + u + ' </option>' for u in sorted_rel_units)) +
'</select></form>')
choose_units_form = choose_units_form.replace(
'<option>' + selected_btc,
'<option selected="selected">' + selected_btc)
choose_units_form = choose_units_form.replace(
'<option>' + selected_rel,
'<option selected="selected">' + selected_rel)
return choose_units_form
# Simplified form that just displays a message that all values are in satoshis
return '<div style="font-family: monospace; margin: 10px 0;">All values displayed in satoshis (sats) with comma formatting</div>'

def get_fidelity_bond_data(taker):
with taker.dblock:
Expand Down Expand Up @@ -553,11 +552,8 @@ def create_orderbook_table(self, btc_unit: str, rel_unit: str) -> Tuple[int, str
html.unescape(btc_unit))

def _okd_satoshi_to_unit(sat, order, btc_unit, rel_unit):
val = sat_to_unit(sat, html.unescape(btc_unit))
if btc_unit == "BTC":
return "%.8f" % val
else:
return str(val)
# Always display in satoshis with commas
return f"{int(sat):,} sats"

order_keys_display = (('ordertype', ordertype_display),
('counterparty', do_nothing),
Expand Down
6 changes: 3 additions & 3 deletions scripts/obwatch/orderbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
text-align: center;
padding: 5px;
}
.tftable {font-size:12px;color:#fbfbfb;border-width: 1px;border-color: #686767;border-collapse: collapse;margin: 10px auto;}
.tftable th {font-size:12px;background-color:#171515;border-width: 1px;padding: 8px;border-style: solid;border-color: #686767;text-align:center;}
.tftable {font-size:12px;color:#fbfbfb;border-width: 1px;border-color: #686767;border-collapse: collapse;margin: 10px auto;font-family: monospace;}
.tftable th {font-size:12px;background-color:#171515;border-width: 1px;padding: 8px;border-style: solid;border-color: #686767;text-align:center;font-family: monospace;}
.tftable tr {background-color:#2f2f2f;}
.tftable td {font-size:12px;border-width: 1px;padding: 8px;border-style: solid;border-color: #686767;}
.tftable td {font-size:12px;border-width: 1px;padding: 8px;border-style: solid;border-color: #686767;font-family: monospace;}
.tftable tr:hover {background-color:#171515;}
.tftable tr.selected {background-color:#171515;}
</style>
Expand Down
124 changes: 124 additions & 0 deletions scripts/obwatch/sample_orderbook.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<!DOCTYPE html>

<html lang="en">
<head>
<title>JoinMarket Browser Interface - Sample</title>
<style>
body {
padding-top: 50px;
background-color: linen;
}
h1 {
color: black
}
h2 {
color: gray;
}
.tftable {
font-size:12px;
color:#fbfbfb;
border-width: 1px;
border-color: #686767;
border-collapse: collapse;
margin: 10px auto;
font-family: monospace;
}
.tftable th {
font-size:12px;
background-color:#171515;
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #686767;
text-align:center;
font-family: monospace;
}
.tftable tr {
background-color:#2f2f2f;
}
.tftable td {
font-size:12px;
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #686767;
font-family: monospace;
}
.tftable tr:hover {
background-color:#171515;
}
</style>
</head>

<body>
<div style="text-align:center; margin:0px auto;">
<h1>JoinMarket Orderbook</h1>
<h2>5 orders found by 3 counterparties</h2>

<div style="font-family: monospace; margin: 10px 0;">All values displayed in satoshis (sats) with comma formatting</div>

<table class="tftable sortable" border="1">
<tr>
<th>Type</th>
<th>Counterparty</th>
<th>Order ID</th>
<th>Fee</th>
<th>Miner Fee Contribution (sats)</th>
<th>Minimum Size (sats)</th>
<th>Maximum Size (sats)</th>
<th>Bond value (sats)</th>
</tr>
<tr>
<td>Native SW Absolute Fee</td>
<td>J5Cqsd2</td>
<td>0001</td>
<td>1,000 sats</td>
<td>10,000 sats</td>
<td>100,000 sats</td>
<td>1,000,000 sats</td>
<td>500,000 sats</td>
</tr>
<tr>
<td>Native SW Relative Fee</td>
<td>J7Hgtr4</td>
<td>0002</td>
<td>0.3%</td>
<td>12,500 sats</td>
<td>200,000 sats</td>
<td>2,000,000 sats</td>
<td>750,000 sats</td>
</tr>
<tr>
<td>SW Absolute Fee</td>
<td>J3Kplm9</td>
<td>0003</td>
<td>2,500 sats</td>
<td>15,000 sats</td>
<td>300,000 sats</td>
<td>3,000,000 sats</td>
<td>1,200,000 sats</td>
</tr>
<tr>
<td>SW Relative Fee</td>
<td>J5Cqsd2</td>
<td>0004</td>
<td>0.2%</td>
<td>10,000 sats</td>
<td>150,000 sats</td>
<td>1,500,000 sats</td>
<td>600,000 sats</td>
</tr>
<tr>
<td>Native SW Absolute Fee</td>
<td>J3Kplm9</td>
<td>0005</td>
<td>1,500 sats</td>
<td>11,000 sats</td>
<td>250,000 sats</td>
<td>2,500,000 sats</td>
<td>900,000 sats</td>
</tr>
</table>
</div>
</body>
</html>