Биткойн — BlockCypher php api 0 Ошибка ввода

Я использую php-клиент BlockCypher с главным образом примером кода:

$input = new \BlockCypher\Api\TXInput();
$input->addAddress($address);

$output = new \BlockCypher\Api\TXOutput();
$output->addAddress($receivingWallet);
$output->setValue(intval($SatoshiAmount));

$tx = new \BlockCypher\Api\TX();
$tx->addInput($input);
$tx->addOutput($output);

$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
$txSkeleton;

$request = clone $tx;

try {
$txSkeleton = $txClient->create($tx);
} catch (Exception $ex) {
ResultPrinter::printError("Created TX", "TXSkeleton", null, $request, $ex);
exit(1);
}
$txSkeleton = $txSkeleton->toJSON(128);

$txSkeleton = json_decode(json_encode(json_decode($txSkeleton)), True);  // Object -> Stdclass -> Array
$signed = array();
$pubkeys = array();

for($x = 0; $x < count($txSkeleton['tosign']); $x++){
$toSign = $txSkeleton['tosign'][$x];
$tmp = \BlockCypher\Crypto\Signer::sign($toSign, $privkey);
array_push($signed, $tmp);
array_push($pubkeys, $pubkey);
}
$txSkeleton["signatures"] = $signed;
$txSkeleton["pubkeys"] = $pubkeys;

$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
$txSkel = new \BlockCypher\Api\TXSkeleton();
$txSkel->fromJson(json_encode($txSkeleton));
$request = clone $txSkel;

try {
$txSkel = $txClient->send($txSkel);
} catch (Exception $ex) {
ResultPrinter::printError("Send TX", "TXSkeleton", null, $request, $ex);
continue 2;
}

За исключением подписи, которая отличается. Исходный код выдаст ошибку из-за неверного формата приватного ключа.

Это работает, иногда. Может работать от 10 до 20 запросов. Затем он генерирует следующую ошибку для каждого следующего запроса:

"errors": [
{
"error": "Unable to find a transaction to spend for address 1Ag7YScJCtqoZ9ZcnuTto4B4yFs9qvkq6."},
{
"error": "Not enough funds in 0 inputs to pay for 1 outputs, missing -233616."},
{
"error": "Not enough funds after fees in 0 inputs to pay for 1 outputs, missing -293816."},
{
"error": "Error validating generated transaction: insufficient priority and fee for relay"}
],

Приоритет по умолчанию высокий. Все транзакции (особенно входящие) подтверждаются. Входы в запросе, но они удалены в ответе об ошибке. У кошелька достаточно баланса.

Что здесь происходит? Разве это не должно просто работать? Я делаю что-то неправильно? Я не могу установить более высокий приоритет, чем высокий.

Смотрите полную ошибку здесь:

https://pastebin.com/XQezVygB

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector