From 903bd8b2d796fcadb4236a0e3ddb4a9f1e30bb09 Mon Sep 17 00:00:00 2001 From: cameleater <34056915+cameleater@users.noreply.github.com> Date: Fri, 18 May 2018 10:57:33 +0800 Subject: [PATCH 1/9] update monero_payments.php should now support all the woocommerce currencies as long as the currency is also supported cryptocompare api --- monero/include/monero_payments.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index ab060eb..2e5fb44 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -583,7 +583,8 @@ class Monero_Gateway extends WC_Payment_Gateway public function retriveprice($currency) { - $xmr_price = file_get_contents('https://min-api.cryptocompare.com/data/price?fsym=XMR&tsyms=BTC,USD,EUR,CAD,INR,GBP,COP,SGD&extraParams=monero_woocommerce'); + $api_link = 'https://min-api.cryptocompare.com/data/price?fsym=XMR&tsyms=BTC,USD,EUR,CAD,INR,GBP,COP,SGD' . ',' . $currency . '&extraParams=monero_woocommerce'; + $xmr_price = file_get_contents($api_link); $price = json_decode($xmr_price, TRUE); if (!isset($price)) { $this->log->add('Monero_Gateway', '[ERROR] Unable to get the price of Monero'); @@ -603,6 +604,8 @@ class Monero_Gateway extends WC_Payment_Gateway return $price['COP']; case 'SGD': return $price['SGD']; + case $currency: + return $price[$currency]; case 'XMR': $price = '1'; return $price; From 8def077ba45344a0a824e1339b325dcdc25b4d17 Mon Sep 17 00:00:00 2001 From: Dimitris Apostolou Date: Sun, 20 May 2018 22:17:38 +0300 Subject: [PATCH 2/9] Fix typos --- README.md | 26 +++++++++++++------------- monero/include/ed25519.php | 2 +- monero/include/monero_payments.php | 26 +++++++++++++------------- monero/library.php | 4 ++-- readme.txt | 4 ++-- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index edc0f26..b9fdee1 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # MoneroWP A WooCommerce extension for accepting Monero -## Dependancies -This plugin is rather simple but there are a few things that need to be set up before hand. +## Dependencies +This plugin is rather simple but there are a few things that need to be set up beforehand. * A web server! Ideally with the most recent versions of PHP and mysql * A Monero wallet. You can find the official wallet [here](https://getmonero.org/downloads/) * [WordPress](https://wordpress.org) -Wordpress is the backend tool that is needed to use WooCommerce and this Monero plugin +WordPress is the backend tool that is needed to use WooCommerce and this Monero plugin * [WooCommerce](https://woocommerce.com) This Monero plugin is an extension of WooCommerce, which works with WordPress @@ -19,7 +19,7 @@ This Monero plugin is an extension of WooCommerce, which works with WordPress * Unzip the file monerowp_release.zip if you downloaded the zip from the releases page [here](https://github.com/monero-integrations/monerowp/releases). -* Put the plugin in the correct directory: You will need to put the folder named `monero` from this repo/unzipped release into the wordpress plugins directory. This can be found at `path/to/wordpress/folder/wp-content/plugins` +* Put the plugin in the correct directory: You will need to put the folder named `monero` from this repo/unzipped release into the WordPress plugins directory. This can be found at `path/to/wordpress/folder/wp-content/plugins` * 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" @@ -28,20 +28,20 @@ This Monero plugin is an extension of WooCommerce, which works with WordPress * Get your Monero wallet address starting with '4' * Get your wallet secret viewkey from your wallet -A note on privacy: When you validate transactions with your private viewkey, your viewkey is sent to (but not stored on) xmrchain.net over HTTPS. This could potentally allow an attacker to see your incoming, but not outgoing, transactions if he were to get his hands on your viewkey. Even if this were to happen, your funds would still be safe and it would be impossible for somebody to steal your money. For maximum privacy use your own monero-wallet-rpc instance. +A note on privacy: When you validate transactions with your private viewkey, your viewkey is sent to (but not stored on) xmrchain.net over HTTPS. This could potentially allow an attacker to see your incoming, but not outgoing, transactions if he were to get his hands on your viewkey. Even if this were to happen, your funds would still be safe and it would be impossible for somebody to steal your money. For maximum privacy use your own monero-wallet-rpc instance. -## Step 2 Option 2: Get a monero daemon to connect to +## Step 2 Option 2: Get a Monero daemon to connect to ### Option 1: Running a full node yourself -To do this: 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. The first time that you start your node, the monero daemon will download and sync the entire monero blockchain. This can take several hours and is best done on a machine with at least 4GB of ram, an SSD hard drive (with at least 40GB of free space), and a high speed internet connection. +To do this: 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. The first time that you start your node, the Monero daemon will download and sync the entire Monero blockchain. This can take several hours and is best done on a machine with at least 4GB of ram, an SSD hard drive (with at least 40GB of free space), and a high speed internet connection. ### Option 2: Connecting to a remote node The easiest way to find a remote node to connect to is to visit [moneroworld.com](https://moneroworld.com/#nodes) and use one of the nodes offered. It is probably easiest to use node.moneroworld.com:18089 which will automatically connect you to a random node. -### Setup your monero wallet-rpc +### Setup your Monero wallet-rpc -* 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) +* 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) * [Create a view-only wallet from that wallet for security.](https://monero.stackexchange.com/questions/3178/how-to-create-a-view-only-wallet-for-the-gui/4582#4582) @@ -61,17 +61,17 @@ The easiest way to find a remote node to connect to is to visit [moneroworld.com If You chose to use viewkey: -* Enter your monero wallet address in the box labled "Monero Address". If you do not know your address, you can run the `address` commmand in your monero wallet +* Enter your Monero wallet address in the box labeled "Monero Address". If you do not know your address, you can run the `address` command in your Monero wallet * Enter your secret viewkey in the box labeled "ViewKey" If you chose to use monero-wallet-rpc: -* Enter your monero wallet address in the box labled "Monero Address". If you do not know your address, you can run the `address` commmand in your monero wallet +* Enter your Monero wallet address in the box labeled "Monero Address". If you do not know your address, you can run the `address` command in your Monero wallet -* Enter the IP address of your server in the box labeled "Monero wallet rpc Host/IP" +* Enter the IP address of your server in the box labeled "Monero wallet RPC Host/IP" -* Enter the port number of the Wallet RPC in the box labeled "Monero wallet rpc port" (will be `18082` if you used the above example). +* Enter the port number of the Wallet RPC in the box labeled "Monero wallet RPC port" (will be `18082` if you used the above example). Finally: diff --git a/monero/include/ed25519.php b/monero/include/ed25519.php index 9852b68..e6d443b 100644 --- a/monero/include/ed25519.php +++ b/monero/include/ed25519.php @@ -48,7 +48,7 @@ class ed25519 public $B; - private $gmp; // Is the GMP extention available? + private $gmp; // Is the GMP extension available? public function __construct() { diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index 2e5fb44..1ad6468 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -136,17 +136,17 @@ class Monero_Gateway extends WC_Payment_Gateway 'title' => __('Use monero-wallet-rpc', 'monero_gateway'), 'label' => __(' Verify transactions with the monero-wallet-rpc ', 'monero_gateway'), 'type' => 'checkbox', - 'description' => __('This must be setup seperatly', 'monero_gateway'), + 'description' => __('This must be setup seperately', 'monero_gateway'), 'default' => 'no' ), 'daemon_host' => array( - 'title' => __('Monero wallet rpc Host/ IP', 'monero_gateway'), + 'title' => __('Monero wallet RPC Host/ IP', 'monero_gateway'), 'type' => 'text', 'desc_tip' => __('This is the Daemon Host/IP to authorize the payment with port', 'monero_gateway'), 'default' => 'localhost', ), 'daemon_port' => array( - 'title' => __('Monero wallet rpc port', 'monero_gateway'), + 'title' => __('Monero wallet RPC port', 'monero_gateway'), 'type' => 'text', 'desc_tip' => __('This is the Daemon Host/IP to authorize the payment with port', 'monero_gateway'), 'default' => '18080', @@ -222,9 +222,9 @@ class Monero_Gateway extends WC_Payment_Gateway { $wallet_amount = $this->monero_daemon->getbalance(); if (!isset($wallet_amount)) { - $this->log->add('Monero_gateway', '[ERROR] Can not connect to monero-wallet-rpc'); - echo "
Your balance is: Not Avaliable
"; - echo "Unlocked balance: Not Avaliable"; + $this->log->add('Monero_gateway', '[ERROR] Cannot connect to monero-wallet-rpc'); + echo "
Your balance is: Not Available
"; + echo "Unlocked balance: Not Available"; } else { @@ -386,7 +386,7 @@ class Monero_Gateway extends WC_Payment_Gateway
- +
@@ -419,7 +419,7 @@ class Monero_Gateway extends WC_Payment_Gateway
- +
@@ -467,7 +467,7 @@ class Monero_Gateway extends WC_Payment_Gateway
- +
@@ -498,7 +498,7 @@ class Monero_Gateway extends WC_Payment_Gateway
- +
@@ -552,7 +552,7 @@ class Monero_Gateway extends WC_Payment_Gateway $rounded_amount = round($final_amount, 12); } else { $new_amount = $amount / $stored_rate_transformed; - $rounded_amount = round($new_amount, 12); //the moneo wallet can't handle decimals smaller than 0.000000000001 + $rounded_amount = round($new_amount, 12); //the Monero wallet can't handle decimals smaller than 0.000000000001 } } else // If the row has not been created then the live exchange rate will be grabbed and stored { @@ -665,7 +665,7 @@ class Monero_Gateway extends WC_Payment_Gateway } return $message; } - public function last_block_seen($height) // sometimes 2 blocks are mined within a few seconds of eacher. Make sure we don't miss one + public function last_block_seen($height) // sometimes 2 blocks are mined within a few seconds of each other. Make sure we don't miss one { if (!isset($_COOKIE['last_seen_block'])) { @@ -810,7 +810,7 @@ class Monero_Gateway extends WC_Payment_Gateway

"; } else { - $this->log->add('Monero_gateway', '[ERROR] Plugin can not reach wallet rpc.'); + $this->log->add('Monero_gateway', '[ERROR] Plugin cannot reach wallet RPC.'); echo "

Error with connection of daemon, see documentation!

"; } } diff --git a/monero/library.php b/monero/library.php index f1cf6d3..d5e895f 100644 --- a/monero/library.php +++ b/monero/library.php @@ -220,7 +220,7 @@ class Monero_Library } /* - * The following functions can all be called to interact with the monero rpc wallet + * The following functions can all be called to interact with the Monero RPC wallet * They will majority of them will return the result as an array * Example: $daemon->address(); where $daemon is an instance of this class, will return the wallet address as string within an array */ @@ -266,7 +266,7 @@ class Monero_Library } /* A payment id can be passed as a string - A random payment id will be generatd if one is not given */ + A random payment id will be generated if one is not given */ public function split_integrated_address($integrated_address) { diff --git a/readme.txt b/readme.txt index 924ad08..2c71579 100644 --- a/readme.txt +++ b/readme.txt @@ -21,12 +21,12 @@ An extension to WooCommerce for accepting Monero as payment in your store. * Add monero payments option to your existing online store with alternative main currency. * Flexible exchange rate calculations fully managed via administrative settings. * Zero fees and no commissions for monero payments processing from any third party. -* Automatic conversion to Monero via realtime exchange rate feed and calculations. +* Automatic conversion to Monero via real time exchange rate feed and calculations. * Ability to set exchange rate calculation multiplier to compensate for any possible losses due to bank conversions and funds transfer fees. == Installation == -1. Install "Monero WooCommerce extension" wordpress plugin just like any other Wordpress plugin. +1. Install "Monero WooCommerce extension" WordPress plugin just like any other WordPress plugin. 2. Activate 3. Setup your monero-wallet-rpc with a view-only wallet 4. Add your monero-wallet-rpc host address and Monero address in the settings panel From d5dd832b910a9d479129aad05342c82de1cba841 Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Fri, 8 Jun 2018 14:39:50 -0500 Subject: [PATCH 3/9] add get_outputs function --- monero/library.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/monero/library.php b/monero/library.php index d5e895f..3fa9f17 100644 --- a/monero/library.php +++ b/monero/library.php @@ -366,6 +366,22 @@ class NodeTools return $array['data']['txs']; } + public function get_outputs($address, $viewkey) + { + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $this->url . '/api/outputsblocks?address=' . $address . '&viewkey=' . $viewkey . '&limit=5&mempool=0', + )); + $resp = curl_exec($curl); + curl_close($curl); + + $array = json_decode($resp, true); + + return $array['data']['outputs']; + } + public function check_tx($tx_hash, $address, $viewKey) { $curl = curl_init(); From 34eac09175293c00eee8a06aef5284c77691aacf Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Fri, 8 Jun 2018 14:43:30 -0500 Subject: [PATCH 4/9] more efficient non rpc validation --- monero/include/monero_payments.php | 73 ++++++------------------------ 1 file changed, 14 insertions(+), 59 deletions(-) diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index 1ad6468..b34f793 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -679,79 +679,34 @@ class Monero_Gateway extends WC_Payment_Gateway return $difference; } } + public function verify_non_rpc($payment_id, $amount, $order_id) { $tools = new NodeTools($this->testnet); - $bc_height = $tools->get_last_block_height(); - - $block_difference = $this->last_block_seen($bc_height); - $txs_from_block = $tools->get_txs_from_block($bc_height); - $tx_count = count($txs_from_block) - 1; // The tx at index 0 is a coinbase tx so it can be ignored + $amount_atomic_units = $amount * 1000000000000; + + $outputs = $tools->get_outputs($this->address, $this->viewKey); + $outs_count = count($outputs); - $output_found; - $block_index; - - if($block_difference != 0) + $i = 0; + $tx_hash; + if($outs_count != 0) { - if($block_difference >= 2){ - $this->log->add('[WARNING] Block difference is greater or equal to 2'); - } - - $txs_from_block_2 = $tools->get_txs_from_block($bc_height - 1); - $tx_count_2 = count($txs_from_block_2) - 1; - - $i = 1; - while($i <= $tx_count_2) + while($i < $outs_count ) { - $tx_hash = $txs_from_block_2[$i]['tx_hash']; - if(strlen($txs_from_block_2[$i]['payment_id']) != 0) + if($outputs[$i]['payment_id'] == $payment_id) { - $result = $tools->check_tx($tx_hash, $this->address, $this->viewKey); - if($result) + if($outputs[$i]['amount'] >= $amount_atomic_units) { - $output_found = $result; - $block_index = $i; - $i = $tx_count_2; // finish loop + $this->on_verified($payment_id, $amount_atomic_units, $order_id); + return true; } } $i++; } } - - $i = 1; - while($i <= $tx_count) - { - $tx_hash = $txs_from_block[$i]['tx_hash']; - if(strlen($txs_from_block[$i]['payment_id']) != 0) - { - $result = $tools->check_tx($tx_hash, $this->address, $this->viewKey); - if($result) - { - $output_found = $result; - $block_index = $i; - $i = $tx_count; // finish loop - } - } - $i++; - } - - if(isset($output_found)) - { - $amount_atomic_units = $amount * 1000000000000; - - if($txs_from_block[$block_index]['payment_id'] == $payment_id && $output_found['amount'] >= $amount_atomic_units) - { - $this->on_verified($payment_id, $amount_atomic_units, $order_id); - } - if($txs_from_block_2[$block_index]['payment_id'] == $payment_id && $output_found['amount'] >= $amount_atomic_units) - { - $this->on_verified($payment_id, $amount_atomic_units, $order_id); - } - - return true; - } - return false; + return false; } public function verify_zero_conf($payment_id, $amount, $order_id) From 8ff6da2d5212cc7310570b9f37bf11ec1dabee4f Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Fri, 8 Jun 2018 15:08:55 -0500 Subject: [PATCH 5/9] always use integrated addresses --- monero/include/monero_payments.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index b34f793..7eded4e 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -343,7 +343,7 @@ class Monero_Gateway extends WC_Payment_Gateway echo ""; $order = wc_get_order($order_id); $amount = floatval(preg_replace('#[^\d.]#', '', $order->get_total())); - $payment_id = $this->set_paymentid_cookie(32); + $payment_id = $this->set_paymentid_cookie(8); $currency = $order->get_currency(); $amount_xmr2 = $this->changeto($amount, $currency, $payment_id); $address = $this->address; @@ -356,8 +356,14 @@ class Monero_Gateway extends WC_Payment_Gateway // If there isn't address (merchant missed that field!), $address will be the Monero address for donating :) $address = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; } - $uri = "monero:$address?tx_payment_id=$payment_id"; + $decoded_address = $this->cryptonote->decode_address($address); + $pub_spendKey = $decoded_address['spendKey']; + $pub_viewKey = $decoded_address['viewKey']; + $integrated_addr = $this->cryptonote->integrated_addr_from_keys($pub_spendKey, $pub_viewKey, $payment_id); + + $uri = "monero:$address?tx_payment_id=$payment_id"; + if($this->zero_confirm){ $this->verify_zero_conf($payment_id, $amount_xmr2, $order_id); } @@ -366,7 +372,7 @@ class Monero_Gateway extends WC_Payment_Gateway } if($this->confirmed == false) { - echo "

We are waiting for your transaction to be confirmed

"; + echo "

We are waiting for your transaction to be confirmed

"; } if($this->confirmed) { @@ -375,7 +381,6 @@ class Monero_Gateway extends WC_Payment_Gateway echo " -

*don't forget to include the payment ID in your transaction

@@ -399,12 +404,10 @@ class Monero_Gateway extends WC_Payment_Gateway
Send:
".$amount_xmr2."
- Payment ID: -
".$payment_id."
To this address: -
".$address."
+
".$integrated_addr."
Or scan QR: From b30ee78993ca9a84802111a00b0c53fcf40f509b Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Fri, 8 Jun 2018 23:56:06 -0400 Subject: [PATCH 6/9] add BCMath to dependencies --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b9fdee1..087fd6a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ WordPress is the backend tool that is needed to use WooCommerce and this Monero * [WooCommerce](https://woocommerce.com) This Monero plugin is an extension of WooCommerce, which works with WordPress +* [BCMath](http://php.net/manual/en/book.bc.php) +A PHP extension used for arbitrary precision maths + ## Step 1: Activating the plugin * Downloading: First of all, you will need to download the plugin. You can download the latest release as a .zip file from https://github.com/monero-integrations/monerowp/releases If you wish, you can also download the latest source code from GitHub. 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. From 4cbcde5e7b6fb21e9e9721c3205c76a2ed97dd2f Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Fri, 8 Jun 2018 23:16:53 -0500 Subject: [PATCH 7/9] add zero_conf option to get_outputs --- monero/library.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/monero/library.php b/monero/library.php index 3fa9f17..8a75108 100644 --- a/monero/library.php +++ b/monero/library.php @@ -366,14 +366,27 @@ class NodeTools return $array['data']['txs']; } - public function get_outputs($address, $viewkey) + public function get_outputs($address, $viewkey, $zero_conf = false) { $curl = curl_init(); - curl_setopt_array($curl, array( - CURLOPT_RETURNTRANSFER => 1, - CURLOPT_URL => $this->url . '/api/outputsblocks?address=' . $address . '&viewkey=' . $viewkey . '&limit=5&mempool=0', - )); + if(!$zero_conf) + { + curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $this->url . '/api/outputsblocks?address=' . $address . '&viewkey=' . $viewkey . '&limit=5&mempool=0', + )); + } + + // also look in mempool if accepting zero confirmation transactions + if($zero_conf) + { + curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $this->url . '/api/outputsblocks?address=' . $address . '&viewkey=' . $viewkey . '&limit=5&mempool=1', + )); + } + $resp = curl_exec($curl); curl_close($curl); From 55356ace73ee545658d2f694d2a07962015f569d Mon Sep 17 00:00:00 2001 From: cryptochangements34 Date: Fri, 8 Jun 2018 23:21:54 -0500 Subject: [PATCH 8/9] refactor zero confirmation verification code --- monero/include/monero_payments.php | 52 ++++-------------------------- 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index 7eded4e..3a8f0aa 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -364,12 +364,8 @@ class Monero_Gateway extends WC_Payment_Gateway $uri = "monero:$address?tx_payment_id=$payment_id"; - if($this->zero_confirm){ - $this->verify_zero_conf($payment_id, $amount_xmr2, $order_id); - } - else{ - $this->verify_non_rpc($payment_id, $amount_xmr2, $order_id); - } + $this->verify_non_rpc($payment_id, $amount_xmr2, $order_id, $this->zero_confirm); + if($this->confirmed == false) { echo "

We are waiting for your transaction to be confirmed

"; @@ -683,13 +679,13 @@ class Monero_Gateway extends WC_Payment_Gateway } } - public function verify_non_rpc($payment_id, $amount, $order_id) + public function verify_non_rpc($payment_id, $amount, $order_id, $accept_zero_conf = false) { $tools = new NodeTools($this->testnet); - - $amount_atomic_units = $amount * 1000000000000; - $outputs = $tools->get_outputs($this->address, $this->viewKey); + $amount_atomic_units = $amount * 1000000000000; + + $outputs = $tools->get_outputs($this->address, $this->viewKey, $accept_zero_conf); $outs_count = count($outputs); $i = 0; @@ -711,42 +707,6 @@ class Monero_Gateway extends WC_Payment_Gateway } return false; } - - public function verify_zero_conf($payment_id, $amount, $order_id) - { - $tools = new NodeTools($this->testnet); - $txs_from_mempool = $tools->get_mempool_txs();; - $tx_count = count($txs_from_mempool['data']['txs']); - $i = 0; - $output_found; - - while($i <= $tx_count) - { - $tx_hash = $txs_from_mempool['data']['txs'][$i]['tx_hash']; - if(strlen($txs_from_mempool['data']['txs'][$i]['payment_id']) != 0) - { - $result = $tools->check_tx($tx_hash, $this->address, $this->viewKey); - if($result) - { - $output_found = $result; - $tx_i = $i; - $i = $tx_count; // finish loop - } - } - $i++; - } - if(isset($output_found)) - { - $amount_atomic_units = $amount * 1000000000000; - if($txs_from_mempool['data']['txs'][$tx_i]['payment_id'] == $payment_id && $output_found['amount'] >= $amount_atomic_units) - { - $this->on_verified($payment_id, $amount_atomic_units, $order_id); - } - return true; - } - else - return false; - } public function do_ssl_check() { From 8ec095d9d62dff068d465bac7ccd1e437e458384 Mon Sep 17 00:00:00 2001 From: SerHack <27734319+serhack@users.noreply.github.com> Date: Thu, 21 Jun 2018 18:24:41 +0200 Subject: [PATCH 9/9] Fix #62 . Thanks @moryoav --- monero/include/monero_payments.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monero/include/monero_payments.php b/monero/include/monero_payments.php index 3a8f0aa..8f1e030 100644 --- a/monero/include/monero_payments.php +++ b/monero/include/monero_payments.php @@ -77,8 +77,8 @@ class Monero_Gateway extends WC_Payment_Gateway if (is_admin()) { /* Save Settings */ add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); - add_filter('woocommerce_currencies', 'add_my_currency'); - add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2); + add_filter('woocommerce_currencies', array($this,'add_my_currency')); + add_filter('woocommerce_currency_symbol', array($this,'add_my_currency_symbol'), 10, 2); add_action('woocommerce_email_before_order_table', array($this, 'email_instructions'), 10, 2); } $this->monero_daemon = new Monero_Library($this->host, $this->port); @@ -190,7 +190,7 @@ class Monero_Gateway extends WC_Payment_Gateway return $currencies; } - function add_my_currency_symbol($currency_symbol, $currency) + public function add_my_currency_symbol($currency_symbol, $currency) { switch ($currency) { case 'XMR':