You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CypherPoker.JS for Desktop requires that the Monero command line client be integrated into the application in order to enable support for the cryptocurrency. This is best accomplished by creating an adapter, similar to the current sqlite3.js adapter.
In short, such an adapter is responsible for spawning the command line client, with RPC functionality enabled, as a Node child_process, and providing async functions that CypherPoker.JS can interact with (especially the CP_Account API endpoint).
The adapter should simultaneously and transparently support Windows, macOS, and Linux Monero clients. If any existing NPM packages exist that are both reliable and support these specifications then they should be considered for inclusion into the adapter.
Additional information, including code documentation and formatting, can be found here: #48
Configuration
Configuration options for adapters are currently stored in the desktop version's main.js file:
However, these may be externalized (to a config.json file, for example), so they should not assume to exist at the application's root level and instead always be passed by reference (to a constructor function, for example).
Post-Install Configuration
One-time post-install configuration options for the adapter (after npm install completes), can be set in the desktop postinstall.js file.
Launching the Adapter
The adapter should be launched using a function similar to the one used to start the SQLite 3 database:
Note that the adapter should exist in its own execution context (a JavaScript virtual machine), and is to be provided with available objects references and data exposed in the electronEnv.server.exposed_objects configuration object (see Configuration above).
Another thing to keep in mind when writing the adapter launcher is that other adapters will almost certainly be included in future versions so the launch process should be as modular and self-contained as possible (an async function rather than flat root-level code).
Adapter-Server Communication (Required)
Once launched, the adapter's data and functionality becomes available to the local server and all loaded API endpoints via the hostEnv property :
Although it's unlikely to be used, at least at the present time, the adapter can also be accessed using a synchronous IPC call from the web client when running as a Desktop application.
In main.js a new case block for the adapter should be added to:
Derive an address from the HD wallet using child indexes. Note the use of the startChain and startIndex values which are maintained between sessions to always generate fresh deposit addresses:
API.default[network].minerFee=String(body.high_fee_per_kb);//should be a string
resolve("updated");
//resolve(body);
}
});
});
return(promise);
}
For much of the above functionality, information such as the private key(s) for the root HD wallet, indexes of derived addresses, and default transaction fees, comes from the server configuration file:
While none of the configuration sections for the new adapter are required to match the existing format or properties, it should be kept in mind that CypherPoker.JS should support both the Monero mainnet and any official testnets with independent configuration options for both.
It's also important to keep in mind that the configuration data is dynamic and is often updated at runtime after being loaded. For example:
console.log("Database last updated "+resultObj.db.elapsedUpdateSeconds+" seconds ago");
}else{
console.log("Using in-memory storage instead of database.");
}
onCreateCB();
return(true);
}
As such, the data stored in the config.json includes only the basic, default options and any sensitive data such as private keys should be omitted from the file entirely and replaced with placeholders:
Overview
CypherPoker.JS for Desktop requires that the Monero command line client be integrated into the application in order to enable support for the cryptocurrency. This is best accomplished by creating an adapter, similar to the current sqlite3.js adapter.
In short, such an adapter is responsible for spawning the command line client, with RPC functionality enabled, as a Node child_process, and providing
async
functions that CypherPoker.JS can interact with (especially the CP_Account API endpoint).The adapter should simultaneously and transparently support Windows, macOS, and Linux Monero clients. If any existing NPM packages exist that are both reliable and support these specifications then they should be considered for inclusion into the adapter.
Additional information, including code documentation and formatting, can be found here: #48
Configuration
Configuration options for adapters are currently stored in the desktop version's
main.js
file:cypherpoker.js/src/desktop/main.js
Lines 111 to 119 in 1a4e605
However, these may be externalized (to a
config.json
file, for example), so they should not assume to exist at the application's root level and instead always be passed by reference (to a constructor function, for example).Post-Install Configuration
One-time post-install configuration options for the adapter (after
npm install
completes), can be set in the desktop postinstall.js file.Launching the Adapter
The adapter should be launched using a function similar to the one used to start the SQLite 3 database:
cypherpoker.js/src/desktop/main.js
Lines 142 to 161 in 1a4e605
A reference to the adapter should be included in the configuration data so that it can be accessed from the
main.js
process. For example:cypherpoker.js/src/desktop/main.js
Line 143 in 1a4e605
Note that the adapter should exist in its own execution context (a JavaScript virtual machine), and is to be provided with available objects references and data exposed in the
electronEnv.server.exposed_objects
configuration object (see Configuration above).Another thing to keep in mind when writing the adapter launcher is that other adapters will almost certainly be included in future versions so the launch process should be as modular and self-contained as possible (an
async
function rather than flat root-level code).Adapter-Server Communication (Required)
Once launched, the adapter's data and functionality becomes available to the local server and all loaded API endpoints via the
hostEnv
property :cypherpoker.js/src/server/server.js
Line 348 in 1a4e605
For example, this is how the SQLite 3 adapter is accessed from the main
server.js
process:cypherpoker.js/src/server/server.js
Line 1085 in 1a4e605
...and here's how it's accessed from an API endpoint (
CP_Account
in this case):cypherpoker.js/src/server/api/CP_Account.js
Line 762 in 1a4e605
In both cases the
hostEnv.database.sqlite3
reference is the one set when the database adapter is started:cypherpoker.js/src/desktop/main.js
Line 153 in 1a4e605
Here
adapterData=electronEnv.database.sqlite3
:cypherpoker.js/src/desktop/main.js
Line 143 in 1a4e605
Adapter-Client Communication (Optional)
Although it's unlikely to be used, at least at the present time, the adapter can also be accessed using a synchronous IPC call from the web client when running as a Desktop application.
In
main.js
a newcase
block for the adapter should be added to:cypherpoker.js/src/desktop/main.js
Lines 232 to 316 in 1a4e605
From the web client this is invoked via the
IPCSend
function:cypherpoker.js/src/web/scripts/index.js
Lines 203 to 220 in 1a4e605
Messages may also be initiated in the opposite direction and received in the web client:
cypherpoker.js/src/web/scripts/index.js
Lines 235 to 254 in 1a4e605
Required Functional Support
In order to provide the full cryptocurrency functionality required by CypherPoker.JS, the adapter must support the following:
CP_Account
API endpoint:cypherpoker.js/src/server/api/CP_Account.js
Line 487 in 1a4e605
startChain
andstartIndex
values which are maintained between sessions to always generate fresh deposit addresses:cypherpoker.js/src/server/api/CP_Account.js
Lines 558 to 599 in 1a4e605
...or:
cypherpoker.js/src/server/api/CP_Account.js
Line 882 in 1a4e605
Derived address must also include private keys and related information required for sending transactions!
cypherpoker.js/src/server/api/CP_Account.js
Lines 535 to 541 in 1a4e605
cypherpoker.js/src/server/api/CP_Account.js
Lines 833 to 854 in 1a4e605
cypherpoker.js/src/server/api/CP_Account.js
Lines 964 to 1005 in 1a4e605
cypherpoker.js/src/server/api/CP_Account.js
Lines 1019 to 1055 in 1a4e605
cypherpoker.js/src/server/api/CP_Account.js
Lines 1070 to 1197 in 1a4e605
cypherpoker.js/src/server/api/CP_Account.js
Lines 1224 to 1241 in 1a4e605
cypherpoker.js/src/server/api/CP_Account.js
Lines 1260 to 1309 in 1a4e605
For much of the above functionality, information such as the private key(s) for the root HD wallet, indexes of derived addresses, and default transaction fees, comes from the server configuration file:
cypherpoker.js/src/server/config.json
Lines 35 to 80 in 1a4e605
While none of the configuration sections for the new adapter are required to match the existing format or properties, it should be kept in mind that CypherPoker.JS should support both the Monero mainnet and any official testnets with independent configuration options for both.
It's also important to keep in mind that the configuration data is dynamic and is often updated at runtime after being loaded. For example:
cypherpoker.js/src/server/server.js
Lines 918 to 1043 in 1a4e605
As such, the data stored in the
config.json
includes only the basic, default options and any sensitive data such as private keys should be omitted from the file entirely and replaced with placeholders:cypherpoker.js/src/server/config.json
Lines 35 to 46 in 1a4e605
The text was updated successfully, but these errors were encountered: