Sending bitcoin outside using coinbase php library returns 422::Invalid amount

452 Views Asked by At

I was trying to send 0.0001 bitcoins to external BTC address using coinbase php library. I have CodeIgniter based website and generating bitcoin addresses, retrieving balances are working fine. but somehow I cant seem to make coin withdrawal work. Below is my code.

$configuration = \Coinbase\Wallet\Configuration::apiKey($apiKey, $apiSecret);
$client = Coinbase\Wallet\Client::create($configuration);
$accountId = $this->getCoinbaseAccountid($coinid);
$account = $client->getAccount($accountId);
$coinsymbol = $this->CI->common_library->getCoinSymbol($coinid);//returns BTC
$withdrawAmount = new Coinbase\Wallet\Value\Money($amountTosend, $coinsymbol);
$transaction = Coinbase\Wallet\Resource\Transaction::send([
  'toBitcoinAddress' => $sendtoAddress,
  'amount' => $withdrawAmount,
  'description' => $comment,
  'fee' => '0.00005' // only required for transactions under BTC0.0001
]);
try {
  $response = $client->createAccountTransaction($account, $transaction);
} catch (Coinbase\Wallet\Exception\HttpException $ex) {
  $error = $ex->getResponse()->getStatusCode() . '::' . $ex->getError();
  $errorcase = 1;
  $this->log_ipn_results(FALSE, $error);
}

In my log file, I get below error. I still unable to find this error even after searching.

422::Invalid amount

1

There are 1 best solutions below

5
On

The minimum withdrawal amount is higher than 0.0001 BTC.