mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
Offer page: Display whether offer is set to automatically accept bids or not
This commit is contained in:
@@ -2165,6 +2165,24 @@ class BasicSwap(BaseApp):
|
|||||||
msg_buf.fee_rate_to
|
msg_buf.fee_rate_to
|
||||||
) # Unused: TODO - Set priority?
|
) # Unused: TODO - Set priority?
|
||||||
|
|
||||||
|
# Set auto-accept type
|
||||||
|
automation_id = extra_options.get("automation_id", -1)
|
||||||
|
if automation_id == -1 and auto_accept_bids:
|
||||||
|
automation_id = 1 # Default strategy
|
||||||
|
|
||||||
|
if automation_id != -1:
|
||||||
|
strategy = self.queryOne(
|
||||||
|
AutomationStrategy,
|
||||||
|
cursor,
|
||||||
|
{"active_ind": 1, "record_id": automation_id},
|
||||||
|
)
|
||||||
|
if strategy:
|
||||||
|
msg_buf.auto_accept_type = (
|
||||||
|
2 if strategy.only_known_identities else 1
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
msg_buf.auto_accept_type = 0
|
||||||
|
|
||||||
# If a prefunded txn is not used, check that the wallet balance can cover the tx fee.
|
# If a prefunded txn is not used, check that the wallet balance can cover the tx fee.
|
||||||
if "prefunded_itx" not in extra_options:
|
if "prefunded_itx" not in extra_options:
|
||||||
# TODO: Better tx size estimate, xmr_swap_b_lock_tx_vsize could be larger than xmr_swap_b_lock_spend_tx_vsize
|
# TODO: Better tx size estimate, xmr_swap_b_lock_tx_vsize could be larger than xmr_swap_b_lock_spend_tx_vsize
|
||||||
@@ -2217,6 +2235,7 @@ class BasicSwap(BaseApp):
|
|||||||
security_token=security_token,
|
security_token=security_token,
|
||||||
from_feerate=msg_buf.fee_rate_from,
|
from_feerate=msg_buf.fee_rate_from,
|
||||||
to_feerate=msg_buf.fee_rate_to,
|
to_feerate=msg_buf.fee_rate_to,
|
||||||
|
auto_accept_type=msg_buf.auto_accept_type,
|
||||||
)
|
)
|
||||||
offer.setState(OfferStates.OFFER_SENT)
|
offer.setState(OfferStates.OFFER_SENT)
|
||||||
|
|
||||||
@@ -7052,6 +7071,11 @@ class BasicSwap(BaseApp):
|
|||||||
expire_at=msg["sent"] + offer_data.time_valid,
|
expire_at=msg["sent"] + offer_data.time_valid,
|
||||||
was_sent=False,
|
was_sent=False,
|
||||||
bid_reversed=bid_reversed,
|
bid_reversed=bid_reversed,
|
||||||
|
auto_accept_type=(
|
||||||
|
offer_data.auto_accept_type
|
||||||
|
if b"\xa0\x01" in offer_bytes
|
||||||
|
else None
|
||||||
|
),
|
||||||
)
|
)
|
||||||
offer.setState(OfferStates.OFFER_RECEIVED)
|
offer.setState(OfferStates.OFFER_RECEIVED)
|
||||||
self.add(offer, cursor)
|
self.add(offer, cursor)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from enum import IntEnum, auto
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
CURRENT_DB_VERSION = 26
|
CURRENT_DB_VERSION = 27
|
||||||
CURRENT_DB_DATA_VERSION = 6
|
CURRENT_DB_DATA_VERSION = 6
|
||||||
|
|
||||||
|
|
||||||
@@ -183,6 +183,7 @@ class Offer(Table):
|
|||||||
|
|
||||||
amount_negotiable = Column("bool")
|
amount_negotiable = Column("bool")
|
||||||
rate_negotiable = Column("bool")
|
rate_negotiable = Column("bool")
|
||||||
|
auto_accept_type = Column("integer")
|
||||||
|
|
||||||
# Local fields
|
# Local fields
|
||||||
auto_accept_bids = Column("bool")
|
auto_accept_bids = Column("bool")
|
||||||
|
|||||||
@@ -425,6 +425,9 @@ def upgradeDatabase(self, db_version):
|
|||||||
last_updated INTEGER,
|
last_updated INTEGER,
|
||||||
PRIMARY KEY (record_id))"""
|
PRIMARY KEY (record_id))"""
|
||||||
)
|
)
|
||||||
|
elif current_version == 26:
|
||||||
|
db_version += 1
|
||||||
|
cursor.execute("ALTER TABLE offers ADD COLUMN auto_accept_type INTEGER")
|
||||||
if current_version != db_version:
|
if current_version != db_version:
|
||||||
self.db_version = db_version
|
self.db_version = db_version
|
||||||
self.setIntKV("db_version", db_version, cursor)
|
self.setIntKV("db_version", db_version, cursor)
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class OfferMessage(NonProtobufClass):
|
|||||||
17: ("amount_negotiable", 0, 2),
|
17: ("amount_negotiable", 0, 2),
|
||||||
18: ("rate_negotiable", 0, 2),
|
18: ("rate_negotiable", 0, 2),
|
||||||
19: ("proof_utxos", 2, 0),
|
19: ("proof_utxos", 2, 0),
|
||||||
|
20: ("auto_accept_type", 0, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -219,16 +219,17 @@
|
|||||||
<td class="py-3 px-6 bold">Revoked</td>
|
<td class="py-3 px-6 bold">Revoked</td>
|
||||||
<td class="py-3 px-6">{{ data.was_revoked }}</td>
|
<td class="py-3 px-6">{{ data.was_revoked }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if data.sent %}
|
|
||||||
<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">Auto Accept Strategy</td>
|
<td class="py-3 px-6 bold">Auto Accept Type</td>
|
||||||
<td class="py-3 px-6">
|
<td class="py-3 px-6">
|
||||||
{% if data.automation_strat_id == -1 %} None {% else %}
|
{% if data.auto_accept_type is none %} Unknown
|
||||||
<a href="/automationstrategy/{{ data.automation_strat_id }}">{{ data.automation_strat_label }}</a>
|
{% elif data.auto_accept_type == 0 %} Bids are accepted manually
|
||||||
|
{% elif data.auto_accept_type == 1 %} Bids are accepted automatically
|
||||||
|
{% elif data.auto_accept_type == 2 %} Bids are accepted automatically from known identities
|
||||||
|
{% else %} Unknown ({{ data.auto_accept_type }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
|
||||||
{% if data.xmr_type == true %}
|
{% if data.xmr_type == true %}
|
||||||
<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">Chain A offer fee rate</td>
|
<td class="py-3 px-6 bold">Chain A offer fee rate</td>
|
||||||
@@ -482,7 +483,7 @@ if (document.readyState === 'loading') {
|
|||||||
name="bid_amount_send"
|
name="bid_amount_send"
|
||||||
value=""
|
value=""
|
||||||
max="{{ data.amt_to }}"
|
max="{{ data.amt_to }}"
|
||||||
onchange="validateMaxAmount(this, {{ data.amt_to }}); updateBidParams('sending');">
|
onchange="validateMaxAmount(this, parseFloat('{{ data.amt_to }}')); updateBidParams('sending');">
|
||||||
<div class="absolute inset-y-0 right-3 flex items-center pointer-events-none text-gray-400 dark:text-gray-300 text-sm">
|
<div class="absolute inset-y-0 right-3 flex items-center pointer-events-none text-gray-400 dark:text-gray-300 text-sm">
|
||||||
max {{ data.amt_to }} ({{ data.tla_to }})
|
max {{ data.amt_to }} ({{ data.tla_to }})
|
||||||
</div>
|
</div>
|
||||||
@@ -505,7 +506,7 @@ if (document.readyState === 'loading') {
|
|||||||
name="bid_amount"
|
name="bid_amount"
|
||||||
value=""
|
value=""
|
||||||
max="{{ data.amt_from }}"
|
max="{{ data.amt_from }}"
|
||||||
onchange="validateMaxAmount(this, {{ data.amt_from }}); updateBidParams('receiving');">
|
onchange="validateMaxAmount(this, parseFloat('{{ data.amt_from }}')); updateBidParams('receiving');">
|
||||||
<div class="absolute inset-y-0 right-3 flex items-center pointer-events-none text-gray-400 dark:text-gray-300 text-sm">
|
<div class="absolute inset-y-0 right-3 flex items-center pointer-events-none text-gray-400 dark:text-gray-300 text-sm">
|
||||||
max {{ data.amt_from }} ({{ data.tla_from }})
|
max {{ data.amt_from }} ({{ data.tla_from }})
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -733,6 +733,9 @@ def page_offer(self, url_split, post_string):
|
|||||||
"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 "",
|
||||||
|
"auto_accept_type": (
|
||||||
|
offer.auto_accept_type if hasattr(offer, "auto_accept_type") else 0
|
||||||
|
),
|
||||||
}
|
}
|
||||||
data.update(extend_data)
|
data.update(extend_data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user