/** * Get locked balance (the current amount of unavailable funds) * * @return decimal locked balance in XMR */ public function get_locked_balance() { $result = $this->_get_balances(); return bc::div(bc::op($result['balance'], '-', $result['unlocked_balance']), $this->multiplier); }
$asset_config = $config['asset'][XMR]; $asset_id = $asset->get_id(); $user_id = $user->id(); $payment_id = null; $balance = null; $balance = $asset->get_balance($user); $payment_id = $asset->get_payment_id($user); // If payment id was not found, create one if (!$payment_id or isset($_POST['new_payment_id'])) { $asset->create_payment_id($user); refresh(); } if (isset($_POST['withdraw_xmr'])) { $amount = trim($_POST['xmr_amount']); // Prepare POST data $post = array('address' => trim($_POST['xmr_address']), 'payment_id' => trim($_POST['xmr_payment_id']), 'amount' => $amount, 'mixin' => filter_var($_POST['xmr_mixin'], FILTER_VALIDATE_INT, array('options' => array('default' => $asset_config['default_mixin'], 'min_range' => $asset_config['min_mixin'], 'max_range' => $asset_config['max_mixin']))), 'receivable_amount' => bc::op($amount, '-', $asset_config['withdraw_fee']), 'asset_id' => $asset->id); if (!csrf_check($_POST['csrf_token'])) { $error->set('xmr_address', 'Invalid CSRF, session expired. Please refresh.'); } if (!$asset->valid_address($post['address'])) { $error->set('xmr_address', 'Please enter a valid XMR Address'); } if (!$asset->valid_payment_id($post['payment_id'])) { $error->set('xmr_payment_id', 'Please enter a valid Payment ID (64 characters, alpha-numeric string) or leave the field empty to send without payment id'); } if (!$asset->valid_amount($post['amount'])) { $error->set('xmr_amount', 'Enter a valid amount'); } if (!$asset->valid_withdraw($post['amount'], $asset_config['withdraw_fee'])) { $error->set('xmr_amount', 'Enter a valid amount'); }
/** * Validates withdraw (minimum withdraw) * * @param string|float amount * @param string|float fee * @return bool */ public function valid_withdraw($amount, $fee) { global $config; $amount_after_fee = bc::op($amount, '-', $fee); // Check if amount after fee is negative if (bc::is($amount_after_fee, '=<', '0')) { return FALSE; } // Enforce minimum withdraw return (bool) (bccomp($amount, $config['asset'][$this->id]['min_withdraw']) !== -1); }