예제 #1
0
 public function execute(array $matches, $rest, $url)
 {
     Debug::setLogger(new STDOUTLogger());
     $argv = Container::dispense('Environment\\Arguments');
     if (isset($argv[2])) {
         $addr = new BitcoinAddress($argv[2]);
     } else {
         $addr = AdminConfig::volatileLoad()->getConfig()->getWalletProvider()->getWalletAddress();
     }
     $am = new BlockchainAddressMonitor($addr);
     $am->updateCache();
     echo $am->getBalance()->get(), "\n";
 }
예제 #2
0
 public function getBalance($confirmations = 1)
 {
     try {
         $am = new BlockchainAddressMonitor($this->fromAddress, true);
         $am->updateCache();
         $balance = $am->getBalance($confirmations);
     } catch (Exception $e) {
         if (strtolower($e->getMessage()) === "no free outputs to spend") {
             return new Amount("0");
         }
         throw new Exception("There was a network error while processing the request.");
     }
     return $balance;
 }