Skip to content

Commit

Permalink
added checks for empty values
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekliptor committed Dec 15, 2020
1 parent a94ccdd commit 758e0ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/BlockchainApi/BchdProtoGatewayApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function getTransaction(string $transactionID): ?Transaction {
$output->index = $out->index;
if (isset($out->value)) // missing on OP_RETURN outputs (value 0)
$output->value = intval($out->value);
if (isset($out->address)) // missing on OP_RETURN outputs (value 0)
if (isset($out->address) && !empty($out->address)) // missing on OP_RETURN outputs (value 0)
$output->address = 'bitcoincash:' . $out->address;
if (isset($out->slp_token))
$this->addSlpTransactionData($output, $out->slp_token);
Expand Down Expand Up @@ -283,13 +283,13 @@ protected function addTokenMetadata(SlpToken $token, array $bchdTokenMetadata):
}

protected function addSlpTransactionData(TransactionBaseData $tx, \stdClass $rawSlpData): void {
if (empty($rawSlpData))
if (empty($rawSlpData || empty($rawSlpData->token_id)))
return;

$tx->slp = new SlpTransactionData();
$tx->slp->tokenID = bin2hex(base64_decode($rawSlpData->token_id));
$tx->slp->amount = intval($rawSlpData->amount);
if (isset($rawSlpData->address)) // not present on inputs
if (isset($rawSlpData->address) && !empty($rawSlpData->address)) // not present on inputs
$tx->slp->address = 'simpleledger:' . $rawSlpData->address;
if (isset($rawSlpData->decimals)) // not present on inputs
$tx->slp->decimals = intval($rawSlpData->decimals);
Expand Down

0 comments on commit 758e0ef

Please sign in to comment.