From 7b1b0f8c146926d3f765d48be84b85dc69f48ea6 Mon Sep 17 00:00:00 2001 From: DrDelphi Date: Sun, 26 Jul 2020 23:57:38 +0300 Subject: [PATCH] completed fix after review changed data field to []byte --- deps/uint256/uint256.h | 2 +- testApp/cmd/testApp/main.go | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/deps/uint256/uint256.h b/deps/uint256/uint256.h index 2db6832..89de9ea 100644 --- a/deps/uint256/uint256.h +++ b/deps/uint256/uint256.h @@ -67,4 +67,4 @@ bool tostring128(uint128_t *number, uint32_t base, char *out, bool tostring256(uint256_t *number, uint32_t base, char *out, uint32_t outLength); -#endif /* _UINT256_H_ */ \ No newline at end of file +#endif /* _UINT256_H_ */ diff --git a/testApp/cmd/testApp/main.go b/testApp/cmd/testApp/main.go index f2551a1..8c767c8 100644 --- a/testApp/cmd/testApp/main.go +++ b/testApp/cmd/testApp/main.go @@ -75,7 +75,7 @@ type transaction struct { SndAddr string `json:"sender"` GasPrice uint64 `json:"gasPrice,omitempty"` GasLimit uint64 `json:"gasLimit,omitempty"` - Data string `json:"data,omitempty"` + Data []byte `json:"data,omitempty"` Signature string `json:"signature,omitempty"` ChainID string `json:"chainID"` Version uint32 `json:"version"` @@ -192,12 +192,7 @@ func getDeviceInfo(nanos *ledger.NanoS) error { // trim removes the trailing crlf characters from the end of a string func trim(s string) string { - if strings.HasSuffix(s, "\n") { - s = strings.TrimSuffix(s, "\n") - } - if strings.HasSuffix(s, "\r") { - s = strings.TrimSuffix(s, "\r") - } + s = strings.TrimRight(s, "\n\r") return s } @@ -357,7 +352,7 @@ func main() { tx.Value = bigIntAmount.String() tx.Nonce = nonce tx.GasPrice = netConfig.Data.Config.MinGasPrice - tx.Data = data + tx.Data = []byte(data) tx.GasLimit = netConfig.Data.Config.MinGasLimit + uint64(len(data))*netConfig.Data.Config.GasPerDataByte tx.ChainID = netConfig.Data.Config.ChainID tx.Version = netConfig.Data.Config.MinTransactionVersion