Skip to content

Commit

Permalink
fixed decimals in URI
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekliptor authored and Ekliptor committed Sep 21, 2019
1 parent dc747b5 commit 6ff0c5c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/CashP.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ public function createPaymentURI(string $address, float $amountBCH, float $amoun
$address = preg_replace("/.+:/i", "", $address);
// we use the bitcoincash URI if tokens are disabled because bitcoin.com and other wallets only support this as of June 2019
//$uri = "simpleledger:$address?amount=$amountBCH";
$uri = sprintf("bitcoincash:%s?amount=%s", $address, number_format($amountBCH, $tokenDigits));
$uri = sprintf("bitcoincash:%s?amount=%s", $address, number_format($amountBCH, $tokenDigits, ".", ""));
if ($amountToken > 0.0) {
if (empty($tokenID))
throw new \Error("A payment URI with SLP tokens must use the tokenID parameter.");
if ($amountBCH > 0.0)
$uri = sprintf("simpleledger:%s?amount=%s&", $address, number_format($amountBCH, $tokenDigits));
$uri = sprintf("simpleledger:%s?amount=%s&", $address, number_format($amountBCH, $tokenDigits, ".", ""));
else
$uri = sprintf("simpleledger:%s?", $address);
$uri .= sprintf("amount1=%s-%s", number_format($amountToken, $tokenDigits), $tokenID);
$uri .= sprintf("amount1=%s-%s", number_format($amountToken, $tokenDigits), $tokenID, ".", "");
}
return $uri;
}
Expand Down

0 comments on commit 6ff0c5c

Please sign in to comment.