Merge pull request #178 from tecnovert/wallets

Wallet blocks and depth spendable
This commit is contained in:
tecnovert 2024-11-29 21:01:54 +00:00 committed by GitHub
commit 744ad7988a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 35 additions and 16 deletions

View file

@ -8,7 +8,7 @@ concurrency:
env: env:
BIN_DIR: /tmp/cached_bin BIN_DIR: /tmp/cached_bin
TEST_RELOAD_PATH: /tmp/test_basicswap1 TEST_RELOAD_PATH: /tmp/test_basicswap
jobs: jobs:
ci: ci:
@ -46,8 +46,8 @@ jobs:
cache-name: cache-cores cache-name: cache-cores
CACHE_KEY: $(printf $(python bin/basicswap-prepare.py --version --withcoins=bitcoin) | sha256sum | head -c 64) CACHE_KEY: $(printf $(python bin/basicswap-prepare.py --version --withcoins=bitcoin) | sha256sum | head -c 64)
with: with:
path: "$BIN_DIR" path: $BIN_DIR
key: "$CACHE_KEY" key: $CACHE_KEY
- if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} - if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }}
name: Running basicswap-prepare name: Running basicswap-prepare
@ -57,6 +57,6 @@ jobs:
run: | run: |
export PYTHONPATH=$(pwd) export PYTHONPATH=$(pwd)
export TEST_PATH=${TEST_RELOAD_PATH} export TEST_PATH=${TEST_RELOAD_PATH}
mkdir -p ${TEST_RELOAD_PATH}/bin mkdir -p ${TEST_PATH}/bin
cp -r $BIN_DIR/* ${TEST_RELOAD_PATH}/bin/ cp -r $BIN_DIR/* ${TEST_PATH}/bin/
pytest tests/basicswap/extended/test_encrypted_xmr_reload.py pytest tests/basicswap/extended/test_encrypted_xmr_reload.py

View file

@ -8767,10 +8767,10 @@ class BasicSwap(BaseApp):
try: try:
chain_height = ci_to.getChainHeight() chain_height = ci_to.getChainHeight()
lock_tx_depth = (chain_height - bid.xmr_b_lock_tx.chain_height) + 1 lock_tx_depth = (chain_height - bid.xmr_b_lock_tx.chain_height)
if lock_tx_depth < ci_to.depth_spendable(): if lock_tx_depth < ci_to.depth_spendable():
raise TemporaryError( raise TemporaryError(
f"Chain B lock tx depth {lock_tx_depth} < required for spending." f"Chain B lock tx still confirming {lock_tx_depth} / {ci_to.depth_spendable()}."
) )
if TxTypes.BCH_MERCY in bid.txns: if TxTypes.BCH_MERCY in bid.txns:
@ -8857,9 +8857,7 @@ class BasicSwap(BaseApp):
): ):
delay = self.get_delay_retry_seconds() delay = self.get_delay_retry_seconds()
self.log.info( self.log.info(
"Retrying sending adaptor-sig swap chain B spend tx for bid %s in %d seconds", f"Retrying sending adaptor-sig swap chain B spend tx for bid {bid_id.hex()} in {delay} seconds"
bid_id.hex(),
delay,
) )
self.createActionInSession( self.createActionInSession(
delay, ActionTypes.REDEEM_XMR_SWAP_LOCK_TX_B, bid_id, cursor delay, ActionTypes.REDEEM_XMR_SWAP_LOCK_TX_B, bid_id, cursor
@ -10285,6 +10283,9 @@ class BasicSwap(BaseApp):
"locked": walletinfo["locked"], "locked": walletinfo["locked"],
} }
if "wallet_blocks" in walletinfo:
rv["wallet_blocks"] = walletinfo["wallet_blocks"]
if "immature_balance" in walletinfo: if "immature_balance" in walletinfo:
rv["immature"] = ci.format_amount( rv["immature"] = ci.format_amount(
walletinfo["immature_balance"], conv_int=True walletinfo["immature_balance"], conv_int=True

View file

@ -1520,7 +1520,9 @@ def printVersion(with_coins):
if len(with_coins) < 1: if len(with_coins) < 1:
return return
print("Core versions:") print("Core versions:")
with_coins_changed: bool = False if len(with_coins) == 1 and "particl" in with_coins else True with_coins_changed: bool = (
False if len(with_coins) == 1 and "particl" in with_coins else True
)
for coin, version in known_coins.items(): for coin, version in known_coins.items():
if with_coins_changed and coin not in with_coins: if with_coins_changed and coin not in with_coins:
continue continue

View file

@ -292,6 +292,7 @@ class XMRInterface(CoinInterface):
rv = {} rv = {}
balance_info = self.rpc_wallet("get_balance") balance_info = self.rpc_wallet("get_balance")
rv["wallet_blocks"] = self.rpc_wallet("get_height")["height"]
rv["balance"] = self.format_amount(balance_info["unlocked_balance"]) rv["balance"] = self.format_amount(balance_info["unlocked_balance"])
rv["unconfirmed_balance"] = self.format_amount( rv["unconfirmed_balance"] = self.format_amount(
balance_info["balance"] - balance_info["unlocked_balance"] balance_info["balance"] - balance_info["unlocked_balance"]

View file

@ -163,6 +163,12 @@
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% if w.wallet_blocks %}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Wallet Blocks:</td>
<td class="py-3 px-6">{{ w.wallet_blocks }}{% if w.known_block_count %} / {{ w.known_block_count }}{% endif %}</td>
</tr>
{% endif %}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600"> <tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Synced:</td> <td class="py-3 px-6 bold">Synced:</td>
<td class="py-3 px-6">{{ w.synced }}</td> <td class="py-3 px-6">{{ w.synced }}</td>

View file

@ -163,7 +163,9 @@ def parseOfferFormData(swap_client, form_data, page_data, options={}):
if swap_client.debug: if swap_client.debug:
page_data["amt_var"] = True if have_data_entry(form_data, "amt_var") else False page_data["amt_var"] = True if have_data_entry(form_data, "amt_var") else False
parsed_data["amt_var"] = page_data["amt_var"] parsed_data["amt_var"] = page_data["amt_var"]
page_data["rate_var"] = True if have_data_entry(form_data, "rate_var") else False page_data["rate_var"] = (
True if have_data_entry(form_data, "rate_var") else False
)
parsed_data["rate_var"] = page_data["rate_var"] parsed_data["rate_var"] = page_data["rate_var"]
else: else:
page_data["amt_var"] = True page_data["amt_var"] = True
@ -634,7 +636,11 @@ def page_offer(self, url_split, post_string):
swap_client.editOffer(offer_id, change_data) swap_client.editOffer(offer_id, change_data)
elif b"newbid" in form_data: elif b"newbid" in form_data:
show_bid_form = True show_bid_form = True
elif b"sendbid" in form_data and b"confirm" in form_data and b"formid" in form_data: elif (
b"sendbid" in form_data
and b"confirm" in form_data
and b"formid" in form_data
):
try: try:
addr_from = form_data[b"addr_from"][0].decode("utf-8") addr_from = form_data[b"addr_from"][0].decode("utf-8")
extend_data["nb_addr_from"] = addr_from extend_data["nb_addr_from"] = addr_from
@ -719,7 +725,7 @@ def page_offer(self, url_split, post_string):
"active_ind": offer.active_ind, "active_ind": offer.active_ind,
"swap_type": strSwapDesc(offer.swap_type), "swap_type": strSwapDesc(offer.swap_type),
"reverse": reverse_bid, "reverse": reverse_bid,
"form_id": get_data_entry_or(form_data, "formid", "") if form_data else "" "form_id": get_data_entry_or(form_data, "formid", "") if form_data else "",
} }
data.update(extend_data) data.update(extend_data)

View file

@ -38,6 +38,9 @@ def format_wallet_data(swap_client, ci, w):
"havedata": True, "havedata": True,
} }
if "wallet_blocks" in w:
wf["wallet_blocks"] = w["wallet_blocks"]
if w.get("bootstrapping", False) is True: if w.get("bootstrapping", False) is True:
wf["bootstrapping"] = True wf["bootstrapping"] = True
if "known_block_count" in w: if "known_block_count" in w: