예제 #1
0
 /**
  * @internal
  */
 private static function getClient()
 {
     if (!is_null(self::$client)) {
         return self::$client;
     }
     if (RippleRestClientCURL::isAvailable()) {
         return self::$client = new RippleRestClientCURL();
     }
     if (RippleRestClientURLFileOpen::isAvailable()) {
         return self::$client = new RippleRestClientURLFileOpen();
     }
     throw new RippleRestProtocolError("There is no Client available. Please try install cURL or turn on 'allow_url_fopen'.");
 }
예제 #2
0
<?php

spl_autoload_register(function ($name) {
    if (is_file("src/{$name}.php")) {
        require_once "src/{$name}.php";
    }
});
RippleRest::setup("http://localhost:5990");
var_dump(RippleRest::isServerConnected());
var_dump(RippleRest::getServerInfo());
var_dump(RippleRest::createUUID());
var_dump(RippleRest::getTransaction("A29DED58C4EA3D04FD4501108AB9AE6EBEF3249E892E34A2351C4A1A1A88E90B"));
$account = new RippleRestAccount("rES1hSkoWauMk3r6sgh7zfjpTCnwGbqaxA", "sSECRET");
var_dump($account->getBalances());
var_dump($account->getSettings());
var_dump($account->getTrustlines());
/* $account->addTrustline(array(
    "limit" => 5,
    "currency" => "ICE",
    "counterparty" => "r4H3F9dDaYPFwbrUsusvNAHLz2sEZk4wE5"
)); */
var_dump($account->getNotification("DD9F40516152090612B12F1CCD5A88828AEA8813FEBD56D9D6B39ED918F4CCCA"));
var_dump($account->findPaymentPaths("rhtgn6PYbXwhA6QJJMY4btieoap31t7Uo8", "5+ICE+rES1hSkoWauMk3r6sgh7zfjpTCnwGbqaxA"));
var_dump($account->queryPayments(array("resultsPerPage" => 10)));
$payment = $account->createPayment("rES1hSkoWauMk3r6sgh7zfjpTCnwGbqaxA", "5+XRP");
$account->submitPayment($payment);
예제 #3
0
 /**
  * Browse historical payments in bulk.
  * @param array $options (Defaults to null) An assoc array with the following options:
  *   * `sourceAccount` [string, RippleRestAccount] If specified, limit the results to payments initiated by a particular account
  *   * `destinationAccount` [string, RippleRestAccount]  If specified, limit the results to payments made to a particular account
  *   * `excludeFailed` [boolean] if set to true, this will return only payment that were successfully validated and written into the Ripple Ledger
  *   * `startLedger` [string] If earliest_first is set to true this will be the index number of the earliest ledger queried, or the most recent one if earliest_first is set to false. Defaults to the first ledger the rippled has in its complete ledger. An error will be returned if this value is outside the rippled's complete ledger set
  *   * `endLedger` [string] If earliest_first is set to true this will be the index number of the most recent ledger queried, or the earliest one if earliest_first is set to false. Defaults to the last ledger the rippled has in its complete ledger. An error will be returned if this value is outside the rippled's complete ledger set
  *   * `earliestFirst` [boolean] Determines the order in which the results should be displayed. Defaults to true
  *   * `resultsPerPage` [int] Limits the number of resources displayed per page. Defaults to 20
  *   * `page` [int] : The page to be displayed. If there are fewer than the results_per_page number displayed, this indicates that this is the last page
  * @throws RippleRestError if RippleRest server returns an error
  * @throws RippleRestProtocolError if protocol is wrong or network is down
  * @return Payment[]
  */
 public function queryPayments($options = null)
 {
     $qs = array();
     $o = array();
     if (is_null($options)) {
         $options = array();
     }
     foreach ($options as $k => $v) {
         $o[strtolower(str_replace("_", "", $k))] = $v;
     }
     if (isset($o["sourceaccount"])) {
         $qs['source_account'] = $o["sourceaccount"] instanceof RippleRestAccount ? $o["sourceaccount"]->address : $o["sourceaccount"];
     }
     if (isset($o["destinationaccount"])) {
         $qs['destination_account'] = $o["destinationaccount"] instanceof RippleRestAccount ? $o["destinationaccount"]->address : $o["destinationaccount"];
     }
     if (isset($o['excludefailed'])) {
         $qs['exclude_failed'] = $o['excludefailed'];
     }
     if (isset($o['startledger'])) {
         $qs['start_ledger'] = $o['startledger'];
     }
     if (isset($o['endledger'])) {
         $qs['end_ledger'] = $o['endledger'];
     }
     if (isset($o['earliestfirst'])) {
         $qs['earliest_first'] = $o['earliestfirst'];
     }
     if (isset($o['resultsperpage'])) {
         $qs['results_per_page'] = $o['resultsperpage'];
     }
     if (isset($o['page'])) {
         $qs['page'] = $o['page'];
     }
     if (count($qs) > 0) {
         $querystring = "?" . http_build_query($qs);
     } else {
         $querystring = "";
     }
     $uri = "v1/accounts/" . $this->address . "/payments{$querystring}";
     $result = RippleRest::get($uri);
     $data = $result["payments"];
     for ($i = 0; $i < count($data); $i++) {
         $clientResourceId = $data[$i]["client_resource_id"];
         $data[$i] = new RippleRestPayment($data[$i]["payment"]);
         $data[$i]->clientResourceId = $clientResourceId;
     }
     return $data;
 }