fix: transfer invaild txid

This commit is contained in:
hashbro
2026-09-04 04:09:32 +08:00
parent 4c49a61149
commit f67da8a102
16 changed files with 730 additions and 24 deletions
+7 -3
View File
@@ -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');