diff --git a/api1.js b/api1.js index e9b69a3..a5fd28a 100644 --- a/api1.js +++ b/api1.js @@ -1453,7 +1453,7 @@ function registerCoinswapHandlers() { // Start coinswap ipcMain.handle( 'coinswap:start', - async (event, { amount, makerCount, outpoints, password }) => { + async (event, { amount, makerCount, outpoints, password, selectedMakerAddresses }) => { try { if (!api1State.takerInstance) { return { success: false, error: 'Taker not initialized' }; @@ -1464,6 +1464,14 @@ function registerCoinswapHandlers() { return { success: false, error: 'Invalid amount' }; } + if ( + selectedMakerAddresses != null && + (!Array.isArray(selectedMakerAddresses) || + selectedMakerAddresses.some((a) => typeof a !== 'string' || !a.trim())) + ) { + return { success: false, error: 'Invalid selectedMakerAddresses: must be an array of non-empty strings' }; + } + const protocol = api1State.protocolVersion || 'v1'; const protocolName = protocol === 'v2' ? 'Taproot' : 'P2WSH'; const swapId = `swap_${Date.now()}_${Math.random().toString(36).substring(7)}`; @@ -1571,7 +1579,7 @@ function registerCoinswapHandlers() { }); const worker = new Worker(path.join(__dirname, 'coinswap-worker.js'), { - workerData: { amount, makerCount, outpoints, config }, + workerData: { amount, makerCount, outpoints, selectedMakerAddresses, config }, }); api1State.activeSwaps.set(swapId, { diff --git a/coinswap-worker.js b/coinswap-worker.js index 6c59af9..64aefa2 100644 --- a/coinswap-worker.js +++ b/coinswap-worker.js @@ -10,7 +10,7 @@ const { parentPort, workerData } = require('worker_threads'); try { const coinswapNapi = require('coinswap-napi'); - const { amount, makerCount, outpoints, config } = workerData; + const { amount, makerCount, outpoints, selectedMakerAddresses, config } = workerData; const protocol = config.protocol || 'v1'; const normalizedProtocol = protocol === 'v2' ? 'Taproot' : 'Legacy'; const protocolName = @@ -58,6 +58,7 @@ const { parentPort, workerData } = require('worker_threads'); sendAmount: amount, makerCount: makerCount, manuallySelectedOutpoints: outpoints || undefined, + preferredMakers: selectedMakerAddresses && selectedMakerAddresses.length > 0 ? selectedMakerAddresses : undefined, }; console.log(`🔄 Syncing offerbook in swap worker before prepare...`); diff --git a/src/components/market/Market.js b/src/components/market/Market.js index 30e93ec..316bb9c 100644 --- a/src/components/market/Market.js +++ b/src/components/market/Market.js @@ -38,20 +38,14 @@ export function Market(container) { } } - function formatTorEndpoint(address, start = 6, end = 0) { + function formatTorEndpoint(address, start = 8, end = 6) { if (!address || typeof address !== 'string') return 'unknown'; const separatorIndex = address.lastIndexOf(':'); - if (separatorIndex === -1) return address; + const host = (separatorIndex !== -1 ? address.slice(0, separatorIndex) : address).replace(/\.onion$/i, ''); - const host = address.slice(0, separatorIndex).replace(/\.onion$/i, ''); - const port = address.slice(separatorIndex + 1); - - if (host.length <= start + end + 3) { - return `${host}:${port}`; - } - - return end > 0 ? `${host.slice(0, start)}..${host.slice(-end)}:${port}` : `${host.slice(0, start)}..:${port}`; + if (host.length <= start + end + 3) return host; + return `${host.slice(0, start)}...${host.slice(-end)}`; } // Check sync state every second @@ -92,12 +86,11 @@ export function Market(container) { const addr = item.address; let fullAddress; if (typeof addr === 'string') { - fullAddress = addr.includes(':') ? addr : `${addr}:6102`; + fullAddress = addr; } else { - const addressObj = addr || {}; - const onionAddr = addressObj.onion_addr || ''; - const port = addressObj.port || '6102'; - fullAddress = `${onionAddr}:${port}`; + const host = addr?.onion_addr || ''; + const portSuffix = addr?.port ? `:${addr.port}` : ''; + fullAddress = host || portSuffix ? `${host}${portSuffix}` : ''; } // Handle null offers (unresponsive makers) @@ -770,7 +763,7 @@ export function Market(container) { .map( (maker) => { return ` -
+
${formatTorEndpoint(maker.address)}
${maker.baseFee}
@@ -871,7 +864,7 @@ export function Market(container) { -
+
Tor Address
Base Fee
% Fee Rate
diff --git a/src/components/settings/FirstTimeSetup.js b/src/components/settings/FirstTimeSetup.js index 3b36276..85f93f2 100644 --- a/src/components/settings/FirstTimeSetup.js +++ b/src/components/settings/FirstTimeSetup.js @@ -140,7 +140,7 @@ export function FirstTimeSetupModal(container, onComplete) { -
+