Esempio n. 1
0
 /**
  * @param Binary $backer
  * @param Signer $signer
  * @return Coin
  * @throws \Exception
  */
 public function confirm(Binary $backer, Signer $signer)
 {
     $allBases = $this->getBases();
     $myBases = array_values(array_filter($allBases, function (Base $base) use($backer) {
         return $base->getOutput()->getTarget() == $backer;
     }));
     if (!$myBases) {
         throw new \Exception('Not a backer');
     }
     $output = new Output($this->getOwner(), $this->getValue()->times($this->baseSum($myBases))->dividedBy($this->baseSum($allBases)));
     $confirmed = $this->input->getTransaction();
     return new Coin(new Input(Confirmation::signedConfirmation($myBases, $output, $confirmed, $signer), 0));
 }