diff --git a/phpcs.xml b/phpcs.xml
index c5b6c24..206febb 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -4,11 +4,22 @@
PHPCS configuration file.
src
- tests
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Cryptonote.php b/src/Cryptonote.php
index 9f8269c..79c444c 100644
--- a/src/Cryptonote.php
+++ b/src/Cryptonote.php
@@ -1,4 +1,5 @@
[
- "STANDARD" => dechex(18),
- "INTEGRATED" => dechex(19),
- "SUBADDRESS" => dechex(42),
- ],
- "stagenet" => [
- "STANDARD" => dechex(24),
- "INTEGRATED" => dechex(25),
- "SUBADDRESS" => dechex(36),
- ],
- "testnet" => [
- "STANDARD" => dechex(53),
- "INTEGRATED" => dechex(54),
- "SUBADDRESS" => dechex(63),
- ]
- ];
- if (array_key_exists($network, $networks_prefixes)) {
- $this->network_prefixes = $networks_prefixes[$network];
- } else {
- throw new Exception("Error: Invalid Network, should be one of " . join(", ", array_keys($networks_prefixes)));
- }
+class Cryptonote
+{
+ // https://github.com/monero-project/monero/blob/master/src/cryptonote_config.h#L222
+ private $network_prefixes;
+ protected $ed25519;
+ protected $base58;
+ protected $varint;
- $this->ed25519 = new ed25519();
- $this->base58 = new base58();
- $this->varint = new Varint();
+ public function __construct($network = "mainnet")
+ {
+ $networks_prefixes = [
+ "mainnet" => [
+ "STANDARD" => dechex(18),
+ "INTEGRATED" => dechex(19),
+ "SUBADDRESS" => dechex(42),
+ ],
+ "stagenet" => [
+ "STANDARD" => dechex(24),
+ "INTEGRATED" => dechex(25),
+ "SUBADDRESS" => dechex(36),
+ ],
+ "testnet" => [
+ "STANDARD" => dechex(53),
+ "INTEGRATED" => dechex(54),
+ "SUBADDRESS" => dechex(63),
+ ]
+ ];
+ if (array_key_exists($network, $networks_prefixes)) {
+ $this->network_prefixes = $networks_prefixes[$network];
+ } else {
+ throw new Exception("Error: Invalid Network, should be one of " . join(", ", array_keys($networks_prefixes)));
}
- /*
- * @param string Hex encoded string of the data to hash
- * @return string Hex encoded string of the hashed data
- *
- */
- public function keccak_256($message)
- {
- $message_bin = hex2bin($message);
- $hash = keccak::hash($message_bin, 256);
-
- return $hash;
- }
+ $this->ed25519 = new ed25519();
+ $this->base58 = new base58();
+ $this->varint = new Varint();
+ }
- /*
- * @return string A hex encoded string of 32 random bytes
- *
- */
- public function gen_new_hex_seed()
- {
- $bytes = random_bytes(32);
- return bin2hex($bytes);
- }
+ /*
+ * @param string Hex encoded string of the data to hash
+ * @return string Hex encoded string of the hashed data
+ *
+ */
+ public function keccak_256($message)
+ {
+ $message_bin = hex2bin($message);
+ $hash = keccak::hash($message_bin, 256);
+
+ return $hash;
+ }
- public function sc_reduce($input)
- {
- $integer = $this->ed25519->decodeint(hex2bin($input));
+ /*
+ * @return string A hex encoded string of 32 random bytes
+ *
+ */
+ public function gen_new_hex_seed()
+ {
+ $bytes = random_bytes(32);
+ return bin2hex($bytes);
+ }
- $modulo = bcmod($integer , $this->ed25519->l);
+ public function sc_reduce($input)
+ {
+ $integer = $this->ed25519->decodeint(hex2bin($input));
- $result = bin2hex($this->ed25519->encodeint($modulo));
- return $result;
- }
+ $modulo = bcmod($integer, $this->ed25519->l);
- /*
- * Hs in the cryptonote white paper
- *
- * @param string Hex encoded data to hash
- *
- * @return string A 32 byte encoded integer
- */
- public function hash_to_scalar($data)
- {
- $hash = $this->keccak_256($data);
- $scalar = $this->sc_reduce($hash);
- return $scalar;
- }
+ $result = bin2hex($this->ed25519->encodeint($modulo));
+ return $result;
+ }
- /*
- * Derive a deterministic private view key from a private spend key
- * @param string A private spend key represented as a 32 byte hex string
- *
- * @return string A deterministic private view key represented as a 32 byte hex string
- */
- public function derive_viewKey($spendKey)
- {
- return $this->hash_to_scalar($spendKey);
- }
+ /*
+ * Hs in the cryptonote white paper
+ *
+ * @param string Hex encoded data to hash
+ *
+ * @return string A 32 byte encoded integer
+ */
+ public function hash_to_scalar($data)
+ {
+ $hash = $this->keccak_256($data);
+ $scalar = $this->sc_reduce($hash);
+ return $scalar;
+ }
- /*
- * Generate a pair of random private keys
- *
- * @param string A hex string to be used as a seed (this should be random)
- *
- * @return array An array containing a private spend key and a deterministic view key
- */
- public function gen_private_keys($seed)
- {
- $spendKey = $this->sc_reduce($seed);
- $viewKey = $this->derive_viewKey($spendKey);
- $result = array("spendKey" => $spendKey,
- "viewKey" => $viewKey);
+ /*
+ * Derive a deterministic private view key from a private spend key
+ * @param string A private spend key represented as a 32 byte hex string
+ *
+ * @return string A deterministic private view key represented as a 32 byte hex string
+ */
+ public function derive_viewKey($spendKey)
+ {
+ return $this->hash_to_scalar($spendKey);
+ }
- return $result;
- }
+ /*
+ * Generate a pair of random private keys
+ *
+ * @param string A hex string to be used as a seed (this should be random)
+ *
+ * @return array An array containing a private spend key and a deterministic view key
+ */
+ public function gen_private_keys($seed)
+ {
+ $spendKey = $this->sc_reduce($seed);
+ $viewKey = $this->derive_viewKey($spendKey);
+ $result = array("spendKey" => $spendKey,
+ "viewKey" => $viewKey);
- /*
- * Get a public key from a private key on the ed25519 curve
- *
- * @param string a 32 byte hex encoded private key
- *
- * @return string a 32 byte hex encoding of a point on the curve to be used as a public key
- */
- public function pk_from_sk($privKey)
- {
+ return $result;
+ }
+
+ /*
+ * Get a public key from a private key on the ed25519 curve
+ *
+ * @param string a 32 byte hex encoded private key
+ *
+ * @return string a 32 byte hex encoding of a point on the curve to be used as a public key
+ */
+ public function pk_from_sk($privKey)
+ {
$keyInt = $this->ed25519->decodeint(hex2bin($privKey));
$aG = $this->ed25519->scalarmult_base($keyInt);
- return bin2hex($this->ed25519->encodepoint($aG));
- }
+ return bin2hex($this->ed25519->encodepoint($aG));
+ }
- /*
- * Generate key derivation
- *
- * @param string a 32 byte hex encoding of a point on the ed25519 curve used as a public key
- * @param string a 32 byte hex encoded private key
- *
- * @return string The hex encoded key derivation
- */
- public function gen_key_derivation($public, $private)
- {
- $point = $this->ed25519->scalarmult($this->ed25519->decodepoint(hex2bin($public)), $this->ed25519->decodeint(hex2bin($private)));
- $res = $this->ed25519->scalarmult($point, 8);
- return bin2hex($this->ed25519->encodepoint($res));
- }
+ /*
+ * Generate key derivation
+ *
+ * @param string a 32 byte hex encoding of a point on the ed25519 curve used as a public key
+ * @param string a 32 byte hex encoded private key
+ *
+ * @return string The hex encoded key derivation
+ */
+ public function gen_key_derivation($public, $private)
+ {
+ $point = $this->ed25519->scalarmult($this->ed25519->decodepoint(hex2bin($public)), $this->ed25519->decodeint(hex2bin($private)));
+ $res = $this->ed25519->scalarmult($point, 8);
+ return bin2hex($this->ed25519->encodepoint($res));
+ }
- public function derivation_to_scalar($der, $index)
- {
- $encoded = $this->varint->encode_varint($index);
- $data = $der . $encoded;
- return $this->hash_to_scalar($data);
- }
+ public function derivation_to_scalar($der, $index)
+ {
+ $encoded = $this->varint->encode_varint($index);
+ $data = $der . $encoded;
+ return $this->hash_to_scalar($data);
+ }
- // this is a one way function used for both encrypting and decrypting 8 byte payment IDs
- public function stealth_payment_id($payment_id, $tx_pub_key, $viewkey)
- {
- if(strlen($payment_id) != 16)
- {
- throw new Exception("Error: Incorrect payment ID size. Should be 8 bytes");
- }
- $der = $this->gen_key_derivation($tx_pub_key, $viewkey);
- $data = $der . '8d';
- $hash = $this->keccak_256($data);
- $key = substr($hash, 0, 16);
- $result = bin2hex(pack('H*',$payment_id) ^ pack('H*',$key));
- return $result;
+ // this is a one way function used for both encrypting and decrypting 8 byte payment IDs
+ public function stealth_payment_id($payment_id, $tx_pub_key, $viewkey)
+ {
+ if (strlen($payment_id) != 16) {
+ throw new Exception("Error: Incorrect payment ID size. Should be 8 bytes");
}
+ $der = $this->gen_key_derivation($tx_pub_key, $viewkey);
+ $data = $der . '8d';
+ $hash = $this->keccak_256($data);
+ $key = substr($hash, 0, 16);
+ $result = bin2hex(pack('H*', $payment_id) ^ pack('H*', $key));
+ return $result;
+ }
- // takes transaction extra field as hex string and returns transaction public key 'R' as hex string
- public function txpub_from_extra($extra)
- {
- $parsed = array_map("hexdec", str_split($extra, 2));
+ // takes transaction extra field as hex string and returns transaction public key 'R' as hex string
+ public function txpub_from_extra($extra)
+ {
+ $parsed = array_map("hexdec", str_split($extra, 2));
- if($parsed[0] == 1)
- {
- return substr($extra, 2, 64);
- }
+ if ($parsed[0] == 1) {
+ return substr($extra, 2, 64);
+ }
- if($parsed[0] == 2)
- {
- if($parsed[0] == 2 || $parsed[2] == 1)
- {
- //$offset = (($parsed[1] + 2) *2) + 2;
- return substr($extra, (($parsed[1] + 2) *2) + 2, 64);
- }
+ if ($parsed[0] == 2) {
+ if ($parsed[0] == 2 || $parsed[2] == 1) {
+ //$offset = (($parsed[1] + 2) *2) + 2;
+ return substr($extra, (($parsed[1] + 2) * 2) + 2, 64);
}
}
+ }
- public function derive_public_key($der, $index, $pub)
- {
- $scalar = $this->derivation_to_scalar($der, $index);
- $sG = $this->ed25519->scalarmult_base($this->ed25519->decodeint(hex2bin($scalar)));
- $pubPoint = $this->ed25519->decodepoint(hex2bin($pub));
- $key = $this->ed25519->encodepoint($this->ed25519->edwards($pubPoint, $sG));
- return bin2hex($key);
- }
+ public function derive_public_key($der, $index, $pub)
+ {
+ $scalar = $this->derivation_to_scalar($der, $index);
+ $sG = $this->ed25519->scalarmult_base($this->ed25519->decodeint(hex2bin($scalar)));
+ $pubPoint = $this->ed25519->decodepoint(hex2bin($pub));
+ $key = $this->ed25519->encodepoint($this->ed25519->edwards($pubPoint, $sG));
+ return bin2hex($key);
+ }
- /*
- * Perform the calculation P = P' as described in the cryptonote whitepaper
- *
- * @param string 32 byte transaction public key R
- * @param string 32 byte receiver private view key a
- * @param string 32 byte receiver public spend key B
- * @param int output index
- * @param string output you want to check against P
- */
- public function is_output_mine($txPublic, $privViewkey, $publicSpendkey, $index, $P)
- {
- $derivation = $this->gen_key_derivation($txPublic, $privViewkey);
- $Pprime = $this->derive_public_key($derivation, $index, $publicSpendkey);
-
- if($P == $Pprime)
- {
- return true;
- }
- else
- return false;
+ /*
+ * Perform the calculation P = P' as described in the cryptonote whitepaper
+ *
+ * @param string 32 byte transaction public key R
+ * @param string 32 byte receiver private view key a
+ * @param string 32 byte receiver public spend key B
+ * @param int output index
+ * @param string output you want to check against P
+ */
+ public function is_output_mine($txPublic, $privViewkey, $publicSpendkey, $index, $P)
+ {
+ $derivation = $this->gen_key_derivation($txPublic, $privViewkey);
+ $Pprime = $this->derive_public_key($derivation, $index, $publicSpendkey);
+
+ if ($P == $Pprime) {
+ return true;
+ } else {
+ return false;
}
+ }
- /*
- * Create a valid base58 encoded Monero address from public keys
- *
- * @param string Public spend key
- * @param string Public view key
- *
- * @return string Base58 encoded Monero address
- */
+ /*
+ * Create a valid base58 encoded Monero address from public keys
+ *
+ * @param string Public spend key
+ * @param string Public view key
+ *
+ * @return string Base58 encoded Monero address
+ */
public function encode_address($pSpendKey, $pViewKey)
{
$data = $this->network_prefixes["STANDARD"] . $pSpendKey . $pViewKey;
$checksum = $this->keccak_256($data);
$encoded = $this->base58->encode($data . substr($checksum, 0, 8));
-
+
return $encoded;
}
@@ -267,18 +263,18 @@ public function verify_checksum($address)
}
/*
- * Decode a base58 encoded Monero address
- *
- * @param string A base58 encoded Monero address
- *
- * @return array An array containing the Address network byte, public spend key, and public view key
- */
+ * Decode a base58 encoded Monero address
+ *
+ * @param string A base58 encoded Monero address
+ *
+ * @return array An array containing the Address network byte, public spend key, and public view key
+ */
public function decode_address($address)
- {
+ {
$decoded = $this->base58->decode($address);
- if(!$this->verify_checksum($address)){
- throw new Exception("Error: invalid checksum");
+ if (!$this->verify_checksum($address)) {
+ throw new Exception("Error: invalid checksum");
}
$network_byte = substr($decoded, 0, 2);
@@ -289,30 +285,30 @@ public function decode_address($address)
"spendKey" => $public_spendKey,
"viewKey" => $public_viewKey);
return $result;
- }
+ }
- /*
- * Get an integrated address from public keys and a payment id
- *
- * @param string A 32 byte hex encoded public spend key
- * @param string A 32 byte hex encoded public view key
- * @param string An 8 byte hex string to use as a payment id
- */
- public function integrated_addr_from_keys($public_spendkey, $public_viewkey, $payment_id)
- {
- $data = $this->network_prefixes["INTEGRATED"].$public_spendkey.$public_viewkey.$payment_id;
- $checksum = substr($this->keccak_256($data), 0, 8);
- $result = $this->base58->encode($data.$checksum);
- return $result;
- }
+ /*
+ * Get an integrated address from public keys and a payment id
+ *
+ * @param string A 32 byte hex encoded public spend key
+ * @param string A 32 byte hex encoded public view key
+ * @param string An 8 byte hex string to use as a payment id
+ */
+ public function integrated_addr_from_keys($public_spendkey, $public_viewkey, $payment_id)
+ {
+ $data = $this->network_prefixes["INTEGRATED"] . $public_spendkey . $public_viewkey . $payment_id;
+ $checksum = substr($this->keccak_256($data), 0, 8);
+ $result = $this->base58->encode($data . $checksum);
+ return $result;
+ }
- /*
- * Generate a Monero address from seed
- *
- * @param string Hex string to use as seed
- *
- * @return string A base58 encoded Monero address
- */
+ /*
+ * Generate a Monero address from seed
+ *
+ * @param string Hex string to use as seed
+ *
+ * @return string A base58 encoded Monero address
+ */
public function address_from_seed($hex_seed)
{
$private_keys = $this->gen_private_keys($hex_seed);
@@ -325,60 +321,59 @@ public function address_from_seed($hex_seed)
$address = $this->encode_address($public_spendKey, $public_viewKey);
return $address;
}
-
+
// m = Hs(a || i)
public function generate_subaddr_secret_key($major_index, $minor_index, $sec_key)
{
- $prefix = "5375624164647200";
- $index = pack("II", $major_index, $minor_index);
- return $this->hash_to_scalar($prefix . $sec_key . bin2hex($index));
+ $prefix = "5375624164647200";
+ $index = pack("II", $major_index, $minor_index);
+ return $this->hash_to_scalar($prefix . $sec_key . bin2hex($index));
+ }
+
+ public function generate_subaddress_spend_public_key($spend_public_key, $subaddr_secret_key)
+ {
+ $mInt = $this->ed25519->decodeint(hex2bin($subaddr_secret_key));
+ $mG = $this->ed25519->scalarmult_base($mInt);
+ $D = $this->ed25519->edwards($this->ed25519->decodepoint(hex2bin($spend_public_key)), $mG);
+ return bin2hex($this->ed25519->encodepoint($D));
+ }
+
+ public function generate_subaddr_view_public_key($subaddr_spend_public_key, $view_secret_key)
+ {
+ $point = $this->ed25519->scalarmult($this->ed25519->decodepoint(hex2bin($subaddr_spend_public_key)), $this->ed25519->decodeint(hex2bin($view_secret_key)));
+ return bin2hex($this->ed25519->encodepoint($point));
}
-
- public function generate_subaddress_spend_public_key($spend_public_key, $subaddr_secret_key)
- {
- $mInt = $this->ed25519->decodeint(hex2bin($subaddr_secret_key));
- $mG = $this->ed25519->scalarmult_base($mInt);
- $D = $this->ed25519->edwards($this->ed25519->decodepoint(hex2bin($spend_public_key)), $mG);
- return bin2hex($this->ed25519->encodepoint($D));
- }
-
- public function generate_subaddr_view_public_key($subaddr_spend_public_key, $view_secret_key)
- {
- $point = $this->ed25519->scalarmult($this->ed25519->decodepoint(hex2bin($subaddr_spend_public_key)), $this->ed25519->decodeint(hex2bin($view_secret_key)));
- return bin2hex($this->ed25519->encodepoint($point));
- }
-
- public function generate_subaddress($major_index, $minor_index, $view_secret_key, $spend_public_key)
- {
- $subaddr_secret_key = $this->generate_subaddr_secret_key($major_index, $minor_index, $view_secret_key);
- $subaddr_public_spend_key = $this->generate_subaddress_spend_public_key($spend_public_key, $subaddr_secret_key);
- $subaddr_public_view_key = $this->generate_subaddr_view_public_key($subaddr_public_spend_key, $view_secret_key);
+
+ public function generate_subaddress($major_index, $minor_index, $view_secret_key, $spend_public_key)
+ {
+ $subaddr_secret_key = $this->generate_subaddr_secret_key($major_index, $minor_index, $view_secret_key);
+ $subaddr_public_spend_key = $this->generate_subaddress_spend_public_key($spend_public_key, $subaddr_secret_key);
+ $subaddr_public_view_key = $this->generate_subaddr_view_public_key($subaddr_public_spend_key, $view_secret_key);
$data = $this->network_prefixes["SUBADDRESS"] . $subaddr_public_spend_key . $subaddr_public_view_key;
$checksum = $this->keccak_256($data);
$encoded = $this->base58->encode($data . substr($checksum, 0, 8));
- return $encoded;
- }
+ return $encoded;
+ }
public function deserialize_block_header($block)
{
- $data = str_split($block, 2);
-
- $major_version = $this->varint->decode_varint($data);
- $data = $this->varint->pop_varint($data);
-
- $minor_version = $this->varint->decode_varint($data);
- $data = $this->varint->pop_varint($data);
-
- $timestamp = $this->varint->decode_varint($data);
- $data = $this->varint->pop_varint($data);
-
- $nonce = $this->varint->decode_varint($data);
- $data = $this->varint->pop_varint($data);
-
- return array("major_version" => $major_version,
+ $data = str_split($block, 2);
+
+ $major_version = $this->varint->decode_varint($data);
+ $data = $this->varint->pop_varint($data);
+
+ $minor_version = $this->varint->decode_varint($data);
+ $data = $this->varint->pop_varint($data);
+
+ $timestamp = $this->varint->decode_varint($data);
+ $data = $this->varint->pop_varint($data);
+
+ $nonce = $this->varint->decode_varint($data);
+ $data = $this->varint->pop_varint($data);
+
+ return array("major_version" => $major_version,
"minor_version" => $minor_version,
"timestamp" => $timestamp,
"nonce" => $nonce);
}
-
- }
+}
diff --git a/src/Varint.php b/src/Varint.php
index 36ffb1b..b83f1cc 100644
--- a/src/Varint.php
+++ b/src/Varint.php
@@ -1,4 +1,5 @@
0) {
+ $encodedBytes[] = 0x80 | ($data & 0x7f);
+ $data >>= 7;
+ }
+
+ $encodedBytes[count($encodedBytes) - 1] &= 0x7f;
+ $bytes = call_user_func_array('pack', array_merge(array('C*'), $encodedBytes));
+ ;
+ return bin2hex($bytes);
+ }
+
+ // https://github.com/monero-project/research-lab/blob/master/source-code/StringCT-java/src/how/monero/hodl/util/VarInt.java
+ public function decode_varint($data)
+ {
+ $result = 0;
+ $c = 0;
+ $pos = 0;
- $encodedBytes = [];
- while ($data > 0)
- {
- $encodedBytes[] = 0x80 | ($data & 0x7f);
- $data >>= 7;
+ while (true) {
+ $isLastByteInVarInt = true;
+ $i = hexdec($data[$pos]);
+ if ($i >= 128) {
+ $isLastByteInVarInt = false;
+ $i -= 128;
}
+ $result += ($i * (pow(128, $c)));
+ $c += 1;
+ $pos += 1;
- $encodedBytes[count($encodedBytes)-1] &= 0x7f;
- $bytes = call_user_func_array('pack', array_merge(array('C*'), $encodedBytes));;
- return bin2hex($bytes);
- }
-
- // https://github.com/monero-project/research-lab/blob/master/source-code/StringCT-java/src/how/monero/hodl/util/VarInt.java
- public function decode_varint($data)
- {
- $result = 0;
- $c = 0;
- $pos = 0;
-
- while (true)
- {
- $isLastByteInVarInt = true;
- $i = hexdec($data[$pos]);
- if ($i >= 128)
- {
- $isLastByteInVarInt = false;
- $i -= 128;
- }
- $result += ($i * (pow(128, $c)));
- $c += 1;
- $pos += 1;
-
- if ($isLastByteInVarInt)
- break;
+ if ($isLastByteInVarInt) {
+ break;
}
- return $result;
}
-
- public function pop_varint($data)
- {
- $result = 0;
- $c = 0;
- $pos = 0;
-
- while (true)
- {
- $isLastByteInVarInt = true;
- $i = hexdec($data[$pos]);
- if ($i >= 128)
- {
- $isLastByteInVarInt = false;
- $i -= 128;
- }
- $result += ($i * (pow(128, $c)));
- $c += 1;
- $pos += 1;
-
- if ($isLastByteInVarInt)
- break;
+ return $result;
+ }
+
+ public function pop_varint($data)
+ {
+ $result = 0;
+ $c = 0;
+ $pos = 0;
+
+ while (true) {
+ $isLastByteInVarInt = true;
+ $i = hexdec($data[$pos]);
+ if ($i >= 128) {
+ $isLastByteInVarInt = false;
+ $i -= 128;
+ }
+ $result += ($i * (pow(128, $c)));
+ $c += 1;
+ $pos += 1;
+
+ if ($isLastByteInVarInt) {
+ break;
}
- for ($x = 0; $x < $pos; $x++)
- array_shift($data);
- return $data;
}
+ for ($x = 0; $x < $pos; $x++) {
+ array_shift($data);
+ }
+ return $data;
}
+}
diff --git a/src/base58.php b/src/base58.php
index 1f0ef53..b90b81b 100644
--- a/src/base58.php
+++ b/src/base58.php
@@ -1,4 +1,5 @@
hex_to_bin(): Invalid input type (must be a string)');
- }
- if (strlen($hex) % 2 != 0) {
- throw new Exception('base58->hex_to_bin(): Invalid input length (must be even)');
- }
-
- $res = array_fill(0, strlen($hex) / 2, 0);
- for ($i = 0; $i < strlen($hex) / 2; $i++) {
- $res[$i] = intval(substr($hex, $i * 2, $i * 2 + 2 - $i * 2), 16);
+ private function hex_to_bin($hex)
+ {
+ if (!is_string($hex)) {
+ throw new Exception('base58->hex_to_bin(): Invalid input type (must be a string)');
+ }
+ if (strlen($hex) % 2 != 0) {
+ throw new Exception('base58->hex_to_bin(): Invalid input length (must be even)');
+ }
+
+ $res = array_fill(0, strlen($hex) / 2, 0);
+ for ($i = 0; $i < strlen($hex) / 2; $i++) {
+ $res[$i] = intval(substr($hex, $i * 2, $i * 2 + 2 - $i * 2), 16);
+ }
+ return $res;
}
- return $res;
- }
/**
*
@@ -71,18 +73,18 @@ private function hex_to_bin($hex)
* @return string
*
*/
- private function bin_to_hex($bin)
- {
- if (!is_array($bin)) {
- throw new Exception('base58->bin_to_hex(): Invalid input type (must be an array)');
- }
+ private function bin_to_hex($bin)
+ {
+ if (!is_array($bin)) {
+ throw new Exception('base58->bin_to_hex(): Invalid input type (must be an array)');
+ }
- $res = [];
- for ($i = 0, $iMax = count($bin); $i < $iMax; $i++) {
- $res[] = substr('0'.dechex($bin[$i]), -2);
+ $res = [];
+ for ($i = 0, $iMax = count($bin); $i < $iMax; $i++) {
+ $res[] = substr('0' . dechex($bin[$i]), -2);
+ }
+ return join($res);
}
- return join($res);
- }
/**
*
@@ -93,18 +95,18 @@ private function bin_to_hex($bin)
* @return array
*
*/
- private function str_to_bin($str)
- {
- if (!is_string($str)) {
- throw new Exception('base58->str_to_bin(): Invalid input type (must be a string)');
- }
+ private function str_to_bin($str)
+ {
+ if (!is_string($str)) {
+ throw new Exception('base58->str_to_bin(): Invalid input type (must be a string)');
+ }
- $res = array_fill(0, strlen($str), 0);
- for ($i = 0, $iMax = strlen($str); $i < $iMax; $i++) {
- $res[$i] = ord($str[$i]);
+ $res = array_fill(0, strlen($str), 0);
+ for ($i = 0, $iMax = strlen($str); $i < $iMax; $i++) {
+ $res[$i] = ord($str[$i]);
+ }
+ return $res;
}
- return $res;
- }
/**
*
@@ -115,18 +117,18 @@ private function str_to_bin($str)
* @return string
*
*/
- private function bin_to_str($bin)
- {
- if (!is_array($bin)) {
- throw new Exception('base58->bin_to_str(): Invalid input type (must be an array)');
- }
+ private function bin_to_str($bin)
+ {
+ if (!is_array($bin)) {
+ throw new Exception('base58->bin_to_str(): Invalid input type (must be an array)');
+ }
- $res = array_fill(0, count($bin), 0);
- for ($i = 0, $iMax = count($bin); $i < $iMax; $i++) {
- $res[$i] = chr($bin[$i]);
+ $res = array_fill(0, count($bin), 0);
+ for ($i = 0, $iMax = count($bin); $i < $iMax; $i++) {
+ $res[$i] = chr($bin[$i]);
+ }
+ return preg_replace('/[[:^print:]]/', '', join($res)); // preg_replace necessary to strip errant non-ASCII characters eg. ''
}
- return preg_replace('/[[:^print:]]/', '', join($res)); // preg_replace necessary to strip errant non-ASCII characters eg. ''
- }
/**
*
@@ -137,38 +139,38 @@ private function bin_to_str($bin)
* @return number
*
*/
- private function uint8_be_to_64($data)
- {
- if (!is_array($data)) {
- throw new Exception ('base58->uint8_be_to_64(): Invalid input type (must be an array)');
+ private function uint8_be_to_64($data)
+ {
+ if (!is_array($data)) {
+ throw new Exception('base58->uint8_be_to_64(): Invalid input type (must be an array)');
+ }
+
+ $res = 0;
+ $i = 0;
+ switch (9 - count($data)) {
+ case 1:
+ $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
+ case 2:
+ $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
+ case 3:
+ $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
+ case 4:
+ $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
+ case 5:
+ $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
+ case 6:
+ $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
+ case 7:
+ $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
+ case 8:
+ $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
+ break;
+ default:
+ throw new Exception('base58->uint8_be_to_64: Invalid input length (1 <= count($data) <= 8)');
+ }
+ return $res;
}
- $res = 0;
- $i = 0;
- switch (9 - count($data)) {
- case 1:
- $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
- case 2:
- $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
- case 3:
- $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
- case 4:
- $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
- case 5:
- $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
- case 6:
- $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
- case 7:
- $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
- case 8:
- $res = bcadd(bcmul($res, bcpow(2, 8)), $data[$i++]);
- break;
- default:
- throw new Exception('base58->uint8_be_to_64: Invalid input length (1 <= count($data) <= 8)');
- }
- return $res;
- }
-
/**
*
* Convert a UInt64 (unsigned 64 bit integer) to a UInt8BE array
@@ -179,25 +181,25 @@ private function uint8_be_to_64($data)
* @return array
*
*/
- private function uint64_to_8_be($num, $size)
- {
- if (!is_numeric($num)) {
- throw new Exception ('base58->uint64_to_8_be(): Invalid input type ($num must be a number)');
- }
- if (!is_int($size)) {
- throw new Exception ('base58->uint64_to_8_be(): Invalid input type ($size must be an integer)');
+ private function uint64_to_8_be($num, $size)
+ {
+ if (!is_numeric($num)) {
+ throw new Exception('base58->uint64_to_8_be(): Invalid input type ($num must be a number)');
+ }
+ if (!is_int($size)) {
+ throw new Exception('base58->uint64_to_8_be(): Invalid input type ($size must be an integer)');
+ }
+ if ($size < 1 || $size > 8) {
+ throw new Exception('base58->uint64_to_8_be(): Invalid size (1 <= $size <= 8)');
+ }
+
+ $res = array_fill(0, $size, 0);
+ for ($i = $size - 1; $i >= 0; $i--) {
+ $res[$i] = bcmod($num, bcpow(2, 8));
+ $num = bcdiv($num, bcpow(2, 8));
+ }
+ return $res;
}
- if ($size < 1 || $size > 8) {
- throw new Exception ('base58->uint64_to_8_be(): Invalid size (1 <= $size <= 8)');
- }
-
- $res = array_fill(0, $size, 0);
- for ($i = $size - 1; $i >= 0; $i--) {
- $res[$i] = bcmod($num, bcpow(2, 8));
- $num = bcdiv($num, bcpow(2, 8));
- }
- return $res;
- }
/**
*
@@ -210,31 +212,31 @@ private function uint64_to_8_be($num, $size)
* @return array
*
*/
- private function encode_block($data, $buf, $index)
- {
- if (!is_array($data)) {
- throw new Exception('base58->encode_block(): Invalid input type ($data must be an array)');
- }
- if (!is_array($buf)) {
- throw new Exception('base58->encode_block(): Invalid input type ($buf must be an array)');
- }
- if (!is_int($index) && !is_float($index)) {
- throw new Exception('base58->encode_block(): Invalid input type ($index must be a number)');
+ private function encode_block($data, $buf, $index)
+ {
+ if (!is_array($data)) {
+ throw new Exception('base58->encode_block(): Invalid input type ($data must be an array)');
+ }
+ if (!is_array($buf)) {
+ throw new Exception('base58->encode_block(): Invalid input type ($buf must be an array)');
+ }
+ if (!is_int($index) && !is_float($index)) {
+ throw new Exception('base58->encode_block(): Invalid input type ($index must be a number)');
+ }
+ if (count($data) < 1 or count($data) > self::$full_encoded_block_size) {
+ throw new Exception('base58->encode_block(): Invalid input length (1 <= count($data) <= 8)');
+ }
+
+ $num = self::uint8_be_to_64($data);
+ $i = self::$encoded_block_sizes[count($data)] - 1;
+ while ($num > 0) {
+ $remainder = bcmod($num, 58);
+ $num = bcdiv($num, 58);
+ $buf[$index + $i] = ord(self::$alphabet[$remainder]);
+ $i--;
+ }
+ return $buf;
}
- if (count($data) < 1 or count($data) > self::$full_encoded_block_size) {
- throw new Exception('base58->encode_block(): Invalid input length (1 <= count($data) <= 8)');
- }
-
- $num = self::uint8_be_to_64($data);
- $i = self::$encoded_block_sizes[count($data)] - 1;
- while ($num > 0) {
- $remainder = bcmod($num, 58);
- $num = bcdiv($num, 58);
- $buf[$index + $i] = ord(self::$alphabet[$remainder]);
- $i--;
- }
- return $buf;
- }
/**
*
@@ -245,33 +247,33 @@ private function encode_block($data, $buf, $index)
* @return string
*
*/
- public function encode($hex)
- {
- if (!is_string($hex)) {
- throw new Exception ('base58->encode(): Invalid input type (must be a string)');
- }
+ public function encode($hex)
+ {
+ if (!is_string($hex)) {
+ throw new Exception('base58->encode(): Invalid input type (must be a string)');
+ }
- $data = self::hex_to_bin($hex);
- if (count($data) == 0) {
- return '';
- }
+ $data = self::hex_to_bin($hex);
+ if (count($data) == 0) {
+ return '';
+ }
- $full_block_count = floor(count($data) / self::$full_block_size);
- $last_block_size = count($data) % self::$full_block_size;
- $res_size = $full_block_count * self::$full_encoded_block_size + self::$encoded_block_sizes[$last_block_size];
+ $full_block_count = floor(count($data) / self::$full_block_size);
+ $last_block_size = count($data) % self::$full_block_size;
+ $res_size = $full_block_count * self::$full_encoded_block_size + self::$encoded_block_sizes[$last_block_size];
- $res = array_fill(0, $res_size, ord(self::$alphabet[0]));
+ $res = array_fill(0, $res_size, ord(self::$alphabet[0]));
- for ($i = 0; $i < $full_block_count; $i++) {
- $res = self::encode_block(array_slice($data, $i * self::$full_block_size, ($i * self::$full_block_size + self::$full_block_size) - ($i * self::$full_block_size)), $res, $i * self::$full_encoded_block_size);
- }
+ for ($i = 0; $i < $full_block_count; $i++) {
+ $res = self::encode_block(array_slice($data, $i * self::$full_block_size, ($i * self::$full_block_size + self::$full_block_size) - ($i * self::$full_block_size)), $res, $i * self::$full_encoded_block_size);
+ }
- if ($last_block_size > 0) {
- $res = self::encode_block(array_slice($data, $full_block_count * self::$full_block_size, $full_block_count * self::$full_block_size + $last_block_size), $res, $full_block_count * self::$full_encoded_block_size);
- }
+ if ($last_block_size > 0) {
+ $res = self::encode_block(array_slice($data, $full_block_count * self::$full_block_size, $full_block_count * self::$full_block_size + $last_block_size), $res, $full_block_count * self::$full_encoded_block_size);
+ }
- return self::bin_to_str($res);
- }
+ return self::bin_to_str($res);
+ }
/**
*
@@ -284,50 +286,50 @@ public function encode($hex)
* @return array
*
*/
- private function decode_block($data, $buf, $index)
- {
- if (!is_array($data)) {
- throw new Exception('base58->decode_block(): Invalid input type ($data must be an array)');
- }
- if (!is_array($buf)) {
- throw new Exception('base58->decode_block(): Invalid input type ($buf must be an array)');
- }
- if (!is_int($index) && !is_float($index)) {
- throw new Exception('base58->decode_block(): Invalid input type ($index must be a number)');
- }
-
- $res_size = self::index_of(self::$encoded_block_sizes, count($data));
- if ($res_size <= 0) {
- throw new Exception('base58->decode_block(): Invalid input length ($data must be a value from base58::$encoded_block_sizes)');
+ private function decode_block($data, $buf, $index)
+ {
+ if (!is_array($data)) {
+ throw new Exception('base58->decode_block(): Invalid input type ($data must be an array)');
+ }
+ if (!is_array($buf)) {
+ throw new Exception('base58->decode_block(): Invalid input type ($buf must be an array)');
+ }
+ if (!is_int($index) && !is_float($index)) {
+ throw new Exception('base58->decode_block(): Invalid input type ($index must be a number)');
+ }
+
+ $res_size = self::index_of(self::$encoded_block_sizes, count($data));
+ if ($res_size <= 0) {
+ throw new Exception('base58->decode_block(): Invalid input length ($data must be a value from base58::$encoded_block_sizes)');
+ }
+
+ $res_num = 0;
+ $order = 1;
+ for ($i = count($data) - 1; $i >= 0; $i--) {
+ $digit = strpos(self::$alphabet, chr($data[$i]));
+ if ($digit < 0) {
+ throw new Exception("base58->decode_block(): Invalid character ($digit \"{$digit}\" not found in base58::\$alphabet)");
+ }
+
+ $product = bcadd(bcmul($order, $digit), $res_num);
+ if ($product > bcpow(2, 64)) {
+ throw new Exception('base58->decode_block(): Integer overflow ($product exceeds the maximum 64bit integer)');
+ }
+
+ $res_num = $product;
+ $order = bcmul($order, 58);
+ }
+ if ($res_size < self::$full_block_size && bcpow(2, 8 * $res_size) <= 0) {
+ throw new Exception('base58->decode_block(): Integer overflow (bcpow(2, 8 * $res_size) exceeds the maximum 64bit integer)');
+ }
+
+ $tmp_buf = self::uint64_to_8_be($res_num, $res_size);
+ for ($i = 0, $iMax = count($tmp_buf); $i < $iMax; $i++) {
+ $buf[$i + $index] = $tmp_buf[$i];
+ }
+ return $buf;
}
- $res_num = 0;
- $order = 1;
- for ($i = count($data) - 1; $i >= 0; $i--) {
- $digit = strpos(self::$alphabet, chr($data[$i]));
- if ($digit < 0) {
- throw new Exception("base58->decode_block(): Invalid character ($digit \"{$digit}\" not found in base58::\$alphabet)");
- }
-
- $product = bcadd(bcmul($order, $digit), $res_num);
- if ($product > bcpow(2, 64)) {
- throw new Exception('base58->decode_block(): Integer overflow ($product exceeds the maximum 64bit integer)');
- }
-
- $res_num = $product;
- $order = bcmul($order, 58);
- }
- if ($res_size < self::$full_block_size && bcpow(2, 8 * $res_size) <= 0) {
- throw new Exception('base58->decode_block(): Integer overflow (bcpow(2, 8 * $res_size) exceeds the maximum 64bit integer)');
- }
-
- $tmp_buf = self::uint64_to_8_be($res_num, $res_size);
- for ($i = 0, $iMax = count($tmp_buf); $i < $iMax; $i++) {
- $buf[$i + $index] = $tmp_buf[$i];
- }
- return $buf;
- }
-
/**
*
* Decode a Base58 string to hexadecimal (Base16)
@@ -337,37 +339,37 @@ private function decode_block($data, $buf, $index)
* @return string
*
*/
- public function decode($enc)
- {
- if (!is_string($enc)) {
- throw new Exception ('base58->decode(): Invalid input type (must be a string)');
- }
+ public function decode($enc)
+ {
+ if (!is_string($enc)) {
+ throw new Exception('base58->decode(): Invalid input type (must be a string)');
+ }
- $enc = self::str_to_bin($enc);
- if (count($enc) == 0) {
- return '';
- }
- $full_block_count = floor(bcdiv(count($enc), self::$full_encoded_block_size));
- $last_block_size = bcmod(count($enc), self::$full_encoded_block_size);
- $last_block_decoded_size = self::index_of(self::$encoded_block_sizes, $last_block_size);
+ $enc = self::str_to_bin($enc);
+ if (count($enc) == 0) {
+ return '';
+ }
+ $full_block_count = floor(bcdiv(count($enc), self::$full_encoded_block_size));
+ $last_block_size = bcmod(count($enc), self::$full_encoded_block_size);
+ $last_block_decoded_size = self::index_of(self::$encoded_block_sizes, $last_block_size);
- $data_size = $full_block_count * self::$full_block_size + $last_block_decoded_size;
+ $data_size = $full_block_count * self::$full_block_size + $last_block_decoded_size;
- if ($data_size == -1) {
- return '';
- }
+ if ($data_size == -1) {
+ return '';
+ }
- $data = array_fill(0, $data_size, 0);
- for ($i = 0; $i <= $full_block_count; $i++) {
- $data = self::decode_block(array_slice($enc, $i * self::$full_encoded_block_size, ($i * self::$full_encoded_block_size + self::$full_encoded_block_size) - ($i * self::$full_encoded_block_size)), $data, $i * self::$full_block_size);
- }
+ $data = array_fill(0, $data_size, 0);
+ for ($i = 0; $i <= $full_block_count; $i++) {
+ $data = self::decode_block(array_slice($enc, $i * self::$full_encoded_block_size, ($i * self::$full_encoded_block_size + self::$full_encoded_block_size) - ($i * self::$full_encoded_block_size)), $data, $i * self::$full_block_size);
+ }
- if ($last_block_size > 0) {
- $data = self::decode_block(array_slice($enc, $full_block_count * self::$full_encoded_block_size, $full_block_count * self::$full_encoded_block_size + $last_block_size), $data, $full_block_count * self::$full_block_size);
- }
+ if ($last_block_size > 0) {
+ $data = self::decode_block(array_slice($enc, $full_block_count * self::$full_encoded_block_size, $full_block_count * self::$full_encoded_block_size + $last_block_size), $data, $full_block_count * self::$full_block_size);
+ }
- return self::bin_to_hex($data);
- }
+ return self::bin_to_hex($data);
+ }
/**
*
@@ -380,16 +382,20 @@ public function decode($enc)
* @return number The index of the element found (or -1 for no match)
*
*/
- private function index_of($haystack, $needle)
- {
- if (!is_array($haystack)) {
- throw new Exception ('base58->decode(): Invalid input type ($haystack must be an array)');
+ private function index_of($haystack, $needle)
+ {
+ if (!is_array($haystack)) {
+ throw new Exception('base58->decode(): Invalid input type ($haystack must be an array)');
+ }
+ // if (gettype($needle) != 'string') {
+ // throw new Exception ('base58->decode(): Invalid input type ($needle must be a string)');
+ // }
+
+ foreach ($haystack as $key => $value) {
+ if ($value === $needle) {
+ return $key;
+ }
+ }
+ return -1;
}
- // if (gettype($needle) != 'string') {
- // throw new Exception ('base58->decode(): Invalid input type ($needle must be a string)');
- // }
-
- foreach ($haystack as $key => $value) if ($value === $needle) return $key;
- return -1;
- }
}
diff --git a/src/daemonRPC.php b/src/daemonRPC.php
index 0ec7b2c..7c4d1cc 100644
--- a/src/daemonRPC.php
+++ b/src/daemonRPC.php
@@ -1,4 +1,5 @@
host = $host;
- $this->port = $port;
- $this->protocol = $protocol;
- $this->user = $user;
- $this->password = $password;
- $this->check_SSL = $SSL;
-
- $this->url = $protocol.'://'.$host.':'.$port.'/';
- $this->client = new jsonRPCClient($this->url, $this->user, $this->password, $this->check_SSL);
- }
+ function __construct($host = '127.0.0.1', $port = 18081, $SSL = true, $user = null, $password = null)
+ {
+ if (is_array($host)) { // Parameters passed in as object/dictionary
+ $params = $host;
+
+ if (array_key_exists('host', $params)) {
+ $host = $params['host'];
+ } else {
+ $host = '127.0.0.1';
+ }
+ if (array_key_exists('port', $params)) {
+ $port = $params['port'];
+ }
+ if (array_key_exists('protocol', $params)) {
+ $protocol = $params['protocol'];
+ }
+ if (array_key_exists('user', $params)) {
+ $user = $params['user'];
+ }
+ if (array_key_exists('password', $params)) {
+ $password = $params['password'];
+ }
+ }
+
+ if ($SSL) {
+ $protocol = 'https';
+ } else {
+ $protocol = 'http';
+ }
+
+ $this->host = $host;
+ $this->port = $port;
+ $this->protocol = $protocol;
+ $this->user = $user;
+ $this->password = $password;
+ $this->check_SSL = $SSL;
+
+ $this->url = $protocol . '://' . $host . ':' . $port . '/';
+ $this->client = new jsonRPCClient($this->url, $this->user, $this->password, $this->check_SSL);
+ }
/**
*
@@ -108,10 +110,10 @@ function __construct($host = '127.0.0.1', $port = 18081, $SSL = true, $user = nu
* @return string Call result
*
*/
- protected function _run($method, $params = null, $path = 'json_rpc')
- {
- return $this->client->_run($method, $params, $path);
- }
+ protected function _run($method, $params = null, $path = 'json_rpc')
+ {
+ return $this->client->_run($method, $params, $path);
+ }
/**
*
@@ -125,10 +127,10 @@ protected function _run($method, $params = null, $path = 'json_rpc')
* }
*
*/
- public function getblockcount()
- {
- return $this->_run('getblockcount');
- }
+ public function getblockcount()
+ {
+ return $this->_run('getblockcount');
+ }
/**
*
@@ -139,12 +141,12 @@ public function getblockcount()
* @return string Example: 'e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6'
*
*/
- public function on_getblockhash($height)
- {
- $params = array($height);
+ public function on_getblockhash($height)
+ {
+ $params = array($height);
- return $this->_run('on_getblockhash', $params);
- }
+ return $this->_run('on_getblockhash', $params);
+ }
/**
*
@@ -163,12 +165,12 @@ public function on_getblockhash($height)
* }
*
*/
- public function getblocktemplate($wallet_address, $reserve_size)
- {
- $params = array('wallet_address' => $wallet_address, 'reserve_size' => $reserve_size);
+ public function getblocktemplate($wallet_address, $reserve_size)
+ {
+ $params = array('wallet_address' => $wallet_address, 'reserve_size' => $reserve_size);
- return $this->client->_run('getblocktemplate', $params, null);
- }
+ return $this->client->_run('getblocktemplate', $params, null);
+ }
/**
*
@@ -179,10 +181,10 @@ public function getblocktemplate($wallet_address, $reserve_size)
* @return // TODO: example
*
*/
- public function submitblock($block)
- {
- return $this->_run('submitblock', $block);
- }
+ public function submitblock($block)
+ {
+ return $this->_run('submitblock', $block);
+ }
/**
*
@@ -208,10 +210,10 @@ public function submitblock($block)
* }
*
*/
- public function getlastblockheader()
- {
- return $this->_run('getlastblockheader');
- }
+ public function getlastblockheader()
+ {
+ return $this->_run('getlastblockheader');
+ }
/**
*
@@ -237,12 +239,12 @@ public function getlastblockheader()
* }
*
*/
- public function getblockheaderbyhash($hash)
- {
- $params = array('hash' => $hash);
+ public function getblockheaderbyhash($hash)
+ {
+ $params = array('hash' => $hash);
- return $this->_run('getblockheaderbyhash', $params);
- }
+ return $this->_run('getblockheaderbyhash', $params);
+ }
/**
*
@@ -268,10 +270,10 @@ public function getblockheaderbyhash($hash)
* }
*
*/
- public function getblockheaderbyheight($height)
- {
- return $this->_run('getblockheaderbyheight', $height);
- }
+ public function getblockheaderbyheight($height)
+ {
+ return $this->_run('getblockheaderbyheight', $height);
+ }
/**
*
@@ -299,12 +301,12 @@ public function getblockheaderbyheight($height)
* }
*
*/
- public function getblock_by_hash($hash)
- {
- $params = array('hash' => $hash);
+ public function getblock_by_hash($hash)
+ {
+ $params = array('hash' => $hash);
- return $this->_run('getblock', $params);
- }
+ return $this->_run('getblock', $params);
+ }
/**
*
@@ -332,12 +334,12 @@ public function getblock_by_hash($hash)
* }
*
*/
- public function getblock_by_height($height)
- {
- $params = array('height' => $height);
+ public function getblock_by_height($height)
+ {
+ $params = array('height' => $height);
- return $this->_run('getblock', $params);
- }
+ return $this->_run('getblock', $params);
+ }
/**
*
@@ -370,10 +372,10 @@ public function getblock_by_height($height)
* }
*
*/
- public function get_connections()
- {
- return $this->_run('get_connections');
- }
+ public function get_connections()
+ {
+ return $this->_run('get_connections');
+ }
/**
*
@@ -399,10 +401,10 @@ public function get_connections()
* }
*
*/
- public function get_info()
- {
- return $this->_run('get_info');
- }
+ public function get_info()
+ {
+ return $this->_run('get_info');
+ }
/**
*
@@ -439,10 +441,10 @@ public function get_info()
* }
*
*/
- public function hardfork_info()
- {
- return $this->_run('hard_fork_info');
- }
+ public function hardfork_info()
+ {
+ return $this->_run('hard_fork_info');
+ }
/**
*
@@ -455,15 +457,15 @@ public function hardfork_info()
* }
*
*/
- public function set_bans($bans)
- {
- if (is_string($bans)) {
- $bans = array($bans);
- }
- $params = array('bans' => $bans);
+ public function set_bans($bans)
+ {
+ if (is_string($bans)) {
+ $bans = array($bans);
+ }
+ $params = array('bans' => $bans);
- return $this->_run('set_bans', $params);
- }
+ return $this->_run('set_bans', $params);
+ }
/**
*
@@ -471,10 +473,10 @@ public function set_bans($bans)
* }
*
*/
- public function setbans($bans)
- {
- return $this->set_bans($bans);
- }
+ public function setbans($bans)
+ {
+ return $this->set_bans($bans);
+ }
/**
*
@@ -491,20 +493,20 @@ public function setbans($bans)
* }
*
*/
- public function get_bans()
- {
- return $this->_run('get_bans');
- }
+ public function get_bans()
+ {
+ return $this->_run('get_bans');
+ }
/**
*
* Alias of get_bans
*
*/
- public function getbans()
- {
- return $this->get_bans();
- }
+ public function getbans()
+ {
+ return $this->get_bans();
+ }
/**
*
@@ -517,15 +519,15 @@ public function getbans()
*/
public function flush_txpool($txids)
{
- return $this->_run('flush_txpool', $txids);
+ return $this->_run('flush_txpool', $txids);
}
-
+
/**
* Alias of flush_txpool
*/
public function flushtxpool($txids)
{
- return $this->flush_txpool($txids);
+ return $this->flush_txpool($txids);
}
/**
@@ -533,65 +535,65 @@ public function flushtxpool($txids)
* Get height
*
*/
- public function get_height()
- {
- return $this->_run(null, null, 'getheight');
- }
+ public function get_height()
+ {
+ return $this->_run(null, null, 'getheight');
+ }
/**
*
* Get transactions
*
*/
- public function get_transactions($txs_hashes = NULL)
+ public function get_transactions($txs_hashes = null)
{
$params = array('txs_hashes' => $txs_hashes, 'decode_as_json' => true);
return $this->_run(null, null, 'gettransactions');
}
-
-
+
+
public function get_alt_blocks_hashes()
{
return $this->_run(null, null, 'get_alt_blocks_hashes');
}
-
+
public function is_key_image_spent($key_images)
{
if (is_string($key_images)) {
$key_images = array($key_images);
}
- if(!is_array($key_images)){
+ if (!is_array($key_images)) {
throw new Exception('Error: key images must be an array or a string');
}
$params = array('key_images' => $key_images);
return $this->_run(null, $params, 'is_key_image_spent');
}
-
+
public function send_raw_transaction($tx_as_hex, $do_not_relay = false, $do_sanity_checks = true)
{
$params = array('tx_as_hex' => $tx_as_hex, 'do_not_relay' => $do_not_relay, 'do_sanity_checks' => $do_sanity_checks);
return $this->_run(null, $params, 'send_raw_transaction');
}
-
+
public function start_mining($background_mining, $ignore_battery = false, $miner_address, $threads_count = 1)
{
- if($threads_count < 0){
+ if ($threads_count < 0) {
throw new Exception('Error: threads_count must be a positive integer');
}
$params = array('do_background_mining' => $background_mining, 'ignore_battery' => $ignore_battery, 'miner_address' => $miner_address, 'threads_count' => $threads_count);
return $this->_run(null, $params, 'start_mining');
}
-
+
public function stop_mining()
{
return $this->_run(null, null, 'stop_mining');
}
-
+
public function mining_status()
{
return $this->_run(null, null, 'mining_status');
}
-
+
public function save_bc()
{
return $this->_run(null, null, 'save_bc');
@@ -602,77 +604,77 @@ public function get_peer_list($public_only = true)
$params = array('public_only' => $public_only);
return $this->_run(null, $params, 'get_peer_list');
}
-
+
public function set_log_hash_rate($visible = true)
{
$params = array('visible' => $visible);
return $this->_run(null, $params, 'set_log_hash_rate');
}
-
+
public function set_log_level($log_level = 0)
{
- if(!is_int($log_level)){
+ if (!is_int($log_level)) {
throw new Exception('Error: log_level must be an integer');
}
$params = array('level' => $log_level);
return $this->_run(null, $params, 'set_log_level');
}
-
+
public function set_log_categories($category)
{
$params = array('categories' => $category);
return $this->_run(null, $params, 'set_log_categories');
}
-
+
public function get_transaction_pool()
{
- return $this->_run(null, null, 'get_transaction_pool');
+ return $this->_run(null, null, 'get_transaction_pool');
}
-
- public function get_transaction_pool_stats(){
+
+ public function get_transaction_pool_stats()
+ {
return $this->_run(null, null, 'get_transaction_pool_stats');
}
-
+
public function stop_daemon()
{
return $this->_run(null, null, 'stop_daemon');
}
-
+
public function get_limit()
{
return $this->_run(null, null, 'get_limit');
}
-
+
public function set_limit($limit_down, $limit_up)
{
$params = array('limit_down' => $limit_down, 'limit_up' => $limit_up);
return $this->_run(null, $params, 'set_limit');
}
-
+
public function out_peers()
{
return $this->_run(null, null, 'out_peers');
}
-
+
public function in_peers()
{
return $this->_run(null, null, 'in_peers');
}
-
+
public function start_save_graph()
{
return $this->_run(null, null, 'start_save_graph');
}
-
+
public function stop_save_graph()
{
return $this->_run(null, null, 'stop_save_graph');
}
-
+
public function get_outs($outputs)
{
$params = array('outputs' => $outputs);
return $this->_run(null, null, 'get_outs');
}
-
}
diff --git a/src/ed25519.php b/src/ed25519.php
index df8c8e3..57ab7c6 100644
--- a/src/ed25519.php
+++ b/src/ed25519.php
@@ -1,4 +1,5 @@
pymod(gmp_sub(gmp_pow($x, 2), $xx), $this->q) != 0) {
$x = $this->pymod(gmp_mul($x, $this->I), $this->q);
}
- if (substr($x, -1)%2 != 0) {
+ if (substr($x, -1) % 2 != 0) {
$x = gmp_sub($this->q, $x);
}
} else {
@@ -140,7 +141,7 @@ public function xrecover($y)
if ($this->pymod(bcsub(bcpow($x, 2), $xx), $this->q) != 0) {
$x = $this->pymod(bcmul($x, $this->I), $this->q);
}
- if (substr($x, -1)%2 != 0) {
+ if (substr($x, -1) % 2 != 0) {
$x = bcsub($this->q, $x);
}
}
@@ -181,7 +182,7 @@ public function scalarmult($P, $e)
}
$Q = $this->scalarmult($P, gmp_div($e, 2, 0));
$Q = $this->edwards($Q, $Q);
- if (substr($e, -1)%2 == 1) {
+ if (substr($e, -1) % 2 == 1) {
$Q = $this->edwards($Q, $P);
}
} else {
@@ -190,7 +191,7 @@ public function scalarmult($P, $e)
}
$Q = $this->scalarmult($P, bcdiv($e, 2, 0));
$Q = $this->edwards($Q, $Q);
- if (substr($e, -1)%2 == 1) {
+ if (substr($e, -1) % 2 == 1) {
$Q = $this->edwards($Q, $P);
}
}
@@ -211,7 +212,7 @@ public function scalarloop($P, $e)
foreach ($temp as $e) {
if ($e == 1) {
$Q = $this->edwards(array(0, 1), $P);
- } elseif (substr($e, -1)%2 == 1) {
+ } elseif (substr($e, -1) % 2 == 1) {
$Q = $this->edwards($this->edwards($Q, $Q), $P);
} else {
$Q = $this->edwards($Q, $Q);
@@ -228,7 +229,7 @@ public function scalarloop($P, $e)
foreach ($temp as $e) {
if ($e == 1) {
$Q = $this->edwards(array(0, 1), $P);
- } elseif (substr($e, -1)%2 == 1) {
+ } elseif (substr($e, -1) % 2 == 1) {
$Q = $this->edwards($this->edwards($Q, $Q), $P);
} else {
$Q = $this->edwards($Q, $Q);
@@ -242,10 +243,10 @@ public function scalarloop($P, $e)
public function bitsToString($bits)
{
$string = '';
- for ($i = 0; $i < $this->b/8; $i++) {
+ for ($i = 0; $i < $this->b / 8; $i++) {
$sum = 0;
for ($j = 0; $j < 8; $j++) {
- $bit = $bits[$i*8+$j];
+ $bit = $bits[$i * 8 + $j];
$sum += (int) $bit << $j;
}
$string .= chr($sum);
@@ -257,15 +258,15 @@ public function bitsToString($bits)
public function dec2bin_i($decimal_i)
{
if ($this->gmp) {
- $binary_i = '';
+ $binary_i = '';
do {
- $binary_i = substr($decimal_i, -1)%2 .$binary_i;
+ $binary_i = substr($decimal_i, -1) % 2 . $binary_i;
$decimal_i = gmp_div($decimal_i, '2', 0);
} while (gmp_cmp($decimal_i, '0'));
} else {
$binary_i = '';
do {
- $binary_i = substr($decimal_i, -1)%2 .$binary_i;
+ $binary_i = substr($decimal_i, -1) % 2 . $binary_i;
$decimal_i = bcdiv($decimal_i, '2', 0);
} while (bccomp($decimal_i, '0'));
}
@@ -283,8 +284,8 @@ public function encodeint($y)
public function encodepoint($P)
{
list($x, $y) = $P;
- $bits = substr(str_pad(strrev($this->dec2bin_i($y)), $this->b-1, '0', STR_PAD_RIGHT), 0, $this->b-1);
- $bits .= (substr($x, -1)%2 == 1 ? '1' : '0');
+ $bits = substr(str_pad(strrev($this->dec2bin_i($y)), $this->b - 1, '0', STR_PAD_RIGHT), 0, $this->b - 1);
+ $bits .= (substr($x, -1) % 2 == 1 ? '1' : '0');
return $this->bitsToString($bits);
}
@@ -292,9 +293,9 @@ public function encodepoint($P)
public function bit($h, $i)
{
if ($this->gmp) {
- return (ord($h[(int) gmp_div($i, 8, 0)]) >> substr($i, -3)%8) & 1;
+ return (ord($h[(int) gmp_div($i, 8, 0)]) >> substr($i, -3) % 8) & 1;
} else {
- return (ord($h[(int) bcdiv($i, 8, 0)]) >> substr($i, -3)%8) & 1;
+ return (ord($h[(int) bcdiv($i, 8, 0)]) >> substr($i, -3) % 8) & 1;
}
}
@@ -310,19 +311,19 @@ public function publickey($sk)
if ($this->gmp) {
$h = $this->H($sk);
$sum = 0;
- for ($i = 3; $i < $this->b-2; $i++) {
+ for ($i = 3; $i < $this->b - 2; $i++) {
$sum = gmp_add($sum, gmp_mul(gmp_pow(2, $i), $this->bit($h, $i)));
}
- $a = gmp_add(gmp_pow(2, $this->b-2), $sum);
+ $a = gmp_add(gmp_pow(2, $this->b - 2), $sum);
$A = $this->scalarmult($this->B, $a);
$data = $this->encodepoint($A);
} else {
$h = $this->H($sk);
$sum = 0;
- for ($i = 3; $i < $this->b-2; $i++) {
+ for ($i = 3; $i < $this->b - 2; $i++) {
$sum = bcadd($sum, bcmul(bcpow(2, $i), $this->bit($h, $i)));
}
- $a = bcadd(bcpow(2, $this->b-2), $sum);
+ $a = bcadd(bcpow(2, $this->b - 2), $sum);
$A = $this->scalarmult($this->B, $a);
$data = $this->encodepoint($A);
}
@@ -335,13 +336,13 @@ public function Hint($m)
if ($this->gmp) {
$h = $this->H($m);
$sum = 0;
- for ($i = 0; $i < $this->b*2; $i++) {
+ for ($i = 0; $i < $this->b * 2; $i++) {
$sum = gmp_add($sum, gmp_mul(gmp_pow(2, $i), $this->bit($h, $i)));
}
} else {
$h = $this->H($m);
$sum = 0;
- for ($i = 0; $i < $this->b*2; $i++) {
+ for ($i = 0; $i < $this->b * 2; $i++) {
$sum = bcadd($sum, bcmul(bcpow(2, $i), $this->bit($h, $i)));
}
}
@@ -354,26 +355,26 @@ public function signature($m, $sk, $pk)
if ($this->gmp) {
$h = $this->H($sk);
$a = gmp_pow(2, (gmp_sub($this->b, 2)));
- for ($i = 3; $i < $this->b-2; $i++) {
+ for ($i = 3; $i < $this->b - 2; $i++) {
$a = gmp_add($a, gmp_mul(gmp_pow(2, $i), $this->bit($h, $i)));
}
- $r = $this->Hint(substr($h, $this->b/8, ($this->b/4-$this->b/8)).$m);
+ $r = $this->Hint(substr($h, $this->b / 8, ($this->b / 4 - $this->b / 8)) . $m);
$R = $this->scalarmult($this->B, $r);
$encR = $this->encodepoint($R);
- $S = $this->pymod(gmp_add($r, gmp_mul($this->Hint($encR.$pk.$m), $a)), $this->l);
+ $S = $this->pymod(gmp_add($r, gmp_mul($this->Hint($encR . $pk . $m), $a)), $this->l);
} else {
$h = $this->H($sk);
$a = bcpow(2, (bcsub($this->b, 2)));
- for ($i = 3; $i < $this->b-2; $i++) {
+ for ($i = 3; $i < $this->b - 2; $i++) {
$a = bcadd($a, bcmul(bcpow(2, $i), $this->bit($h, $i)));
}
- $r = $this->Hint(substr($h, $this->b/8, ($this->b/4-$this->b/8)).$m);
+ $r = $this->Hint(substr($h, $this->b / 8, ($this->b / 4 - $this->b / 8)) . $m);
$R = $this->scalarmult($this->B, $r);
$encR = $this->encodepoint($R);
- $S = $this->pymod(bcadd($r, bcmul($this->Hint($encR.$pk.$m), $a)), $this->l);
+ $S = $this->pymod(bcadd($r, bcmul($this->Hint($encR . $pk . $m), $a)), $this->l);
}
- return $encR.$this->encodeint($S);
+ return $encR . $this->encodeint($S);
}
public function isoncurve($P)
@@ -424,11 +425,11 @@ public function decodepoint($s)
{
if ($this->gmp) {
$y = 0;
- for ($i = 0; $i < $this->b-1; $i++) {
+ for ($i = 0; $i < $this->b - 1; $i++) {
$y = gmp_add($y, gmp_mul(gmp_pow(2, $i), $this->bit($s, $i)));
}
$x = $this->xrecover($y);
- if (substr($x, -1)%2 != $this->bit($s, $this->b-1)) {
+ if (substr($x, -1) % 2 != $this->bit($s, $this->b - 1)) {
$x = gmp_sub($this->q, $x);
}
$P = array($x, $y);
@@ -437,11 +438,11 @@ public function decodepoint($s)
}
} else {
$y = 0;
- for ($i = 0; $i < $this->b-1; $i++) {
+ for ($i = 0; $i < $this->b - 1; $i++) {
$y = bcadd($y, bcmul(bcpow(2, $i), $this->bit($s, $i)));
}
$x = $this->xrecover($y);
- if (substr($x, -1)%2 != $this->bit($s, $this->b-1)) {
+ if (substr($x, -1) % 2 != $this->bit($s, $this->b - 1)) {
$x = bcsub($this->q, $x);
}
$P = array($x, $y);
@@ -455,20 +456,20 @@ public function decodepoint($s)
public function checkvalid($s, $m, $pk)
{
- if (strlen($s) != $this->b/4) {
+ if (strlen($s) != $this->b / 4) {
throw new Exception('Signature length is wrong');
}
- if (strlen($pk) != $this->b/8) {
- throw new Exception('Public key length is wrong: '.strlen($pk));
+ if (strlen($pk) != $this->b / 8) {
+ throw new Exception('Public key length is wrong: ' . strlen($pk));
}
- $R = $this->decodepoint(substr($s, 0, $this->b/8));
+ $R = $this->decodepoint(substr($s, 0, $this->b / 8));
try {
$A = $this->decodepoint($pk);
} catch (Exception $e) {
return false;
}
- $S = $this->decodeint(substr($s, $this->b/8, $this->b/4));
- $h = $this->Hint($this->encodepoint($R).$pk.$m);
+ $S = $this->decodeint(substr($s, $this->b / 8, $this->b / 4));
+ $h = $this->Hint($this->encodepoint($R) . $pk . $m);
return $this->scalarmult($this->B, $S) == $this->edwards($R, $this->scalarmult($A, $h));
}
@@ -483,7 +484,7 @@ public function scalarmult_base($e)
}
$Q = $this->scalarmult($this->B, gmp_div($e, 2, 0));
$Q = $this->edwards($Q, $Q);
- if (substr($e, -1)%2 == 1) {
+ if (substr($e, -1) % 2 == 1) {
$Q = $this->edwards($Q, $this->B);
}
} else {
@@ -492,7 +493,7 @@ public function scalarmult_base($e)
}
$Q = $this->scalarmult($this->B, bcdiv($e, 2, 0));
$Q = $this->edwards($Q, $Q);
- if (substr($e, -1)%2 == 1) {
+ if (substr($e, -1) % 2 == 1) {
$Q = $this->edwards($Q, $this->B);
}
}
diff --git a/src/jsonRPCClient.php b/src/jsonRPCClient.php
index b10435a..fb1c924 100644
--- a/src/jsonRPCClient.php
+++ b/src/jsonRPCClient.php
@@ -1,4 +1,5 @@
* http://implix.com
*/
+
namespace MoneroIntegrations\MoneroPhp;
use InvalidArgumentException;
@@ -15,7 +17,9 @@
class jsonRPCClient
{
- protected $url = null, $is_debug = false, $parameters_structure = 'array';
+ protected $url = null;
+ protected $is_debug = false;
+ protected $parameters_structure = 'array';
private $username;
private $password;
private $SSL;
@@ -57,12 +61,9 @@ public function setDebug($pIsDebug)
public function setCurlOptions($pOptionsArray)
{
- if (is_array($pOptionsArray))
- {
+ if (is_array($pOptionsArray)) {
$this->curl_options = $pOptionsArray + $this->curl_options;
- }
- else
- {
+ } else {
throw new InvalidArgumentException('Invalid options type.');
}
return $this;
@@ -85,16 +86,14 @@ public function _run($pMethod, $pParams, $path)
$responseDecoded = json_decode($responseMessage, true);
// check if decoding json generated any errors
$jsonErrorMsg = json_last_error_msg();
- $this->validate( !is_null($jsonErrorMsg) && $jsonErrorMsg !== 'No error' , $jsonErrorMsg . ': ' . $responseMessage);
- if (isset($responseDecoded['error']))
- {
+ $this->validate(!is_null($jsonErrorMsg) && $jsonErrorMsg !== 'No error', $jsonErrorMsg . ': ' . $responseMessage);
+ if (isset($responseDecoded['error'])) {
$errorMessage = 'Request have return error: ' . $responseDecoded['error']['message'] . '; ' . "\n" .
'Request: ' . $request . '; ';
- if (isset($responseDecoded['error']['data']))
- {
+ if (isset($responseDecoded['error']['data'])) {
$errorMessage .= "\n" . 'Error data: ' . $responseDecoded['error']['data'];
}
- $this->validate( !is_null($responseDecoded['error']), $errorMessage);
+ $this->validate(!is_null($responseDecoded['error']), $errorMessage);
}
return $responseDecoded['result'] ?? -1;
}
@@ -103,11 +102,10 @@ protected function & getResponse(&$pRequest, &$path)
{
// do the actual connection
$ch = curl_init();
- if (!$ch)
- {
+ if (!$ch) {
throw new RuntimeException('Could\'t initialize a cURL session');
}
- curl_setopt($ch, CURLOPT_URL, $this->url.$path);
+ curl_setopt($ch, CURLOPT_URL, $this->url . $path);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, $this->username . ":" . $this->password);
curl_setopt($ch, CURLOPT_POST, 1);
@@ -116,29 +114,25 @@ protected function & getResponse(&$pRequest, &$path)
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- if ($this->SSL)
- {
+ if ($this->SSL) {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '2');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
- }else{
+ } else {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
- if (!curl_setopt_array($ch, $this->curl_options))
- {
+ if (!curl_setopt_array($ch, $this->curl_options)) {
throw new RuntimeException('Error while setting curl options');
}
// send the request
$response = curl_exec($ch);
// check http status code
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- if (isset($this->httpErrors[$httpCode]))
- {
+ if (isset($this->httpErrors[$httpCode])) {
throw new RuntimeException('Response Http Error - ' . $this->httpErrors[$httpCode]);
}
// check for curl error
- if (0 < curl_errno($ch))
- {
- throw new RuntimeException('Unable to connect to '.$this->url . ' Error: ' . curl_error($ch));
+ if (0 < curl_errno($ch)) {
+ throw new RuntimeException('Unable to connect to ' . $this->url . ' Error: ' . curl_error($ch));
}
// close the connection
curl_close($ch);
@@ -147,8 +141,7 @@ protected function & getResponse(&$pRequest, &$path)
public function validate($pFailed, $pErrMsg)
{
- if ($pFailed)
- {
+ if ($pFailed) {
throw new RuntimeException($pErrMsg);
}
}
@@ -157,16 +150,14 @@ protected function debug($pAdd, $pShow = false)
{
static $debug, $startTime;
// is_debug off return
- if (false === $this->is_debug)
- {
+ if (false === $this->is_debug) {
return;
}
// add
$debug .= $pAdd;
// get starttime
$startTime = empty($startTime) ? array_sum(explode(' ', microtime())) : $startTime;
- if (true === $pShow and !empty($debug))
- {
+ if (true === $pShow and !empty($debug)) {
// get endtime
$endTime = array_sum(explode(' ', microtime()));
// performance summary
diff --git a/src/mnemonic.php b/src/mnemonic.php
index 15476ca..798b29e 100644
--- a/src/mnemonic.php
+++ b/src/mnemonic.php
@@ -6,7 +6,7 @@
*
* Translated to PHP from https://raw.githubusercontent.com/bigreddmachine/MoneroPy/master/moneropy/mnemonic.py
* initially using https://github.com/dan-da/py2php. mnemonic.php contains the following notice.
-
+
* Electrum - lightweight Bitcoin client
* Copyright (C) 2011 thomasv@gitorious
*
@@ -19,7 +19,7 @@
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
+ * included in all copies or substantial portions of the Software.
* Further improvements, notably support for multiple languages/wordsets adapted
* from mnemonic.js found at https://xmr.llcoins.net/js/mnemonic.js which is in
* the public domain.
@@ -34,17 +34,18 @@
* All access to this class is via static methods, so it never needs to
* be instantiated.
*/
-class mnemonic {
-
+class mnemonic
+{
/**
* Given a mnemonic seed word list, return a string of the seed checksum.
*/
- static function checksum($words, $prefix_len) {
+ static function checksum($words, $prefix_len)
+ {
$plen = $prefix_len;
$words = array_slice($words, null, count($words) > 13 ? 24 : 12);
-
+
$wstr = '';
- foreach($words as $word) {
+ foreach ($words as $word) {
$wstr .= ($plen == 0 ? $word : mb_substr($word, 0, $plen));
}
@@ -52,24 +53,26 @@ static function checksum($words, $prefix_len) {
$idx = $checksum % count($words);
return $words[$idx];
}
-
+
/**
* Given a mnemonic seed word list, check if checksum word is valid.
* Returns boolean value.
*/
- static function validate_checksum($words, $prefix_len) {
- return (self::checksum($words, $prefix_len) == $words[count($words)-1]) ? true : false;
+ static function validate_checksum($words, $prefix_len)
+ {
+ return (self::checksum($words, $prefix_len) == $words[count($words) - 1]) ? true : false;
}
/**
* Given an 8 byte word (or shorter),
* pads to 8 bytes (adds 0 at left) and reverses endian byte order.
*/
- static function swap_endian($word) {
- $word = str_pad ( $word, 8, 0, STR_PAD_LEFT);
+ static function swap_endian($word)
+ {
+ $word = str_pad($word, 8, 0, STR_PAD_LEFT);
return implode('', array_reverse(str_split($word, 2)));
}
-
+
/**
* Given a hexadecimal key string (seed),
* return it's mnemonic representation.
@@ -78,18 +81,19 @@ static function swap_endian($word) {
* pure PHP math (no gmp or bcmath), please submit a
* pull request.
*/
- static function encode($seed, $wordset_name = null) {
+ static function encode($seed, $wordset_name = null)
+ {
assert(mb_strlen($seed) % 8 == 0);
$out = [];
-
- $wordset = self::get_wordset_by_name( $wordset_name );
+
+ $wordset = self::get_wordset_by_name($wordset_name);
$words = $wordset['words'];
-
+
$ng = count($words);
- for($i = 0; $i < mb_strlen($seed) / 8; $i ++) {
- $word = self::swap_endian(mb_substr($seed, 8*$i, (8*$i+8) - (8*$i) ));
+ for ($i = 0; $i < mb_strlen($seed) / 8; $i++) {
+ $word = self::swap_endian(mb_substr($seed, 8 * $i, (8 * $i + 8) - (8 * $i)));
$x = gmp_init($word, 16);
- $w1 = gmp_mod($x,$ng);
+ $w1 = gmp_mod($x, $ng);
$w2 = gmp_mod(gmp_add(gmp_div($x, $ng), $w1), $ng);
$w3 = gmp_mod(gmp_add(gmp_div(gmp_div($x, $ng), $ng), $w2), $ng);
$out[] = $words[gmp_strval($w1)];
@@ -104,14 +108,15 @@ static function encode($seed, $wordset_name = null) {
* return it's mnemonic representation plus an
* extra checksum word.
*/
- static function encode_with_checksum($message, $wordset_name = null) {
+ static function encode_with_checksum($message, $wordset_name = null)
+ {
$list = self::encode($message, $wordset_name);
-
+
$wordset = self::get_wordset_by_name($wordset_name);
$list[] = self::checksum($list, $wordset['prefix_len']);
return $list ;
}
-
+
/**
* Given a mnemonic word list, return a hexadecimal encoded string (seed).
*
@@ -119,9 +124,10 @@ static function encode_with_checksum($message, $wordset_name = null) {
* pure PHP math (no gmp or bcmath), please submit a
* pull request.
*/
- static function decode($wlist, $wordset_name = null) {
- $wordset = self::get_wordset_by_name( $wordset_name );
-
+ static function decode($wlist, $wordset_name = null)
+ {
+ $wordset = self::get_wordset_by_name($wordset_name);
+
$plen = $wordset['prefix_len'];
$tw = $wordset['trunc_words'];
$wcount = count($tw);
@@ -132,45 +138,44 @@ static function decode($wlist, $wordset_name = null) {
if ($plen > 0 && (count($wlist) % 3 === 0)) {
throw new \Exception("last word missing");
}
-
+
$out = '';
- for ($i = 0; $i < count($wlist)-1; $i += 3) {
-
- if($plen == 0) {
+ for ($i = 0; $i < count($wlist) - 1; $i += 3) {
+ if ($plen == 0) {
$w1 = @$tw[$wlist[$i]];
$w2 = @$tw[$wlist[$i + 1]];
$w3 = @$tw[$wlist[$i + 2]];
- }
- else {
+ } else {
$w1 = @$tw[mb_substr($wlist[$i], 0, $plen)];
$w2 = @$tw[mb_substr($wlist[$i + 1], 0, $plen)];
$w3 = @$tw[mb_substr($wlist[$i + 2], 0, $plen)];
}
-
+
if ($w1 === null || $w2 === null || $w3 === null) {
throw new \Exception("invalid word in mnemonic");
}
// $x = (($w1 + ($n * (($w2 - $w1) % $n))) + (($n * $n) * (($w3 - $w2) % $n)));
- $x = gmp_add(gmp_add($w1, gmp_mul($wcount, (gmp_mod(gmp_sub($w2, $w1), $wcount)))), gmp_mul((gmp_mul($wcount,$wcount)), (gmp_mod(gmp_sub($w3, $w2), $wcount))));
+ $x = gmp_add(gmp_add($w1, gmp_mul($wcount, (gmp_mod(gmp_sub($w2, $w1), $wcount)))), gmp_mul((gmp_mul($wcount, $wcount)), (gmp_mod(gmp_sub($w3, $w2), $wcount))));
$out .= self::swap_endian(gmp_strval($x, 16));
}
return $out;
}
-
+
/**
* Given a wordset identifier, returns the full wordset
*/
- static public function get_wordset_by_name($name = null) {
+ public static function get_wordset_by_name($name = null)
+ {
$name = $name ?: 'english';
$wordset = self::get_wordsets();
$ws = @$wordset[$name];
- if( !$ws ) {
+ if (!$ws) {
throw new \Exception("Invalid wordset $name");
}
return $ws;
}
-
+
/**
* Given a mnemonic array of words, returns name of matching
* wordset that contains all words, or null if not found.
@@ -178,64 +183,66 @@ static public function get_wordset_by_name($name = null) {
* throws an exception if more than one wordset matches all words,
* but in theory that should never happen.
*/
- static public function find_wordset_by_mnemonic($mnemonic) {
+ public static function find_wordset_by_mnemonic($mnemonic)
+ {
$sets = self::get_wordsets();
$matched_wordsets = [];
- foreach($sets as $ws_name => $ws) {
-
+ foreach ($sets as $ws_name => $ws) {
// note, to make the search faster, we truncate each word
// according to prefix_len of the wordset, and lookup
// by key in trunc_words, rather than searching through
// entire wordset array.
$allmatch = true;
- foreach($mnemonic as $word) {
+ foreach ($mnemonic as $word) {
$tw = $ws['prefix_len'] == 0 ? $word : mb_substr($word, 0, $ws['prefix_len']);
- if( @$ws['trunc_words'][$tw] === null) {
+ if (@$ws['trunc_words'][$tw] === null) {
$allmatch = false;
break;
}
}
- if( $allmatch) {
+ if ($allmatch) {
$matched_wordsets[] = $ws_name;
}
}
-
+
$cnt = count($matched_wordsets);
- if($cnt > 1) {
+ if ($cnt > 1) {
throw new \Exception("Ambiguous match. mnemonic matches $cnt wordsets.");
}
-
+
return @$matched_wordsets[0];
}
-
-
+
+
/**
* returns list of available wordsets
*/
- static public function get_wordset_list() {
- return array_keys( self::get_wordsets() );
+ public static function get_wordset_list()
+ {
+ return array_keys(self::get_wordsets());
}
-
+
/**
* This function returns all available wordsets.
*
* Each wordset is in a separate file in wordsets/*.ws.php
*/
- static public function get_wordsets() {
-
+ public static function get_wordsets()
+ {
+
static $wordsets = null;
- if( $wordsets ) {
+ if ($wordsets) {
return $wordsets;
}
-
+
$wordsets = [];
$files = glob(__DIR__ . 'wordsets/*.ws.php');
- foreach($files as $f) {
+ foreach ($files as $f) {
require_once($f);
-
+
list($wordset) = explode('.', basename($f));
$classname = __NAMESPACE__ . '\\' . $wordset;
-
+
$wordsets[$wordset] = [
'name' => $classname::name(),
'english_name' => $classname::english_name(),
@@ -243,7 +250,7 @@ static public function get_wordsets() {
'words' => $classname::words(),
];
}
-
+
// This loop adds the key 'trunc_words' to each wordset, which contains
// a pre-generated list of words truncated to length prefix_len.
// This list is optimized for fast lookup of the truncated word
@@ -251,37 +258,35 @@ static public function get_wordsets() {
// This optimization assumes/requires that each truncated word is unique.
// A further optimization could be to only pre-generate trunc_words on the fly
// when a wordset is actually used, rather than for all wordsets.
- foreach($wordsets as &$ws) {
-
+ foreach ($wordsets as &$ws) {
$tw = [];
$plen = $ws['prefix_len'];
$i = 0;
- foreach( $ws['words'] as $w) {
+ foreach ($ws['words'] as $w) {
$key = $plen == 0 ? $w : mb_substr($w, 0, $plen);
$tw[$key] = $i++;
}
-
+
$ws['trunc_words'] = $tw;
}
return $wordsets;
}
-
}
-interface wordset {
-
+interface wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string;
+ public static function name(): string;
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string;
-
+ public static function english_name(): string;
+
/* Returns integer indicating length of unique prefix,
* such that each prefix of this length is unique across
* the entire set of words.
@@ -289,9 +294,9 @@ static public function english_name() : string;
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
*/
- static public function prefix_length() : int;
-
+ public static function prefix_length(): int;
+
/* Returns an array of all words in the wordset.
*/
- static public function words() : array;
-};
\ No newline at end of file
+ public static function words(): array;
+}
diff --git a/src/subaddress.php b/src/subaddress.php
index e7ebf3f..c0dab26 100644
--- a/src/subaddress.php
+++ b/src/subaddress.php
@@ -1,4 +1,4 @@
-ed25519 = new ed25519();
- $this->base58 = new base58();
- $this->gmp = extension_loaded('gmp');
- }
-
- private function sc_reduce($input)
- {
- $integer = $this->ed25519->decodeint(hex2bin($input));
- if($this->gmp)
- $modulo = gmp_mod($integer , $this->ed25519->l);
- else
- $modulo = bcmod($integer , $this->ed25519->l);
- $result = bin2hex($this->ed25519->encodeint($modulo));
- return $result;
- }
-
- private function ge_add($point1, $point2)
- {
- $point3 = $this->ed25519->edwards($this->ed25519->decodepoint(hex2bin($point1)), $this->ed25519->decodepoint(hex2bin($point2)));
- return bin2hex($this->ed25519->encodepoint($point3));
- }
-
- private function ge_scalarmult($public, $secret)
- {
- $point = $this->ed25519->decodepoint(hex2bin($public));
- $scalar = $this->ed25519->decodeint(hex2bin($secret));
- $res = $this->ed25519->scalarmult($point, $scalar);
- return bin2hex($this->ed25519->encodepoint($res));
- }
-
- private function ge_scalarmult_base($scalar)
- {
- $decoded = $this->ed25519->decodeint(hex2bin($scalar));
- $res = $this->ed25519->scalarmult_base($decoded);
- return bin2hex($this->ed25519->encodepoint($res));
- }
-
- /*
- * @param string Hex encoded string of the data to hash
- * @return string Hex encoded string of the hashed data
- *
- */
- private function keccak_256($message)
- {
- $message_bin = hex2bin($message);
- $hash = keccak::hash($message_bin, 256);
- return $hash;
- }
+ public function __construct()
+ {
+ $this->ed25519 = new ed25519();
+ $this->base58 = new base58();
+ $this->gmp = extension_loaded('gmp');
+ }
- /*
- * Hs in the cryptonote white paper
- *
- * @param string Hex encoded data to hash
- *
- * @return string A 32 byte encoded integer
- */
- private function hash_to_scalar($data)
- {
- $hash = $this->keccak_256($data);
- $scalar = $this->sc_reduce($hash);
- return $scalar;
- }
-
- public function generate_subaddr_secret_key($major_index, $minor_index, $sec_key)
- {
- $prefix = "5375624164647200"; // hex encoding of string "SubAddr"
- $index = pack("II", $major_index, $minor_index);
- return $this->hash_to_scalar($prefix . $sec_key . bin2hex($index));
- }
-
- public function generate_subaddress_spend_public_key($spend_public_key, $subaddr_secret_key)
- {
- $mG = $this->ge_scalarmult_base($subaddr_secret_key);
- $D = $this->ge_add($spend_public_key, $mG);
- return $D;
- }
-
- public function generate_subaddr_view_public_key($subaddr_spend_public_key, $view_secret_key)
- {
- return $this->ge_scalarmult($subaddr_spend_public_key, $view_secret_key);
- }
-
- public function generate_subaddress($major_index, $minor_index, $view_secret_key, $spend_public_key)
- {
- $subaddr_secret_key = $this->generate_subaddr_secret_key($major_index, $minor_index, $view_secret_key);
- $subaddr_public_spend_key = $this->generate_subaddress_spend_public_key($spend_public_key, $subaddr_secret_key);
- $subaddr_public_view_key = $this->generate_subaddr_view_public_key($subaddr_public_spend_key, $view_secret_key);
- // mainnet subaddress network byte is 42 (0x2a)
- $data = "2a" . $subaddr_public_spend_key . $subaddr_public_view_key;
- $checksum = $this->keccak_256($data);
- $encoded = $this->base58->encode($data . substr($checksum, 0, 8));
- return $encoded;
- }
+ private function sc_reduce($input)
+ {
+ $integer = $this->ed25519->decodeint(hex2bin($input));
+ if ($this->gmp) {
+ $modulo = gmp_mod($integer, $this->ed25519->l);
+ } else {
+ $modulo = bcmod($integer, $this->ed25519->l);
+ }
+ $result = bin2hex($this->ed25519->encodeint($modulo));
+ return $result;
+ }
+
+ private function ge_add($point1, $point2)
+ {
+ $point3 = $this->ed25519->edwards($this->ed25519->decodepoint(hex2bin($point1)), $this->ed25519->decodepoint(hex2bin($point2)));
+ return bin2hex($this->ed25519->encodepoint($point3));
+ }
+
+ private function ge_scalarmult($public, $secret)
+ {
+ $point = $this->ed25519->decodepoint(hex2bin($public));
+ $scalar = $this->ed25519->decodeint(hex2bin($secret));
+ $res = $this->ed25519->scalarmult($point, $scalar);
+ return bin2hex($this->ed25519->encodepoint($res));
+ }
+
+ private function ge_scalarmult_base($scalar)
+ {
+ $decoded = $this->ed25519->decodeint(hex2bin($scalar));
+ $res = $this->ed25519->scalarmult_base($decoded);
+ return bin2hex($this->ed25519->encodepoint($res));
+ }
+
+ /*
+ * @param string Hex encoded string of the data to hash
+ * @return string Hex encoded string of the hashed data
+ *
+ */
+ private function keccak_256($message)
+ {
+ $message_bin = hex2bin($message);
+ $hash = keccak::hash($message_bin, 256);
+ return $hash;
+ }
+
+ /*
+ * Hs in the cryptonote white paper
+ *
+ * @param string Hex encoded data to hash
+ *
+ * @return string A 32 byte encoded integer
+ */
+ private function hash_to_scalar($data)
+ {
+ $hash = $this->keccak_256($data);
+ $scalar = $this->sc_reduce($hash);
+ return $scalar;
+ }
+
+ public function generate_subaddr_secret_key($major_index, $minor_index, $sec_key)
+ {
+ $prefix = "5375624164647200"; // hex encoding of string "SubAddr"
+ $index = pack("II", $major_index, $minor_index);
+ return $this->hash_to_scalar($prefix . $sec_key . bin2hex($index));
+ }
+
+ public function generate_subaddress_spend_public_key($spend_public_key, $subaddr_secret_key)
+ {
+ $mG = $this->ge_scalarmult_base($subaddr_secret_key);
+ $D = $this->ge_add($spend_public_key, $mG);
+ return $D;
+ }
+
+ public function generate_subaddr_view_public_key($subaddr_spend_public_key, $view_secret_key)
+ {
+ return $this->ge_scalarmult($subaddr_spend_public_key, $view_secret_key);
+ }
+
+ public function generate_subaddress($major_index, $minor_index, $view_secret_key, $spend_public_key)
+ {
+ $subaddr_secret_key = $this->generate_subaddr_secret_key($major_index, $minor_index, $view_secret_key);
+ $subaddr_public_spend_key = $this->generate_subaddress_spend_public_key($spend_public_key, $subaddr_secret_key);
+ $subaddr_public_view_key = $this->generate_subaddr_view_public_key($subaddr_public_spend_key, $view_secret_key);
+ // mainnet subaddress network byte is 42 (0x2a)
+ $data = "2a" . $subaddr_public_spend_key . $subaddr_public_view_key;
+ $checksum = $this->keccak_256($data);
+ $encoded = $this->base58->encode($data . substr($checksum, 0, 8));
+ return $encoded;
+ }
}
diff --git a/src/walletRPC.php b/src/walletRPC.php
index 3f52b6a..57c73f6 100644
--- a/src/walletRPC.php
+++ b/src/walletRPC.php
@@ -1,4 +1,5 @@
host = $host;
- $this->port = $port;
- $this->protocol = $protocol;
- $this->user = $user;
- $this->password = $password;
- $this->check_SSL = $SSL;
-
- $this->url = $protocol.'://'.$host.':'.$port.'/';
- $this->client = new jsonRPCClient($this->url, $this->user, $this->password, $this->check_SSL);
- }
+ public function __construct($host = '127.0.0.1', $port = 18081, $SSL = true, $user = null, $password = null)
+ {
+ if (is_array($host)) { // Parameters passed in as object/dictionary
+ $params = $host;
+
+ if (array_key_exists('host', $params)) {
+ $host = $params['host'];
+ } else {
+ $host = '127.0.0.1';
+ }
+ if (array_key_exists('port', $params)) {
+ $port = $params['port'];
+ }
+ if (array_key_exists('protocol', $params)) {
+ $protocol = $params['protocol'];
+ }
+ if (array_key_exists('user', $params)) {
+ $user = $params['user'];
+ }
+ if (array_key_exists('password', $params)) {
+ $password = $params['password'];
+ }
+ }
+
+ if ($SSL) {
+ $protocol = 'https';
+ } else {
+ $protocol = 'http';
+ }
+
+ $this->host = $host;
+ $this->port = $port;
+ $this->protocol = $protocol;
+ $this->user = $user;
+ $this->password = $password;
+ $this->check_SSL = $SSL;
+
+ $this->url = $protocol . '://' . $host . ':' . $port . '/';
+ $this->client = new jsonRPCClient($this->url, $this->user, $this->password, $this->check_SSL);
+ }
/**
*
@@ -107,11 +108,11 @@ function __construct($host = '127.0.0.1', $port = 18081, $SSL = true, $user = nu
* @return string Call result
*
*/
- private function _run($method, $params = null, $path = 'json_rpc')
- {
- $result = $this->client->_run($method, $params, $path);
- return $result;
- }
+ private function _run($method, $params = null, $path = 'json_rpc')
+ {
+ $result = $this->client->_run($method, $params, $path);
+ return $result;
+ }
/**
*
@@ -122,10 +123,10 @@ private function _run($method, $params = null, $path = 'json_rpc')
* @return none
*
*/
- public function _print($json)
- {
- echo json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- }
+ public function _print($json)
+ {
+ echo json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
+ }
/**
*
@@ -136,10 +137,10 @@ public function _print($json)
* @return number
*
*/
- public function _transform($amount = 0)
- {
- return intval(bcmul($amount, 1000000000000));
- }
+ public function _transform($amount = 0)
+ {
+ return intval(bcmul($amount, 1000000000000));
+ }
/**
*
@@ -153,21 +154,21 @@ public function _transform($amount = 0)
* }
*
*/
- public function get_balance($account_index = 0)
- {
- $params = array('account_index' => $account_index);
- return $this->_run('get_balance', $params);
- }
+ public function get_balance($account_index = 0)
+ {
+ $params = array('account_index' => $account_index);
+ return $this->_run('get_balance', $params);
+ }
/**
*
* Alias of get_balance()
*
*/
- public function getbalance($account_index = 0)
- {
- return $this->get_balance($account_index);
- }
+ public function getbalance($account_index = 0)
+ {
+ return $this->get_balance($account_index);
+ }
/**
*
@@ -194,11 +195,11 @@ public function getbalance($account_index = 0)
* }
*
*/
- public function get_address($account_index = 0, $address_index = 0)
- {
- $params = array('account_index' => $account_index, 'address_index' => $address_index);
- return $this->_run('get_address', $params);
- }
+ public function get_address($account_index = 0, $address_index = 0)
+ {
+ $params = array('account_index' => $account_index, 'address_index' => $address_index);
+ return $this->_run('get_address', $params);
+ }
/**
* @param string $address Monero address
@@ -209,10 +210,11 @@ public function get_address($account_index = 0, $address_index = 0)
* }
* }
*/
- public function get_address_index($address){
- $params = array('address' => $address);
- return $this->_run('get_address_index', $params);
- }
+ public function get_address_index($address)
+ {
+ $params = array('address' => $address);
+ return $this->_run('get_address_index', $params);
+ }
/**
*
@@ -226,10 +228,10 @@ public function get_address_index($address){
* }
*
*/
- public function getaddress($account_index = 0, $address_index = 0)
- {
- return $this->get_address($account_index = 0, $address_index = 0);
- }
+ public function getaddress($account_index = 0, $address_index = 0)
+ {
+ return $this->get_address($account_index = 0, $address_index = 0);
+ }
/**
*
@@ -244,15 +246,15 @@ public function getaddress($account_index = 0, $address_index = 0)
* }
*
*/
- public function create_address($account_index = 0, $label = '')
- {
- $params = array('account_index' => $account_index, 'label' => $label);
- $create_address_method = $this->_run('create_address', $params);
+ public function create_address($account_index = 0, $label = '')
+ {
+ $params = array('account_index' => $account_index, 'label' => $label);
+ $create_address_method = $this->_run('create_address', $params);
- $save = $this->store(); // Save wallet state after subaddress creation
+ $save = $this->store(); // Save wallet state after subaddress creation
- return $create_address_method;
- }
+ return $create_address_method;
+ }
/**
*
@@ -264,11 +266,11 @@ public function create_address($account_index = 0, $label = '')
* @return none
*
*/
- public function label_address($index, $label)
- {
- $params = array('index' => $index ,'label' => $label);
- return $this->_run('label_address', $params);
- }
+ public function label_address($index, $label)
+ {
+ $params = array('index' => $index ,'label' => $label);
+ return $this->_run('label_address', $params);
+ }
/**
*
@@ -299,10 +301,10 @@ public function label_address($index, $label)
* }
*
*/
- public function get_accounts($tag = null)
- {
- return (is_null($tag)) ? $this->_run('get_accounts') : $this->_run('get_accounts', array('tag' => $tag));
- }
+ public function get_accounts($tag = null)
+ {
+ return (is_null($tag)) ? $this->_run('get_accounts') : $this->_run('get_accounts', array('tag' => $tag));
+ }
/**
*
@@ -313,15 +315,15 @@ public function get_accounts($tag = null)
* @return none
*
*/
- public function create_account($label = '')
- {
- $params = array('label' => $label);
- $create_account_method = $this->_run('create_account', $params);
+ public function create_account($label = '')
+ {
+ $params = array('label' => $label);
+ $create_account_method = $this->_run('create_account', $params);
- $save = $this->store(); // Save wallet state after account creation
+ $save = $this->store(); // Save wallet state after account creation
- return $create_account_method;
- }
+ return $create_account_method;
+ }
/**
*
@@ -333,15 +335,15 @@ public function create_account($label = '')
* @return none
*
*/
- public function label_account($account_index, $label)
- {
- $params = array('account_index' => $account_index, 'label' => $label);
- $label_account_method = $this->_run('label_account', $params);
+ public function label_account($account_index, $label)
+ {
+ $params = array('account_index' => $account_index, 'label' => $label);
+ $label_account_method = $this->_run('label_account', $params);
- $save = $this->store(); // Save wallet state after account label
+ $save = $this->store(); // Save wallet state after account label
- return $label_account_method;
- }
+ return $label_account_method;
+ }
/**
*
@@ -363,10 +365,10 @@ public function label_account($account_index, $label)
* }
*
*/
- public function get_account_tags()
- {
- return $this->_run('get_account_tags');
- }
+ public function get_account_tags()
+ {
+ return $this->_run('get_account_tags');
+ }
/**
*
@@ -378,15 +380,15 @@ public function get_account_tags()
* @return none
*
*/
- public function tag_accounts($accounts, $tag)
- {
- $params = array('accounts' => $accounts, 'tag' => $tag);
- $tag_accounts_method = $this->_run('tag_accounts', $params);
+ public function tag_accounts($accounts, $tag)
+ {
+ $params = array('accounts' => $accounts, 'tag' => $tag);
+ $tag_accounts_method = $this->_run('tag_accounts', $params);
- $save = $this->store(); // Save wallet state after account tagging
+ $save = $this->store(); // Save wallet state after account tagging
- return $tag_accounts_method;
- }
+ return $tag_accounts_method;
+ }
/**
*
@@ -397,15 +399,15 @@ public function tag_accounts($accounts, $tag)
* @return none
*
*/
- public function untag_accounts($accounts)
- {
- $params = array('accounts' => $accounts);
- $untag_accounts_method = $this->_run('untag_accounts', $params);
+ public function untag_accounts($accounts)
+ {
+ $params = array('accounts' => $accounts);
+ $untag_accounts_method = $this->_run('untag_accounts', $params);
- $save = $this->store(); // Save wallet state after untagging accounts
+ $save = $this->store(); // Save wallet state after untagging accounts
- return $untag_accounts_method;
- }
+ return $untag_accounts_method;
+ }
/**
*
@@ -419,15 +421,15 @@ public function untag_accounts($accounts)
* }
*
*/
- public function set_account_tag_description($tag, $description)
- {
- $params = array('tag' => $tag, 'description' => $description);
- $set_account_tag_description_method = $this->_run('set_account_tag_description', $params);
+ public function set_account_tag_description($tag, $description)
+ {
+ $params = array('tag' => $tag, 'description' => $description);
+ $set_account_tag_description_method = $this->_run('set_account_tag_description', $params);
- $save = $this->store(); // Save wallet state after describing tag
+ $save = $this->store(); // Save wallet state after describing tag
- return $set_account_tag_description_method;
- }
+ return $set_account_tag_description_method;
+ }
/**
*
@@ -440,20 +442,20 @@ public function set_account_tag_description($tag, $description)
* }
*
*/
- public function get_height()
- {
- return $this->_run('get_height');
- }
+ public function get_height()
+ {
+ return $this->_run('get_height');
+ }
/**
*
* Alias of get_height()
*
*/
- public function getheight()
- {
- return $this->get_height();
- }
+ public function getheight()
+ {
+ return $this->get_height();
+ }
/**
*
@@ -483,146 +485,146 @@ public function getheight()
* }
*
*/
- public function transfer($amount, $address = '', $payment_id = '', $mixin = 15, $account_index = 0, $subaddr_indices = '', $priority = 2, $unlock_time = 0, $do_not_relay = false, $ringsize = 11)
- {
- if (is_array($amount)) { // Parameters passed in as object/dictionary
- $params = $amount;
+ public function transfer($amount, $address = '', $payment_id = '', $mixin = 15, $account_index = 0, $subaddr_indices = '', $priority = 2, $unlock_time = 0, $do_not_relay = false, $ringsize = 11)
+ {
+ if (is_array($amount)) { // Parameters passed in as object/dictionary
+ $params = $amount;
+
+ if (array_key_exists('destinations', $params)) {
+ $destinations = $params['destinations'];
+
+ if (!is_array($destinations)) {
+ throw new Exception('Error: destinations must be an array');
+ }
+
+ foreach ($destinations as $destination_index => $destination) {
+ if (array_key_exists('amount', $destination)) {
+ $destinations[$destination_index]['amount'] = $this->_transform($destination['amount']);
+ } else {
+ throw new Exception('Error: Amount required');
+ }
+ if (!array_key_exists('address', $destination)) {
+ throw new Exception('Error: Address required');
+ }
+ }
+ } else {
+ if (array_key_exists('amount', $params)) {
+ $amount = $params['amount'];
+ } else {
+ throw new Exception('Error: Amount required');
+ }
+ if (array_key_exists('address', $params)) {
+ $address = $params['address'];
+ } else {
+ throw new Exception('Error: Address required');
+ }
+ $destinations = array(array('amount' => $this->_transform($amount), 'address' => $address));
+ }
+ if (array_key_exists('payment_id', $params)) {
+ throw new Exception('Error: Payment ids have been deprecated.');
+ }
+ if (array_key_exists('mixin', $params)) {
+ $mixin = $params['mixin'];
+ }
+ if (array_key_exists('account_index', $params)) {
+ $account_index = $params['account_index'];
+ }
+ if (array_key_exists('subaddr_indices', $params)) {
+ $subaddr_indices = $params['subaddr_indices'];
+ }
+ if (array_key_exists('priority', $params)) {
+ $priority = $params['priority'];
+ }
+ if (array_key_exists('unlock_time', $params)) {
+ $unlock_time = $params['unlock_time'];
+ }
+ if (array_key_exists('do_not_relay', $params)) {
+ $do_not_relay = $params['do_not_relay'];
+ }
+ } else { // Legacy parameters used
+ $destinations = array(array('amount' => $this->_transform($amount), 'address' => $address));
+ }
- if (array_key_exists('destinations', $params)) {
- $destinations = $params['destinations'];
+ $params = array('destinations' => $destinations, 'mixin' => $mixin, 'get_tx_key' => true, 'account_index' => $account_index, 'subaddr_indices' => $subaddr_indices, 'priority' => $priority, 'do_not_relay' => $do_not_relay, 'ringsize' => $ringsize);
+ $transfer_method = $this->_run('transfer', $params);
- if (!is_array($destinations)) {
- throw new Exception('Error: destinations must be an array');
- }
+ $save = $this->store(); // Save wallet state after transfer
- foreach ($destinations as $destination_index => $destination) {
- if (array_key_exists('amount', $destination)) {
- $destinations[$destination_index]['amount'] = $this->_transform($destination['amount']);
- } else {
- throw new Exception('Error: Amount required');
- }
- if (!array_key_exists('address', $destination)) {
- throw new Exception('Error: Address required');
- }
- }
- } else {
- if (array_key_exists('amount', $params)) {
- $amount = $params['amount'];
- } else {
- throw new Exception('Error: Amount required');
- }
- if (array_key_exists('address', $params)) {
- $address = $params['address'];
- } else {
- throw new Exception('Error: Address required');
- }
- $destinations = array(array('amount' => $this->_transform($amount), 'address' => $address));
- }
- if (array_key_exists('payment_id', $params)) {
- throw new Exception('Error: Payment ids have been deprecated.');
- }
- if (array_key_exists('mixin', $params)) {
- $mixin = $params['mixin'];
- }
- if (array_key_exists('account_index', $params)) {
- $account_index = $params['account_index'];
- }
- if (array_key_exists('subaddr_indices', $params)) {
- $subaddr_indices = $params['subaddr_indices'];
- }
- if (array_key_exists('priority', $params)) {
- $priority = $params['priority'];
- }
- if (array_key_exists('unlock_time', $params)) {
- $unlock_time = $params['unlock_time'];
- }
- if (array_key_exists('do_not_relay', $params)) {
- $do_not_relay = $params['do_not_relay'];
- }
- } else { // Legacy parameters used
- $destinations = array(array('amount' => $this->_transform($amount), 'address' => $address));
- }
-
- $params = array('destinations' => $destinations, 'mixin' => $mixin, 'get_tx_key' => true, 'account_index' => $account_index, 'subaddr_indices' => $subaddr_indices, 'priority' => $priority, 'do_not_relay' => $do_not_relay, 'ringsize' => $ringsize);
- $transfer_method = $this->_run('transfer', $params);
-
- $save = $this->store(); // Save wallet state after transfer
-
- return $transfer_method;
- }
+ return $transfer_method;
+ }
/**
*
* Same as transfer, but splits transfer into more than one transaction if necessary
*
*/
- public function transfer_split($amount, $address = '', $payment_id = '', $mixin = 15, $account_index = 0, $subaddr_indices = '', $priority = 2, $unlock_time = 0, $do_not_relay = false)
- {
- if (is_array($amount)) { // Parameters passed in as object/dictionary
- $params = $amount;
+ public function transfer_split($amount, $address = '', $payment_id = '', $mixin = 15, $account_index = 0, $subaddr_indices = '', $priority = 2, $unlock_time = 0, $do_not_relay = false)
+ {
+ if (is_array($amount)) { // Parameters passed in as object/dictionary
+ $params = $amount;
+
+ if (array_key_exists('destinations', $params)) {
+ $destinations = $params['destinations'];
+
+ if (!is_array($destinations)) {
+ throw new Exception('Error: destinations must be an array');
+ }
+
+ foreach ($destinations as $destination) {
+ if (array_key_exists('amount', $destinations[$destination])) {
+ $destinations[$destination]['amount'] = $this->_transform($destinations[$destination]['amount']);
+ } else {
+ throw new Exception('Error: Amount required');
+ }
+ if (!array_key_exists('address', $destinations[$destination])) {
+ throw new Exception('Error: Address required');
+ }
+ }
+ } else {
+ if (array_key_exists('amount', $params)) {
+ $amount = $params['amount'];
+ } else {
+ throw new Exception('Error: Amount required');
+ }
+ if (array_key_exists('address', $params)) {
+ $address = $params['address'];
+ } else {
+ throw new Exception('Error: Address required');
+ }
+ $destinations = array(array('amount' => $this->_transform($amount), 'address' => $address));
+ }
+ if (array_key_exists('mixin', $params)) {
+ $mixin = $params['mixin'];
+ }
+ if (array_key_exists('payment_id', $params)) {
+ $payment_id = $params['payment_id'];
+ }
+ if (array_key_exists('account_index', $params)) {
+ $account_index = $params['account_index'];
+ }
+ if (array_key_exists('subaddr_indices', $params)) {
+ $subaddr_indices = $params['subaddr_indices'];
+ }
+ if (array_key_exists('priority', $params)) {
+ $priority = $params['priority'];
+ }
+ if (array_key_exists('unlock_time', $params)) {
+ $unlock_time = $params['unlock_time'];
+ }
+ if (array_key_exists('do_not_relay', $params)) {
+ $do_not_relay = $params['do_not_relay'];
+ }
+ } else { // Legacy parameters used
+ $destinations = array(array('amount' => $this->_transform($amount), 'address' => $address));
+ }
- if (array_key_exists('destinations', $params)) {
- $destinations = $params['destinations'];
+ $params = array('destinations' => $destinations, 'mixin' => $mixin, 'get_tx_key' => true, 'account_index' => $account_index, 'subaddr_indices' => $subaddr_indices, 'payment_id' => $payment_id, 'priority' => $priority, 'unlock_time' => $unlock_time, 'do_not_relay' => $do_not_relay);
+ $transfer_method = $this->_run('transfer_split', $params);
- if (!is_array($destinations)) {
- throw new Exception('Error: destinations must be an array');
- }
+ $save = $this->store(); // Save wallet state after transfer
- foreach ($destinations as $destination) {
- if (array_key_exists('amount', $destinations[$destination])) {
- $destinations[$destination]['amount'] = $this->_transform($destinations[$destination]['amount']);
- } else {
- throw new Exception('Error: Amount required');
- }
- if (!array_key_exists('address', $destinations[$destination])) {
- throw new Exception('Error: Address required');
- }
- }
- } else {
- if (array_key_exists('amount', $params)) {
- $amount = $params['amount'];
- } else {
- throw new Exception('Error: Amount required');
- }
- if (array_key_exists('address', $params)) {
- $address = $params['address'];
- } else {
- throw new Exception('Error: Address required');
- }
- $destinations = array(array('amount' => $this->_transform($amount), 'address' => $address));
- }
- if (array_key_exists('mixin', $params)) {
- $mixin = $params['mixin'];
- }
- if (array_key_exists('payment_id', $params)) {
- $payment_id = $params['payment_id'];
- }
- if (array_key_exists('account_index', $params)) {
- $account_index = $params['account_index'];
- }
- if (array_key_exists('subaddr_indices', $params)) {
- $subaddr_indices = $params['subaddr_indices'];
- }
- if (array_key_exists('priority', $params)) {
- $priority = $params['priority'];
- }
- if (array_key_exists('unlock_time', $params)) {
- $unlock_time = $params['unlock_time'];
- }
- if (array_key_exists('do_not_relay', $params)) {
- $do_not_relay = $params['do_not_relay'];
- }
- } else { // Legacy parameters used
- $destinations = array(array('amount' => $this->_transform($amount), 'address' => $address));
- }
-
- $params = array('destinations' => $destinations, 'mixin' => $mixin, 'get_tx_key' => true, 'account_index' => $account_index, 'subaddr_indices' => $subaddr_indices, 'payment_id' => $payment_id, 'priority' => $priority, 'unlock_time' => $unlock_time, 'do_not_relay' => $do_not_relay);
- $transfer_method = $this->_run('transfer_split', $params);
-
- $save = $this->store(); // Save wallet state after transfer
-
- return $transfer_method;
- }
+ return $transfer_method;
+ }
/**
*
@@ -635,10 +637,10 @@ public function transfer_split($amount, $address = '', $payment_id = '', $mixin
* }
*
*/
- public function sweep_dust()
- {
- return $this->_run('sweep_dust');
- }
+ public function sweep_dust()
+ {
+ return $this->_run('sweep_dust');
+ }
/**
*
@@ -651,10 +653,10 @@ public function sweep_dust()
* }
*
*/
- public function sweep_unmixable()
- {
- return $this->_run('sweep_unmixable');
- }
+ public function sweep_unmixable()
+ {
+ return $this->_run('sweep_unmixable');
+ }
/**
*
@@ -682,49 +684,49 @@ public function sweep_unmixable()
* }
*
*/
- public function sweep_all($address, $subaddr_indices = '', $account_index = 0, $payment_id = '', $mixin = 15, $priority = 2, $below_amount = 0, $unlock_time = 0, $do_not_relay = false)
- {
- if (is_array($address)) { // Parameters passed in as object/dictionary
- $params = $address;
-
- if (array_key_exists('address', $params)) {
- $address = $params['address'];
- } else {
- throw new Exception('Error: Address required');
- }
- if (array_key_exists('subaddr_indices', $params)) {
- $subaddr_indices = $params['subaddr_indices'];
- }
- if (array_key_exists('account_index', $params)) {
- $account_index = $params['account_index'];
- }
- if (array_key_exists('payment_id', $params)) {
- $payment_id = $params['payment_id'];
- }
- if (array_key_exists('mixin', $params)) {
- $mixin = $params['mixin'];
- }
- if (array_key_exists('priority', $params)) {
- $priority = $params['priority'];
- }
- if (array_key_exists('below_amount', $params)) {
- $below_amount = $params['below_amount'];
- }
- if (array_key_exists('unlock_time', $params)) {
- $unlock_time = $params['unlock_time'];
- }
- if (array_key_exists('do_not_relay', $params)) {
- $do_not_relay = $params['do_not_relay'];
- }
- }
-
- $params = array('address' => $address, 'mixin' => $mixin, 'get_tx_key' => true, 'subaddr_indices' => $subaddr_indices, 'account_index' => $account_index, 'payment_id' => $payment_id, 'priority' => $priority, 'below_amount' => $this->_transform($below_amount), 'unlock_time' => $unlock_time, 'do_not_relay' => $do_not_relay);
- $sweep_all_method = $this->_run('sweep_all', $params);
-
- $save = $this->store(); // Save wallet state after transfer
-
- return $sweep_all_method;
- }
+ public function sweep_all($address, $subaddr_indices = '', $account_index = 0, $payment_id = '', $mixin = 15, $priority = 2, $below_amount = 0, $unlock_time = 0, $do_not_relay = false)
+ {
+ if (is_array($address)) { // Parameters passed in as object/dictionary
+ $params = $address;
+
+ if (array_key_exists('address', $params)) {
+ $address = $params['address'];
+ } else {
+ throw new Exception('Error: Address required');
+ }
+ if (array_key_exists('subaddr_indices', $params)) {
+ $subaddr_indices = $params['subaddr_indices'];
+ }
+ if (array_key_exists('account_index', $params)) {
+ $account_index = $params['account_index'];
+ }
+ if (array_key_exists('payment_id', $params)) {
+ $payment_id = $params['payment_id'];
+ }
+ if (array_key_exists('mixin', $params)) {
+ $mixin = $params['mixin'];
+ }
+ if (array_key_exists('priority', $params)) {
+ $priority = $params['priority'];
+ }
+ if (array_key_exists('below_amount', $params)) {
+ $below_amount = $params['below_amount'];
+ }
+ if (array_key_exists('unlock_time', $params)) {
+ $unlock_time = $params['unlock_time'];
+ }
+ if (array_key_exists('do_not_relay', $params)) {
+ $do_not_relay = $params['do_not_relay'];
+ }
+ }
+
+ $params = array('address' => $address, 'mixin' => $mixin, 'get_tx_key' => true, 'subaddr_indices' => $subaddr_indices, 'account_index' => $account_index, 'payment_id' => $payment_id, 'priority' => $priority, 'below_amount' => $this->_transform($below_amount), 'unlock_time' => $unlock_time, 'do_not_relay' => $do_not_relay);
+ $sweep_all_method = $this->_run('sweep_all', $params);
+
+ $save = $this->store(); // Save wallet state after transfer
+
+ return $sweep_all_method;
+ }
/**
*
@@ -751,52 +753,52 @@ public function sweep_all($address, $subaddr_indices = '', $account_index = 0, $
* }
*
*/
- public function sweep_single($key_image, $address, $payment_id = '', $mixin = 15, $priority = 2, $below_amount = 0, $unlock_time = 0, $do_not_relay = 0)
- {
- if (is_array($key_image)) { // Parameters passed in as object/dictionary
- $params = $key_image;
-
- if (array_key_exists('key_image', $params)) {
- $key_image = $params['key_image'];
- } else {
- throw new Exception('Error: Key image required');
- }
- if (array_key_exists('address', $params)) {
- $address = $params['address'];
- } else {
- throw new Exception('Error: Address required');
- }
-
- if (array_key_exists('payment_id', $params)) {
- $payment_id = $params['payment_id'];
- }
- if (array_key_exists('mixin', $params)) {
- $mixin = $params['mixin'];
- }
- if (array_key_exists('account_index', $params)) {
- $account_index = $params['account_index'];
- }
- if (array_key_exists('priority', $params)) {
- $priority = $params['priority'];
- }
- if (array_key_exists('unlock_time', $params)) {
- $unlock_time = $params['unlock_time'];
- }
- if (array_key_exists('below_amount', $params)) {
- $below_amount = $params['below_amount'];
- }
- if (array_key_exists('do_not_relay', $params)) {
- $do_not_relay = $params['do_not_relay'];
- }
- }
-
- $params = array('address' => $address, 'mixin' => $mixin, 'get_tx_key' => true, 'account_index' => $account_index, 'payment_id' => $payment_id, 'priority' => $priority, 'below_amount' => $this->_transform($below_amount), 'unlock_time' => $unlock_time, 'do_not_relay' => $do_not_relay);
- $sweep_single_method = $this->_run('sweep_single', $params);
-
- $save = $this->store(); // Save wallet state after transfer
-
- return $sweep_single_method;
- }
+ public function sweep_single($key_image, $address, $payment_id = '', $mixin = 15, $priority = 2, $below_amount = 0, $unlock_time = 0, $do_not_relay = 0)
+ {
+ if (is_array($key_image)) { // Parameters passed in as object/dictionary
+ $params = $key_image;
+
+ if (array_key_exists('key_image', $params)) {
+ $key_image = $params['key_image'];
+ } else {
+ throw new Exception('Error: Key image required');
+ }
+ if (array_key_exists('address', $params)) {
+ $address = $params['address'];
+ } else {
+ throw new Exception('Error: Address required');
+ }
+
+ if (array_key_exists('payment_id', $params)) {
+ $payment_id = $params['payment_id'];
+ }
+ if (array_key_exists('mixin', $params)) {
+ $mixin = $params['mixin'];
+ }
+ if (array_key_exists('account_index', $params)) {
+ $account_index = $params['account_index'];
+ }
+ if (array_key_exists('priority', $params)) {
+ $priority = $params['priority'];
+ }
+ if (array_key_exists('unlock_time', $params)) {
+ $unlock_time = $params['unlock_time'];
+ }
+ if (array_key_exists('below_amount', $params)) {
+ $below_amount = $params['below_amount'];
+ }
+ if (array_key_exists('do_not_relay', $params)) {
+ $do_not_relay = $params['do_not_relay'];
+ }
+ }
+
+ $params = array('address' => $address, 'mixin' => $mixin, 'get_tx_key' => true, 'account_index' => $account_index, 'payment_id' => $payment_id, 'priority' => $priority, 'below_amount' => $this->_transform($below_amount), 'unlock_time' => $unlock_time, 'do_not_relay' => $do_not_relay);
+ $sweep_single_method = $this->_run('sweep_single', $params);
+
+ $save = $this->store(); // Save wallet state after transfer
+
+ return $sweep_single_method;
+ }
/**
*
@@ -807,15 +809,15 @@ public function sweep_single($key_image, $address, $payment_id = '', $mixin = 15
* @return object // TODO example
*
*/
- public function relay_tx($hex)
- {
- $params = array('hex' => $hex);
- $relay_tx_method = $this->_run('relay_tx_method', $params);
+ public function relay_tx($hex)
+ {
+ $params = array('hex' => $hex);
+ $relay_tx_method = $this->_run('relay_tx_method', $params);
- $save = $this->store(); // Save wallet state after transaction relay
+ $save = $this->store(); // Save wallet state after transaction relay
- return $this->_run('relay_tx');
- }
+ return $this->_run('relay_tx');
+ }
/**
*
@@ -826,10 +828,10 @@ public function relay_tx($hex)
* @return object Example:
*
*/
- public function store()
- {
- return $this->_run('store');
- }
+ public function store()
+ {
+ return $this->_run('store');
+ }
/**
*
@@ -848,13 +850,13 @@ public function store()
* }
*
*/
- public function get_payments($payment_id)
- {
- // $params = array('payment_id' => $payment_id); // does not work
- $params = [];
- $params['payment_id'] = $payment_id;
- return $this->_run('get_payments', $params);
- }
+ public function get_payments($payment_id)
+ {
+ // $params = array('payment_id' => $payment_id); // does not work
+ $params = [];
+ $params['payment_id'] = $payment_id;
+ return $this->_run('get_payments', $params);
+ }
/**
*
@@ -874,22 +876,22 @@ public function get_payments($payment_id)
* }
*
*/
- public function get_bulk_payments($payment_ids, $min_block_height)
- {
- // $params = array('payment_ids' => $payment_ids, 'min_block_height' => $min_block_height); // does not work
- //$params = array('min_block_height' => $min_block_height); // does not work
- $params = [];
- if (!is_array($payment_ids)) {
- throw new Exception('Error: Payment IDs must be array.');
- }
- if ($payment_ids) {
- $params['payment_ids'] = [];
- foreach ($payment_ids as $payment_id) {
- $params['payment_ids'][] = $payment_id;
- }
+ public function get_bulk_payments($payment_ids, $min_block_height)
+ {
+ // $params = array('payment_ids' => $payment_ids, 'min_block_height' => $min_block_height); // does not work
+ //$params = array('min_block_height' => $min_block_height); // does not work
+ $params = [];
+ if (!is_array($payment_ids)) {
+ throw new Exception('Error: Payment IDs must be array.');
+ }
+ if ($payment_ids) {
+ $params['payment_ids'] = [];
+ foreach ($payment_ids as $payment_id) {
+ $params['payment_ids'][] = $payment_id;
+ }
+ }
+ return $this->_run('get_bulk_payments', $params);
}
- return $this->_run('get_bulk_payments', $params);
- }
/**
*
@@ -921,11 +923,11 @@ public function get_bulk_payments($payment_ids, $min_block_height)
* }]
* }
*/
- public function incoming_transfers($type = 'all', $account_index = 0, $subaddr_indices = '')
- {
- $params = array('transfer_type' => $type, 'account_index' => $account_index, 'subaddr_indices' => $subaddr_indices);
- return $this->_run('incoming_transfers', $params);
- }
+ public function incoming_transfers($type = 'all', $account_index = 0, $subaddr_indices = '')
+ {
+ $params = array('transfer_type' => $type, 'account_index' => $account_index, 'subaddr_indices' => $subaddr_indices);
+ return $this->_run('incoming_transfers', $params);
+ }
/**
*
@@ -938,11 +940,11 @@ public function incoming_transfers($type = 'all', $account_index = 0, $subaddr_i
* }
*
*/
- public function query_key($key_type)
- {
- $params = array('key_type' => $key_type);
- return $this->_run('query_key', $params);
- }
+ public function query_key($key_type)
+ {
+ $params = array('key_type' => $key_type);
+ return $this->_run('query_key', $params);
+ }
/**
*
@@ -955,11 +957,11 @@ public function query_key($key_type)
* }
*
*/
- public function view_key()
- {
- $params = array('key_type' => 'view_key');
- return $this->_run('query_key', $params);
- }
+ public function view_key()
+ {
+ $params = array('key_type' => 'view_key');
+ return $this->_run('query_key', $params);
+ }
/**
*
@@ -972,11 +974,11 @@ public function view_key()
* }
*
*/
- public function spend_key()
- {
- $params = array('key_type' => 'spend_key');
- return $this->_run('query_key', $params);
- }
+ public function spend_key()
+ {
+ $params = array('key_type' => 'spend_key');
+ return $this->_run('query_key', $params);
+ }
/**
*
@@ -989,11 +991,11 @@ public function spend_key()
* }
*
*/
- public function mnemonic()
- {
- $params = array('key_type' => 'mnemonic');
- return $this->_run('query_key', $params);
- }
+ public function mnemonic()
+ {
+ $params = array('key_type' => 'mnemonic');
+ return $this->_run('query_key', $params);
+ }
/**
*
@@ -1006,11 +1008,11 @@ public function mnemonic()
* }
*
*/
- public function make_integrated_address($payment_id = null)
- {
- $params = array('payment_id' => $payment_id);
- return $this->_run('make_integrated_address', $params);
- }
+ public function make_integrated_address($payment_id = null)
+ {
+ $params = array('payment_id' => $payment_id);
+ return $this->_run('make_integrated_address', $params);
+ }
/**
*
@@ -1024,11 +1026,11 @@ public function make_integrated_address($payment_id = null)
* }
*
*/
- public function split_integrated_address($integrated_address)
- {
- $params = array('integrated_address' => $integrated_address);
- return $this->_run('split_integrated_address', $params);
- }
+ public function split_integrated_address($integrated_address)
+ {
+ $params = array('integrated_address' => $integrated_address);
+ return $this->_run('split_integrated_address', $params);
+ }
/**
*
@@ -1039,10 +1041,10 @@ public function split_integrated_address($integrated_address)
* @return none
*
*/
- public function stop_wallet()
- {
- return $this->_run('stop_wallet');
- }
+ public function stop_wallet()
+ {
+ return $this->_run('stop_wallet');
+ }
/*
*
@@ -1054,10 +1056,10 @@ public function stop_wallet()
*
*/
- public function rescan_blockchain()
- {
- return $this->_run('rescan_blockchain');
- }
+ public function rescan_blockchain()
+ {
+ return $this->_run('rescan_blockchain');
+ }
/**
*
@@ -1069,11 +1071,11 @@ public function rescan_blockchain()
* @return none
*
*/
- public function set_tx_notes($txids, $notes)
- {
- $params = array('txids' => $txids, 'notes' => $notes);
- return $this->_run('set_tx_notes', $params);
- }
+ public function set_tx_notes($txids, $notes)
+ {
+ $params = array('txids' => $txids, 'notes' => $notes);
+ return $this->_run('set_tx_notes', $params);
+ }
/**
*
@@ -1086,11 +1088,11 @@ public function set_tx_notes($txids, $notes)
* }
*
*/
- public function get_tx_notes($txids)
- {
- $params = array('txids' => $txids);
- return $this->_run('get_tx_notes', $params);
- }
+ public function get_tx_notes($txids)
+ {
+ $params = array('txids' => $txids);
+ return $this->_run('get_tx_notes', $params);
+ }
/**
*
@@ -1102,11 +1104,11 @@ public function get_tx_notes($txids)
* @return none
*
*/
- public function set_attribute($key, $value)
- {
- $params = array('key' => $key, 'value' => $value);
- return $this->_run('set_attribute', $params);
- }
+ public function set_attribute($key, $value)
+ {
+ $params = array('key' => $key, 'value' => $value);
+ return $this->_run('set_attribute', $params);
+ }
/**
*
@@ -1119,11 +1121,11 @@ public function set_attribute($key, $value)
* }
*
*/
- public function get_attribute($key)
- {
- $params = array('key' => $key);
- return $this->_run('get_attribute', $params);
- }
+ public function get_attribute($key)
+ {
+ $params = array('key' => $key);
+ return $this->_run('get_attribute', $params);
+ }
/**
*
@@ -1136,11 +1138,11 @@ public function get_attribute($key)
* }
*
*/
- public function get_tx_key($txid)
- {
- $params = array('txid' => $txid);
- return $this->_run('get_tx_key', $params);
- }
+ public function get_tx_key($txid)
+ {
+ $params = array('txid' => $txid);
+ return $this->_run('get_tx_key', $params);
+ }
/**
*
@@ -1157,11 +1159,11 @@ public function get_tx_key($txid)
* }
*
*/
- public function check_tx_key($address, $txid, $tx_key)
- {
- $params = array('address' => $address, 'txid' => $txid, 'tx_key' => $tx_key);
- return $this->_run('check_tx_key', $params);
- }
+ public function check_tx_key($address, $txid, $tx_key)
+ {
+ $params = array('address' => $address, 'txid' => $txid, 'tx_key' => $tx_key);
+ return $this->_run('check_tx_key', $params);
+ }
/**
*
@@ -1175,11 +1177,11 @@ public function check_tx_key($address, $txid, $tx_key)
* }
*
*/
- public function get_tx_proof($address, $txid)
- {
- $params = array('address' => $address, 'txid' => $txid);
- return $this->_run('get_tx_proof', $params);
- }
+ public function get_tx_proof($address, $txid)
+ {
+ $params = array('address' => $address, 'txid' => $txid);
+ return $this->_run('get_tx_proof', $params);
+ }
/**
*
@@ -1197,11 +1199,11 @@ public function get_tx_proof($address, $txid)
* }
*
*/
- public function check_tx_proof($address, $txid, $signature)
- {
- $params = array('address' => $address, 'txid' => $txid, 'signature' => $signature);
- return $this->_run('check_tx_proof', $params);
- }
+ public function check_tx_proof($address, $txid, $signature)
+ {
+ $params = array('address' => $address, 'txid' => $txid, 'signature' => $signature);
+ return $this->_run('check_tx_proof', $params);
+ }
/**
*
@@ -1214,14 +1216,14 @@ public function check_tx_proof($address, $txid, $signature)
* }
*
*/
- public function get_spend_proof($txid, $message=null)
- {
- $params = array('txid' => $txid);
- if( $message !== null ) {
- $params['message'] = $message;
+ public function get_spend_proof($txid, $message = null)
+ {
+ $params = array('txid' => $txid);
+ if ($message !== null) {
+ $params['message'] = $message;
+ }
+ return $this->_run('get_spend_proof', $params);
}
- return $this->_run('get_spend_proof', $params);
- }
/**
*
@@ -1235,14 +1237,14 @@ public function get_spend_proof($txid, $message=null)
* }
*
*/
- public function check_spend_proof($txid, $signature, $message=null)
- {
- $params = array('txid' => $txid, 'signature' => $signature);
- if( $message !== null ) {
- $params['message'] = $message;
+ public function check_spend_proof($txid, $signature, $message = null)
+ {
+ $params = array('txid' => $txid, 'signature' => $signature);
+ if ($message !== null) {
+ $params['message'] = $message;
+ }
+ return $this->_run('check_spend_proof', $params);
}
- return $this->_run('check_spend_proof', $params);
- }
/**
*
@@ -1255,16 +1257,16 @@ public function check_spend_proof($txid, $signature, $message=null)
* }
*
*/
- public function get_reserve_proof($account_index = 'all')
- {
- if ($account_index == 'all') {
- $params = array('all' => true);
- } else {
- $params = array('account_index' => $account_index);
- }
+ public function get_reserve_proof($account_index = 'all')
+ {
+ if ($account_index == 'all') {
+ $params = array('all' => true);
+ } else {
+ $params = array('account_index' => $account_index);
+ }
- return $this->_run('get_reserve_proof');
- }
+ return $this->_run('get_reserve_proof');
+ }
/**
*
@@ -1280,11 +1282,11 @@ public function get_reserve_proof($account_index = 'all')
* }
*
*/
- public function check_reserve_proof($address, $signature)
- {
- $params = array('address' => $address, 'signature' => $signature);
- return $this->_run('check_reserve_proof', $params);
- }
+ public function check_reserve_proof($address, $signature)
+ {
+ $params = array('address' => $address, 'signature' => $signature);
+ return $this->_run('check_reserve_proof', $params);
+ }
/**
*
@@ -1314,62 +1316,62 @@ public function check_reserve_proof($address, $signature)
* }
*
*/
- public function get_transfers($input_types = ['all'], $account_index = 0, $subaddr_indices = '', $min_height = 0, $max_height = 4206931337)
- {
- if (is_string($input_types)) { // If user is using old method
- $params = array('subaddr_indices' => $subaddr_indices, 'min_height' => $min_height, 'max_height' => $max_height);
- if (is_bool($account_index)) { // If user passed eg. get_transfers('in', true)
- $params['account_index'] = 0;
- $params[$input_types] = $account_index; // $params = array($input_type => $input_value);
- } else { // If user passed eg. get_transfers('in')
- $params['account_index'] = $account_index;
- $params[$input_types] = true;
- }
- } else {
- if (is_object($input_types) || is_array($input_types)) { // Parameters passed in as object/dictionary
- $params = $input_types;
-
- if (array_key_exists('input_types', $params)) {
- $input_types = $params['input_types'];
+ public function get_transfers($input_types = ['all'], $account_index = 0, $subaddr_indices = '', $min_height = 0, $max_height = 4206931337)
+ {
+ if (is_string($input_types)) { // If user is using old method
+ $params = array('subaddr_indices' => $subaddr_indices, 'min_height' => $min_height, 'max_height' => $max_height);
+ if (is_bool($account_index)) { // If user passed eg. get_transfers('in', true)
+ $params['account_index'] = 0;
+ $params[$input_types] = $account_index; // $params = array($input_type => $input_value);
+ } else { // If user passed eg. get_transfers('in')
+ $params['account_index'] = $account_index;
+ $params[$input_types] = true;
+ }
} else {
- $input_types = ['all'];
+ if (is_object($input_types) || is_array($input_types)) { // Parameters passed in as object/dictionary
+ $params = $input_types;
+
+ if (array_key_exists('input_types', $params)) {
+ $input_types = $params['input_types'];
+ } else {
+ $input_types = ['all'];
+ }
+ if (array_key_exists('account_index', $params)) {
+ $account_index = $params['account_index'];
+ }
+ if (array_key_exists('subaddr_indices', $params)) {
+ $subaddr_indices = $params['subaddr_indices'];
+ }
+ if (array_key_exists('min_height', $params)) {
+ $min_height = $params['min_height'];
+ }
+ if (array_key_exists('max_height', $params)) {
+ $max_height = $params['max_height'];
+ }
+ }
+
+ $params = array('account_index' => $account_index, 'subaddr_indices' => $subaddr_indices, 'min_height' => $min_height, 'max_height' => $max_height);
+ for ($i = 0, $iMax = count($input_types); $i < $iMax; $i++) {
+ $params[$input_types[$i]] = true;
+ }
}
- if (array_key_exists('account_index', $params)) {
- $account_index = $params['account_index'];
- }
- if (array_key_exists('subaddr_indices', $params)) {
- $subaddr_indices = $params['subaddr_indices'];
- }
- if (array_key_exists('min_height', $params)) {
- $min_height = $params['min_height'];
- }
- if (array_key_exists('max_height', $params)) {
- $max_height = $params['max_height'];
- }
- }
- $params = array('account_index' => $account_index, 'subaddr_indices' => $subaddr_indices, 'min_height' => $min_height, 'max_height' => $max_height);
- for ($i = 0, $iMax = count($input_types); $i < $iMax; $i++) {
- $params[$input_types[$i]] = true;
- }
- }
+ if (array_key_exists('all', $params)) {
+ unset($params['all']);
+ $params['in'] = true;
+ $params['out'] = true;
+ $params['pending'] = true;
+ $params['failed'] = true;
+ $params['pool'] = true;
+ }
- if (array_key_exists('all', $params)) {
- unset($params['all']);
- $params['in'] = true;
- $params['out'] = true;
- $params['pending'] = true;
- $params['failed'] = true;
- $params['pool'] = true;
- }
+ if (($min_height || $max_height) && $max_height != 4206931337) {
+ $params['filter_by_height'] = true;
+ }
- if (($min_height || $max_height) && $max_height != 4206931337) {
- $params['filter_by_height'] = true;
+ return $this->_run('get_transfers', $params);
}
- return $this->_run('get_transfers', $params);
- }
-
/**
*
* Look up transaction by transaction ID
@@ -1391,11 +1393,11 @@ public function get_transfers($input_types = ['all'], $account_index = 0, $subad
* }
*
*/
- public function get_transfer_by_txid($txid, $account_index = 0)
- {
- $params = array('txid' => $txid, 'account_index' => $account_index);
- return $this->_run('get_transfer_by_txid', $params);
- }
+ public function get_transfer_by_txid($txid, $account_index = 0)
+ {
+ $params = array('txid' => $txid, 'account_index' => $account_index);
+ return $this->_run('get_transfer_by_txid', $params);
+ }
/**
*
@@ -1408,11 +1410,11 @@ public function get_transfer_by_txid($txid, $account_index = 0)
* }
*
*/
- public function sign($data)
- {
- $params = array('string' => $data);
- return $this->_run('sign', $params);
- }
+ public function sign($data)
+ {
+ $params = array('string' => $data);
+ return $this->_run('sign', $params);
+ }
/**
*
@@ -1427,11 +1429,11 @@ public function sign($data)
* }
*
*/
- public function verify($data, $address, $signature)
- {
- $params = array('data' => $data, 'address' => $address, 'signature' => $signature);
- return $this->_run('verify', $params);
- }
+ public function verify($data, $address, $signature)
+ {
+ $params = array('data' => $data, 'address' => $address, 'signature' => $signature);
+ return $this->_run('verify', $params);
+ }
/**
*
@@ -1444,10 +1446,10 @@ public function verify($data, $address, $signature)
* }
*
*/
- public function export_key_images()
- {
- return $this->_run('export_key_images');
- }
+ public function export_key_images()
+ {
+ return $this->_run('export_key_images');
+ }
/**
*
@@ -1463,11 +1465,11 @@ public function export_key_images()
* }
*
*/
- public function import_key_images($signed_key_images)
- {
- $params = array('signed_key_images' => $signed_key_images);
- return $this->_run('import_key_images', $params);
- }
+ public function import_key_images($signed_key_images)
+ {
+ $params = array('signed_key_images' => $signed_key_images);
+ return $this->_run('import_key_images', $params);
+ }
/**
*
@@ -1484,11 +1486,11 @@ public function import_key_images($signed_key_images)
* }
*
*/
- public function make_uri($address, $amount, $payment_id = null, $recipient_name = null, $tx_description = null)
- {
- $params = array('address' => $address, 'amount' => $this->_transform($amount), 'payment_id' => $payment_id, 'recipient_name' => $recipient_name, 'tx_description' => $tx_description);
- return $this->_run('make_uri', $params);
- }
+ public function make_uri($address, $amount, $payment_id = null, $recipient_name = null, $tx_description = null)
+ {
+ $params = array('address' => $address, 'amount' => $this->_transform($amount), 'payment_id' => $payment_id, 'recipient_name' => $recipient_name, 'tx_description' => $tx_description);
+ return $this->_run('make_uri', $params);
+ }
/**
*
@@ -1507,11 +1509,11 @@ public function make_uri($address, $amount, $payment_id = null, $recipient_name
* }
*
*/
- public function parse_uri($uri)
- {
- $params = array('uri' => $uri);
- return $this->_run('parse_uri', $params);
- }
+ public function parse_uri($uri)
+ {
+ $params = array('uri' => $uri);
+ return $this->_run('parse_uri', $params);
+ }
/**
*
@@ -1524,11 +1526,11 @@ public function parse_uri($uri)
* }
*
*/
- public function get_address_book($entries)
- {
- $params = array('entries' => $entries);
- return $this->_run('get_address_book', $params);
- }
+ public function get_address_book($entries)
+ {
+ $params = array('entries' => $entries);
+ return $this->_run('get_address_book', $params);
+ }
/**
*
@@ -1543,11 +1545,11 @@ public function get_address_book($entries)
* }
*
*/
- public function add_address_book($address, $payment_id, $description)
- {
- $params = array('address' => $address, 'payment_id' => $payment_id, 'description' => $description);
- return $this->_run('add_address_book', $params);
- }
+ public function add_address_book($address, $payment_id, $description)
+ {
+ $params = array('address' => $address, 'payment_id' => $payment_id, 'description' => $description);
+ return $this->_run('add_address_book', $params);
+ }
/**
*
@@ -1558,11 +1560,11 @@ public function add_address_book($address, $payment_id, $description)
* @return none
*
*/
- public function delete_address_book($index)
- {
- $params = array('index' => $index);
- return $this->_run('delete_address_book', $params);
- }
+ public function delete_address_book($index)
+ {
+ $params = array('index' => $index);
+ return $this->_run('delete_address_book', $params);
+ }
/**
*
@@ -1575,21 +1577,21 @@ public function delete_address_book($index)
* }
*
*/
- public function refresh($start_height = null)
- {
- $params = array('start_height' => $start_height);
- return $this->_run('refresh', $params);
- }
+ public function refresh($start_height = null)
+ {
+ $params = array('start_height' => $start_height);
+ return $this->_run('refresh', $params);
+ }
/**
*
* Rescan the blockchain for spent outputs
*
*/
- public function rescan_spent()
- {
- return $this->_run('rescan_spent');
- }
+ public function rescan_spent()
+ {
+ return $this->_run('rescan_spent');
+ }
/**
*
@@ -1602,11 +1604,11 @@ public function rescan_spent()
* @return none
*
*/
- public function start_mining($threads_count, $do_background_mining, $ignore_battery)
- {
- $params = array('threads_count' => $threads_count, 'do_background_mining' => $do_background_mining, 'ignore_battery' => $ignore_battery);
- return $this->_run('start_mining', $params);
- }
+ public function start_mining($threads_count, $do_background_mining, $ignore_battery)
+ {
+ $params = array('threads_count' => $threads_count, 'do_background_mining' => $do_background_mining, 'ignore_battery' => $ignore_battery);
+ return $this->_run('start_mining', $params);
+ }
/**
*
@@ -1617,10 +1619,10 @@ public function start_mining($threads_count, $do_background_mining, $ignore_batt
* @return none
*
*/
- public function stop_mining()
- {
- return $this->_run('stop_mining');
- }
+ public function stop_mining()
+ {
+ return $this->_run('stop_mining');
+ }
/**
*
@@ -1633,10 +1635,10 @@ public function stop_mining()
* }
*
*/
- public function get_languages()
- {
- return $this->_run('get_languages');
- }
+ public function get_languages()
+ {
+ return $this->_run('get_languages');
+ }
/**
*
@@ -1649,11 +1651,11 @@ public function get_languages()
* @return none
*
*/
- public function create_wallet($filename = 'monero_wallet', $password = null, $language = 'English')
- {
- $params = array('filename' => $filename, 'password' => $password, 'language' => $language);
- return $this->_run('create_wallet', $params);
- }
+ public function create_wallet($filename = 'monero_wallet', $password = null, $language = 'English')
+ {
+ $params = array('filename' => $filename, 'password' => $password, 'language' => $language);
+ return $this->_run('create_wallet', $params);
+ }
/**
*
@@ -1665,11 +1667,11 @@ public function create_wallet($filename = 'monero_wallet', $password = null, $la
* @return none
*
*/
- public function open_wallet($filename = 'monero_wallet', $password = null)
- {
- $params = array('filename' => $filename, 'password' => $password);
- return $this->_run('open_wallet', $params);
- }
+ public function open_wallet($filename = 'monero_wallet', $password = null)
+ {
+ $params = array('filename' => $filename, 'password' => $password);
+ return $this->_run('open_wallet', $params);
+ }
/**
*
@@ -1685,10 +1687,10 @@ public function open_wallet($filename = 'monero_wallet', $password = null)
* } // TODO multisig wallet example
*
*/
- public function is_multisig()
- {
- return $this->_run('is_multisig');
- }
+ public function is_multisig()
+ {
+ return $this->_run('is_multisig');
+ }
/**
*
@@ -1701,10 +1703,10 @@ public function is_multisig()
* }
*
*/
- public function prepare_multisig()
- {
- return $this->_run('prepare_multisig');
- }
+ public function prepare_multisig()
+ {
+ return $this->_run('prepare_multisig');
+ }
/**
*
@@ -1719,11 +1721,11 @@ public function prepare_multisig()
* }
*
*/
- public function make_multisig($multisig_info, $threshold, $password = '')
- {
- $params = array('multisig_info' => $multisig_info, 'threshold' => $threshold, 'password' => $password);
- return $this->_run('make_multisig', $params);
- }
+ public function make_multisig($multisig_info, $threshold, $password = '')
+ {
+ $params = array('multisig_info' => $multisig_info, 'threshold' => $threshold, 'password' => $password);
+ return $this->_run('make_multisig', $params);
+ }
/**
*
@@ -1736,10 +1738,10 @@ public function make_multisig($multisig_info, $threshold, $password = '')
* }
*
*/
- public function export_multisig_info()
- {
- return $this->_run('export_multisig_info');
- }
+ public function export_multisig_info()
+ {
+ return $this->_run('export_multisig_info');
+ }
/**
*
@@ -1752,11 +1754,11 @@ public function export_multisig_info()
* }
*
*/
- public function import_multisig_info($info)
- {
- $params = array('info' => $info);
- return $this->_run('import_multisig_info', $params);
- }
+ public function import_multisig_info($info)
+ {
+ $params = array('info' => $info);
+ return $this->_run('import_multisig_info', $params);
+ }
/**
*
@@ -1770,11 +1772,11 @@ public function import_multisig_info($info)
* }
*
*/
- public function finalize_multisig($multisig_info, $password = '')
- {
- $params = array('multisig_info' => $multisig_info, 'password' => $password);
- return $this->_run('finalize_multisig', $params);
- }
+ public function finalize_multisig($multisig_info, $password = '')
+ {
+ $params = array('multisig_info' => $multisig_info, 'password' => $password);
+ return $this->_run('finalize_multisig', $params);
+ }
/**
*
@@ -1787,11 +1789,11 @@ public function finalize_multisig($multisig_info, $password = '')
* }
*
*/
- public function sign_multisig($tx_data_hex)
- {
- $params = array('tx_data_hex' => $tx_data_hex);
- return $this->_run('sign_multisig', $params);
- }
+ public function sign_multisig($tx_data_hex)
+ {
+ $params = array('tx_data_hex' => $tx_data_hex);
+ return $this->_run('sign_multisig', $params);
+ }
/**
*
@@ -1804,57 +1806,57 @@ public function sign_multisig($tx_data_hex)
* }
*
*/
- public function submit_multisig($tx_data_hex)
- {
- $params = array('tx_data_hex' => $tx_data_hex);
- return $this->_run('submit_multisig', $params);
- }
+ public function submit_multisig($tx_data_hex)
+ {
+ $params = array('tx_data_hex' => $tx_data_hex);
+ return $this->_run('submit_multisig', $params);
+ }
/**
* @return jsonRPCClient
*/
- public function get_client()
- {
- return $this->client;
- }
+ public function get_client()
+ {
+ return $this->client;
+ }
/**
* @return jsonRPCClient
*/
- public function getClient()
- {
- return $this->client;
- }
+ public function getClient()
+ {
+ return $this->client;
+ }
/**
*
* Validate a wallet address
*
- * @param address - string; The address to validate.
- * any_net_type - boolean (Optional); If true, consider addresses belonging to any of the three Monero networks (mainnet, stagenet, and testnet) valid. Otherwise, only consider an address valid if it belongs to the network on which the rpc-wallet's current daemon is running (Defaults to false).
+ * @param address - string; The address to validate.
+ * any_net_type - boolean (Optional); If true, consider addresses belonging to any of the three Monero networks (mainnet, stagenet, and testnet) valid. Otherwise, only consider an address valid if it belongs to the network on which the rpc-wallet's current daemon is running (Defaults to false).
* allow_openalias - boolean (Optional); If true, consider OpenAlias-formatted addresses valid (Defaults to false).
*
- * @return valid - boolean; True if the input address is a valid Monero address.
- * integrated - boolean; True if the given address is an integrated address.
- * subaddress - boolean; True if the given address is a subaddress
- * nettype - string; Specifies which of the three Monero networks (mainnet, stagenet, and testnet) the address belongs to.
+ * @return valid - boolean; True if the input address is a valid Monero address.
+ * integrated - boolean; True if the given address is an integrated address.
+ * subaddress - boolean; True if the given address is a subaddress
+ * nettype - string; Specifies which of the three Monero networks (mainnet, stagenet, and testnet) the address belongs to.
* openalias_address - boolean; True if the address is OpenAlias-formatted.
*
*/
- public function validate_address($address, $strict_nettype = false, $allow_openalias = false)
- {
- $params = array(
- 'address' => $address,
- 'any_net_type' => $strict_nettype,
- 'allow_openalias' => $allow_openalias
- );
- return $this->_run('validate_address', $params);
- }
+ public function validate_address($address, $strict_nettype = false, $allow_openalias = false)
+ {
+ $params = array(
+ 'address' => $address,
+ 'any_net_type' => $strict_nettype,
+ 'allow_openalias' => $allow_openalias
+ );
+ return $this->_run('validate_address', $params);
+ }
/**
*
* Create a wallet on the RPC server from an address, view key, and (optionally) spend key.
- *
+ *
* @param filename is the name of the wallet to create on the RPC server
* @param password is the password encrypt the wallet
* @param address is the address of the wallet to construct
@@ -1867,20 +1869,20 @@ public function validate_address($address, $strict_nettype = false, $allow_opena
* @return TODO
*
*/
- public function generate_from_keys($filename, $password, $address, $viewKey, $spendKey = '', $language = 'English', $restoreHeight = 0, $saveCurrent = true)
- {
- $params = array(
- 'filename' => $filename,
- 'password' => $password,
- 'address' => $address,
- 'viewkey' => $viewKey,
- 'spendkey' => $spendKey,
- 'language' => $language,
- 'restore_height' => $restoreHeight,
- 'autosave_current' => $saveCurrent
- );
- return $this->_run('generate_from_keys', $params);
- }
+ public function generate_from_keys($filename, $password, $address, $viewKey, $spendKey = '', $language = 'English', $restoreHeight = 0, $saveCurrent = true)
+ {
+ $params = array(
+ 'filename' => $filename,
+ 'password' => $password,
+ 'address' => $address,
+ 'viewkey' => $viewKey,
+ 'spendkey' => $spendKey,
+ 'language' => $language,
+ 'restore_height' => $restoreHeight,
+ 'autosave_current' => $saveCurrent
+ );
+ return $this->_run('generate_from_keys', $params);
+ }
/**
*
@@ -1890,14 +1892,14 @@ public function generate_from_keys($filename, $password, $address, $viewKey, $sp
* @param multisig_info info (from eg. prepare_multisig)
*
*/
- public function exchange_multisig_keys($password, $multisig_info)
- {
- $params = array(
- 'password' => $password,
- 'multisig_info' => $multisig_info
- );
- return $this->_run('exchange_multisig_keys', $params);
- }
+ public function exchange_multisig_keys($password, $multisig_info)
+ {
+ $params = array(
+ 'password' => $password,
+ 'multisig_info' => $multisig_info
+ );
+ return $this->_run('exchange_multisig_keys', $params);
+ }
/**
*
@@ -1906,21 +1908,21 @@ public function exchange_multisig_keys($password, $multisig_info)
* @param txinfo txinfo
*
*/
- public function describe_transfer($txinfo)
- {
- $params = array(
- 'multisig_txset' => $txinfo,
- );
- return $this->_run('describe_transfer', $params);
- }
+ public function describe_transfer($txinfo)
+ {
+ $params = array(
+ 'multisig_txset' => $txinfo,
+ );
+ return $this->_run('describe_transfer', $params);
+ }
/**
* Export all outputs in hex format
*/
- public function export_outputs()
- {
- return $this->_run('export_outputs');
- }
+ public function export_outputs()
+ {
+ return $this->_run('export_outputs');
+ }
/**
*
@@ -1930,58 +1932,58 @@ public function export_outputs()
*
*
*/
- public function import_outputs($outputs_data_hex)
- {
- $params = array(
- 'outputs_data_hex' => $outputs_data_hex,
- );
- return $this->_run('import_outputs', $params);
- }
+ public function import_outputs($outputs_data_hex)
+ {
+ $params = array(
+ 'outputs_data_hex' => $outputs_data_hex,
+ );
+ return $this->_run('import_outputs', $params);
+ }
/**
* Set whether and how often to automatically refresh the current wallet
- *
+ *
* @param enable Enable or disable automatic refreshing (default = true)
* @param period The period of the wallet refresh cycle (i.e. time between refreshes) in seconds
- *
+ *
*/
- public function auto_refresh($enable = true, $period = 10)
- {
- $params = array(
- 'enable' => $enable,
- 'period' => $period
- );
- return $this->_run('auto_refresh', $params);
- }
+ public function auto_refresh($enable = true, $period = 10)
+ {
+ $params = array(
+ 'enable' => $enable,
+ 'period' => $period
+ );
+ return $this->_run('auto_refresh', $params);
+ }
/**
* Change a wallet password
- *
+ *
* @param old_password old password or blank
* @param new_password new password or blank
*/
- public function change_wallet_password($old_password = '', $new_password = '')
- {
- $params = array(
- 'old_password' => $old_password,
- 'new_password' => $new_password
- );
- return $this->_run('change_wallet_password', $params);
- }
+ public function change_wallet_password($old_password = '', $new_password = '')
+ {
+ $params = array(
+ 'old_password' => $old_password,
+ 'new_password' => $new_password
+ );
+ return $this->_run('change_wallet_password', $params);
+ }
/**
* Close wallet
*/
- public function close_wallet()
- {
- return $this->_run('close_wallet');
- }
+ public function close_wallet()
+ {
+ return $this->_run('close_wallet');
+ }
/**
* Get RPC version Major & Minor integer-format, where Major is the first 16 bits and Minor the last 16 bits.
*/
- public function get_version()
- {
- return $this->_run('get_version');
- }
+ public function get_version()
+ {
+ return $this->_run('get_version');
+ }
}
diff --git a/src/wordsets/chinese_simplified.ws.php b/src/wordsets/chinese_simplified.ws.php
index bb0c943..101ec6e 100644
--- a/src/wordsets/chinese_simplified.ws.php
+++ b/src/wordsets/chinese_simplified.ws.php
@@ -2,20 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class chinese_simplified implements wordset {
-
+class chinese_simplified implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "简体中文 (中国)";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "Chinese (simplified)";
}
@@ -25,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 1; // first letter of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"的",
"一",
@@ -1662,4 +1666,4 @@ static public function words() : array {
"貌",
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/dutch.ws.php b/src/wordsets/dutch.ws.php
index 6005986..27d7906 100644
--- a/src/wordsets/dutch.ws.php
+++ b/src/wordsets/dutch.ws.php
@@ -2,20 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class dutch implements wordset {
-
+class dutch implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "Nederlands";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "Dutch";
}
@@ -25,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 4; // first 4 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"aalglad",
"aalscholver",
@@ -1659,7 +1663,7 @@ static public function words() : array {
"zwepen",
"zwiep",
"zwijmel",
- "zworen"
+ "zworen"
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/english.ws.php b/src/wordsets/english.ws.php
index 9f96360..2b3d9c3 100644
--- a/src/wordsets/english.ws.php
+++ b/src/wordsets/english.ws.php
@@ -2,21 +2,23 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class english implements wordset {
-
+class english implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "English";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
- return "English";
+ public static function english_name(): string
+ {
+ return "English";
}
/* Returns integer indicating length of unique prefix,
@@ -25,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 3; // first 3 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"abbey",
"abducts",
@@ -1662,4 +1666,4 @@ static public function words() : array {
"zoom",
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/english_old.ws.php b/src/wordsets/english_old.ws.php
index 419a067..821cd0b 100644
--- a/src/wordsets/english_old.ws.php
+++ b/src/wordsets/english_old.ws.php
@@ -7,20 +7,22 @@
*/
-class english_old implements wordset {
-
+class english_old implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "EnglishOld";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "English (old)";
}
@@ -30,14 +32,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 0; // require entire word.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"like",
"just",
@@ -1667,4 +1671,4 @@ static public function words() : array {
"weary",
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/esperanto.ws.php b/src/wordsets/esperanto.ws.php
index de33c2d..b0bb5d7 100644
--- a/src/wordsets/esperanto.ws.php
+++ b/src/wordsets/esperanto.ws.php
@@ -2,20 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class esperanto implements wordset {
-
+class esperanto implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "Esperanto";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "Esperanto";
}
@@ -25,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 4; // first 4 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"abako",
"abdiki",
@@ -1659,7 +1663,7 @@ static public function words() : array {
"zoologio",
"zorgi",
"zukino",
- "zumilo",
+ "zumilo",
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/french.ws.php b/src/wordsets/french.ws.php
index 658c40d..74fa375 100644
--- a/src/wordsets/french.ws.php
+++ b/src/wordsets/french.ws.php
@@ -2,20 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class french implements wordset {
-
+class french implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
- return "Français";
+ public static function name(): string
+ {
+ return "Français";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "French";
}
@@ -25,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 4; // first 4 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"abandon",
"abattre",
@@ -1662,4 +1666,4 @@ static public function words() : array {
"zoom",
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/german.ws.php b/src/wordsets/german.ws.php
index 9805987..8d19213 100644
--- a/src/wordsets/german.ws.php
+++ b/src/wordsets/german.ws.php
@@ -2,20 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class german implements wordset {
-
+class german implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
- return "Deutsch";
+ public static function name(): string
+ {
+ return "Deutsch";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "German";
}
@@ -26,14 +28,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 4; // first 4 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"Abakus",
"Abart",
@@ -1660,7 +1664,7 @@ static public function words() : array {
"Zugvogel",
"Zündung",
"Zweck",
- "Zyklop"
+ "Zyklop"
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/italian.ws.php b/src/wordsets/italian.ws.php
index f730449..412ecbc 100644
--- a/src/wordsets/italian.ws.php
+++ b/src/wordsets/italian.ws.php
@@ -2,20 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class italian implements wordset {
-
+class italian implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "Italiano";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "Italian";
}
@@ -25,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 4; // first 4 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"abbinare",
"abbonato",
@@ -1659,7 +1663,7 @@ static public function words() : array {
"zoccolo",
"zolfo",
"zombie",
- "zucchero"
+ "zucchero"
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/japanese.ws.php b/src/wordsets/japanese.ws.php
index 6e63d70..9b66a9f 100644
--- a/src/wordsets/japanese.ws.php
+++ b/src/wordsets/japanese.ws.php
@@ -2,20 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class japanese implements wordset {
-
+class japanese implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "日本語";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "Japanese";
}
@@ -25,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 3; // first 3 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"あいこくしん",
"あいさつ",
@@ -1659,7 +1663,7 @@ static public function words() : array {
"ひさしぶり",
"ひさん",
"びじゅつかん",
- "ひしょ"
+ "ひしょ"
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/lojban.ws.php b/src/wordsets/lojban.ws.php
index 2219125..e2bafe6 100644
--- a/src/wordsets/lojban.ws.php
+++ b/src/wordsets/lojban.ws.php
@@ -2,21 +2,23 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class lojban implements wordset {
-
+class lojban implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
- return "Lojban";
+ public static function name(): string
+ {
+ return "Lojban";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
- return "Lojban";
+ public static function english_name(): string
+ {
+ return "Lojban";
}
/* Returns integer indicating length of unique prefix,
@@ -25,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 4; // first 4 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"backi",
"bacru",
@@ -1662,4 +1666,4 @@ static public function words() : array {
"snaxa'a",
];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/portuguese.ws.php b/src/wordsets/portuguese.ws.php
index cee713d..4cd4806 100644
--- a/src/wordsets/portuguese.ws.php
+++ b/src/wordsets/portuguese.ws.php
@@ -2,20 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class portuguese implements wordset {
-
+class portuguese implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "Português";
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "Portuguese";
}
@@ -26,14 +28,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 4; // first 4 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"abaular",
"abdominal",
@@ -1661,6 +1665,6 @@ static public function words() : array {
"zeloso",
"zenite",
"zumbi"
- ];
+ ];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/russian.ws.php b/src/wordsets/russian.ws.php
index 5c6a02d..003b71a 100644
--- a/src/wordsets/russian.ws.php
+++ b/src/wordsets/russian.ws.php
@@ -2,21 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class russian implements wordset {
-
+class russian implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "русский язык";
-
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "Russian";
}
@@ -26,14 +27,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 3; // first 3 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"абажур",
"абзац",
@@ -1660,7 +1663,7 @@ static public function words() : array {
"ясный",
"яхта",
"ячейка",
- "ящик"
- ];
+ "ящик"
+ ];
}
-}
\ No newline at end of file
+}
diff --git a/src/wordsets/spanish.ws.php b/src/wordsets/spanish.ws.php
index f5854b1..c0d95ef 100644
--- a/src/wordsets/spanish.ws.php
+++ b/src/wordsets/spanish.ws.php
@@ -2,21 +2,22 @@
namespace MoneroIntegrations\MoneroPhp\mnemonic;
-class spanish implements wordset {
-
+class spanish implements wordset
+{
/* Returns name of wordset in the wordset's native language.
* This is a human-readable string, and should be capitalized
* if the language supports it.
*/
- static public function name() : string {
+ public static function name(): string
+ {
return "Español";
-
}
- /* Returns name of wordset in english.
+ /* Returns name of wordset in english.
* This is a human-readable string, and should be capitalized
*/
- static public function english_name() : string {
+ public static function english_name(): string
+ {
return "Spanish";
}
@@ -27,14 +28,16 @@ static public function english_name() : string {
*
* A value of 0 indicates that there is no unique prefix
* and the entire word must be used instead.
- */
- static public function prefix_length() : int {
+ */
+ public static function prefix_length(): int
+ {
return 4; // first 4 letters of each word in wordset is unique.
}
-
+
/* Returns an array of all words in the wordset.
- */
- static public function words() : array {
+ */
+ public static function words(): array
+ {
return [
"ábaco",
"abdomen",
@@ -1661,7 +1664,7 @@ static public function words() : array {
"riqueza",
"risa",
"ritmo",
- "rito"
+ "rito"
];
}
-}
\ No newline at end of file
+}