From bc5dc7bfd32927694db6f81afae97831889efb5e Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Sun, 23 Jul 2017 11:38:54 -0500 Subject: [PATCH 1/5] Fix typos --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bce2aac..79c7080 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This plugin is rather simple but there are a few things that need to be set up b * A web server! Ideally with the most recent versions of PHP and mysql -* The Monero wallet-cli and Moenro wallet-rpc tools found [here](https://getmonero.org/downloads/) +* The Monero wallet-cli and Monero wallet-rpc tools found [here](https://getmonero.org/downloads/) * [WordPress](https://wordpress.org) Wordpress is the backend tool that is needed to use WooCommerce and this Monero plugin @@ -15,15 +15,15 @@ Wordpress is the backend tool that is needed to use WooCommerce and this Monero This Monero plugin is an extension of WooCommerce, which works with WordPress ## Step 1: Activating the plugin -* Downloading: First of all, you will need to download the plugin. This can be done by typing `git clone https://github.com/monero-integrations/monerowp.git` or can be downloaded as a zip file from the GitHub web page. +* Downloading: First of all, you will need to download the plugin. This can be done with the command `git clone https://github.com/monero-integrations/monerowp.git` or can be downloaded as a zip file from the GitHub web page. * Put the plugin in the correct directory: You will need to put the folder named `monero` from this repo into the wordpress plugins directory. This can be found at `path/to/wordpress/folder/wp-content/plugins` -* Ativate the plugin from the WordPress admin panel: Once you login to the admin panel in WordPress, click on "Installed Plugins" under "Plugins". Then simply click "Activate" where it says "Monero - WooCommerce Gateway" +* Activate the plugin from the WordPress admin panel: Once you login to the admin panel in WordPress, click on "Installed Plugins" under "Plugins". Then simply click "Activate" where it says "Monero - WooCommerce Gateway" ## Step 2: Setup the Monero Wallet RPC -* Setup a monero wallet using the moenro-wallet-cli tool. If you do not knwo how to do this you can learn about it at [getmonero.org](https://getmonero.org/resources/user-guides/monero-wallet-cli.html) +* Setup a monero wallet using the monero-wallet-cli tool. If you do not know how to do this you can learn about it at [getmonero.org](https://getmonero.org/resources/user-guides/monero-wallet-cli.html) * Start the monero daemon on your server and leave it running in the background. This can be accomplished by running `./monerod` inside your monero downloads folder. From ba65a4452a65068dd35c5ba93d836f2d6867a06e Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Sun, 23 Jul 2017 21:11:10 -0500 Subject: [PATCH 2/5] Update to include instructions for using password Updates README to include instructions for using server authentication with the wallet rpc --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 79c7080..e8a0129 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ This Monero plugin is an extension of WooCommerce, which works with WordPress * Start the monero daemon on your server and leave it running in the background. This can be accomplished by running `./monerod` inside your monero downloads folder. -* Start the Wallet RPC and leave it running in the background. This can be accomplished by running `monero-wallet-rpc --rpc-bind-port 18081 --disable-rpc-login --wallet-file /path/walletfile` where "/path/walletfile" is your actual wallet file. +* Start the Wallet RPC and leave it running in the background. This can be accomplished by running `monero-wallet-rpc --rpc-bind-port 18081 --rpc-login username:password --wallet-file /path/walletfile` where "username:password" is the username and password that you want to use, seperated by a colon and "/path/walletfile" is your actual wallet file. ## Step 3: Setup Monero Gateway in WooCommerce @@ -45,4 +45,9 @@ This Monero plugin is an extension of WooCommerce, which works with WordPress * Enter the port number of the Wallet RPC in the box labeled "Daemon PORT" (will be `18081` if you used the above example). +* Enter the username and password that you want to use in their respective feilds + * Click on "Save changes" + +## Info on server authentication +It is reccommended that you specify a username/password with your wallet rpc. This can be done by starting your wallet rpc with `monero-wallet-rpc --rpc-bind-port 18081 --rpc-login username:password --wallet-file /path/walletfile` where "username:password" is the username and password that you want to use, seperated by a colon. Alternatively, you can use the `--restricted-rpc` flag with the wallet rpc like so `./monero-wallet-rpc --testnet --rpc-bind-port 2808 --restricted-rpc --wallet-file testnetWallet`. From 4fdf314736f8116f532516a592785bebc0bb97d5 Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Sun, 23 Jul 2017 21:12:24 -0500 Subject: [PATCH 3/5] Update README.md Makes examples consistent with each other --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8a0129..4be3a6c 100644 --- a/README.md +++ b/README.md @@ -50,4 +50,4 @@ This Monero plugin is an extension of WooCommerce, which works with WordPress * Click on "Save changes" ## Info on server authentication -It is reccommended that you specify a username/password with your wallet rpc. This can be done by starting your wallet rpc with `monero-wallet-rpc --rpc-bind-port 18081 --rpc-login username:password --wallet-file /path/walletfile` where "username:password" is the username and password that you want to use, seperated by a colon. Alternatively, you can use the `--restricted-rpc` flag with the wallet rpc like so `./monero-wallet-rpc --testnet --rpc-bind-port 2808 --restricted-rpc --wallet-file testnetWallet`. +It is reccommended that you specify a username/password with your wallet rpc. This can be done by starting your wallet rpc with `monero-wallet-rpc --rpc-bind-port 18081 --rpc-login username:password --wallet-file /path/walletfile` where "username:password" is the username and password that you want to use, seperated by a colon. Alternatively, you can use the `--restricted-rpc` flag with the wallet rpc like so `./monero-wallet-rpc --testnet --rpc-bind-port 18081 --restricted-rpc --wallet-file wallet/path`. From 4dc7b7b28693b0b5a9797dec5d6c9643525bbdb2 Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Sun, 23 Jul 2017 21:13:33 -0500 Subject: [PATCH 4/5] Update library.php to use server authentication --- monero/library.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/monero/library.php b/monero/library.php index fb0ec80..3970d5e 100644 --- a/monero/library.php +++ b/monero/library.php @@ -11,7 +11,9 @@ */ class Monero_Library { - protected $url = null, $is_debug = false, $parameters_structure = 'array'; + protected $url = null, $is_debug = false, $parameters_structure = 'array'; + private $username; + private $password; protected $curl_options = array( CURLOPT_CONNECTTIMEOUT => 8, CURLOPT_TIMEOUT => 8 @@ -31,12 +33,14 @@ class Monero_Library 503 => '503 Service Unavailable' ); - public function __construct($pUrl) + public function __construct($pUrl, $pUser, $pPass) { $this->validate(false === extension_loaded('curl'), 'The curl extension must be loaded for using this class!'); $this->validate(false === extension_loaded('json'), 'The json extension must be loaded for using this class!'); $this->url = $pUrl; + $this->username = $pUser; + $this->password = $pPass; } private function getHttpErrorMessage($pErrorNumber) @@ -123,6 +127,8 @@ class Monero_Library throw new RuntimeException('Could\'t initialize a cURL session'); } curl_setopt($ch, CURLOPT_URL, $this->url); + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + curl_setopt($ch, CURLOPT_USERPWD, $this->username . ":" . $this->password); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $pRequest); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); From ddd883827520fa9ad8d28fda5c4dde4445916120 Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Sun, 23 Jul 2017 21:14:59 -0500 Subject: [PATCH 5/5] Update to use server authentication Also makes some changes to text --- monero/include/monero_payments.php | 37 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index 4954505..47e2e4a 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -4,7 +4,6 @@ class Monero_Gateway extends WC_Payment_Gateway { private $monero_daemon; - function __construct() { @@ -21,6 +20,8 @@ class Monero_Gateway extends WC_Payment_Gateway $this->host = $this->get_option('daemon_host'); $this->port = $this->get_option('daemon_port'); $this->address = $this->get_option('monero_address'); + $this->username = $this->get_option('username'); + $this->password = $this->get_option('password'); // After init_settings() is called, you can get the settings and load them into variables, e.g: // $this->title = $this->get_option('title' ); @@ -30,7 +31,7 @@ class Monero_Gateway extends WC_Payment_Gateway foreach ($this->settings as $setting_key => $value) { $this->$setting_key = $value; } - + add_action('admin_notices', array( $this, @@ -44,7 +45,6 @@ class Monero_Gateway extends WC_Payment_Gateway - add_action('woocommerce_thankyou_' . $this->id, array( $this, 'instruction' ) ); if (is_admin()) { @@ -54,7 +54,7 @@ class Monero_Gateway extends WC_Payment_Gateway 'process_admin_options' )); } - $this->monero_daemon = new Monero_Library($this->host . ':' . $this->port . '/json_rpc'); + $this->monero_daemon = new Monero_Library($this->host . ':' . $this->port . '/json_rpc', $this->username, $this->password); } public function admin_options() @@ -64,7 +64,7 @@ class Monero_Gateway extends WC_Payment_Gateway echo ""; $this->generate_settings_html(); echo "
"; - + echo "

Learn more about using a password with the monero wallet-rpc here

"; } @@ -98,7 +98,7 @@ class Monero_Gateway extends WC_Payment_Gateway 'type' => 'text', 'desc_tip' => __('Monero Wallet Address', 'monero_gateway') ), - 'daemon_host' => array( + 'daemon_host' => array( 'title' => __('Daemon Host/ IP', 'monero_gateway'), 'type' => 'text', 'desc_tip' => __('This is the Daemon Host/IP to authorize the payment with port', 'monero_gateway'), @@ -110,14 +110,28 @@ class Monero_Gateway extends WC_Payment_Gateway 'desc_tip' => __('This is the Daemon Host/IP to authorize the payment with port', 'monero_gateway'), 'default' => '18080', ), - + 'username' => array( + 'title' => __('username', 'monero_gateway'), + 'desc_tip' => __('This is the username that you used with your monero wallet-rpc', 'monero_gateway'), + 'type' => __('text'), + 'default' => __('username') + + ), + 'password' => array( + 'title' => __('password', 'monero_gateway'), + 'desc_tip' => __('This is the password that you used with your monero wallet-rpc', 'monero_gateway'), + 'description' => __('you can leave these fields empty if you did not set', 'monero_gateway'), + 'type' => __('text'), + 'default' => __('password') + + ), 'environment' => array( 'title' => __(' Test Mode', 'monero_gateway'), 'label' => __('Enable Test Mode', 'monero_gateway'), 'type' => 'checkbox', - 'description' => __('Place the payment gateway in test mode.', 'monero_gateway'), + 'description' => __('Check this box if you are using testnet', 'monero_gateway'), 'default' => 'no' - ) + ), ); } @@ -193,7 +207,7 @@ class Monero_Gateway extends WC_Payment_Gateway $payment_id = bin2hex(openssl_random_pseudo_bytes(8)); $uri = "monero:$address?amount=$amount?payment_id=$payment_id"; $array_integrated_address = $this->monero_daemon->make_integrated_address($payment_id); - + // Generate a QR code echo ""; @@ -310,6 +324,5 @@ class Monero_Gateway extends WC_Payment_Gateway }*/ - } - + } }