fix: transfer invaild txid
This commit is contained in:
@@ -12,9 +12,13 @@ final class TronSigner
|
||||
*/
|
||||
public static function signTxId(string $privateKeyHex, string $txIdHex): string
|
||||
{
|
||||
$txIdHex = strtolower(ltrim($txIdHex, '0x'));
|
||||
if (strlen($txIdHex) !== 64) {
|
||||
throw new RuntimeException('Invalid txID');
|
||||
// Tron full-node returns txID as 64-char hex (no 0x). Sign it as-is.
|
||||
$raw = $txIdHex;
|
||||
$txIdHex = strtolower(trim($txIdHex));
|
||||
if (! preg_match('/^[0-9a-f]{64}$/', $txIdHex)) {
|
||||
throw new RuntimeException(
|
||||
'Invalid txID (len='.strlen($txIdHex).', raw_len='.strlen($raw).', value='.$raw.')'
|
||||
);
|
||||
}
|
||||
|
||||
$ec = new EC('secp256k1');
|
||||
|
||||
Reference in New Issue
Block a user