public static function LTC_processing() { $transaction_hash = Core::validate($_POST['transaction_hash']); $address = Core::validate($_POST['address']); $value_in_ltc = Core::validate($_POST['amount']); $confirmations = Core::validate($_POST['confirmations']); if ($_GET['test'] == true) { exit; } $at_ltc = new AtLtc(); $exist = $at_ltc->findBy(array('address' => $address, 'type' => 0, 'done' => 0)); if ($exist == false) { return; } if ($confirmations >= LTC_CONFIRMATIONS) { $currency = new Currency(); $currency->findBy(array('Name' => 'LTC')); $limits = self::transactionLimits($currency->getId(), 'LTC', 0); if ($value_in_ltc < $limits['min'] || $limits['max'] != null && $value_in_ltc > $limits['max']) { return; } $litecoin = new jsonRPCClient('http://' . LTC_RPC_USER . ':' . LTC_RPC_PASSWORD . '@' . LTC_RPC_HOST . ":" . LTC_RPC_PORT . '/'); try { $account = $litecoin->getaccount($address); } catch (Exception $e) { return; } $wallets = WalletsLtc::findBy(array('account' => $account)); if (empty($wallets)) { return; } $feeVolume = $value_in_ltc * $limits['fee']; $feeVolume = Core::round_up($feeVolume, 8); $purses = Purse::findBy(array('UID' => $at_ltc->getUID(), 'CurId' => $currency->getId())); $purse = new Purse(); $purse->findById($purses[0]['id']); $purse->addValue($value_in_ltc - $feeVolume); $purse->save(); $wallet = new WalletsLtc(); $wallet->findById($wallets[0]['id']); $profit = $feeVolume * $wallet->getShare(); $wallet->setProfit($wallet->getProfit() + $profit); $wallet->save(); $at_ltc->setDone(1); $at_ltc->setTransactionHash($transaction_hash); $at_ltc->setValue($value_in_ltc); $at_ltc->setTimestamp(Core::timestamp_gmp()); $at_ltc->save(); } }
public static function addNewLTCWallet() { $account = Core::validate($_POST['ACCOUNT']); $share = Core::validate($_POST['SHARE']); // percent if ($account == null || $share == null || !Core::isDouble($share)) { print 'Incorrect input data'; exit; } $result = WalletsLtc::findBy(array('account' => $account)); if (!empty($result)) { print 'This account already exists'; exit; } $litecoin = new jsonRPCClient('http://' . LTC_RPC_USER . ':' . LTC_RPC_PASSWORD . '@' . LTC_RPC_HOST . ':' . LTC_RPC_PORT . '/'); try { $balance = $litecoin->getbalance($account); } catch (Exception $e) { print $e; exit; } $wallet = new WalletsLtc(); $wallet->setAccount($account); $wallet->setValue($balance); $wallet->setShare($share / 100.0); $wallet->insert(); header('Location: /admin/ltc'); }