mirror of
https://github.com/basicswap/basicswap.git
synced 2025-05-05 12:22:16 +00:00
parent
7c17ff2dd2
commit
fbfb4c95ba
2 changed files with 14 additions and 6 deletions
basicswap
|
@ -11,9 +11,11 @@ import shlex
|
||||||
import traceback
|
import traceback
|
||||||
import threading
|
import threading
|
||||||
import http.client
|
import http.client
|
||||||
from urllib import parse
|
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
from jinja2 import Environment, PackageLoader
|
from jinja2 import Environment, PackageLoader
|
||||||
|
from socket import error as SocketError
|
||||||
|
from urllib import parse
|
||||||
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
from .util import (
|
from .util import (
|
||||||
|
@ -30,7 +32,6 @@ from .basicswap_util import (
|
||||||
strTxState,
|
strTxState,
|
||||||
strBidState,
|
strBidState,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .js_server import (
|
from .js_server import (
|
||||||
js_error,
|
js_error,
|
||||||
js_url_to_function,
|
js_url_to_function,
|
||||||
|
@ -616,14 +617,20 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
response = self.handle_http(200, self.path)
|
response = self.handle_http(200, self.path)
|
||||||
self.wfile.write(response)
|
try:
|
||||||
|
self.wfile.write(response)
|
||||||
|
except SocketError as e:
|
||||||
|
self.server.swap_client.log.debug(f"do_GET SocketError {e}")
|
||||||
|
|
||||||
def do_POST(self):
|
def do_POST(self):
|
||||||
post_string = self.rfile.read(int(self.headers.get("Content-Length")))
|
post_string = self.rfile.read(int(self.headers.get("Content-Length")))
|
||||||
|
|
||||||
is_json = True if "json" in self.headers.get("Content-Type", "") else False
|
is_json = True if "json" in self.headers.get("Content-Type", "") else False
|
||||||
response = self.handle_http(200, self.path, post_string, is_json)
|
response = self.handle_http(200, self.path, post_string, is_json)
|
||||||
self.wfile.write(response)
|
try:
|
||||||
|
self.wfile.write(response)
|
||||||
|
except SocketError as e:
|
||||||
|
self.server.swap_client.log.debug(f"do_POST SocketError {e}")
|
||||||
|
|
||||||
def do_HEAD(self):
|
def do_HEAD(self):
|
||||||
self.putHeaders(200, "text/html")
|
self.putHeaders(200, "text/html")
|
||||||
|
|
|
@ -328,9 +328,10 @@ def formatBids(swap_client, bids, filters) -> bytes:
|
||||||
offer = swap_client.getOffer(b[3])
|
offer = swap_client.getOffer(b[3])
|
||||||
ci_to = swap_client.ci(offer.coin_to) if offer else None
|
ci_to = swap_client.ci(offer.coin_to) if offer else None
|
||||||
|
|
||||||
|
bid_rate: int = 0 if b[10] is None else b[10]
|
||||||
amount_to = None
|
amount_to = None
|
||||||
if ci_to:
|
if ci_to:
|
||||||
amount_to = ci_to.format_amount((b[4] * b[10]) // ci_from.COIN())
|
amount_to = ci_to.format_amount((b[4] * bid_rate) // ci_from.COIN())
|
||||||
|
|
||||||
bid_data = {
|
bid_data = {
|
||||||
"bid_id": b[2].hex(),
|
"bid_id": b[2].hex(),
|
||||||
|
@ -341,7 +342,7 @@ def formatBids(swap_client, bids, filters) -> bytes:
|
||||||
"coin_to": ci_to.coin_name() if ci_to else "Unknown",
|
"coin_to": ci_to.coin_name() if ci_to else "Unknown",
|
||||||
"amount_from": ci_from.format_amount(b[4]),
|
"amount_from": ci_from.format_amount(b[4]),
|
||||||
"amount_to": amount_to,
|
"amount_to": amount_to,
|
||||||
"bid_rate": swap_client.ci(b[14]).format_amount(b[10]),
|
"bid_rate": swap_client.ci(b[14]).format_amount(bid_rate),
|
||||||
"bid_state": strBidState(b[5]),
|
"bid_state": strBidState(b[5]),
|
||||||
"addr_from": b[11],
|
"addr_from": b[11],
|
||||||
"addr_to": offer.addr_to if offer else None,
|
"addr_to": offer.addr_to if offer else None,
|
||||||
|
|
Loading…
Reference in a new issue