forked from KomodoPlatform/WooCommerce-KMD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspace-mpkgen.php
More file actions
executable file
·52 lines (43 loc) · 2.16 KB
/
space-mpkgen.php
File metadata and controls
executable file
·52 lines (43 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
Spacecoin for WooCommerce
https://github.com/SpaceWorksCo/WooCommerce-SPACE
*/
//
// Example using GenAddress as a cmd line utility
//
// requires phpecc library
// easy way is: git clone git://github.com/mdanter/phpecc.git
// in the directory where this code lives
// and then this loader below will take care of it.
// bcmath module in php seems to be very slow
// apparently the gmp module is much faster
// base2dec needs to be written for gmp as phpecc is missing it
//===========================================================================
function SPACE__MATH_generate_spacecoin_address_from_mpk_v1 ($master_public_key, $key_index)
{
return SPACEElectroHelper::mpk_to_bc_address($master_public_key, $key_index, SPACEElectroHelper::V1);
}
//===========================================================================
//===========================================================================
function SPACE__MATH_generate_spacecoin_address_from_mpk_v2 ($master_public_key, $key_index, $is_for_change = false)
{
return SPACEElectroHelper::mpk_to_bc_address($master_public_key, $key_index, SPACEElectroHelper::V2, $is_for_change);
}
//===========================================================================
//===========================================================================
function SPACE__MATH_generate_spacecoin_address_from_mpk ($master_public_key, $key_index, $is_for_change = false)
{
if (USE_EXT != 'GMP' && USE_EXT != 'BCMATH')
{
SPACE__log_event (__FILE__, __LINE__, "Neither GMP nor BCMATH PHP math libraries are present. Aborting.");
return false;
}
if (preg_match ('/^[a-f0-9]{128}$/', $master_public_key))
return SPACE__MATH_generate_spacecoin_address_from_mpk_v1 ($master_public_key, $key_index);
if (preg_match ('/^xpub[a-zA-Z0-9]{107}$/', $master_public_key))
return SPACE__MATH_generate_spacecoin_address_from_mpk_v2 ($master_public_key, $key_index, $is_for_change);
SPACE__log_event (__FILE__, __LINE__, "Invalid MPK passed: '$master_public_key'. Aborting.");
return false;
}
//===========================================================================