mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-25 21:00:39 +00:00
API: WalletEx: payouts (optional) (#291)
new config keys : YAAMP_API_PAYOUTS (def. false) and YAAMP_API_PAYOUTS_PERIOD (last 24h)
This commit is contained in:
parent
c25d7b9b77
commit
d78a932939
3 changed files with 36 additions and 1 deletions
|
@ -48,6 +48,8 @@ if (!defined('EXCH_STOCKSEXCHANGE_KEY')) define('EXCH_STOCKSEXCHANGE_KEY', '');
|
|||
if (!defined('YAAMP_BTCADDRESS')) define('YAAMP_BTCADDRESS', '');
|
||||
if (!defined('YAAMP_SITE_URL')) define('YAAMP_SITE_URL', 'localhost');
|
||||
if (!defined('YAAMP_API_URL')) define('YAAMP_API_URL', YAAMP_SITE_URL);
|
||||
if (!defined('YAAMP_API_PAYOUTS')) define('YAAMP_API_PAYOUTS', false);
|
||||
if (!defined('YAAMP_API_PAYOUTS_PERIOD')) define('YAAMP_API_PAYOUTS_PERIOD', 24 * 60 * 60);
|
||||
if (!defined('YAAMP_STRATUM_URL')) define('YAAMP_STRATUM_URL', YAAMP_SITE_URL);
|
||||
if (!defined('YAAMP_SITE_NAME')) define('YAAMP_SITE_NAME', 'YiiMP');
|
||||
if (!defined('YAAMP_DEFAULT_ALGO')) define('YAAMP_DEFAULT_ALGO', 'x11');
|
||||
|
|
|
@ -284,6 +284,29 @@ class ApiController extends CommonController
|
|||
}
|
||||
|
||||
echo "]";
|
||||
|
||||
if(YAAMP_API_PAYOUTS)
|
||||
{
|
||||
$json_payouts = controller()->memcache->get("api_payouts-$user->id");
|
||||
if (empty($json_payouts)) {
|
||||
$json_payouts = ",\"payouts\": ";
|
||||
$json_payouts .= "[";
|
||||
$list = getdbolist('db_payouts', "account_id={$user->id} AND completed>0 AND tx IS NOT NULL AND time >= ".(time() - YAAMP_API_PAYOUTS_PERIOD)." ORDER BY time DESC");
|
||||
foreach($list as $j => payout)
|
||||
{
|
||||
if($j) $json_payouts .= ", ";
|
||||
$json_payouts .= "{";
|
||||
$json_payouts .= "\"time\": \"$payout->time\",";
|
||||
$json_payouts .= "\"amount\": \"$payout->amount\",";
|
||||
$json_payouts .= "\"tx\": \"$payout->tx\"";
|
||||
$json_payouts .= "}";
|
||||
}
|
||||
$json_payouts .= "]";
|
||||
controller()->memcache->set("api_payouts-$user->id", $json_payouts, 60, MEMCACHE_COMPRESSED);
|
||||
}
|
||||
echo str_replace("},","},\n", $json_payouts);
|
||||
}
|
||||
|
||||
echo "}";
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,19 @@ result:
|
|||
"accepted": 82463372.083,
|
||||
"rejected": 0
|
||||
}]
|
||||
<?php if (YAAMP_API_PAYOUTS) : ?>
|
||||
"payouts":[{
|
||||
"time": "1529860641",
|
||||
"amount": "0.001",
|
||||
"tx": "transaction_id_of_the_payout"
|
||||
}]
|
||||
<?php endif; ?>
|
||||
}
|
||||
</pre>
|
||||
|
||||
<?php
|
||||
if (YAAMP_API_PAYOUTS)
|
||||
echo "Payouts of the last ".(YAAMP_API_PAYOUTS_PERIOD / 3600)." hours are displayed, please use a block explorer to see all payouts.";
|
||||
?>
|
||||
<p><b>Pool Status</b></p>
|
||||
|
||||
request:
|
||||
|
|
Loading…
Add table
Reference in a new issue