Created
January 11, 2014 22:55
-
-
Save theblazehen/8378100 to your computer and use it in GitHub Desktop.
eMu api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @package | |
| * @author theblazehen | |
| * @version 0.1 | |
| * @access public | |
| */ | |
| class eMu { | |
| private $url; | |
| public function __construct($url="localhost"){ | |
| $this->url = $url; | |
| } | |
| public function emunie_query($query, $query_params){ | |
| $url = $this->url; | |
| $curlurl = $url . ':20001' . '/' . $query . '?' . http_build_query($query_params); | |
| //initialize curl | |
| $ch = null; //dunno if it will try and reatin values from previous run, this is here just in case | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($ch, CURLOPT_USERAGENT, 'eMunie PHP Class'); | |
| curl_setopt($ch, CURLOPT_URL, $curlurl); | |
| $result = json_decode(curl_exec($ch)); | |
| return $result; | |
| } | |
| function closeWallet($wallet){ | |
| /*$wallet can be either name or address, as this function will call close on both*/ | |
| //todo see if it works when you put both values in array | |
| $query_params = array('name' => $wallet); | |
| emunie_query("closewallet", $query_params); | |
| $query_params = array('address' => $wallet); | |
| emunie_query("closewallet", $query_params); | |
| } | |
| function createAssets($quantity, $asset, $account, $key, $message=null){ | |
| $query_params = array( | |
| 'quantity' => $quantity, | |
| 'asset' => $asset, | |
| 'account' => $account, | |
| 'key' => $key, | |
| 'message' => $message | |
| ); | |
| return emunie_query("createassets", $query_params); | |
| } | |
| function createENS($address, $ens, $key){ | |
| $query_params = array( | |
| 'address' => $address, | |
| 'ens' => $ens, | |
| 'key' => $key | |
| ); | |
| return emunie_query("createens", $queryparams); | |
| } | |
| function createWallet($name, $path){ | |
| $query_params = array( | |
| 'name' => $name, | |
| 'path' => $path | |
| ); | |
| return emunie_query("createwallet", $query_params); | |
| } | |
| function deleteENS($ens, $key){ | |
| $query_params( | |
| 'ens' => $ens, | |
| 'key' => $key | |
| ); | |
| return emunie_query("deleteens", $query_params); | |
| } | |
| function getAccount($account){ | |
| $query_params('account' => $account); | |
| return emunie_query("getaccount", $query_params); | |
| } | |
| function getBlockCount(){ | |
| return emunie_query("getblockcount") | |
| } | |
| function getBalance($account){ | |
| $query_params = array('account' => $account); | |
| return emunie_query("getbalance", $query_params); | |
| } | |
| function getBlock($block){ | |
| $query_params = array('block' => $block); | |
| return emunie_query("getblock", $block); | |
| } | |
| function getBlockCount(){ | |
| $query_params = array(); | |
| return emunie_query("getblockcount", $query_params); | |
| } | |
| function getBlockHeader($block){ | |
| $query_params = array('block' => $block); | |
| return emunie_query("getblockheader", $query_params); | |
| } | |
| function getBlockWithTransaction($tx){ | |
| $query_params = array('tx' => $tx); | |
| return emunie_query("getblockwithtransaction", $query_params); | |
| } | |
| function getConnectionCount(){ | |
| $query_params = array(); | |
| return emunie_query("getconnectioncount", $query_params); | |
| } | |
| function getSyncStats(){ | |
| $query_params = array(); | |
| return emunie_query("getsyncstats", $query_params); | |
| } | |
| function getTreeStats(){ | |
| $query_params = array(); | |
| return emunie_query("gettreestats", $query_params); | |
| } | |
| function getTxCount(){ | |
| $query_params = array(); | |
| return emunie_query("gettxcount", $query_params); | |
| } | |
| function help(){ | |
| $query_params = array(); | |
| return emunie_query("help", $query_params); | |
| } | |
| function isTransactionInBlock($tx){ | |
| $query_params = array('tx' => $tx); | |
| return emunie_query("istransactioninblock", $query_params); | |
| } | |
| function listTransactions($account){ | |
| $query_params = array('account' => $account); | |
| return emunie_query("listtransactions", $query_params); | |
| } | |
| function openWallet($name, $path){ | |
| $query_params = array( | |
| 'name' => $name, | |
| 'path' => $path | |
| ); | |
| return emunie_query("openwallet", $query_params); | |
| } | |
| function registerAsset($iso, $label, $desc, $class, $settings, $expires, $assetKey){ | |
| $query_params = array( | |
| 'iso' => $iso, | |
| 'label' => $label, | |
| 'desc' => $desc, | |
| 'class' => $class, | |
| 'settings' => $settings, | |
| 'expires' => $expires, | |
| 'assetKey' => $assetKey | |
| ); | |
| return emunie_query("registerasset", $query_params); | |
| } | |
| function send($amount, $asset, $account, $receiver, $fee, $message){ | |
| $query_params = array( | |
| 'amount' => $amount, | |
| 'asset' => $asset, | |
| 'account' => $account, | |
| 'receiver' => $receiver, | |
| 'fee' => $fee, | |
| 'message' => $message | |
| ); | |
| return emunie_query("send", $query_params); | |
| function transferENS($ens, $address, $newaddress, $key){ | |
| $query_params = array( | |
| 'ens' => $ens, | |
| 'address' => $address, | |
| 'newaddress' => $newaddress, | |
| 'key' => $key | |
| ); | |
| return emunie_query("transferens", $query_params); | |
| } | |
| function unBanPeer($address){ | |
| $query_params = array('address' => $address); | |
| return emunie_query("unbanpeer", $query_params); | |
| } | |
| function updateENS($address, $ens, $data, $key){ | |
| $query_params = array( | |
| 'address' => $address, | |
| 'ens' => $ens, | |
| 'data' => $data, | |
| 'key' => $key | |
| ); | |
| return emunie_query("updateens", $query_params); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment