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
|
// Include all settings and classes
|
||||||
require_once('shared.inc.php');
|
require_once('shared.inc.php');
|
||||||
|
|
||||||
// Check For RPC Connection
|
// Simple configuration check
|
||||||
if ($bitcoin->can_connect() === true){
|
if (empty($config['coldwallet'])) {
|
||||||
$dBalance = $bitcoin->getbalance();
|
$log->logFatal('Missing config option: coldwallet');
|
||||||
// Check Wallet Balance
|
$monitoring->endCronjob($cron_name, 'E0075', 1, true);
|
||||||
$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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$dBalance = 0;
|
// Check RPC connection
|
||||||
$dNewmint = -1;
|
if ($bitcoin->can_connect() !== true) {
|
||||||
$log->logError('Unable to connect to wallet RPC service');
|
$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
|
// Fetch locked balance from transactions
|
||||||
$dLockedBalance = $transaction->getLockedBalance();
|
$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
|
// Fetch Final Wallet Balance after Transfer
|
||||||
$dFloat = $dLockedBalance + $config['coldwallet']['reserve'];
|
$dFloat = $dLockedBalance + $config['coldwallet']['reserve'];
|
||||||
$dThreshold = $config['coldwallet']['threshold'];
|
$dThreshold = $config['coldwallet']['threshold'];
|
||||||
$sendAddress = $config['coldwallet']['address'];
|
$log->logDebug('The locked wallet balance + reserves amounts to: ' . $dFloat);
|
||||||
|
|
||||||
$log->logDebug("The Locked Wallet Balance & Float amounts to: " .$dFloat. "\n");
|
|
||||||
|
|
||||||
// Send Liquid Balance
|
// Send Liquid Balance
|
||||||
|
$sendAddress = $config['coldwallet']['address'];
|
||||||
$send = $dBalance - $dFloat ;
|
$send = $dBalance - $dFloat ;
|
||||||
$log->logInfo("Final Sending Amount is : " .$send. "\n");
|
$log->logDebug('Final Sending Amount is : ' . $send);
|
||||||
|
|
||||||
if($send > $dThreshold){
|
if($send > $dThreshold) {
|
||||||
if($sendAddress !== ''){
|
if (!empty($sendAddress)) {
|
||||||
$bitcoin->sendtoaddress($sendAddress, $send);
|
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 {
|
} else {
|
||||||
$log->logInfo("No wallet address set\n");
|
$log->logDebug('Final sending amount not exceeding threshold: ' . $send);
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->logInfo("Final Sending Amount Not Exceed threshold : " .$send. "\n");
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@ -73,4 +73,5 @@ $aErrorCodes['E0072'] = 'Worker names must be alphanumeric';
|
|||||||
$aErrorCodes['E0073'] = 'Worker name is too long; try entering a shorter name';
|
$aErrorCodes['E0073'] = 'Worker name is too long; try entering a shorter name';
|
||||||
$aErrorCodes['E0074'] = 'Failed deleting expired tokens';
|
$aErrorCodes['E0074'] = 'Failed deleting expired tokens';
|
||||||
$aErrorCodes['E0075'] = 'Upgrade required';
|
$aErrorCodes['E0075'] = 'Upgrade required';
|
||||||
|
$aErrorCodes['E0076'] = 'No coins in wallet available';
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -77,19 +77,28 @@ $config['wallet']['username'] = 'testnet';
|
|||||||
$config['wallet']['password'] = 'testnet';
|
$config['wallet']['password'] = 'testnet';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Added support for payout of liquid assets
|
* Payout of liquid assets
|
||||||
*
|
*
|
||||||
* address: the address of the wallet to the address you'd like to receive the coins in
|
* Explanation:
|
||||||
* * reserve: is the amount you'd like to remain in the wallet. Recommended is at least 1 block value
|
* Running pools, especially those with active fees, will build up a good
|
||||||
* threshold: is the amount of coins you'd like to send per batch minimum. once exceeded this is sent
|
* amount of liquid assets that can be used by pool operators. If you wish
|
||||||
* to the address of the cold wallet.
|
* 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']['address'] = '';
|
||||||
$config['coldwallet']['reserve'] = 1.1;
|
$config['coldwallet']['reserve'] = 50;
|
||||||
$config['coldwallet']['threshold'] = 1;
|
$config['coldwallet']['threshold'] = 5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock account after maximum failed logins
|
* Lock account after maximum failed logins
|
||||||
|
|||||||
@ -10,7 +10,7 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default crons to monitor
|
// 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
|
// Special cases, only add them if activated
|
||||||
switch ($config['payout_system']) {
|
switch ($config['payout_system']) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user