diff --git a/web/yaamp/core/rpc/wallet-rpc.php b/web/yaamp/core/rpc/wallet-rpc.php index 5a304bd..6397524 100644 --- a/web/yaamp/core/rpc/wallet-rpc.php +++ b/web/yaamp/core/rpc/wallet-rpc.php @@ -218,8 +218,59 @@ class WalletRPC { $this->error = $this->rpc_wallet->error; break; case 'listtransactions': - $res = $this->rpc_wallet->get_bulk_payments(); + // make it as close as possible as bitcoin rpc... sigh (todo: xmr-rpc function) + $txs = array(); + $named_params = array('transfer_type' => 'all'); + $res = $this->rpc_wallet->incoming_transfers($named_params); + $res = isset($res['transfers']) ? $res['transfers'] : array(); $this->error = $this->rpc_wallet->error; + foreach ($res as $k=>$tx) { + $tx['category'] = 'receive'; + $tx['txid'] = $tx['tx_hash']; + $tx['amount'] = $tx['amount'] / 1e12; + $raw = $this->rpc->gettransactions(array( + 'txs_hashes' => array($tx['tx_hash']), + 'decode_as_json' => true + )); + $raw = reset(arraySafeVal($raw,'txs',array())); + if (!empty($raw)) { + $k = (double) $raw['block_height'] + ($k/1000.0); + unset($raw['as_hex']); + unset($raw['tx_hash']); + //$raw['json'] = json_decode($raw['as_json']); + unset($raw['as_json']); + } + $tx = array_merge($tx, $raw); + unset($tx['tx_hash']); + $k = sprintf("%015.4F", $k); // sort key + $txs[$k] = $tx; + } + $named_params = array('min_block_height' => 1); + $res = $this->rpc_wallet->get_bulk_payments($named_params); + $res = isset($res['payments']) ? $res['payments'] : array(); + foreach ($res as $k=>$tx) { + $tx['category'] = 'send'; + $k = (double) $raw['block_height'] + 0.5 + ($k/1000.0); // sort key + $tx['txid'] = $tx['tx_hash']; + $tx['amount'] = $tx['amount'] / 1e12; + $raw = $this->rpc->gettransactions(array( + 'txs_hashes' => array($tx['tx_hash']), + 'decode_as_json' => true + )); + $raw = reset(arraySafeVal($raw,'txs',array())); + if (!empty($raw)) { + unset($raw['as_hex']); + unset($raw['tx_hash']); + //$raw['json'] = json_decode($raw['as_json']); + unset($raw['as_json']); + } + $tx = array_merge($tx, $raw); + unset($tx['tx_hash']); + $k = sprintf("%015.4F", $k); + $txs[$k] = $tx; + } + krsort($txs); + $res = array_values($txs); break; case 'getaddress': $res = $this->rpc_wallet->getaddress(); @@ -241,7 +292,10 @@ class WalletRPC { $this->error = $this->rpc_wallet->error; break; case 'incoming_transfers': // deprecated ? - $res = $this->rpc_wallet->incoming_transfers(); + $named_params = array( + "transfer_type"=>arraySafeVal($params, 0) + ); + $res = $this->rpc_wallet->incoming_transfers($named_params); $this->error = $this->rpc_wallet->error; break; case 'sendtoaddress': @@ -298,6 +352,16 @@ class WalletRPC { $res = $this->rpc_wallet->store(); $this->error = $this->rpc_wallet->error; break; + case 'gettransactions': + $named_params = array( + "txs_hashes" => array(arraySafeVal($params, 0, array())), + 'decode_as_json' => true + ); + $res = $this->rpc->gettransactions($named_params); + unset($res['txs_as_hex']); // dup + unset($res['txs_as_json']); // dup + $this->error = $this->rpc->error; + return $res; default: // default to daemon $res = $this->rpc->__call($method,$params); diff --git a/web/yaamp/core/rpc/xmr-rpc.php b/web/yaamp/core/rpc/xmr-rpc.php index 4b95e2e..b7d28b8 100644 --- a/web/yaamp/core/rpc/xmr-rpc.php +++ b/web/yaamp/core/rpc/xmr-rpc.php @@ -43,11 +43,11 @@ class CryptoRPC switch ($method) { case 'getheight': case 'getinfo': - case 'gettransactions': case 'start_mining': case 'stop_mining': return $this->rpcget($method, $params); + case 'gettransactions': // decodetransaction case 'sendrawtransaction': return $this->rpcpost($method, $params); @@ -63,6 +63,7 @@ class CryptoRPC // queries with named params case 'getblocktemplate': case 'get_payments': + case 'incoming_transfers': if (count($params) == 1) { // __call put all params in array $params $pop = array_shift($params); @@ -110,11 +111,13 @@ class CryptoRPC ); curl_setopt_array($curl, $options); - curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); - //debuglog(json_encode($data)); + $postdata = json_encode($data); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); + //debuglog($postdata); // Execute the request and decode to an array $this->raw_response = curl_exec($curl); + //debuglog($this->raw_response); $this->response = json_decode($this->raw_response, TRUE); diff --git a/web/yaamp/modules/market/update.php b/web/yaamp/modules/market/update.php index 132af8f..7ec013a 100644 --- a/web/yaamp/modules/market/update.php +++ b/web/yaamp/modules/market/update.php @@ -12,13 +12,13 @@ echo CUFHtml::openTag('fieldset', array('class'=>'inlineLabels')); echo CUFHtml::openActiveCtrlHolder($market, 'deposit_address'); echo CUFHtml::activeLabelEx($market, 'deposit_address'); echo CUFHtml::activeTextField($market, 'deposit_address', array('maxlength'=>200)); -echo "

.

"; +echo '

Use Address::PaymentID on XMR forks

'; echo CUFHtml::closeCtrlHolder(); echo CUFHtml::openActiveCtrlHolder($market, 'base_coin'); echo CUFHtml::activeLabelEx($market, 'base_coin'); echo CUFHtml::activeTextField($market, 'base_coin', array('maxlength'=>16,'style'=>'width: 40px;')); -echo "

Default (empty) is BTC

"; +echo '

Default (empty) is BTC

'; echo CUFHtml::closeCtrlHolder(); echo CUFHtml::closeTag('fieldset'); diff --git a/web/yaamp/modules/site/coin_results.php b/web/yaamp/modules/site/coin_results.php index 76bf2e5..4f0be2f 100644 --- a/web/yaamp/modules/site/coin_results.php +++ b/web/yaamp/modules/site/coin_results.php @@ -81,7 +81,7 @@ foreach($list as $market) echo ''.$price.''; echo ''.$price2.''; - echo ''; + echo ''; if (!empty($market->deposit_address)) { $name = CJavaScript::encode($market->name); $addr = CJavaScript::encode($market->deposit_address); @@ -307,12 +307,13 @@ $txs_array = array(); $lastday = ''; if (!empty($txs)) { // to hide truncated days sums $tx = reset($txs); - if (count($txs) == 2500) + + if (count($txs) == 2500 && isset($tx['time'])) $lastday = strftime('%F', $tx['time']); if (!empty($txs)) foreach($txs as $tx) { - if (intval($tx['time']) > $list_since) + if (ArraySafeVal($tx, 'time', $list_since+1) > $list_since) $txs_array[] = $tx; } @@ -393,7 +394,7 @@ if ($DCR) { $rows = 0; foreach($txs_array as $tx) { - $category = $tx['category']; + $category = ArraySafeVal($tx,'category'); if ($category == 'spent') continue; $block = null; @@ -402,6 +403,12 @@ foreach($txs_array as $tx) echo ''; + if (!isset($tx['time'])) { + // martian wallets + echo ''.json_encode($tx).''; + continue; + } + $d = datetoa2($tx['time']); echo ''.$d.''; @@ -470,6 +477,8 @@ end; $sums = array(); foreach($txs_array as $tx) { + if (!isset($tx['time'])) continue; + $day = strftime('%F', $tx['time']); // YYYY-MM-DD if ($day == $lastday) break; // do not show truncated days