diff --git a/src/MetaHash.php b/src/MetaHash.php index ea17e46..14ae8ab 100644 --- a/src/MetaHash.php +++ b/src/MetaHash.php @@ -563,6 +563,7 @@ public function queryProxy(string $method, array $params = []): array public function sendTx(string $privateKey, string $to, int $value, string $data = '', int $nonce = 1, int $fee = 0): array { $metaHashCrypto = $this->getMetahashCrypto(); + $data = $data === '' ? $data : $metaHashCrypto->str2hex($data); $signText = $metaHashCrypto->makeSign($to, $value, $nonce, $fee, $data); $sign = $metaHashCrypto->sign($signText, $privateKey); @@ -571,7 +572,7 @@ public function sendTx(string $privateKey, string $to, int $value, string $data 'value' => (string)$value, 'fee' => (string)$fee, 'nonce' => (string)$nonce, - 'data' => $metaHashCrypto->str2hex($data), + 'data' => (string)$data, 'pubkey' => $metaHashCrypto->privateToPublic($privateKey), 'sign' => $sign, ]; diff --git a/src/MetaHashCrypto.php b/src/MetaHashCrypto.php index 7a867ae..fe3707c 100644 --- a/src/MetaHashCrypto.php +++ b/src/MetaHashCrypto.php @@ -268,8 +268,6 @@ public function checkAdress(string $address): bool */ public function makeSign(string $address, int $value, int $nonce, int $fee = 0, string $data = '') { - $data = $data === '' ? $data : $this->str2hex($data); - $addressClear = (\strpos($address, '0x') === 0) ? \substr($address, 2) : $address; $valueUInt = IntHelper::VarUInt($value, true); $feeUInt = IntHelper::VarUInt($fee, true);