1
1
<?php
2
2
namespace IEXBase \RippleAPI ;
3
3
4
- use GuzzleHttp \Client ;
5
- use GuzzleHttp \Exception \GuzzleException ;
6
4
use IEXBase \RippleAPI \Objects \AccountObject ;
7
5
use IEXBase \RippleAPI \Objects \PaymentObject ;
8
6
use IEXBase \RippleAPI \Objects \SignObject ;
9
7
use IEXBase \RippleAPI \Objects \TransactionObject ;
10
- use IEXBase \RippleAPI \Support \Collection ;
11
8
use IEXBase \RippleAPI \Transaction \TransactionBuilder ;
12
9
13
10
class Ripple
@@ -16,49 +13,50 @@ class Ripple
16
13
* Адрес кошелька
17
14
*
18
15
* @var string
19
- */
16
+ */
20
17
protected $ address ;
21
18
22
19
/**
23
20
* Приватный ключ кошелька
24
21
*
25
22
* @var string
26
- */
23
+ */
27
24
protected $ secret ;
28
25
29
26
/**
30
27
* Ripple client service
31
28
*
32
29
* @var RippleClient
33
- */
30
+ */
34
31
protected $ client ;
35
32
36
33
/**
37
34
* Получаем Хэш подписанной транзакции
38
35
*
39
36
* @var string
40
- */
37
+ */
41
38
protected $ tx_blob ;
42
39
43
40
/**
44
41
* Создаем объект суперкласса Ripple.
45
42
*
46
43
* @param $address
47
44
* @param null $secret
45
+ * @param array $nodes
48
46
*/
49
- public function __construct ($ address , $ secret = null )
47
+ public function __construct ($ address , $ secret = null , $ nodes = [] )
50
48
{
51
49
$ this ->address = $ address ;
52
50
$ this ->secret = $ secret ;
53
51
54
- $ this ->client = new RippleClient ();
52
+ $ this ->client = new RippleClient ($ nodes );
55
53
}
56
54
57
55
/**
58
56
* Получение пинга
59
57
*
60
58
* @return array
61
- */
59
+ */
62
60
public function getPing () : array
63
61
{
64
62
return $ this ->call ('ping ' , '/ ' );
@@ -68,7 +66,7 @@ public function getPing() : array
68
66
* Получаем детальную информацию о сервере
69
67
*
70
68
* @return array
71
- */
69
+ */
72
70
public function getServerInfo () : array
73
71
{
74
72
return $ this ->call ('server_info ' , '/ ' );
@@ -78,7 +76,7 @@ public function getServerInfo() : array
78
76
* Генерация случайних чисел
79
77
*
80
78
* @return array
81
- */
79
+ */
82
80
public function getRandom () : array
83
81
{
84
82
return $ this ->call ('random ' , '/ ' );
@@ -232,7 +230,7 @@ public function getTransaction($hash = null, $params = [])
232
230
* Получение последних версий
233
231
*
234
232
* @return array
235
- */
233
+ */
236
234
public function getRippledVersion ()
237
235
{
238
236
return $ this ->call ('GET ' , '/network/rippled_versions ' );
@@ -242,7 +240,7 @@ public function getRippledVersion()
242
240
* Получаем список всех шлюзов
243
241
*
244
242
* @return array
245
- */
243
+ */
246
244
public function getGateways ()
247
245
{
248
246
return $ this ->call ('GET ' , '/gateways ' );
@@ -307,7 +305,7 @@ public function getHealthValidationsEtl($params = [])
307
305
* Получаем комиссию
308
306
*
309
307
* @return array
310
- */
308
+ */
311
309
public function getFee ()
312
310
{
313
311
return $ this ->call ('fee ' , '/ ' );
@@ -389,6 +387,24 @@ public function submit()
389
387
}
390
388
}
391
389
390
+ /**
391
+ * Отправляем средства используя стронний сервер
392
+ *
393
+ * @param $options
394
+ * @return array
395
+ * @throws \Exception
396
+ */
397
+ public function sendAndSubmitForServer ($ options )
398
+ {
399
+ $ result = $ this ->client ->sendRequestWss ('POST ' ,'/send-xrp ' , $ options );
400
+
401
+ if (empty ($ result )) {
402
+ throw new \Exception ('Транзакция не отправлена ' );
403
+ } else {
404
+ return $ result ;
405
+ }
406
+ }
407
+
392
408
/**
393
409
* Базовая функция для формировании запросов
394
410
*
@@ -399,7 +415,7 @@ public function submit()
399
415
*/
400
416
protected function call ($ method , $ path , $ params = [])
401
417
{
402
- if (in_array ($ method , ['GET ' ,'POST ' ,'PUT ' ,'DELETE ' ])) {
418
+ if (in_array ($ method , ['GET ' , 'POST ' , 'PUT ' , 'DELETE ' ])) {
403
419
return $ this ->client ->sendRequest (
404
420
$ method ,
405
421
trim ($ path ),
0 commit comments