【发布时间】:2016-11-04 16:57:12
【问题描述】:
我有一个使用 blockcypher 创建的比特币地址,我想将一些比特币从它(已经存款)转移到另一个地址。
我正在使用 blockcypher php 客户端使用示例代码 https://www.blockcypher.com/dev/bitcoin/?php#creating-transactions 和 https://github.com/blockcypher/php-client/blob/master/sample/transaction-api/CreateTransaction.php 创建事务,我收到错误消息
Class 'Mdanter\Ecc\Math\Gmp' not found in C:\xampp\htdocs\cck\vendor\bitwasp\bitcoin\src\Math\Math.php on line 8
我检查了供应商的文件,并且在 Mdanter\Ecc\Math\Gmp 中有 Gmp 文件或类,所以我编辑了 math.php 文件并编辑了第 6 行以使用 \Mdanter\Ecc\Math\GmpMath 作为 Gmp;现在得到类似https://github.com/blockcypher/php-client/issues/21中的错误
我的代码如下
require_once __DIR__.'/vendor/autoload.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Rest\ApiContext;
use BlockCypher\Api\TX as DD;
use BlockCypher\Client\TXClient;
// ... other classes
$apiContext = ApiContext::create(
'main', 'btc', 'v1',
new SimpleTokenCredential('4e3a287e603f48c994d978dab061084a'),
array('log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG') );
$tx = new DD();
// Tx inputs
$input = new \BlockCypher\Api\TXInput();
$input->addAddress("1DZR2kUCa5HTyVZLY8TWFf2ZfjhWgsgNtf");
$tx->addInput($input);
// Tx outputs
$output = new \BlockCypher\Api\TXOutput();
$output->addAddress("1Mye4sZmd9rzjY6yUw19etZhzeVU2q1kcj");
$output->setValue(1000); // Satoshis
$tx->addOutput($output);
// Tx amount
$txClient = new TXClient($apiContext);
$txSkeleton = $txClient->create($tx);
$privateKeys = array("3ed07ff3e458fabb8b99b723002f4817eebd5fc11f9c76fdd9c200090c04fd1c");
$txSkeleton = $txClient->sign($txSkeleton, $privateKeys);
$txSkeleton = $txClient->send($txSkeleton);
【问题讨论】:
-
你能告诉我你的“mdanter/ecc”库版本是什么吗?我认为问题可能是“bitwasp/bitcoi”库正在使用这个依赖 mdanter/ecc”:“~0.3”,而最新版本的 mdanter/ecc 没有“Mdanter\Ecc\Math\Gmp”类。在那如果我们应该在github.com/Bit-Wasp/bitcoin-php 中打开一个问题并告诉他们将 mdanter/ecc": "~0.3" 替换为 mdanter/ecc": "0.3.*"
-
@josecelano 您使用的是什么版本的 sdk?
标签: php transactions bitcoin