merge: Fix merge and lint issues.
This commit is contained in:
		
							parent
							
								
									e913957e41
								
							
						
					
					
						commit
						58a2707526
					
				@ -8,7 +8,7 @@ lint_task:
 | 
				
			|||||||
  script:
 | 
					  script:
 | 
				
			||||||
    - flake8 --version
 | 
					    - flake8 --version
 | 
				
			||||||
    - PYTHONWARNINGS="ignore" flake8 --ignore=E501,F841,W503 --exclude=basicswap/contrib,basicswap/interface/contrib,messages_pb2.py,.eggs,.tox,bin/install_certifi.py
 | 
					    - 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:
 | 
					test_task:
 | 
				
			||||||
  environment:
 | 
					  environment:
 | 
				
			||||||
 | 
				
			|||||||
@ -53,7 +53,7 @@ jobs:
 | 
				
			|||||||
      before_script:
 | 
					      before_script:
 | 
				
			||||||
      script:
 | 
					      script:
 | 
				
			||||||
        - PYTHONWARNINGS="ignore" flake8 --ignore=E501,F841,W503 --exclude=basicswap/contrib,basicswap/interface/contrib,messages_pb2.py,.eggs,.tox,bin/install_certifi.py
 | 
					        - 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:
 | 
					      after_success:
 | 
				
			||||||
        - echo "End lint"
 | 
					        - echo "End lint"
 | 
				
			||||||
    - stage: test
 | 
					    - stage: test
 | 
				
			||||||
 | 
				
			|||||||
@ -2415,21 +2415,9 @@ class BasicSwap(BaseApp):
 | 
				
			|||||||
            initiate_tx_block_time = int(self.callcoinrpc(coin_from, 'getblock', [initiate_tx_block_hash, ])['time'])
 | 
					            initiate_tx_block_time = int(self.callcoinrpc(coin_from, 'getblock', [initiate_tx_block_hash, ])['time'])
 | 
				
			||||||
            if offer.lock_type == TxLockTypes.ABS_LOCK_BLOCKS:
 | 
					            if offer.lock_type == TxLockTypes.ABS_LOCK_BLOCKS:
 | 
				
			||||||
                # Walk the coin_to chain back until block time matches
 | 
					                # Walk the coin_to chain back until block time matches
 | 
				
			||||||
                blockchaininfo = self.callcoinrpc(coin_to, 'getblockchaininfo')
 | 
					                block_header_at = ci_to.getBlockHeaderAt(initiate_tx_block_time, block_after=True)
 | 
				
			||||||
                cblock_hash = blockchaininfo['bestblockhash']
 | 
					                cblock_hash = block_header_at['hash']
 | 
				
			||||||
                cblock_height = blockchaininfo['blocks']
 | 
					                cblock_height = block_header_at['height']
 | 
				
			||||||
                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')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                self.log.debug('Setting lock value from height of block %s %s', coin_to, cblock_hash)
 | 
					                self.log.debug('Setting lock value from height of block %s %s', coin_to, cblock_hash)
 | 
				
			||||||
                contract_lock_value = cblock_height + lock_value
 | 
					                contract_lock_value = cblock_height + lock_value
 | 
				
			||||||
@ -4084,7 +4072,10 @@ class BasicSwap(BaseApp):
 | 
				
			|||||||
            ensure(script_lock_value == expect_sequence, 'sequence mismatch')
 | 
					            ensure(script_lock_value == expect_sequence, 'sequence mismatch')
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            if offer.lock_type == TxLockTypes.ABS_LOCK_BLOCKS:
 | 
					            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:
 | 
					            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 + 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')
 | 
					                ensure(script_lock_value >= bid.created_at + offer.lock_value, 'script lock time too low')
 | 
				
			||||||
