askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
31 lines • 1.19 kB
JavaScript
import { getWalletClient } from "../../../wallet/utils.js";
import { RemoteClient } from "../../../remote/RemoteClient.js";
import { debugClient, enableAllDebug } from "../../../common/debug.js";
/**
* Create a wallet client based on command options
*
* @param options Command options
* @returns A wallet client instance
*/
export function createWalletClient(options) {
// Enable debug output if debug flag is set
if (options.debug) {
enableAllDebug();
}
// Use remote client if remote flag is set
if (options.remote) {
// Use the provided URL or default to https://walletapi.askexperts.io
const serverUrl = options.url || "https://walletapi.askexperts.io";
debugClient(`Connecting to remote server at ${serverUrl}`);
// Create a RemoteClient to get the private key
const remoteClient = new RemoteClient();
const privateKey = remoteClient.getPrivateKey();
// Create a WalletRemoteClient with the server URL and private key
return getWalletClient(serverUrl, privateKey);
}
else {
// Use local client
return getWalletClient();
}
}
//# sourceMappingURL=client.js.map