coinbase / coinbase-php

DEPRECATED — PHP wrapper for the Coinbase API
Apache License 2.0
297 stars 198 forks source link

As of 2018-09-10 - transactions return invalid signature. #184

Closed ed9 closed 4 years ago

ed9 commented 6 years ago

Hi,

this code was working all alone, suddenly it stopped working when trying to get transaction list due to signature issues. I've checked the coinbases's credentials, all seem to be fine, the fact it gets trough client creation and account data download tells me all is good, what's up with this? Anyone :) ?

EDIT: Aparently this happens only when starting_after is present.

<?php

class myClass {

    private static $client;

    private function getClient(){
        if(!self::$client){
            $configuration = Configuration::apiKey($this->config['api']['key'], $this->config['api']['secret']);
            $configuration->setApiVersion(config('services.coinbase.api-version'));
            self::$client = Client::create($configuration);
        }
        return self::$client;
    }

    public function syncTransactions(){
        $client = $this->getClient(); // passes

        foreach ($client->getAccounts() as $account) { // passes
            $search = [
                'order' => 'asc',
                'starting_after' => LAST_STARTING_AFTER
            ];

            // EXCEPTION GETS THROWN HERE
            $transactions = $account->getTransactions($search); // exception

            // .. do job here..
        }
    }
}

Exception

GuzzleHttp\Exception\ClientException: Client error: `GET https://api.coinbase.com/v2/accounts/f00e7c3a-ec93-508c-a07d-51f218c6cc9c/transactions?starting_after=500c56c9-538c-52ce-82c3-a7d27f9a2b4f&order=asc` resulted in a `401 Unauthorized` response:
{"errors":[{"id":"authentication_error","message":"invalid signature"}]}
 in /home/ubuntu/www/api/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /home/ubuntu/www/api/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /home/ubuntu/www/api/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/ubuntu/www/api/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /home/ubuntu/www/api/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /home/ubuntu/www/api/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true)
#5 /home/ubuntu/www/api/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 /home/ubuntu/www/api/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#7 /home/ubuntu/www/api/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 /home/ubuntu/www/api/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /home/ubuntu/www/api/vendor/guzzlehttp/guzzle/src/Client.php(106): GuzzleHttp\Promise\Promise->wait()
#10 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/HttpClient.php(135): GuzzleHttp\Client->send(Object(GuzzleHttp\Psr7\Request), Array)
#11 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/HttpClient.php(121): Coinbase\Wallet\HttpClient->send(Object(GuzzleHttp\Psr7\Request), Array)
#12 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/HttpClient.php(74): Coinbase\Wallet\HttpClient->request('GET', '/v2/accounts/f0...', Array)
#13 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/Client.php(831): Coinbase\Wallet\HttpClient->get('/v2/accounts/f0...', Array)
#14 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/Client.php(329): Coinbase\Wallet\Client->getAndMapCollection('/v2/accounts/f0...', Array, 'toTransactions')
#15 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/ActiveRecord/AccountActiveRecord.php(88): Coinbase\Wallet\Client->getAccountTransactions(Object(Coinbase\Wallet\Resource\Account), Array)
#16 /home/ubuntu/www/api/app/Personal/Service/ExchangeMarket/Coinbase.php(72): Coinbase\Wallet\Resource\Account->getTransactions(Array)
#17 /home/ubuntu/www/api/app/Jobs/Service/DownloadExchangeTransactions.php(51): App\Personal\Service\ExchangeMarket\Coinbase->syncRemoteToLocal()
#18 [internal function]: App\Jobs\Service\DownloadExchangeTransactions->handle()
#19 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#20 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#21 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#22 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#23 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#24 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(App\Jobs\Service\DownloadExchangeTransactions))
#25 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(App\Jobs\Service\DownloadExchangeTransactions))
#26 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#27 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\Service\DownloadExchangeTransactions), false)
#28 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#29 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(322): Illuminate\Queue\Jobs\Job->fire()
#30 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(272): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#31 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#32 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'funding', Object(Illuminate\Queue\WorkerOptions))
#33 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'funding')
#34 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#35 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#36 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#37 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#38 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#39 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#40 /home/ubuntu/www/api/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#41 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#42 /home/ubuntu/www/api/vendor/symfony/console/Application.php(865): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#43 /home/ubuntu/www/api/vendor/symfony/console/Application.php(241): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#44 /home/ubuntu/www/api/vendor/symfony/console/Application.php(143): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#45 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#46 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#47 /home/ubuntu/www/api/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#48 {main}

Next Coinbase\Wallet\Exception\AuthenticationException: invalid signature in /home/ubuntu/www/api/vendor/coinbase/coinbase/src/Exception/HttpException.php:37
Stack trace:
#0 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/HttpClient.php(137): Coinbase\Wallet\Exception\HttpException::wrap(Object(GuzzleHttp\Exception\ClientException))
#1 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/HttpClient.php(121): Coinbase\Wallet\HttpClient->send(Object(GuzzleHttp\Psr7\Request), Array)
#2 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/HttpClient.php(74): Coinbase\Wallet\HttpClient->request('GET', '/v2/accounts/f0...', Array)
#3 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/Client.php(831): Coinbase\Wallet\HttpClient->get('/v2/accounts/f0...', Array)
#4 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/Client.php(329): Coinbase\Wallet\Client->getAndMapCollection('/v2/accounts/f0...', Array, 'toTransactions')
#5 /home/ubuntu/www/api/vendor/coinbase/coinbase/src/ActiveRecord/AccountActiveRecord.php(88): Coinbase\Wallet\Client->getAccountTransactions(Object(Coinbase\Wallet\Resource\Account), Array)
#6 /home/ubuntu/www/api/app/Personal/Service/ExchangeMarket/Coinbase.php(72): Coinbase\Wallet\Resource\Account->getTransactions(Array)
#7 /home/ubuntu/www/api/app/Jobs/Service/DownloadExchangeTransactions.php(51): App\Personal\Service\ExchangeMarket\Coinbase->syncRemoteToLocal()
#8 [internal function]: App\Jobs\Service\DownloadExchangeTransactions->handle()
#9 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#10 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#11 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#12 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#13 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#14 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(App\Jobs\Service\DownloadExchangeTransactions))
#15 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(App\Jobs\Service\DownloadExchangeTransactions))
#16 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\Service\DownloadExchangeTransactions), false)
#18 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#19 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(322): Illuminate\Queue\Jobs\Job->fire()
#20 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(272): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#21 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#22 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'funding', Object(Illuminate\Queue\WorkerOptions))
#23 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'funding')
#24 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#25 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#26 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#27 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#28 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#29 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#30 /home/ubuntu/www/api/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#31 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#32 /home/ubuntu/www/api/vendor/symfony/console/Application.php(865): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /home/ubuntu/www/api/vendor/symfony/console/Application.php(241): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /home/ubuntu/www/api/vendor/symfony/console/Application.php(143): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 /home/ubuntu/www/api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#37 /home/ubuntu/www/api/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#38 {main}
danifantom commented 6 years ago

Same here, was working few weeks ago. When I try to make a transaction this happens

EDIT: My bad! I downloaded my old project to new PC and my .env file with the apikey was missing.

drewrothstein commented 4 years ago

Hi, we are closing out PRs + Issues as this project is being archived.