Exemplo n.º 1
0
 /**
  * @param string $description
  * @param Binary $currency
  * @param Output $output
  * @param Signer $signer
  * @return Base
  */
 public static function signedBase($description, Binary $currency, Output $output, Signer $signer)
 {
     return new Base($currency, $description, $output, $signer->getAddress(), $signer->sign([$currency, $description, $output]));
 }
Exemplo n.º 2
0
 /**
  * @param Binary $issuerAddress
  * @param Signer $signer
  * @return Authorization
  */
 public static function signed(Binary $issuerAddress, Signer $signer)
 {
     return new Authorization($issuerAddress, $signer->getAddress(), $signer->sign($issuerAddress));
 }
Exemplo n.º 3
0
 /**
  * @param Input[] $inputs
  * @param Output[] $outputs
  * @param Signer $signer
  * @return Transaction
  */
 public static function signedTransaction($inputs, $outputs, Signer $signer)
 {
     return new Transaction($inputs, $outputs, $signer->sign([$inputs, $outputs]));
 }
Exemplo n.º 4
0
 /**
  * @return Binary
  */
 public function hash()
 {
     return new Binary(hash('sha256', Signer::squash($this), true));
 }
Exemplo n.º 5
0
 private function uniqueInput(Transaction $transaction, $acc)
 {
     $inputs = isset($acc['inputs']) ? $acc['inputs'] : [];
     $transactions = isset($acc['transactions']) ? $acc['transactions'] : [];
     $squashedTransaction = Signer::squash($transaction);
     $acc['transactions'][] = $squashedTransaction;
     if (in_array($squashedTransaction, $transactions)) {
         return $acc;
     }
     foreach ($transaction->getInputs() as $input) {
         $squashed = Signer::squash($input);
         if (in_array($squashed, $inputs)) {
             $this->errors[] = "Output already used";
         }
         $inputs[] = $squashed;
     }
     $acc['inputs'] = $inputs;
     return $acc;
 }
Exemplo n.º 6
0
 /**
  * @param Base[] $bases
  * @param Output $output
  * @param Transaction $confirmed
  * @param Signer $signer
  * @return Confirmation
  */
 public static function signedConfirmation($bases, Output $output, Transaction $confirmed, Signer $signer)
 {
     $hash = self::hash(Signer::squash($confirmed));
     return new Confirmation($bases, $output, $hash, $signer->sign([$bases, $output, $hash]));
 }