parent
fca7bd7b3d
commit
90a8404bab
77
cronjobs/liquid_payout.php
Normal file → Executable file
77
cronjobs/liquid_payout.php
Normal file → Executable file
@ -6,53 +6,64 @@ chdir(dirname(__FILE__));
|
||||
// Include all settings and classes
|
||||
require_once('shared.inc.php');
|
||||
|
||||
// Check For RPC Connection
|
||||
if ($bitcoin->can_connect() === true){
|
||||
$dBalance = $bitcoin->getbalance();
|
||||
// Check Wallet Balance
|
||||
$log->logDebug("The Wallet Balance is " .$dBalance. "\n");
|
||||
$dGetInfo = $bitcoin->getinfo();
|
||||
|
||||
// Check for POS Mint
|
||||
|
||||
if (is_array($dGetInfo) && array_key_exists('newmint', $dGetInfo)) {
|
||||
$dNewmint = $dGetInfo['newmint'];
|
||||
$log->logDebug("Current Mint is: " .$dNewmint);
|
||||
} else {
|
||||
$dNewmint = -1;
|
||||
}
|
||||
// Simple configuration check
|
||||
if (empty($config['coldwallet'])) {
|
||||
$log->logFatal('Missing config option: coldwallet');
|
||||
$monitoring->endCronjob($cron_name, 'E0075', 1, true);
|
||||
}
|
||||
else {
|
||||
$dBalance = 0;
|
||||
$dNewmint = -1;
|
||||
$log->logError('Unable to connect to wallet RPC service');
|
||||
|
||||
// Check RPC connection
|
||||
if ($bitcoin->can_connect() !== true) {
|
||||
$log->logFatal('Unable to connect to RPC server, exiting');
|
||||
$monitoring->endCronjob($cron_name, 'E0006', 1, true);
|
||||
} else {
|
||||
// Check Wallet Balance
|
||||
$dBalance = $bitcoin->getbalance();
|
||||
$log->logDebug('The wallet balance is: ' .$dBalance);
|
||||
|
||||
// Do we have anything available at all?
|
||||
if (! ($dBalance > 0)) {
|
||||
$log->logInfo('No coins available in wallet');
|
||||
$monitoring->endCronjob($cron_name, 'E0076', 0, true, false);
|
||||
}
|
||||
|
||||
// Check for POS Mint
|
||||
$dGetInfo = $bitcoin->getinfo();
|
||||
if (is_array($dGetInfo) && array_key_exists('newmint', $dGetInfo)) {
|
||||
$dNewmint = $dGetInfo['newmint'];
|
||||
$log->logDebug('Current Mint is: ' . $dNewmint);
|
||||
} else {
|
||||
$dNewmint = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch locked balance from transactions
|
||||
$dLockedBalance = $transaction->getLockedBalance();
|
||||
$log->logDebug("The Locked Wallet Balance for Users is: " .$dLockedBalance. "\n");
|
||||
$log->logDebug('The locked wallet balance for users is: ' . $dLockedBalance);
|
||||
|
||||
// Fetch Final Wallet Balance after Transfer
|
||||
$dFloat = $dLockedBalance + $config['coldwallet']['reserve'];
|
||||
$dThreshold = $config['coldwallet']['threshold'];
|
||||
$sendAddress = $config['coldwallet']['address'];
|
||||
|
||||
$log->logDebug("The Locked Wallet Balance & Float amounts to: " .$dFloat. "\n");
|
||||
$log->logDebug('The locked wallet balance + reserves amounts to: ' . $dFloat);
|
||||
|
||||
// Send Liquid Balance
|
||||
$sendAddress = $config['coldwallet']['address'];
|
||||
$send = $dBalance - $dFloat ;
|
||||
$log->logInfo("Final Sending Amount is : " .$send. "\n");
|
||||
$log->logDebug('Final Sending Amount is : ' . $send);
|
||||
|
||||
if($send > $dThreshold){
|
||||
if($sendAddress !== ''){
|
||||
$bitcoin->sendtoaddress($sendAddress, $send);
|
||||
if($send > $dThreshold) {
|
||||
if (!empty($sendAddress)) {
|
||||
try {
|
||||
$bitcoin->sendtoaddress($sendAddress, $send);
|
||||
} catch (BitcoinClientException $e) {
|
||||
$log->logError('Failed to send coins to address, skipping liquid assets payout');
|
||||
}
|
||||
$log->logInfo('Sent out ' . $send . ' liquid assets');
|
||||
} else {
|
||||
$log->logDebug('No wallet address set');
|
||||
}
|
||||
else {
|
||||
$log->logInfo("No wallet address set\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$log->logInfo("Final Sending Amount Not Exceed threshold : " .$send. "\n");
|
||||
} else {
|
||||
$log->logDebug('Final sending amount not exceeding threshold: ' . $send);
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@ -73,4 +73,5 @@ $aErrorCodes['E0072'] = 'Worker names must be alphanumeric';
|
||||
$aErrorCodes['E0073'] = 'Worker name is too long; try entering a shorter name';
|
||||
$aErrorCodes['E0074'] = 'Failed deleting expired tokens';
|
||||
$aErrorCodes['E0075'] = 'Upgrade required';
|
||||
$aErrorCodes['E0076'] = 'No coins in wallet available';
|
||||
?>
|
||||
|
||||
@ -77,19 +77,28 @@ $config['wallet']['username'] = 'testnet';
|
||||
$config['wallet']['password'] = 'testnet';
|
||||
|
||||
/**
|
||||
* Added support for payout of liquid assets
|
||||
*
|
||||
* address: the address of the wallet to the address you'd like to receive the coins in
|
||||
* * reserve: is the amount you'd like to remain in the wallet. Recommended is at least 1 block value
|
||||
* threshold: is the amount of coins you'd like to send per batch minimum. once exceeded this is sent
|
||||
* to the address of the cold wallet.
|
||||
*
|
||||
* Payout of liquid assets
|
||||
*
|
||||
* Explanation:
|
||||
* Running pools, especially those with active fees, will build up a good
|
||||
* amount of liquid assets that can be used by pool operators. If you wish
|
||||
* to automaitcally send your assets to a offline wallet, set your account
|
||||
* address, reserves and thresholds here.
|
||||
*
|
||||
* Options:
|
||||
* address : The address of the wallet to the address you'd like to receive the coins in
|
||||
* reserve : The amount you'd like to remain in the wallet. Recommended is at least 1 block value
|
||||
* threshold : The amount of coins you'd like to send per batch minimum. Once exceeded, this is sent
|
||||
* to the offline wallet address specified.
|
||||
* Default:
|
||||
* addresss : empty
|
||||
* reserve : 50
|
||||
* threshold : 25
|
||||
**/
|
||||
|
||||
$config['coldwallet']['address'] = '';
|
||||
$config['coldwallet']['reserve'] = 1.1;
|
||||
$config['coldwallet']['threshold'] = 1;
|
||||
|
||||
$config['coldwallet']['reserve'] = 50;
|
||||
$config['coldwallet']['threshold'] = 5;
|
||||
|
||||
/**
|
||||
* Lock account after maximum failed logins
|
||||
|
||||
@ -10,7 +10,7 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) {
|
||||
}
|
||||
|
||||
// Default crons to monitor
|
||||
$aCrons = array('statistics','payouts','token_cleanup','archive_cleanup','blockupdate','findblock','notifications','tickerupdate');
|
||||
$aCrons = array('statistics','payouts','token_cleanup','archive_cleanup','blockupdate','findblock','notifications','tickerupdate','liquid_payout');
|
||||
|
||||
// Special cases, only add them if activated
|
||||
switch ($config['payout_system']) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user