Set default anon tx ring size to 12 and add setting.

This commit is contained in:
tecnovert 2022-04-11 00:11:51 +02:00
parent a4683c8450
commit 88c94c4acd
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
6 changed files with 34 additions and 6 deletions

View file

@ -390,6 +390,7 @@ class BasicSwap(BaseApp):
}
if coin == Coins.PART:
self.coin_clients[coin]['anon_tx_ring_size'] = chain_client_settings.get('anon_tx_ring_size', 12)
self.coin_clients[Coins.PART_ANON] = self.coin_clients[coin]
self.coin_clients[Coins.PART_BLIND] = self.coin_clients[coin]
@ -5094,6 +5095,19 @@ class BasicSwap(BaseApp):
self.ci(coin).setConfTarget(new_conf_target)
break
if 'anon_tx_ring_size' in data:
new_anon_tx_ring_size = data['anon_tx_ring_size']
ensure(new_anon_tx_ring_size >= 3 and new_anon_tx_ring_size < 33, 'Invalid anon_tx_ring_size')
if settings_cc.get('anon_tx_ring_size', 12) != new_anon_tx_ring_size:
settings_changed = True
settings_cc['anon_tx_ring_size'] = new_anon_tx_ring_size
for coin, cc in self.coin_clients.items():
if cc['name'] == coin_name:
cc['anon_tx_ring_size'] = new_anon_tx_ring_size
self.ci(coin).setAnonTxRingSize(new_anon_tx_ring_size)
break
if settings_changed:
settings_path = os.path.join(self.data_dir, cfg.CONFIG_FILENAME)
shutil.copyfile(settings_path, settings_path + '.last')

View file

@ -575,6 +575,8 @@ class HttpHandler(BaseHTTPRequestHandler):
data['automatically_select_daemon'] = True if get_data_entry(form_data, 'autosetdaemon_' + name) == 'true' else False
else:
data['conf_target'] = int(get_data_entry(form_data, 'conf_target_' + name))
if name == 'particl':
data['anon_tx_ring_size'] = int(get_data_entry(form_data, 'rct_ring_size_' + name))
settings_changed, suggest_reboot = swap_client.editSettings(name, data)
if settings_changed is True:
@ -609,7 +611,10 @@ class HttpHandler(BaseHTTPRequestHandler):
chains_formatted[-1]['autosetdaemon'] = c.get('automatically_select_daemon', False)
else:
chains_formatted[-1]['conf_target'] = c.get('conf_target', 2)
if name != 'particl':
if name == 'particl':
chains_formatted[-1]['anon_tx_ring_size'] = c.get('anon_tx_ring_size', 12)
else:
if c.get('connection_type', 'Unknown') == 'none':
if 'connection_type_prev' in c:
chains_formatted[-1]['can_reenable'] = True

View file

@ -208,7 +208,7 @@ class BTCInterface(CoinInterface):
rpc_conn.close()
def setConfTarget(self, new_conf_target):
assert(new_conf_target >= 1 and new_conf_target < 33), 'Invalid conf_target value'
ensure(new_conf_target >= 1 and new_conf_target < 33, 'Invalid conf_target value')
self._conf_target = new_conf_target
def testDaemonRPC(self):

View file

@ -65,9 +65,13 @@ class PARTInterface(BTCInterface):
def txoType():
return CTxOutPart
def setDefaults(self) -> None:
super().setDefaults()
self._anon_tx_ring_size = 8 # TODO: Make option
def __init__(self, coin_settings, network, swap_client=None):
super().__init__(coin_settings, network, swap_client)
self.setAnonTxRingSize(int(coin_settings.get('anon_tx_ring_size', 12)))
def setAnonTxRingSize(self, value):
ensure(value >= 3 and value < 33, 'Invalid anon_tx_ring_size value')
self._anon_tx_ring_size = value
def knownWalletSeed(self):
# TODO: Double check
@ -708,6 +712,7 @@ class PARTInterfaceAnon(PARTInterface):
utxo = autxos[0]
utxo_sats = make_int(utxo['amount'])
if spend_actual_balance and utxo_sats != cb_swap_value:
self._log.warning('Spending actual balance {}, not swap value {}.'.format(utxo_sats, cb_swap_value))
cb_swap_value = utxo_sats

View file

@ -59,6 +59,9 @@ node.xmr.to:18081<br/>
{% else %}
<tr><td>Blocks Confirmed Target</td><td><input type="number" name="conf_target_{{ c.name }}" min="1" max="32" value="{{ c.conf_target }}"></td></tr>
{% endif %}
{% if c.name == 'particl' %}
<tr><td>Anon Tx Ring Size</td><td><input type="number" name="rct_ring_size_{{ c.name }}" min="3" max="32" value="{{ c.anon_tx_ring_size }}"></td></tr>
{% endif %}
<tr><td><input type="submit" name="apply_{{ c.name }}" value="Apply">
{% if c.can_disable == true %}
<input type="submit" name="disable_{{ c.name }}" value="Disable" onclick="return confirmPopup('Disable', '{{ c.name|capitalize }}');">

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2021 tecnovert
# Copyright (c) 2020-2022 tecnovert
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
@ -168,6 +168,7 @@ def prepare_swapclient_dir(datadir, node_id, network_key, network_pubkey, with_l
'datadir': os.path.join(datadir, 'part_' + str(node_id)),
'bindir': cfg.PARTICL_BINDIR,
'blocks_confirmed': 2, # Faster testing
'anon_tx_ring_size': 5, # Faster testing
},
'bitcoin': {
'connection_type': 'rpc',