From 6ef2069f9082364a4c9ecf29d378350c5eb9ff73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BC=D0=B8=D0=BB=D1=8C=20=D0=9C=D1=83=D1=85?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D0=B7=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Sat, 8 Jun 2019 11:34:08 +0300 Subject: [PATCH 1/2] make transaction params in right order before signing --- src/Minter/SDK/MinterTx.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Minter/SDK/MinterTx.php b/src/Minter/SDK/MinterTx.php index f3d5c35..8379dbf 100644 --- a/src/Minter/SDK/MinterTx.php +++ b/src/Minter/SDK/MinterTx.php @@ -29,9 +29,7 @@ class MinterTx */ protected $tx; - /** - * @var RLP - */ + /** @var RLP */ protected $rlp; /** @@ -63,24 +61,16 @@ class MinterTx */ protected $txDataObject; - /** - * Fee in PIP - */ + /** Fee in PIP */ const PAYLOAD_COMMISSION = 2; - /** - * All gas price multiplied by FEE DEFAULT (PIP) - */ + /** All gas price multiplied by FEE DEFAULT (PIP) */ const FEE_DEFAULT_MULTIPLIER = 1000000000000000; - /** - * Type of single signature for the transaction - */ + /** Type of single signature for the transaction */ const SIGNATURE_SINGLE_TYPE = 1; - /** - * Type of multi signature for the transaction - */ + /** Type of multi signature for the transaction */ const SIGNATURE_MULTI_TYPE = 2; /** Mainnet chain id */ @@ -274,7 +264,10 @@ protected function decode(string $tx): array */ protected function encode(array $tx, bool $isHexFormat = false): array { + // validate transaction structure $this->validateTx($tx); + // order transaction params in right order + $tx = array_replace(array_intersect_key(array_flip($this->structure), $tx), $tx); switch ($tx['type']) { case MinterSendCoinTx::TYPE: From 144fff666c10f1140a6492ce8b618b2dc981c758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BC=D0=B8=D0=BB=D1=8C=20=D0=9C=D1=83=D1=85?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D0=B7=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Sat, 8 Jun 2019 11:36:13 +0300 Subject: [PATCH 2/2] fix comment --- src/Minter/SDK/MinterTx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Minter/SDK/MinterTx.php b/src/Minter/SDK/MinterTx.php index 8379dbf..f1245aa 100644 --- a/src/Minter/SDK/MinterTx.php +++ b/src/Minter/SDK/MinterTx.php @@ -266,7 +266,7 @@ protected function encode(array $tx, bool $isHexFormat = false): array { // validate transaction structure $this->validateTx($tx); - // order transaction params in right order + // make right order in transaction params $tx = array_replace(array_intersect_key(array_flip($this->structure), $tx), $tx); switch ($tx['type']) {