Skip to content

Commit 5ea46fc

Browse files
committed
get xpub is working
1 parent 95de052 commit 5ea46fc

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/Blockchain.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function post($resource, $data=null) {
101101
curl_setopt($this->ch, CURLOPT_URL, $url.$resource);
102102
curl_setopt($this->ch, CURLOPT_POST, true);
103103

104-
curl_setopt($this->ch, CURLOPT_HTTPHEADER,
104+
curl_setopt($this->ch, CURLOPT_HTTPHEADER,
105105
array("Content-Type: application/x-www-form-urlencoded"));
106106

107107
if(!is_null($this->api_code)) {
@@ -120,7 +120,7 @@ public function post($resource, $data=null) {
120120
return $json;
121121
}
122122

123-
public function get($resource, $params=null) {
123+
public function get($resource, $params=array()) {
124124
$url = Blockchain::URL;
125125

126126
if (($resource == "api/v2/create") || (substr($resource, 0, 8) === "merchant")) {

src/Explorer/Explorer.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,20 @@ public function getXpub($xpub, $limit=100, $offset=0, $filter=FilterType::Remove
7272
'format'=>'json',
7373
'limit'=>intval($limit),
7474
'offset'=>intval($offset),
75-
'filter'=>intval($filter)
75+
'filter'=>intval($filter),
76+
'active'=>$xpub
7677
);
77-
return new Xpub($this->blockchain->get('multiaddr?' . $params));
78+
$resp = $this->blockchain->get('multiaddr?', $params);
79+
if(array_key_exists('addresses', $resp)) {
80+
$xpub = new Xpub($resp['addresses'][0]);
81+
if(array_key_exists('txs', $resp)) {
82+
foreach ($resp['txs'] as $txn) {
83+
$xpub->transactions[] = new Transaction($txn);
84+
}
85+
}
86+
}
87+
return $xpub;
88+
7889
}
7990

8091
public function getMultiAddress($addresses, $limit=100, $offset=0, $filter=FilterType::RemoveUnspendable) {
@@ -88,7 +99,7 @@ public function getMultiAddress($addresses, $limit=100, $offset=0, $filter=Filte
8899
'filter'=>intval($filter),
89100
'active'=>implode('|', $addresses)
90101
);
91-
return new MultiAddress($this->blockchain->get('multiaddr?' . $params));
102+
return new MultiAddress($this->blockchain->get('multiaddr?', $params));
92103
}
93104

94105
/* Get a list of unspent outputs for an array of addresses

src/Explorer/Xpub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ public function __construct($json) {
2222
$this->change_index = $json['account_index'];
2323
if (array_key_exists('gap_limit', $json))
2424
$this->change_index = $json['gap_limit'];
25+
Address::__construct($json);
2526
}
2627
}

0 commit comments

Comments
 (0)