Пример #1
0
 /**
  * @param \BitWasp\Bitcoin\Signature\TransactionSignatureInterface $signature
  * @param PublicKeyInterface $publicKey
  * @return ScriptInterface
  */
 public function payToPubKeyHash(TransactionSignatureInterface $signature, PublicKeyInterface $publicKey)
 {
     return ScriptFactory::create()->push($signature->getBuffer())->push($publicKey->getBuffer())->getScript();
 }
 /**
  * @param TransactionSignatureInterface $signature
  * @return Script
  */
 public function payToPubKey(TransactionSignatureInterface $signature)
 {
     return ScriptFactory::create()->push($signature->getBuffer());
 }
 /**
  * @param Peer $sender
  * @param TransactionSignatureInterface $txSig
  * @return TransactionSignatureInterface
  */
 public function fixSig(Peer $sender, TransactionSignatureInterface $txSig, &$wasMalleated = false)
 {
     $sig = $txSig->getSignature();
     if (!$this->adapter->validateSignatureElement($sig->getS(), true)) {
         $ip = $sender->getRemoteAddr()->getIp();
         if (!isset($this->violators[$ip])) {
             $this->violators[$sender->getRemoteAddr()->getIp()] = 1;
         } else {
             $this->violators[$sender->getRemoteAddr()->getIp()]++;
         }
         $wasMalleated = true;
         $this->counter++;
         $txSig = new TransactionSignature($this->adapter, new Signature($this->adapter, $sig->getR(), $this->math->sub($this->order, $sig->getS())), $txSig->getHashType());
         if (!$this->adapter->validateSignatureElement($txSig->getSignature()->getS(), true)) {
             die('failed to produce a low-s signature');
         }
     }
     return $txSig;
 }