Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->comment('Sweeping account');
     $address_sender = app('App\\Blockchain\\Sender\\PaymentAddressSender');
     $payment_address_repo = app('App\\Repositories\\PaymentAddressRepository');
     $payment_address = $payment_address_repo->findByUuid($this->input->getArgument('payment-address-id'));
     if (!$payment_address) {
         throw new Exception("Payment address not found", 1);
     }
     $destination = $this->input->getArgument('destination-address');
     if (!AddressValidator::isValid($destination)) {
         throw new Exception("The destination address was invalid", 1);
     }
     $float_fee = $this->input->getOption('fee');
     $api_call = app('App\\Repositories\\APICallRepository')->create(['user_id' => $this->getConsoleUser()['id'], 'details' => ['command' => 'xchain:sweep-address', 'args' => ['payment_address' => $payment_address['uuid'], 'destination' => $destination, 'fee' => $float_fee]]]);
     // get lock
     $lock_acquired = AccountHandler::acquirePaymentAddressLock($payment_address);
     // do the send
     list($txid, $float_balance_sent) = $address_sender->sweepAllAssets($payment_address, $destination, $float_fee);
     // clear all balances from all accounts
     AccountHandler::zeroAllBalances($payment_address, $api_call);
     // release the account lock
     if ($lock_acquired) {
         AccountHandler::releasePaymentAddressLock($payment_address);
     }
     $this->comment('done');
 }
Ejemplo n.º 2
0
 protected function releasePaymentAddressLockWithDelay($payment_address)
 {
     if (app()->environment() != 'testing') {
         $delay = 1500000;
         Log::debug("delaying for " . $delay / 1000 . " ms before releasing payment address lock");
         usleep($delay);
     }
     AccountHandler::releasePaymentAddressLock($payment_address);
 }