Esempio n. 1
0
 public function __construct($addr)
 {
     if (!AddressUtility::checkAddress($addr) && !AddressUtility::checkAddress($addr, AddressUtility::P2SH_ADDRESS_VERSION)) {
         throw new InvalidArgumentException("Invalid Bitcoin address.");
     }
     $this->addr = $addr;
 }
Esempio n. 2
0
 public function getErrors(Post $post)
 {
     $i18n = Localization::getTranslator();
     //TODO: implement range checking on modifier values, and static pricing
     $walletSettings = [];
     if (empty($post['wallet']['id'])) {
         $walletSettings[] = ['id' => '#wallet-id-error', 'error' => $i18n->_('A valid Blockchain.info wallet id is required.')];
     }
     if (empty($post['wallet']['mainPass'])) {
         $walletSettings[] = ['id' => '#wallet-mainPass-error', 'error' => $i18n->_('Your respective Blockchain.info password is required.')];
     }
     if (empty($post['wallet']['fromAddress'])) {
         $walletSettings[] = ['id' => '#wallet-fromAddress-error', 'error' => $i18n->_('An address controlled by your Blockchain.info wallet is required to send from.')];
     } elseif (!AddressUtility::checkAddress($post['wallet']['fromAddress'])) {
         $walletSettings[] = ['id' => '#wallet-fromAddress-error', 'error' => $i18n->_('A valid Bitcoin address is required.')];
     }
     $emailUser = @$post['email']['username'];
     $emailSettings = [];
     if (empty($emailUser)) {
         $emailSettings[] = ['id' => '#email-username-error', 'error' => $i18n->_('A valid email address is required.')];
     } elseif (filter_var($emailUser, FILTER_VALIDATE_EMAIL) !== $emailUser) {
         $emailSettings[] = ['id' => '#email-username-error', 'error' => $i18n->_('Email address entered is not valid.')];
     }
     if (empty($post['email']['password'])) {
         $emailSettings[] = ['id' => '#email-password-error', 'error' => $i18n->_('Email password is required.')];
     }
     $passwordSettings = [];
     if (strlen(@$post['admin_password']) < 5) {
         $passwordSettings[] = ['id' => '#password-error', 'error' => $i18n->_('Minimum password length is 5 characters.')];
     }
     if (@$post['admin_password'] !== @$post['confirm_admin_password']) {
         $passwordSettings[] = ['id' => '#password-error', 'error' => $i18n->_('Admin passwords must match')];
     }
     $transactionSettings = [];
     if (isset($post['transactions']['maximum'])) {
         if (!preg_match('#^[0-9]+$#', $post['transactions']['maximum'])) {
             $transactionSettings[] = ['id' => '#maximum-errors', 'error' => $i18n->_('Maximum transaction value must be a positive integer.')];
         }
     }
     $localeSettings = [];
     if (isset($post['locale'])) {
         if (!Localization::localePresent($post['locale'])) {
             $transactionSettings[] = ['id' => '#locale-errors', 'error' => $i18n->_('Unkown Locale.')];
         }
     }
     $errors = [];
     if (!empty($transactionSettings)) {
         $errors['#locale-settings'] = $localeSettings;
     }
     if (!empty($transactionSettings)) {
         $errors['#transaction-settings'] = $transactionSettings;
     }
     if (!empty($passwordSettings)) {
         $errors['#password-settings'] = $passwordSettings;
     }
     if (!empty($pricingSettings)) {
         $errors['#pricing-settings'] = self::getPricingErrors($post);
     }
     if (!empty($walletSettings)) {
         $errors['#wallet-settings'] = $walletSettings;
     }
     if (!empty($emailSettings)) {
         $errors['#email-settings'] = $emailSettings;
     }
     return $errors;
 }