Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/update wasabi binaries #6967

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Git LFS file not shown
4 changes: 2 additions & 2 deletions packages/suite-data/files/bin/coinjoin/linux-x64/WalletWasabi.WabiSabiClientLibrary
100644 → 100755
Git LFS file not shown
Binary file modified packages/suite-data/files/bin/coinjoin/mac-arm64/WalletWasabi.WabiSabiClientLibrary
100644 → 100755
Binary file not shown.
Binary file modified packages/suite-data/files/bin/coinjoin/mac-x64/WalletWasabi.WabiSabiClientLibrary
100644 → 100755
Binary file not shown.
8 changes: 5 additions & 3 deletions packages/suite-data/files/bin/coinjoin/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ BINARY_NAME=WalletWasabi.WabiSabiClientLibrary

7z x -y CoinjoinClientLibrary-binary.zip

# Re-naming direcotry from osx to mac to match the naming using in all the processes.
mv osx-arm64/ mac-arm64/
mv osx-x64/ mac-x64/
# Re-naming directory from osx to mac to match the naming using in all the processes.
cp -r osx-arm64/* mac-arm64/
rm -rf osx-arm64
cp -r osx-x64/* mac-x64/
rm -rf osx-x64

for p in linux-x64 linux-arm64 mac-x64 mac-arm64 win-x64; do
cp -r ${p}/publish/* ${p}/
Expand Down
Git LFS file not shown
31 changes: 20 additions & 11 deletions packages/suite-desktop/src/libs/processes/CoinjoinProcess.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseProcess, Status } from './BaseProcess';
import { getFreePort } from '../getFreePort';

export class CoinjoinProcess extends BaseProcess {
port = 37128; // Default port, that is going to be updated when starting the process.
Expand All @@ -9,6 +10,17 @@ export class CoinjoinProcess extends BaseProcess {
});
}

getUrl() {
return `http://localhost:${this.port}/Cryptography/`;
}

async getPort() {
if (!(await this.status()).process) {
this.port = await getFreePort();
}
return this.port;
}

async status(): Promise<Status> {
if (!this.process) {
return {
Expand All @@ -19,18 +31,16 @@ export class CoinjoinProcess extends BaseProcess {

// service
try {
const resp = await fetch(
`http://localhost:${this.port}/Cryptography/analyze-transaction`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json-patch+json',
},
body: JSON.stringify({ transactions: [] }),
const resp = await fetch(`${this.getUrl()}get-version`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
);
});
this.logger.debug(this.logTopic, `Checking status (${resp.status})`);
if (resp.status === 200) {
const { version } = await resp.json();
this.logger.debug(this.logTopic, `WabiSabiClientLibrary version: ${version}`);
return {
service: true,
process: true,
Expand All @@ -47,8 +57,7 @@ export class CoinjoinProcess extends BaseProcess {
};
}

startOnPort(port: number): Promise<void> {
this.port = port;
start() {
// We add the port where the process is going to run
// since there is no way to pass it as argument yet.
process.env.WCL_BIND_PORT = `${this.port}`;
Expand Down
16 changes: 4 additions & 12 deletions packages/suite-desktop/src/modules/coinjoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { createIpcProxyHandler, IpcProxyHandlerOptions } from '@trezor/ipc-proxy
import { CoinjoinBackend, CoinjoinClient } from '@trezor/coinjoin';

import { CoinjoinProcess } from '../libs/processes/CoinjoinProcess';
import { getFreePort } from '../libs/getFreePort';

import type { Module } from './index';

Expand Down Expand Up @@ -48,16 +47,9 @@ export const init: Module = ({ mainWindow }) => {

const clientProxyOptions: IpcProxyHandlerOptions<CoinjoinClient> = {
onCreateInstance: async (settings: ConstructorParameters<typeof CoinjoinClient>[0]) => {
let port: number;
if (!(await coinjoinMiddleware.status()).process) {
port = await getFreePort();
} else {
// If coinjoin middleware is already running but other client instance is created
// we use the same port.
port = coinjoinMiddleware.port;
}

settings.middlewareUrl = `http://localhost:${port}/Cryptography/`;
const port = await coinjoinMiddleware.getPort();
// override default url in coinjoin settings
settings.middlewareUrl = coinjoinMiddleware.getUrl();
const client = new CoinjoinClient(settings);
client.on('log', message => logger.debug(SERVICE_NAME, message));
clients.push(client);
Expand All @@ -67,7 +59,7 @@ export const init: Module = ({ mainWindow }) => {
if (method === 'enable') {
logger.debug(SERVICE_NAME, `CoinjoinClient binary enable on port ${port}`);
try {
await coinjoinMiddleware.startOnPort(port);
await coinjoinMiddleware.start();
} catch (err) {
logger.error(SERVICE_NAME, `Start failed: ${err.message}`);
throw err; // pass this error to suite toast
Expand Down