0

这是我的创建、签名和发送代码

  $request = clone $tx;
/// For Sample Purposes Only.
    $params = array(
           'includeToSignTx' => 1,
           'script_type'=>'mutlisig-n-of-m',
        );
$txClient = new TXClient($apiContext);

try {

  // dd($tx);
    $txSkeleton = $txClient->create($tx,$params);
    $privateKeys = array("private key");
$txSkeleton = $txClient->sign($txSkeleton, $privateKeys);
$txSkeleton = $txClient->send($txSkeleton);
} catch (Exception $ex) {
    dd("Created TX", "TXSkeleton", null, $request, $ex);
    exit(1);
}

这是我得到的错误:

PrivateKeyList.php 第 54 行中的 FatalThrowableError:类型错误:传递给 BlockCypher\Crypto\PrivateKeyList::addPrivateKey() 的参数 1 必须是 BitWasp\Bitcoin\Key\PrivateKeyInterface 的实例,BitWasp\Bitcoin\Crypto\EcAdapter\Impl\ 的实例PhpEcc\Key\PrivateKey 给定,在第 43 行的 /home/pixel/Documents/tests/vendor/blockcypher/php-client/lib/BlockCypher/Crypto/PrivateKeyList.php 中调用

这是代码

public function addPrivateKey(PrivateKeyInterface $privateKey)
{
   $pubKeyHex = $privateKey->getPublicKey()->getHex();
   $this->privateKeys[$pubKeyHex] = $privateKey;
}
4

1 回答 1

0

这么少的信息很难说到底出了什么问题,但是从错误中可以清楚地看出你传入$privateKey的类型是不正确的。从这里回到调用这个函数的代码。

验证BitWasp\Bitcoin\Crypto\EcAdapter\Impl\PhpEcc\Key\PrivateKey实现接口BitWasp\Bitcoin\Key\PrivateKeyInterface

于 2018-01-30T10:16:50.213 回答