Fix revoke ttl too low. Remove XMR fee warnings.

2024-05-20_merge
tecnovert 10 months ago
parent 0d344a907c
commit 483d77a0c6
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 14
      basicswap/basicswap.py
  2. 13
      basicswap/interface/xmr.py

@ -1622,7 +1622,7 @@ class BasicSwap(BaseApp):
offer_bytes = msg_buf.SerializeToString()
payload_hex = str.format('{:02x}', MessageTypes.OFFER) + offer_bytes.hex()
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR * 1, valid_for_seconds)
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR, valid_for_seconds)
offer_id = self.sendSmsg(offer_addr, offer_addr_to, payload_hex, msg_valid)
security_token = extra_options.get('security_token', None)
@ -1717,7 +1717,9 @@ class BasicSwap(BaseApp):
msg_bytes = msg_buf.SerializeToString()
payload_hex = str.format('{:02x}', MessageTypes.OFFER_REVOKE) + msg_bytes.hex()
msg_id = self.sendSmsg(offer.addr_from, self.network_addr, payload_hex, offer.time_valid)
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR, offer.time_valid)
msg_id = self.sendSmsg(offer.addr_from, self.network_addr, payload_hex, msg_valid)
self.log.debug('Revoked offer %s in msg %s', offer_id.hex(), msg_id.hex())
finally:
self.closeSession(session, commit=False)
@ -1902,7 +1904,7 @@ class BasicSwap(BaseApp):
def estimateWithdrawFee(self, coin_type, fee_rate):
if coin_type == Coins.XMR:
self.log.error('TODO: estimateWithdrawFee XMR')
# Fee estimate must be manually initiated
return None
tx_vsize = self.ci(coin_type).getHTLCSpendTxVSize()
est_fee = (fee_rate * tx_vsize) / 1000
@ -2298,7 +2300,7 @@ class BasicSwap(BaseApp):
payload_hex = str.format('{:02x}', MessageTypes.BID) + bid_bytes.hex()
bid_addr = self.newSMSGAddress(use_type=AddressTypes.BID)[0] if addr_send_from is None else addr_send_from
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR * 1, valid_for_seconds)
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR, valid_for_seconds)
bid_id = self.sendSmsg(bid_addr, offer.addr_from, payload_hex, msg_valid)
bid = Bid(
@ -2657,7 +2659,7 @@ class BasicSwap(BaseApp):
xmr_swap.contract_count = self.getNewContractId()
bid_addr = self.newSMSGAddress(use_type=AddressTypes.BID)[0] if addr_send_from is None else addr_send_from
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR * 1, valid_for_seconds)
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR, valid_for_seconds)
xmr_swap.bid_id = self.sendSmsg(bid_addr, offer.addr_from, payload_hex, msg_valid)
bid = Bid(
@ -2743,7 +2745,7 @@ class BasicSwap(BaseApp):
payload_hex = str.format('{:02x}', MessageTypes.XMR_BID_FL) + bid_bytes.hex()
bid_addr = self.newSMSGAddress(use_type=AddressTypes.BID)[0] if addr_send_from is None else addr_send_from
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR * 1, valid_for_seconds)
msg_valid: int = max(self.SMSG_SECONDS_IN_HOUR, valid_for_seconds)
xmr_swap.bid_id = self.sendSmsg(bid_addr, offer.addr_from, payload_hex, msg_valid)
bid_msg_ids = {}

@ -76,7 +76,7 @@ class XMRInterface(CoinInterface):
@staticmethod
def xmr_swap_b_lock_spend_tx_vsize() -> int:
# TODO: Estimate with ringsize
return 1507
return 1604
def __init__(self, coin_settings, network, swap_client=None):
super().__init__(network)
@ -254,8 +254,15 @@ class XMRInterface(CoinInterface):
return new_address
def get_fee_rate(self, conf_target: int = 2):
self._log.warning('TODO - estimate XMR fee rate?')
return 0.0, 'unused'
# fees - array of unsigned int; Represents the base fees at different priorities [slow, normal, fast, fastest].
fee_est = self.rpc('get_fee_estimate')
if conf_target <= 1:
conf_target = 1 # normal
else:
conf_target = 0 # slow
fee_per_k_bytes = fee_est['fees'][conf_target] * 1000
return float(self.format_amount(fee_per_k_bytes)), 'get_fee_estimate'
def getNewSecretKey(self) -> bytes:
# Note: Returned bytes are in big endian order

Loading…
Cancel
Save