@ -5327,7 +5318,7 @@ class BasicSwap(BaseApp):
 | 
				
			|||||||
                'version': self.coin_clients[coin]['core_version'],
 | 
					                'version': self.coin_clients[coin]['core_version'],
 | 
				
			||||||
                'name': ci.coin_name(),
 | 
					                'name': ci.coin_name(),
 | 
				
			||||||
                'blocks': blockchaininfo['blocks'],
 | 
					                'blocks': blockchaininfo['blocks'],
 | 
				
			||||||
                'synced': '{:.2f}'.format(round(100*blockchaininfo['verificationprogress'], 2)),
 | 
					                'synced': '{:.2f}'.format(round(100 * blockchaininfo['verificationprogress'], 2)),
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if 'known_block_count' in blockchaininfo:
 | 
					            if 'known_block_count' in blockchaininfo:
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,6 @@ from .basicswap_util import (
 | 
				
			|||||||
from .js_server import (
 | 
					from .js_server import (
 | 
				
			||||||
    js_error,
 | 
					    js_error,
 | 
				
			||||||
    js_url_to_function,
 | 
					    js_url_to_function,
 | 
				
			||||||
    js_generatenotification,
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
from .ui.util import (
 | 
					from .ui.util import (
 | 
				
			||||||
    getCoinName,
 | 
					    getCoinName,
 | 
				
			||||||
@ -88,6 +87,7 @@ def listExplorerActions(swap_client):
 | 
				
			|||||||
               ('unspent', 'List Unspent')]
 | 
					               ('unspent', 'List Unspent')]
 | 
				
			||||||
    return actions
 | 
					    return actions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class HttpHandler(BaseHTTPRequestHandler):
 | 
					class HttpHandler(BaseHTTPRequestHandler):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def checkForm(self, post_string, name, messages):
 | 
					    def checkForm(self, post_string, name, messages):
 | 
				
			||||||
 | 
				
			|||||||
@ -243,6 +243,19 @@ class BTCInterface(CoinInterface):
 | 
				
			|||||||
    def getBlockHeader(self, block_hash):
 | 
					    def getBlockHeader(self, block_hash):
 | 
				
			||||||
        return self.rpc_callback('getblockheader', [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):
 | 
					    def initialiseWallet(self, key_bytes):
 | 
				
			||||||
        key_wif = self.encodeKey(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)
 | 
					        }.get(url_split[2], js_index)
 | 
				
			||||||
    return js_index
 | 
					    return js_index
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def js_generatenotification(self, url_split, post_string, is_json):
 | 
					def js_generatenotification(self, url_split, post_string, is_json):
 | 
				
			||||||
    swap_client = self.server.swap_client
 | 
					    swap_client = self.server.swap_client
 | 
				
			||||||
    r = random.randint(0, 3)
 | 
					    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>
 | 
					              <path d="M5.34 0.671999L2.076 14.1H0.732L3.984 0.671999H5.34Z" fill="#BBC3CF"></path>
 | 
				
			||||||
            </svg>
 | 
					            </svg>
 | 
				
			||||||
          </li>
 | 
					          </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>
 | 
					          <li>
 | 
				
			||||||
            <svg width="6" height="15" viewBox="0 0 6 15" fill="none" xmlns="http://www.w3.org/2000/svg">
 | 
					            <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>
 | 
					              <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">
 | 
					              <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="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="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 class="text-xs text-blue-600">15 minutes ago</div>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
              </a>
 | 
					              </a>
 | 
				
			||||||
              <a href="#" class="flex py-3 px-4 hover:bg-gray-100">
 | 
					              <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="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="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 class="text-xs text-blue-600">30 minutes ago</div>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
              </a>
 | 
					              </a>
 | 
				
			||||||
 | 
				
			|||||||
@ -20,7 +20,7 @@
 | 
				
			|||||||
					<div class="w-full md:w-0/12">
 | 
										<div class="w-full md:w-0/12">
 | 
				
			||||||
						<div class="flex flex-wrap justify-center -m-1.5">
 | 
											<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">
 | 
												<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>
 | 
				
			||||||
							<div class="w-full md:w-auto py-1 md:py-0 md:mr-6">
 | 
												<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>
 | 
													<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,
 | 
					    strConcepts,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def page_automation_strategies(self, url_split, post_string):
 | 
					def page_automation_strategies(self, url_split, post_string):
 | 
				
			||||||
    server = self.server
 | 
					    server = self.server
 | 
				
			||||||
    swap_client = server.swap_client
 | 
					    swap_client = server.swap_client
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user