diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 7fd46de..7935f50 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -2165,6 +2165,24 @@ class BasicSwap(BaseApp): msg_buf.fee_rate_to ) # 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 "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 @@ -2217,6 +2235,7 @@ class BasicSwap(BaseApp): security_token=security_token, from_feerate=msg_buf.fee_rate_from, to_feerate=msg_buf.fee_rate_to, + auto_accept_type=msg_buf.auto_accept_type, ) offer.setState(OfferStates.OFFER_SENT) @@ -7054,6 +7073,11 @@ class BasicSwap(BaseApp): expire_at=msg["sent"] + offer_data.time_valid, was_sent=False, 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) self.add(offer, cursor) diff --git a/basicswap/db.py b/basicswap/db.py index bb583f2..1cea42d 100644 --- a/basicswap/db.py +++ b/basicswap/db.py @@ -13,7 +13,7 @@ from enum import IntEnum, auto from typing import Optional -CURRENT_DB_VERSION = 26 +CURRENT_DB_VERSION = 27 CURRENT_DB_DATA_VERSION = 6 @@ -183,6 +183,7 @@ class Offer(Table): amount_negotiable = Column("bool") rate_negotiable = Column("bool") + auto_accept_type = Column("integer") # Local fields auto_accept_bids = Column("bool") diff --git a/basicswap/db_upgrades.py b/basicswap/db_upgrades.py index 5208d0f..16da49a 100644 --- a/basicswap/db_upgrades.py +++ b/basicswap/db_upgrades.py @@ -425,6 +425,9 @@ def upgradeDatabase(self, db_version): last_updated INTEGER, 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: self.db_version = db_version self.setIntKV("db_version", db_version, cursor) diff --git a/basicswap/messages_npb.py b/basicswap/messages_npb.py index fa3ac14..ef2c98e 100644 --- a/basicswap/messages_npb.py +++ b/basicswap/messages_npb.py @@ -136,6 +136,7 @@ class OfferMessage(NonProtobufClass): 17: ("amount_negotiable", 0, 2), 18: ("rate_negotiable", 0, 2), 19: ("proof_utxos", 2, 0), + 20: ("auto_accept_type", 0, 0), } diff --git a/basicswap/templates/offer.html b/basicswap/templates/offer.html index e34979c..0d18c5b 100644 --- a/basicswap/templates/offer.html +++ b/basicswap/templates/offer.html @@ -219,16 +219,17 @@