diff --git a/firesales.py b/firesales.py index 8dbafa0..86778ca 100644 --- a/firesales.py +++ b/firesales.py @@ -139,27 +139,23 @@ def startListingTransfer(params, authentication): # node node_modules/shakedex/bin/shakedex transfer-lock domain -n main -w wallet -a key -p ./data --httphost host process = subprocess.Popen( - ["node", f"{path}/node_modules/shakedex/bin/shakedex", "transfer-lock", domain, "-n", "main", "-w", wallet, "-a", api_key, "-p", f"{path}/data", "--httphost", host], - stdin=subprocess.PIPE, + ["node", f"{path}/node_modules/shakedex/bin/shakedex", "transfer-lock", domain, "-n", "main", "-w", wallet, "-a", api_key, "-p", f"{path}/data", "--httphost", host, "-P", passphrase], + text=True, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - text=True + stderr=subprocess.STDOUT ) - - process.stdin.write('\n') # For yes prompt - process.stdin.flush() - process.stdin.write(passphrase + '\n') # For passphrase - process.stdin.flush() + # Wait for the process to finish stdout, stderr = process.communicate() - print(stdout) - print(stderr) + + print(f"STDOUT: {stdout}") + print(f"STDERR: {stderr}") if process.returncode != 0: - return {"status": "Error: " + stderr} - - txhash = stdout.split(" hash ")[1].split("\n")[0] + return {"status": f"Error: {stderr}", "txid": None} + txhash:str = stdout.split(" hash ")[1] + txhash = txhash.split("\n")[0].rstrip('.') return {"status": "Success", "txid": txhash} def list(params, authentication): diff --git a/shakedex/context.js b/shakedex/context.js index 62e61ac..9cb5833 100644 --- a/shakedex/context.js +++ b/shakedex/context.js @@ -1,6 +1,6 @@ const { NodeClient, WalletClient } = require('hsd/lib/client'); const Network = require('hsd/lib/protocol/network.js'); -const passwordPrompt = require('password-prompt'); +const readline = require("readline"); class Context { constructor( @@ -64,14 +64,4 @@ exports.Context = Context; exports.staticPassphraseGetter = function (passphrase) { return () => new Promise((resolve) => resolve(passphrase)); -}; - -function noopPassphraseGetter() { - return new Promise((resolve) => resolve(null)); -} - -exports.promptPassphraseGetter = function ( - prefix = '>> Please enter your passphrase: ' -) { - return () => new Promise((resolve) => resolve(passwordPrompt(prefix))); -}; +}; \ No newline at end of file diff --git a/shakedex/main.js b/shakedex/main.js index 907e9e4..ad5e6dc 100644 --- a/shakedex/main.js +++ b/shakedex/main.js @@ -53,7 +53,8 @@ program 'https://api.shakedex.com', ) .option('--no-passphrase', 'Disable prompts for the wallet passphrase.') - .option('-H, --httphost ', 'HSD Host.', '127.0.0.1'); + .option('-H, --httphost ', 'HSD Host.', '127.0.0.1') + .option('-P --password ') @@ -155,7 +156,7 @@ function getContext(opts) { opts.network, opts.walletId, opts.apiKey, - opts.passphrase ? promptPassphraseGetter() : staticPassphraseGetter(null), + opts.passphrase = staticPassphraseGetter(opts.password), opts.httphost, ); } @@ -261,11 +262,6 @@ async function viewExternalLock(name) { async function transferLock(name) { const {db, context} = await setupCLI(); - await confirm( - `Your name ${name} will be transferred to a locking script. ` + - 'This can be undone, but requires additional on-chain transactions. Do you wish to continue?', - ); - log('Performing locking script transfer.'); const lockTransfer = await transferNameLock(context, name); await db.putLockTransfer(lockTransfer);