mirror of
https://github.com/basicswap/basicswap.git
synced 2024-11-16 15:58:17 +00:00
Merge pull request #1 from tecnovert/GUI
merge: Fix merge and lint issues.
This commit is contained in:
commit
e0b575b50e
10 changed files with 32 additions and 26 deletions
|
@ -8,7 +8,7 @@ lint_task:
|
|||
script:
|
||||
- flake8 --version
|
||||
- PYTHONWARNINGS="ignore" flake8 --ignore=E501,F841,W503 --exclude=basicswap/contrib,basicswap/interface/contrib,messages_pb2.py,.eggs,.tox,bin/install_certifi.py
|
||||
- codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=tests/lint/spelling.ignore-words.txt -S .git,.eggs,.tox,pgp,*.pyc,*basicswap/contrib,*basicswap/interface/contrib,*mnemonics.py,bin/install_certifi.py
|
||||
- codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=tests/lint/spelling.ignore-words.txt -S .git,.eggs,.tox,pgp,*.pyc,*basicswap/contrib,*basicswap/interface/contrib,*mnemonics.py,bin/install_certifi.py,*basicswap/static
|
||||
|
||||
test_task:
|
||||
environment:
|
||||
|
|
|
@ -53,7 +53,7 @@ jobs:
|
|||
before_script:
|
||||
script:
|
||||
- PYTHONWARNINGS="ignore" flake8 --ignore=E501,F841,W503 --exclude=basicswap/contrib,basicswap/interface/contrib,messages_pb2.py,.eggs,.tox,bin/install_certifi.py
|
||||
- codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=tests/lint/spelling.ignore-words.txt -S .git,.eggs,.tox,pgp,*.pyc,*basicswap/contrib,*basicswap/interface/contrib,*mnemonics.py,bin/install_certifi.py
|
||||
- codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=tests/lint/spelling.ignore-words.txt -S .git,.eggs,.tox,pgp,*.pyc,*basicswap/contrib,*basicswap/interface/contrib,*mnemonics.py,bin/install_certifi.py,*basicswap/static
|
||||
after_success:
|
||||
- echo "End lint"
|
||||
- stage: test
|
||||
|
|
|
@ -2415,21 +2415,9 @@ class BasicSwap(BaseApp):
|
|||
initiate_tx_block_time = int(self.callcoinrpc(coin_from, 'getblock', [initiate_tx_block_hash, ])['time'])
|
||||
if offer.lock_type == TxLockTypes.ABS_LOCK_BLOCKS:
|
||||
# Walk the coin_to chain back until block time matches
|
||||
blockchaininfo = self.callcoinrpc(coin_to, 'getblockchaininfo')
|
||||
cblock_hash = blockchaininfo['bestblockhash']
|
||||
cblock_height = blockchaininfo['blocks']
|
||||
max_tries = 1000
|
||||
for i in range(max_tries):
|
||||
prev_block = self.callcoinrpc(coin_to, 'getblock', [cblock_hash, ])
|
||||
self.log.debug('prev_block %s', str(prev_block))
|
||||
|
||||
if prev_block['time'] <= initiate_tx_block_time:
|
||||
break
|
||||
# cblock_hash and height are out of step unless loop breaks
|
||||
cblock_hash = prev_block['previousblockhash']
|
||||
cblock_height = prev_block['height']
|
||||
|
||||
ensure(prev_block['time'] <= initiate_tx_block_time, 'Block not found for lock height')
|
||||
block_header_at = ci_to.getBlockHeaderAt(initiate_tx_block_time, block_after=True)
|
||||
cblock_hash = block_header_at['hash']
|
||||
cblock_height = block_header_at['height']
|
||||
|
||||
self.log.debug('Setting lock value from height of block %s %s', coin_to, cblock_hash)
|
||||
contract_lock_value = cblock_height + lock_value
|
||||
|
@ -4084,7 +4072,10 @@ class BasicSwap(BaseApp):
|
|||
ensure(script_lock_value == expect_sequence, 'sequence mismatch')
|
||||
else:
|
||||
if offer.lock_type == TxLockTypes.ABS_LOCK_BLOCKS:
|
||||
self.log.warning('TODO: validate absolute lock values')
|
||||
block_header_from = ci_from.getBlockHeaderAt(bid.created_at)
|
||||
chain_height_at_bid_creation = block_header_from['height']
|
||||
ensure(script_lock_value <= chain_height_at_bid_creation + offer.lock_value + atomic_swap_1.ABS_LOCK_BLOCKS_LEEWAY, 'script lock height too high')
|
||||
ensure(script_lock_value >= chain_height_at_bid_creation + offer.lock_value - atomic_swap_1.ABS_LOCK_BLOCKS_LEEWAY, 'script lock height too low')
|
||||
else:
|
||||
ensure(script_lock_value <= bid.created_at + offer.lock_value + atomic_swap_1.INITIATE_TX_TIMEOUT, 'script lock time too high')
|
||||
ensure(script_lock_value >= bid.created_at + offer.lock_value, 'script lock time too low')
|
||||
|
|
|
@ -32,7 +32,6 @@ from .basicswap_util import (
|
|||
from .js_server import (
|
||||
js_error,
|
||||
js_url_to_function,
|
||||
js_generatenotification,
|
||||
)
|
||||
from .ui.util import (
|
||||
getCoinName,
|
||||
|
@ -88,6 +87,7 @@ def listExplorerActions(swap_client):
|
|||
('unspent', 'List Unspent')]
|
||||
return actions
|
||||
|
||||
|
||||
class HttpHandler(BaseHTTPRequestHandler):
|
||||
|
||||
def checkForm(self, post_string, name, messages):
|
||||
|
@ -132,7 +132,7 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||
**args_dict,
|
||||
), 'UTF-8')
|
||||
|
||||
def page_info(self, info_str, post_string):
|
||||
def page_info(self, info_str, post_string=None):
|
||||
template = env.get_template('info.html')
|
||||
swap_client = self.server.swap_client
|
||||
summary = swap_client.getSummary()
|
||||
|
@ -142,7 +142,7 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||
'summary': summary,
|
||||
})
|
||||
|
||||
def page_error(self, error_str, post_string):
|
||||
def page_error(self, error_str, post_string=None):
|
||||
template = env.get_template('error.html')
|
||||
swap_client = self.server.swap_client
|
||||
summary = swap_client.getSummary()
|
||||
|
|
|
@ -243,6 +243,19 @@ class BTCInterface(CoinInterface):
|
|||
def getBlockHeader(self, block_hash):
|
||||
return self.rpc_callback('getblockheader', [block_hash])
|
||||
|
||||
def getBlockHeaderAt(self, time, block_after=False):
|
||||
blockchaininfo = self.rpc_callback('getblockchaininfo')
|
||||
last_block_header = self.rpc_callback('getblockheader', [blockchaininfo['bestblockhash']])
|
||||
|
||||
max_tries = 5000
|
||||
for i in range(max_tries):
|
||||
prev_block_header = self.rpc_callback('getblock', [last_block_header['previousblockhash']])
|
||||
if prev_block_header['time'] <= time:
|
||||
return last_block_header if block_after else prev_block_header
|
||||
|
||||
last_block_header = prev_block_header
|
||||
raise ValueError(f'Block header not found at time: {time}')
|
||||
|
||||
def initialiseWallet(self, key_bytes):
|
||||
key_wif = self.encodeKey(key_bytes)
|
||||
|
||||
|
|
|
@ -412,6 +412,7 @@ def js_url_to_function(url_split):
|
|||
}.get(url_split[2], js_index)
|
||||
return js_index
|
||||
|
||||
|
||||
def js_generatenotification(self, url_split, post_string, is_json):
|
||||
swap_client = self.server.swap_client
|
||||
r = random.randint(0, 3)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<path d="M5.34 0.671999L2.076 14.1H0.732L3.984 0.671999H5.34Z" fill="#BBC3CF"></path>
|
||||
</svg>
|
||||
</li>
|
||||
<li><a class="flex font-medium text-xs text-coolGray-500 hover:text-coolGray-700" href="/active">Swaps In Progres</a></li>
|
||||
<li><a class="flex font-medium text-xs text-coolGray-500 hover:text-coolGray-700" href="/active">Swaps In Progress</a></li>
|
||||
<li>
|
||||
<svg width="6" height="15" viewBox="0 0 6 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5.34 0.671999L2.076 14.1H0.732L3.984 0.671999H5.34Z" fill="#BBC3CF"></path>
|
||||
|
|
|
@ -251,14 +251,14 @@
|
|||
<a href="#" class="flex py-3 px-4 hover:bg-gray-100">
|
||||
<div class="flex-shrink-0"> <img class="w-11 h-11 rounded-full" src="/static/images/coins/Bitcoin.png" alt="Bitcoin"> </div>
|
||||
<div class="pl-3 w-full">
|
||||
<div class="text-gray-500 text-sm mb-1.5"><span class="font-semibold text-gray-900">BTC DEPOSIT</span> of <span class="font-medium text-gray-900">0.000493 BTC</span> sucesfull.</div>
|
||||
<div class="text-gray-500 text-sm mb-1.5"><span class="font-semibold text-gray-900">BTC DEPOSIT</span> of <span class="font-medium text-gray-900">0.000493 BTC</span> successful.</div>
|
||||
<div class="text-xs text-blue-600">15 minutes ago</div>
|
||||
</div>
|
||||
</a>
|
||||
<a href="#" class="flex py-3 px-4 hover:bg-gray-100">
|
||||
<div class="flex-shrink-0"> <img class="w-11 h-11 rounded-full" src="/static/images/coins/Particl.png" alt="Particl"> </div>
|
||||
<div class="pl-3 w-full">
|
||||
<div class="text-gray-500 text-sm mb-1.5"><span class="font-semibold text-gray-900">PART WITHDRAW</span> of <span class="font-medium text-gray-900">39.494 PART</span> sucesfull.</div>
|
||||
<div class="text-gray-500 text-sm mb-1.5"><span class="font-semibold text-gray-900">PART WITHDRAW</span> of <span class="font-medium text-gray-900">39.494 PART</span> successful.</div>
|
||||
<div class="text-xs text-blue-600">30 minutes ago</div>
|
||||
</div>
|
||||
</a>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<div class="w-full md:w-0/12">
|
||||
<div class="flex flex-wrap justify-center -m-1.5">
|
||||
<div class="w-full md:w-auto py-1 md:py-0 md:mr-6">
|
||||
<button name="" value="Apply" type="submit" class="text-center justify-center md:text-lg w-full md:text-lg flex flex-wrap py-3 px-4 bg-blue-500 hover:bg-blue-600 font-medium text-sm text-white border border-blue-500 rounded-md shadow-button focus:ring-0 focus:outline-none"> <span><a href="/wallets">Top your Wallets</a></span> </button>
|
||||
<button name="" value="Apply" type="submit" class="text-center justify-center md:text-lg w-full md:text-lg flex flex-wrap py-3 px-4 bg-blue-500 hover:bg-blue-600 font-medium text-sm text-white border border-blue-500 rounded-md shadow-button focus:ring-0 focus:outline-none"> <span><a href="/wallets">To your Wallets</a></span> </button>
|
||||
</div>
|
||||
<div class="w-full md:w-auto py-1 md:py-0 md:mr-6">
|
||||
<button name="" value="Apply" type="submit" class="text-center justify-center md:text-lg w-full md:text-lg flex flex-wrap py-3 px-4 text-coolGray-800 font-medium text-sm bg-white hover:bg-coolGray-100 border border-coolGray-200 rounded-md shadow-button focus:ring-0 focus:outline-none"> <span><a href="/offers">Start Trading</a></span> </button>
|
||||
|
|
|
@ -17,6 +17,7 @@ from basicswap.db import (
|
|||
strConcepts,
|
||||
)
|
||||
|
||||
|
||||
def page_automation_strategies(self, url_split, post_string):
|
||||
server = self.server
|
||||
swap_client = server.swap_client
|
||||
|
|
Loading…
Reference in a new issue