From 6b724ece84c4beee23c2743e871c4f7d317ce2b5 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sun, 30 Mar 2025 22:36:03 +0200 Subject: [PATCH] nmc: Add to test_xmr_persistent. --- basicswap/bin/prepare.py | 111 ++++++++++-------- basicswap/bin/run.py | 6 +- basicswap/static/images/coins/Namecoin-20.png | Bin 0 -> 743 bytes basicswap/static/images/coins/Namecoin.png | Bin 0 -> 4282 bytes basicswap/static/js/bids_available.js | 20 ++-- basicswap/static/js/modules/api-manager.js | 4 +- basicswap/static/js/modules/cache-manager.js | 3 +- basicswap/static/js/modules/config-manager.js | 7 +- basicswap/static/js/modules/wallet-manager.js | 3 + basicswap/static/js/offers.js | 49 ++++---- basicswap/static/js/pricechart.js | 2 +- basicswap/static/js/swaps_in_progress.js | 11 +- basicswap/templates/offers.html | 9 +- tests/basicswap/common_xmr.py | 108 +++++++++++++---- tests/basicswap/extended/test_nmc.py | 1 + .../basicswap/extended/test_xmr_persistent.py | 34 +++++- 16 files changed, 240 insertions(+), 128 deletions(-) create mode 100644 basicswap/static/images/coins/Namecoin-20.png create mode 100644 basicswap/static/images/coins/Namecoin.png diff --git a/basicswap/bin/prepare.py b/basicswap/bin/prepare.py index f70f602..f513c21 100755 --- a/basicswap/bin/prepare.py +++ b/basicswap/bin/prepare.py @@ -117,7 +117,9 @@ known_coins = { "dogecoin": (DOGECOIN_VERSION, DOGECOIN_VERSION_TAG, ("tecnovert",)), } -disabled_coins = ["navcoin"] +disabled_coins = [ + "navcoin", +] expected_key_ids = { "tecnovert": ("13F13651C9CF0D6B",), @@ -207,6 +209,7 @@ DCR_RPC_PWD = os.getenv("DCR_RPC_PWD", random.randbytes(random.randint(14, 18)). NMC_RPC_HOST = os.getenv("NMC_RPC_HOST", "127.0.0.1") NMC_RPC_PORT = int(os.getenv("NMC_RPC_PORT", 19698)) +NMC_PORT = int(os.getenv("NMC_PORT", 8134)) NMC_ONION_PORT = int(os.getenv("NMC_ONION_PORT", 9698)) NMC_RPC_USER = os.getenv("NMC_RPC_USER", "") NMC_RPC_PWD = os.getenv("NMC_RPC_PWD", "") @@ -1349,6 +1352,8 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}): fp.write("printtoconsole=0\n") fp.write("daemon=0\n") fp.write(f"wallet={wallet_name}\n") + if "watch_wallet_name" in core_settings: + fp.write("wallet={}\n".format(core_settings["watch_wallet_name"])) if tor_control_password is not None: writeTorSettings(fp, coin, core_settings, tor_control_password) @@ -1408,6 +1413,7 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}): fp.write("deprecatedrpc=create_bdb\n") fp.write("addresstype=bech32\n") fp.write("changetype=bech32\n") + fp.write("fallbackfee=0.001\n") # minrelaytxfee elif coin == "pivx": params_dir = os.path.join(data_dir, "pivx-params") downloadPIVXParams(params_dir) @@ -2391,22 +2397,6 @@ def main(): "core_version_no": getKnownVersion("bitcoin"), "core_version_group": 28, }, - "bitcoincash": { - "connection_type": "rpc", - "manage_daemon": shouldManageDaemon("BCH"), - "rpchost": BCH_RPC_HOST, - "rpcport": BCH_RPC_PORT + port_offset, - "onionport": BCH_ONION_PORT + port_offset, - "datadir": os.getenv("BCH_DATA_DIR", os.path.join(data_dir, "bitcoincash")), - "bindir": os.path.join(bin_dir, "bitcoincash"), - "port": BCH_PORT + port_offset, - "config_filename": "bitcoin.conf", - "use_segwit": False, - "blocks_confirmed": 1, - "conf_target": 2, - "core_version_no": getKnownVersion("bitcoincash"), - "core_version_group": 22, - }, "litecoin": { "connection_type": "rpc", "manage_daemon": shouldManageDaemon("LTC"), @@ -2422,22 +2412,6 @@ def main(): "core_version_group": 20, "min_relay_fee": 0.00001, }, - "dogecoin": { - "connection_type": "rpc", - "manage_daemon": shouldManageDaemon("DOGE"), - "rpchost": DOGE_RPC_HOST, - "rpcport": DOGE_RPC_PORT + port_offset, - "onionport": DOGE_ONION_PORT + port_offset, - "datadir": os.getenv("DOGE_DATA_DIR", os.path.join(data_dir, "dogecoin")), - "bindir": os.path.join(bin_dir, "dogecoin"), - "use_segwit": False, - "use_csv": False, - "blocks_confirmed": 2, - "conf_target": 2, - "core_version_no": getKnownVersion("dogecoin"), - "core_version_group": 23, - "min_relay_fee": 0.01, # RECOMMENDED_MIN_TX_FEE - }, "decred": { "connection_type": "rpc", "manage_daemon": shouldManageDaemon("DCR"), @@ -2468,6 +2442,7 @@ def main(): "onionport": NMC_ONION_PORT + port_offset, "datadir": os.getenv("NMC_DATA_DIR", os.path.join(data_dir, "namecoin")), "bindir": os.path.join(bin_dir, "namecoin"), + "port": NMC_PORT + port_offset, "use_segwit": True, "use_csv": True, "blocks_confirmed": 1, @@ -2499,6 +2474,28 @@ def main(): "core_version_no": getKnownVersion("monero"), "core_type_group": "xmr", }, + "wownero": { + "connection_type": "rpc", + "manage_daemon": shouldManageDaemon("WOW"), + "manage_wallet_daemon": shouldManageDaemon("WOW_WALLET"), + "rpcport": WOW_RPC_PORT + port_offset, + "zmqport": WOW_ZMQ_PORT + port_offset, + "walletrpcport": WOW_WALLET_RPC_PORT + port_offset, + "rpchost": WOW_RPC_HOST, + "trusted_daemon": extra_opts.get("trust_remote_node", "auto"), + "walletrpchost": WOW_WALLET_RPC_HOST, + "walletrpcuser": WOW_WALLET_RPC_USER, + "walletrpcpassword": WOW_WALLET_RPC_PWD, + "datadir": os.getenv("WOW_DATA_DIR", os.path.join(data_dir, "wownero")), + "bindir": os.path.join(bin_dir, "wownero"), + "restore_height": wow_restore_height, + "blocks_confirmed": 2, + "rpctimeout": 60, + "walletrpctimeout": 120, + "walletrpctimeoutlong": 300, + "core_version_no": getKnownVersion("wownero"), + "core_type_group": "xmr", + }, "pivx": { "connection_type": "rpc", "manage_daemon": shouldManageDaemon("PIVX"), @@ -2562,27 +2559,37 @@ def main(): "chain_lookups": "local", "startup_tries": 40, }, - "wownero": { + "bitcoincash": { "connection_type": "rpc", - "manage_daemon": shouldManageDaemon("WOW"), - "manage_wallet_daemon": shouldManageDaemon("WOW_WALLET"), - "rpcport": WOW_RPC_PORT + port_offset, - "zmqport": WOW_ZMQ_PORT + port_offset, - "walletrpcport": WOW_WALLET_RPC_PORT + port_offset, - "rpchost": WOW_RPC_HOST, - "trusted_daemon": extra_opts.get("trust_remote_node", "auto"), - "walletrpchost": WOW_WALLET_RPC_HOST, - "walletrpcuser": WOW_WALLET_RPC_USER, - "walletrpcpassword": WOW_WALLET_RPC_PWD, - "datadir": os.getenv("WOW_DATA_DIR", os.path.join(data_dir, "wownero")), - "bindir": os.path.join(bin_dir, "wownero"), - "restore_height": wow_restore_height, + "manage_daemon": shouldManageDaemon("BCH"), + "rpchost": BCH_RPC_HOST, + "rpcport": BCH_RPC_PORT + port_offset, + "onionport": BCH_ONION_PORT + port_offset, + "datadir": os.getenv("BCH_DATA_DIR", os.path.join(data_dir, "bitcoincash")), + "bindir": os.path.join(bin_dir, "bitcoincash"), + "port": BCH_PORT + port_offset, + "config_filename": "bitcoin.conf", + "use_segwit": False, + "blocks_confirmed": 1, + "conf_target": 2, + "core_version_no": getKnownVersion("bitcoincash"), + "core_version_group": 22, + }, + "dogecoin": { + "connection_type": "rpc", + "manage_daemon": shouldManageDaemon("DOGE"), + "rpchost": DOGE_RPC_HOST, + "rpcport": DOGE_RPC_PORT + port_offset, + "onionport": DOGE_ONION_PORT + port_offset, + "datadir": os.getenv("DOGE_DATA_DIR", os.path.join(data_dir, "dogecoin")), + "bindir": os.path.join(bin_dir, "dogecoin"), + "use_segwit": False, + "use_csv": False, "blocks_confirmed": 2, - "rpctimeout": 60, - "walletrpctimeout": 120, - "walletrpctimeoutlong": 300, - "core_version_no": getKnownVersion("wownero"), - "core_type_group": "xmr", + "conf_target": 2, + "core_version_no": getKnownVersion("dogecoin"), + "core_version_group": 23, + "min_relay_fee": 0.01, # RECOMMENDED_MIN_TX_FEE }, } diff --git a/basicswap/bin/run.py b/basicswap/bin/run.py index 091e857..c34c721 100755 --- a/basicswap/bin/run.py +++ b/basicswap/bin/run.py @@ -265,7 +265,11 @@ def getCoreBinArgs(coin_id: int, coin_settings, prepare=False, use_tor_proxy=Fal # As BCH may use port 8334, disable it here. # When tor is enabled a bind option for the onionport will be added to bitcoin.conf. # https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-28.0.md?plain=1#L84 - if prepare is False and use_tor_proxy is False and coin_id == Coins.BTC: + if ( + prepare is False + and use_tor_proxy is False + and coin_id in (Coins.BTC, Coins.NMC) + ): port: int = coin_settings.get("port", 8333) extra_args.append(f"--bind=0.0.0.0:{port}") return extra_args diff --git a/basicswap/static/images/coins/Namecoin-20.png b/basicswap/static/images/coins/Namecoin-20.png new file mode 100644 index 0000000000000000000000000000000000000000..204808d0076f9c5a086911ecaac5c1e1e8d17256 GIT binary patch literal 743 zcmV?P)r}UB_+3RqaOeO0(414 zK~y-)t(DDB6Hye!f1OU5rVs}a((u)46jVT<2{9qE5kpHC$jS|x$O_^gpvkyu;(~=6 zHZF#Zu82z#O`s$snt*Ykl9XVOgoqFzKvNyW%FtF_%(S+{&|uKT3}>ue3}Oc31*)apuM5Wc*BY^ zPL-B0_u(`B-Oc!`jC;@3od#feEn%g033*MMgTKZgtgOZ9?{4Px{5tW(K6m@t0I2nr zlS*fJyR>ViN`hUse7MiFn*jb~W9`dX83A>DB(% zaOhE$@SALv0WhaU&@?*#FusCWu>!$7(Nr}UB@P?XT3-MF5JyQw zK~#9!?VV|GRM(ZqfA@83K?@Q>NFWd(B!Sq(V!(FB9vg#E12#-D8RHmx;@DLq**G&* zlh|%0RpY6eiX|LUHSxr@`a|q^z*OR`92V0Oi|vrH4JZZ)31mP*AhT#eD@bbfa_2)g zAn5J&@)`+rs-Q~U@4b89`S(5lbM86!UKo)fC1N;r_TM(`78aX5RZ5uwA{k@~knDO7 z0oZ_UpcA-+5Y181F)hFQ_oZ?KkPxM))SM_K3qjru%m-!yIY4{>{gyxvP!Ajj4ud!( zgs3bt7F-zt#3uk1LQ2P6kZXX4fxCeijheFn2Z3@B+l3HE%Zvqb1Q4LG)SQi!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#f}hL+~TO4KPWR6)Q3XudYvF6 z{nq5D2W$@B@wsGSGzoG3%SG!W!ymg%Mnk<{KwRVG^J!K5BDst3y8u|E*&6nBv zMQGb^R7WITE8g%p)8Oetojz(8P#a7$v$Fj2N6(dh_San0&X25YqV{BP&u{PQrCytI z(ZN!q)9F7|4al1>E^~k=38tm2Nxpr2DPjBPby#iM`uOkctf8Yj@QlJ=Do;mZbZmU{ zrR5IQfB+~u-JgJCfix2vrDMXlB%fgHJ8+V}9KERdD_`!nv1LcK*D6R)a`H?Y<&{lZ zcdb_Fls|gaySFdidg);sh~hw6nwOp8HAmgsZ{@>^YCib9o=8dU*-rKyPFJBu zQBK$7JvA zHph26&#T(P?RzTEA%ytnVR3x7i|p%!5cdMF;5-!mb`cBkicoZarv(_AjgT8nn0Xe+ z*U|W3mTniMNidSxrL}L+6=oOWg>!p;B zyUr#V>gVXzfOu6=l=t6yd4)Yvjoy+B>+`SeQS5f>YG4D-lNfYE1Oz*<2gK__r~2#-8cbkMTpHNqoLte>O%|_`%qL`E~J!mK|YFe%kw2@ zx3RMY=W4MEgxDq!HD$&EITZ9TWB~CnauR?=AQu4(ac-qL%@uH}?Y9K3;9T=k2OLI- z0|LG&Ga4=r#rGbvfOwJ(oAwEtZ6FOvI>@m&wDW@Bjb+ literal 0 HcmV?d00001 diff --git a/basicswap/static/js/bids_available.js b/basicswap/static/js/bids_available.js index 3cb11e8..53d5251 100644 --- a/basicswap/static/js/bids_available.js +++ b/basicswap/static/js/bids_available.js @@ -10,6 +10,7 @@ const COIN_NAME_TO_SYMBOL = { 'Firo': 'FIRO', 'Dash': 'DASH', 'Decred': 'DCR', + 'Namecoin': 'NMC', 'Wownero': 'WOW', 'Bitcoin Cash': 'BCH', 'Dogecoin': 'DOGE' @@ -335,13 +336,13 @@ const createBidTableRow = async (bid) => {
- Offer ID: + Offer ID: ${formatAddress(bid.offer_id)}
- Bid ID: + Bid ID: ${formatAddress(bid.bid_id)} @@ -366,8 +367,8 @@ const createBidTableRow = async (bid) => {
- ${bid.coin_from} @@ -375,15 +376,14 @@ const createBidTableRow = async (bid) => { - ${bid.coin_to}
-
@@ -410,7 +410,7 @@ const createBidTableRow = async (bid) => { - Accept @@ -506,13 +506,13 @@ const createDetailsColumn = (bid, identity, uniqueId) => `
- Offer ID: + Offer ID: ${formatAddress(bid.offer_id)}
- Bid ID: + Bid ID: ${formatAddress(bid.bid_id)} diff --git a/basicswap/static/js/modules/api-manager.js b/basicswap/static/js/modules/api-manager.js index 9f299e1..e166593 100644 --- a/basicswap/static/js/modules/api-manager.js +++ b/basicswap/static/js/modules/api-manager.js @@ -220,7 +220,7 @@ const ApiManager = (function() { .filter(coin => coin.usesCoinGecko) .map(coin => coin.name) .join(',') : - 'bitcoin,monero,particl,bitcoincash,pivx,firo,dash,litecoin,dogecoin,decred'; + 'bitcoin,monero,particl,bitcoincash,pivx,firo,dash,litecoin,dogecoin,decred,namecoin'; //console.log('Fetching coin prices for:', coins); const response = await this.fetchCoinPrices(coins); @@ -254,7 +254,7 @@ const ApiManager = (function() { .filter(coin => coin.usesCoinGecko) .map(coin => getCoinBackendId ? getCoinBackendId(coin.name) : coin.name) .join(',') : - 'bitcoin,monero,particl,bitcoin-cash,pivx,firo,dash,litecoin,dogecoin,decred'; + 'bitcoin,monero,particl,bitcoin-cash,pivx,firo,dash,litecoin,dogecoin,decred,namecoin'; const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coins}&vs_currencies=usd&include_24hr_vol=true&include_24hr_change=true`; diff --git a/basicswap/static/js/modules/cache-manager.js b/basicswap/static/js/modules/cache-manager.js index e8fba7c..1deddc8 100644 --- a/basicswap/static/js/modules/cache-manager.js +++ b/basicswap/static/js/modules/cache-manager.js @@ -504,13 +504,14 @@ const CacheManager = (function() { 'bitcoin': 'BTC', 'litecoin': 'LTC', 'monero': 'XMR', + 'wownero': 'WOW', 'particl': 'PART', 'pivx': 'PIVX', 'firo': 'FIRO', 'zcoin': 'FIRO', 'dash': 'DASH', 'decred': 'DCR', - 'wownero': 'WOW', + 'namecoin': 'NMR', 'bitcoin-cash': 'BCH', 'dogecoin': 'DOGE' }; diff --git a/basicswap/static/js/modules/config-manager.js b/basicswap/static/js/modules/config-manager.js index 1176cc3..0b70751 100644 --- a/basicswap/static/js/modules/config-manager.js +++ b/basicswap/static/js/modules/config-manager.js @@ -72,6 +72,7 @@ const ConfigManager = (function() { { symbol: 'LTC', name: 'litecoin', usesCryptoCompare: true, usesCoinGecko: true, historicalDays: 30 }, { symbol: 'DOGE', name: 'dogecoin', usesCryptoCompare: true, usesCoinGecko: true, historicalDays: 30 }, { symbol: 'DCR', name: 'decred', usesCryptoCompare: true, usesCoinGecko: true, historicalDays: 30 }, + { symbol: 'NMC', name: 'namecoin', usesCryptoCompare: true, usesCoinGecko: true, historicalDays: 30 }, { symbol: 'WOW', name: 'wownero', usesCryptoCompare: false, usesCoinGecko: true, historicalDays: 30 } ], @@ -88,6 +89,7 @@ const ConfigManager = (function() { 'Zcoin': 'FIRO', 'Dash': 'DASH', 'Decred': 'DCR', + 'Namecoin': 'NMC', 'Wownero': 'WOW', 'Bitcoin Cash': 'BCH', 'Dogecoin': 'DOGE' @@ -105,13 +107,14 @@ const ConfigManager = (function() { 'Zcoin': 'Firo', 'Dash': 'Dash', 'Decred': 'Decred', + 'Namecoin': 'Namecoin', 'Wownero': 'Wownero', 'Bitcoin Cash': 'Bitcoin Cash', 'Dogecoin': 'Dogecoin' }, idToName: { - 1: 'particl', 2: 'bitcoin', 3: 'litecoin', 4: 'decred', + 1: 'particl', 2: 'bitcoin', 3: 'litecoin', 4: 'decred', 5: 'namecoin', 6: 'monero', 7: 'particl blind', 8: 'particl anon', 9: 'wownero', 11: 'pivx', 13: 'firo', 17: 'bitcoincash', 18: 'dogecoin' @@ -130,6 +133,7 @@ const ConfigManager = (function() { 'litecoin': 'litecoin', 'dogecoin': 'dogecoin', 'decred': 'decred', + 'namecoin': 'namecoin', 'wownero': 'wownero' } }, @@ -367,6 +371,7 @@ const ConfigManager = (function() { 'dash': { usd: null, btc: null }, 'dogecoin': { usd: null, btc: null }, 'decred': { usd: null, btc: null }, + 'namecoin': { usd: null, btc: null }, 'litecoin': { usd: null, btc: null }, 'particl': { usd: null, btc: null }, 'pivx': { usd: null, btc: null }, diff --git a/basicswap/static/js/modules/wallet-manager.js b/basicswap/static/js/modules/wallet-manager.js index b97f5b6..6b4b775 100644 --- a/basicswap/static/js/modules/wallet-manager.js +++ b/basicswap/static/js/modules/wallet-manager.js @@ -35,6 +35,7 @@ const WalletManager = (function() { 'Dash': 'DASH', 'PIVX': 'PIVX', 'Decred': 'DCR', + 'Namecoin': 'NMC', 'Bitcoin Cash': 'BCH' }, @@ -49,6 +50,7 @@ const WalletManager = (function() { 'DASH': 'dash', 'PIVX': 'pivx', 'DCR': 'dcr', + 'NMC': 'nmc', 'BCH': 'bch' }, @@ -63,6 +65,7 @@ const WalletManager = (function() { 'Dash': 'DASH', 'PIVX': 'PIVX', 'Decred': 'DCR', + 'Namecoin': 'NMC', 'Bitcoin Cash': 'BCH', 'Dogecoin': 'DOGE' } diff --git a/basicswap/static/js/offers.js b/basicswap/static/js/offers.js index 1d534cf..355f3ec 100644 --- a/basicswap/static/js/offers.js +++ b/basicswap/static/js/offers.js @@ -34,6 +34,7 @@ window.tableRateModule = { 'Dash': 'DASH', 'PIVX': 'PIVX', 'Decred': 'DCR', + 'Namecoin': 'NMC', 'Zano': 'ZANO', 'Bitcoin Cash': 'BCH', 'Dogecoin': 'DOGE' @@ -56,9 +57,9 @@ window.tableRateModule = { }, setCachedValue(key, value, resourceType = null) { - const ttl = resourceType ? - window.config.cacheConfig.ttlSettings[resourceType] || - window.config.cacheConfig.defaultTTL : + const ttl = resourceType ? + window.config.cacheConfig.ttlSettings[resourceType] || + window.config.cacheConfig.defaultTTL : 900000; const item = { @@ -306,13 +307,14 @@ async function calculateProfitLoss(fromCoin, toCoin, fromAmount, toAmount, isOwn 'ltc': 'litecoin', 'doge': 'dogecoin', 'dcr': 'decred', + 'nmc': 'namecoin', 'wow': 'wownero' }; if (lowerCoin === 'zcoin') return 'firo'; if (lowerCoin === 'bitcoin cash') return 'bitcoin-cash'; if (lowerCoin === 'particl anon' || lowerCoin === 'particl blind') return 'particl'; - + return symbolToName[lowerCoin] || lowerCoin; }; @@ -406,7 +408,7 @@ async function fetchLatestPrices() { const coinIds = [ 'bitcoin', 'particl', 'monero', 'litecoin', 'dogecoin', 'firo', 'dash', 'pivx', - 'decred', 'bitcoincash' + 'decred', 'namecoin', 'bitcoincash' ]; let processedData = {}; @@ -419,7 +421,7 @@ async function fetchLatestPrices() { if (mainResponse && mainResponse.rates) { Object.entries(mainResponse.rates).forEach(([coinId, price]) => { const normalizedCoinId = coinId === 'bitcoincash' ? 'bitcoin-cash' : coinId.toLowerCase(); - + processedData[normalizedCoinId] = { usd: price, btc: normalizedCoinId === 'bitcoin' ? 1 : price / (mainResponse.rates.bitcoin || 1) @@ -453,7 +455,7 @@ async function fetchLatestPrices() { } catch (error) { console.error(`Price fetch attempt ${attempt + 1} failed:`, error); NetworkManager.handleNetworkError(error); - + if (attempt < MAX_RETRIES - 1) { const delay = Math.min(500 * Math.pow(2, attempt), 5000); await new Promise(resolve => setTimeout(resolve, delay)); @@ -520,7 +522,7 @@ async function fetchOffers() { originalJsonData = [...jsonData]; latestPrices = pricesData || getEmptyPriceData(); - + CacheManager.set('offers_cached', jsonData, 'offers'); await updateOffersTable(); @@ -1353,7 +1355,7 @@ function createRateColumn(offer, coinFrom, coinTo) { const getPriceKey = (coin) => { const lowerCoin = coin.toLowerCase(); - + const symbolToName = { 'btc': 'bitcoin', 'xmr': 'monero', @@ -1365,13 +1367,14 @@ function createRateColumn(offer, coinFrom, coinTo) { 'ltc': 'litecoin', 'doge': 'dogecoin', 'dcr': 'decred', + 'nmc': 'namecoin', 'wow': 'wownero' }; - + if (lowerCoin === 'zcoin') return 'firo'; if (lowerCoin === 'bitcoin cash') return 'bitcoin-cash'; if (lowerCoin === 'particl anon' || lowerCoin === 'particl blind') return 'particl'; - + return symbolToName[lowerCoin] || lowerCoin; }; @@ -1655,23 +1658,24 @@ function createTooltipContent(isSentOffers, coinFrom, coinTo, fromAmount, toAmou 'ltc': 'litecoin', 'doge': 'dogecoin', 'dcr': 'decred', + 'nmc': 'namecoin', 'wow': 'wownero' }; if (lowerCoin === 'zcoin') return 'firo'; if (lowerCoin === 'bitcoin cash') return 'bitcoin-cash'; if (lowerCoin === 'particl anon' || lowerCoin === 'particl blind') return 'particl'; - + return symbolToName[lowerCoin] || lowerCoin; }; - + if (latestPrices && latestPrices['firo'] && !latestPrices['zcoin']) { latestPrices['zcoin'] = JSON.parse(JSON.stringify(latestPrices['firo'])); } const fromSymbol = getPriceKey(coinFrom); const toSymbol = getPriceKey(coinTo); - + let fromPriceUSD = latestPrices && latestPrices[fromSymbol] ? latestPrices[fromSymbol].usd : null; let toPriceUSD = latestPrices && latestPrices[toSymbol] ? latestPrices[toSymbol].usd : null; @@ -1685,7 +1689,7 @@ function createTooltipContent(isSentOffers, coinFrom, coinTo, fromAmount, toAmou isNaN(fromPriceUSD) || isNaN(toPriceUSD)) { return `

Price Information Unavailable

Current market prices are temporarily unavailable.

-

You are ${isSentOffers ? 'selling' : 'buying'} ${fromAmount.toFixed(8)} ${coinFrom} +

You are ${isSentOffers ? 'selling' : 'buying'} ${fromAmount.toFixed(8)} ${coinFrom} for ${toAmount.toFixed(8)} ${coinTo}.

Note:

Profit/loss calculations will be available when price data is restored.

`; @@ -1757,13 +1761,14 @@ function createCombinedRateTooltip(offer, coinFrom, coinTo, treatAsSentOffer) { 'ltc': 'litecoin', 'doge': 'dogecoin', 'dcr': 'decred', + 'nmc': 'namecoin', 'wow': 'wownero' }; if (lowerCoin === 'zcoin') return 'firo'; if (lowerCoin === 'bitcoin cash') return 'bitcoin-cash'; if (lowerCoin === 'particl anon' || lowerCoin === 'particl blind') return 'particl'; - + return symbolToName[lowerCoin] || lowerCoin; }; @@ -1876,7 +1881,7 @@ function clearFilters() { jsonData = [...originalJsonData]; currentPage = 1; - + const storageKey = isSentOffers ? 'sentOffersTableSettings' : 'networkOffersTableSettings'; localStorage.removeItem(storageKey); @@ -2194,7 +2199,7 @@ async function initializeTableAndData() { function loadSavedSettings() { const storageKey = isSentOffers ? 'sentOffersTableSettings' : 'networkOffersTableSettings'; const saved = localStorage.getItem(storageKey); - + if (saved) { const settings = JSON.parse(saved); @@ -2229,7 +2234,7 @@ document.addEventListener('DOMContentLoaded', async () => { NetworkManager.initialize({ connectionTestEndpoint: '/json', connectionTestTimeout: 3000, - reconnectDelay: 5000, + reconnectDelay: 5000, maxReconnectAttempts: 5 }); window.networkManagerInitialized = true; @@ -2252,7 +2257,7 @@ document.addEventListener('DOMContentLoaded', async () => { }); const tableLoadPromise = initializeTableAndData(); - + WebSocketManager.initialize({ debug: false }); @@ -2262,7 +2267,7 @@ document.addEventListener('DOMContentLoaded', async () => { if (!NetworkManager.isOnline()) { return; } - + const endpoint = isSentOffers ? '/json/sentoffers' : '/json/offers'; const response = await fetch(endpoint); if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); @@ -2349,7 +2354,7 @@ async function cleanup() { lastRefreshTime = null; const domRefs = [ - 'offersBody', 'filterForm', 'prevPageButton', 'nextPageButton', + 'offersBody', 'filterForm', 'prevPageButton', 'nextPageButton', 'currentPageSpan', 'totalPagesSpan', 'lastRefreshTimeSpan', 'newEntriesCountSpan' ]; diff --git a/basicswap/static/js/pricechart.js b/basicswap/static/js/pricechart.js index 1e785d1..b8b818a 100644 --- a/basicswap/static/js/pricechart.js +++ b/basicswap/static/js/pricechart.js @@ -548,7 +548,7 @@ const ui = { }, setActiveContainer: (containerId) => { - const containerIds = ['btc', 'xmr', 'part', 'pivx', 'firo', 'dash', 'ltc', 'doge', 'eth', 'dcr', 'zano', 'wow', 'bch'].map(id => `${id}-container`); + const containerIds = ['btc', 'xmr', 'part', 'pivx', 'firo', 'dash', 'ltc', 'doge', 'eth', 'dcr', 'nmc', 'zano', 'wow', 'bch'].map(id => `${id}-container`); containerIds.forEach(id => { const container = document.getElementById(id); if (container) { diff --git a/basicswap/static/js/swaps_in_progress.js b/basicswap/static/js/swaps_in_progress.js index 3724bbd..8aeee3d 100644 --- a/basicswap/static/js/swaps_in_progress.js +++ b/basicswap/static/js/swaps_in_progress.js @@ -10,6 +10,7 @@ const COIN_NAME_TO_SYMBOL = { 'Firo': 'FIRO', 'Dash': 'DASH', 'Decred': 'DCR', + 'Namecoin': 'NMC', 'Wownero': 'WOW', 'Bitcoin Cash': 'BCH', 'Dogecoin': 'DOGE' @@ -383,8 +384,8 @@ const createSwapTableRow = async (swap) => {
- ${swap.coin_from} @@ -392,8 +393,8 @@ const createSwapTableRow = async (swap) => { - ${swap.coin_to} @@ -421,7 +422,7 @@ const createSwapTableRow = async (swap) => { - Details diff --git a/basicswap/templates/offers.html b/basicswap/templates/offers.html index eb04efb..7cb93b1 100644 --- a/basicswap/templates/offers.html +++ b/basicswap/templates/offers.html @@ -13,7 +13,7 @@
-
@@ -21,7 +21,7 @@

{{ page_type_description }}