Plugin Directory

Changeset 701888


Ignore:
Timestamp:
04/23/2013 12:40:54 AM (13 years ago)
Author:
gesman
Message:

2.10

Location:
bitcoin-payments-for-woocommerce/trunk
Files:
3 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • bitcoin-payments-for-woocommerce/trunk/bitcoinway-woocommerce.php

    r701653 r701888  
    1212Plugin URI: http://www.bitcoinway.com/
    1313Description: Bitcoin Payments for WooCommerce plugin allows you to accept payments in bitcoins for physical and digital products at your WooCommerce-powered online store.
    14 Version: 2.04
     14Version: 2.10
    1515Author: BitcoinWay
    1616Author URI: http://www.bitcoinway.com/
  • bitcoin-payments-for-woocommerce/trunk/bwwc-bitcoin-gateway.php

    r701236 r701888  
    133133                    $valid = false;
    134134                }
    135 ////// Add it back when GMP support will be included in code
    136 //////              else if (!extension_loaded('gmp') && !extension_loaded('bcmath'))
    137 //////
    138                 else if (!extension_loaded('bcmath'))
    139 //////
     135                else if (!extension_loaded('gmp') && !extension_loaded('bcmath'))
    140136                {
    141 ////// Add it back when GMP support will be included in code
    142 //////                  $reason_message = __("ERROR: neither 'bcmath' nor 'gmp' math extensions are loaded For Electrum wallet options to function. Contact your hosting company and ask them to enable either 'bcmath' nor 'gmp' extensions. \nAlternatively you may choose another 'Bitcoin Service Provider' option.", 'woocommerce');
    143 //////
    144                     $reason_message = __("ERROR: 'bcmath' math extension is not loaded For Electrum wallet options to function. Contact your hosting company and ask them to enable 'bcmath' extension. \nAlternatively you may choose another 'Bitcoin Service Provider' option.", 'woocommerce');
    145 //////
     137                    $reason_message = __("ERROR: neither 'bcmath' nor 'gmp' math extensions are loaded For Electrum wallet options to function. Contact your hosting company and ask them to enable either 'bcmath' or 'gmp' extensions. 'gmp' is preferred (much faster)! \nAlternatively you may choose another 'Bitcoin Service Provider' option.", 'woocommerce');
    146138                    $valid = false;
    147139                }
  • bitcoin-payments-for-woocommerce/trunk/bwwc-include-all.php

    r701653 r701888  
    99if (!defined('BWWC_PLUGIN_NAME'))
    1010  {
    11   define('BWWC_VERSION',           '2.04');
     11  define('BWWC_VERSION',           '2.10');
    1212
    1313  //-----------------------------------------------
     
    2222  define('BWWC_I18N_DOMAIN',       'bwwc');
    2323
    24 ////// Add these back when GMP code will support it
    25 //////  if (extension_loaded('gmp') && !defined('USE_EXT'))
    26 //////    define ('USE_EXT', 'GMP');
    27   if (extension_loaded('bcmath') && !defined('USE_EXT'))
     24  if (extension_loaded('gmp') && !defined('USE_EXT'))
     25    define ('USE_EXT', 'GMP');
     26  else if (extension_loaded('bcmath') && !defined('USE_EXT'))
    2827    define ('USE_EXT', 'BCMATH');
    2928  }
  • bitcoin-payments-for-woocommerce/trunk/bwwc-mpkgen.php

    r701237 r701888  
    1919function BWWC__MATH_generate_bitcoin_address_from_mpk ($master_public_key, $key_index)
    2020{
     21    if (USE_EXT != 'GMP' && USE_EXT != 'BCMATH')
     22        return false;
     23
     24    /*
    2125    if (USE_EXT == 'GMP')
    2226    {
     
    3539    else
    3640        return false;
     41*/
    3742
    3843    // create the ecc curve
    39     $_p         = $utils_class::$fn_bchexdec('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F');
    40   $_r       = $utils_class::$fn_bchexdec('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141');
    41   $_b       = $utils_class::$fn_bchexdec('0x0000000000000000000000000000000000000000000000000000000000000007');
    42   $_Gx      = $utils_class::$fn_bchexdec('0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798');
    43   $_Gy      = $utils_class::$fn_bchexdec('0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8');
     44    if (USE_EXT == 'GMP')
     45    {   // GMP
     46        $_p         = gmp_Utils::gmp_hexdec('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F');
     47      $_r       = gmp_Utils::gmp_hexdec('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141');
     48      $_b       = gmp_Utils::gmp_hexdec('0x0000000000000000000000000000000000000000000000000000000000000007');
     49      $_Gx      = gmp_Utils::gmp_hexdec('0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798');
     50      $_Gy      = gmp_Utils::gmp_hexdec('0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8');
     51    }
     52    else
     53    { // BCMATH
     54        $_p         = bcmath_Utils::bchexdec('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F');
     55      $_r       = bcmath_Utils::bchexdec('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141');
     56      $_b       = bcmath_Utils::bchexdec('0x0000000000000000000000000000000000000000000000000000000000000007');
     57      $_Gx      = bcmath_Utils::bchexdec('0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798');
     58      $_Gy      = bcmath_Utils::bchexdec('0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8');
     59    }
    4460    $curve  = new CurveFp($_p, 0, $_b);
    4561  $gen      = new Point( $curve, $_Gx, $_Gy, $_r );
    4662
    4763    // prepare the input values
    48     $x = $utils_class::$fn_bchexdec(substr($master_public_key, 0, 64));
    49     $y = $utils_class::$fn_bchexdec(substr($master_public_key, 64, 64));
    50     $z = $utils_class::$fn_bchexdec(hash('sha256', hash('sha256', $key_index.':0:'.pack('H*',$master_public_key), TRUE)));
     64    if (USE_EXT == 'GMP')
     65    {   // GMP
     66        $x = gmp_Utils::gmp_hexdec('0x'.substr($master_public_key, 0, 64));
     67        $y = gmp_Utils::gmp_hexdec('0x'.substr($master_public_key, 64, 64));
     68        $z = gmp_Utils::gmp_hexdec('0x'.hash('sha256', hash('sha256', $key_index.':0:'.pack('H*',$master_public_key), TRUE)));
     69    }
     70    else
     71    {   // BCMATH
     72        $x = bcmath_Utils::bchexdec('0x'.substr($master_public_key, 0, 64));
     73        $y = bcmath_Utils::bchexdec('0x'.substr($master_public_key, 64, 64));
     74        $z = bcmath_Utils::bchexdec('0x'.hash('sha256', hash('sha256', $key_index.':0:'.pack('H*',$master_public_key), TRUE)));
     75    }
    5176
    5277    // generate the new public key based off master and sequence points
    5378    $pt = Point::add(new Point($curve, $x, $y), Point::mul($z, $gen) );
    54     $keystr = "\x04".str_pad($utils_class::$fn_dec2base($pt->getX(), 256), 32, "\x0", STR_PAD_LEFT)
    55         .str_pad($utils_class::$fn_dec2base($pt->getY(), 256), 32, "\x0", STR_PAD_LEFT);
     79    if (USE_EXT == 'GMP')
     80    {   // GMP
     81        $keystr = "\x04" . str_pad(gmp_Utils::gmp_dec2base($pt->getX(), 256), 32, "\x0", STR_PAD_LEFT) . str_pad(gmp_Utils::gmp_dec2base($pt->getY(), 256), 32, "\x0", STR_PAD_LEFT);
     82    }
     83    else
     84    {   // BCMATH
     85        $keystr = "\x04" . str_pad(bcmath_Utils::dec2base($pt->getX(), 256), 32, "\x0", STR_PAD_LEFT) . str_pad(bcmath_Utils::dec2base($pt->getY(), 256), 32, "\x0", STR_PAD_LEFT);
     86    }
     87
    5688    $vh160 =  "\x0".hash('ripemd160', hash('sha256', $keystr, TRUE), TRUE);
    5789    $addr = $vh160.substr(hash('sha256', hash('sha256', $vh160, TRUE), TRUE), 0, 4);
     
    6092    $alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
    6193  $encoded  = '';
    62   $num = $utils_class::$fn_base2dec($addr, 256);  // this needs to be rewritten if switching to gmp math
     94    if (USE_EXT == 'GMP')
     95    {   // GMP
     96      $num = gmp_Utils::gmp_base2dec($addr, 256);
     97    }
     98    else
     99    { // BCMATH
     100      $num = bcmath_Utils::base2dec($addr, 256);
     101    }
    63102
    64103  while (intval($num) >= 58)
  • bitcoin-payments-for-woocommerce/trunk/bwwc-utils.php

    r701236 r701888  
    4242   $funds_received_value_expires_in_secs = $bwwc_settings['funds_received_value_expires_in_mins'] * 60;
    4343   $assigned_address_expires_in_secs     = $bwwc_settings['assigned_address_expires_in_mins'] * 60;
    44 
    45   ///////////!!!
    46    // This done in cron
    47    // 0. Force-expire addresses that did not receive payments within 2 hours after beign assigned to prospect.
    48    //$query = "UPDATE `$btc_addresses_table_name` SET `status` = 'unused' WHERE `status`='assigned' AND `assigned_at` < (NOW() - INTERVAL 2 HOUR);";
    49    //$wpdb->query ($query);
    50 
    51    // 1. Search DB for 'unused' addresses. Validate it's virginity by analyzing blockchain. Update DB if necessary.
    52   ///////////!!!
    5344
    5445   $clean_address = NULL;
  • bitcoin-payments-for-woocommerce/trunk/phpecc/classes/util/gmp_Utils.php

    r701237 r701888  
    7676    }
    7777
     78    public static function gmp_dec2base($dec, $base, $digits=FALSE) {
     79        if (extension_loaded('gmp')) {
     80            if ($base < 2 or $base > 256)
     81                die("Invalid Base: " . $base);
     82            $value = "";
     83            if (!$digits)
     84                $digits = self::digits($base);
     85            $dec = gmp_init($dec);
     86            $base = gmp_init($base);
     87            while (gmp_cmp($dec, gmp_sub($base, '1')) > 0) {
     88                $rest = gmp_mod($dec, $base);
     89                $dec = gmp_div($dec, $base);
     90                $value = $digits[gmp_intval($rest)] . $value;
     91            }
     92            $value = $digits[gmp_intval($dec)] . $value;
     93            return (string) $value;
     94        } else {
     95            throw new ErrorException("Please install GMP");
     96        }
     97    }
     98
     99    public static function gmp_base2dec($value, $base, $digits=FALSE) {
     100        if (extension_loaded('gmp')) {
     101            if ($base < 2 or $base > 256)
     102                die("Invalid Base: " . $base);
     103            if ($base < 37)
     104                $value = strtolower($value);
     105            if (!$digits)
     106                $digits = self::digits($base);
     107            $size = strlen($value);
     108            $dec = "0";
     109            for ($loop = 0; $loop < $size; $loop++) {
     110                $element = strpos($digits, $value[$loop]);
     111                $power = gmp_pow(gmp_init($base), $size - $loop - 1);
     112                $dec = gmp_add($dec, gmp_mul($element, $power));
     113            }
     114            return gmp_strval($dec);
     115        } else {
     116            throw new ErrorException("Please install GMP");
     117        }
     118    }
     119
     120    public static function digits($base) {
     121        if ($base > 64) {
     122            $digits = "";
     123            for ($loop = 0; $loop < 256; $loop++) {
     124                $digits.=chr($loop);
     125            }
     126        } else {
     127            $digits = "0123456789abcdefghijklmnopqrstuvwxyz";
     128            $digits.="ABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
     129        }
     130        $digits = substr($digits, 0, $base);
     131        return (string) $digits;
     132    }
    78133}
    79134?>
  • bitcoin-payments-for-woocommerce/trunk/readme.txt

    r701653 r701888  
    3737
    3838
    39 == Remove plugin ==
    40 
    41 1. Deactivate plugin through the 'Plugins' menu in WordPress
    42 2. Delete plugin through the 'Plugins' menu in WordPress
    43 
    44 
    4539== Screenshots ==
    4640
     
    48422. Order received screen, including QR code of bitcoin address and payment amount.
    49433. Bitcoin Gsteway settings screen.
     44
     45
     46== Remove plugin ==
     47
     481. Deactivate plugin through the 'Plugins' menu in WordPress
     492. Delete plugin through the 'Plugins' menu in WordPress
    5050
    5151
     
    6060
    6161== Changelog ==
     62
     63= 2.10 =
     64* Added support for much faster GMP math library to generate bitcoin addresses. This improves performance of checkout 3x - 4x times.
     65  Special thanks to Chris Savery: https://github.com/bkkcoins/misc
     66* Improved compatibility with older versions of PHP now allowing to use plugin in wider range of hosting services.
    6267
    6368= 2.04 =
Note: See TracChangeset for help on using the changeset viewer.