Commit Graph

35 Commits

Author SHA1 Message Date
Steven Roose afb8154eab common: improve IsHexAddress and add tests (#15551)
Also unexport isHex, hasHexPrefix because IsHexAddress is the only caller.

Fixes #15550
2017-12-04 19:34:15 +01:00
Martin Holst Swende fc87bc5f52 common: improve documentation of Hash.SetBytes (#15062)
Fixes #15004
2017-09-07 23:32:59 +02:00
Jim McDonald 9e80d9bee1 common: Address.Hex() outputs EIP55-compliant string 2017-07-16 13:26:16 +01:00
Felix Lange 4a741df757 common/hexutil: wrap errors in json.UnmarshalTypeError
This adds type and struct field context to error messages.
Instead of "hex string of odd length" users will now see "json: cannot
unmarshal hex string of odd length into Go struct field SendTxArgs.from
of type common.Address".
2017-06-27 13:15:12 +02:00
Felix Lange d42a56afc5 common: add UnprefixedHash, UnprefixedAddress 2017-03-23 15:58:42 +01:00
Felix Lange d304da3803 common/hexutil: implement TextMarshaler, TextUnmarshaler
This commit makes the wrapper types more generally applicable.
encoding.TextMarshaler is supported by most codec implementations (e.g.
for yaml).

The tests now ensure that package json actually recognizes the custom
marshaler implementation irrespective of how it is implemented.

The Uint type has new tests, too. These are tricky because uint size
depends on the CPU word size. Turns out that there was one incorrect
case where decoding returned ErrUint64Range instead of ErrUintRange.
2017-03-02 14:05:46 +01:00
Péter Szilágyi e588e0ca2b
all: next batch of log polishes to contextual versions 2017-02-28 15:03:20 +02:00
Péter Szilágyi 2f28a12cdb
common, eth/downloader, log: support terminal log formatting 2017-02-27 19:15:18 +02:00
Felix Lange 5c8fe28b72 common: move big integer math to common/math (#3699)
* common: remove CurrencyToString

Move denomination values to params instead.

* common: delete dead code

* common: move big integer operations to common/math

This commit consolidates all big integer operations into common/math and
adds tests and documentation.

There should be no change in semantics for BigPow, BigMin, BigMax, S256,
U256, Exp and their behaviour is now locked in by tests.

The BigD, BytesToBig and Bytes2Big functions don't provide additional
value, all uses are replaced by new(big.Int).SetBytes().

BigToBytes is now called PaddedBigBytes, its minimum output size
parameter is now specified as the number of bytes instead of bits. The
single use of this function is in the EVM's MSTORE instruction.

Big and String2Big are replaced by ParseBig, which is slightly stricter.
It previously accepted leading zeros for hexadecimal inputs but treated
decimal inputs as octal if a leading zero digit was present.

ParseUint64 is used in places where String2Big was used to decode a
uint64.

The new functions MustParseBig and MustParseUint64 are now used in many
places where parsing errors were previously ignored.

* common: delete unused big integer variables

* accounts/abi: replace uses of BytesToBig with use of encoding/binary

* common: remove BytesToBig

* common: remove Bytes2Big

* common: remove BigTrue

* cmd/utils: add BigFlag and use it for error-checked integer flags

While here, remove environment variable processing for DirectoryFlag
because we don't use it.

* core: add missing error checks in genesis block parser

* common: remove String2Big

* cmd/evm: use utils.BigFlag

* common/math: check for 256 bit overflow in ParseBig

This is supposed to prevent silent overflow/truncation of values in the
genesis block JSON. Without this check, a genesis block that set a
balance larger than 256 bits would lead to weird behaviour in the VM.

* cmd/utils: fixup import
2017-02-26 22:21:51 +01:00
Felix Lange 37e5816bcd common: use package hexutil for fixed size type encoding 2016-11-28 11:37:13 +01:00
Péter Szilágyi 178da7c6a9
mobile: initial wrappers for mobile support 2016-11-14 17:56:58 +02:00
Paulo L F Casaretto a20d3fc362 common: Add tests for Address#UnmarshalJSON 2016-04-26 09:12:36 -03:00
Jeffrey Wilcke d63e29241d common: added Hash unmarshal json length validation 2016-04-01 12:56:54 +02:00
Bas van Kervel eae81465c1 rpc: new RPC implementation with pub/sub support 2015-12-14 16:34:05 +01:00
Péter Szilágyi 18ea468cf8 common: fix #2008, wrong hex prefix check 2015-11-27 19:32:46 +02:00
Péter Szilágyi 1e806c4c77 cmd, common, core, eth, node, rpc, tests, whisper, xeth: use protocol stacks 2015-11-27 11:06:12 +02:00
Felix Lange bfbcfbe4a9 all: fix license headers one more time
I forgot to update one instance of "go-ethereum" in commit 3f047be5a.
2015-07-23 18:35:11 +02:00
Felix Lange 3f047be5aa all: update license headers to distiguish GPL/LGPL
All code outside of cmd/ is licensed as LGPL. The headers
now reflect this by calling the whole work "the go-ethereum library".
2015-07-22 18:51:45 +02:00
Felix Lange ea54283b30 all: update license information 2015-07-07 14:12:44 +02:00
obscuren 787a61bb27 core/state, core/vm: reworked storage get / set to use common.Hash 2015-06-17 11:24:40 +02:00
obscuren 21fa29111b core: reduce max allowed queued txs per address
Transactions in the queue are now capped to a maximum of 200
transactions. This number is completely arbitrary.
2015-06-15 12:16:29 +02:00
Felix Lange d457a1187d common: add Hash.Generate 2015-04-30 15:02:23 +02:00
obscuren 62236dd95e copy over loop 2015-03-19 23:20:41 +01:00
obscuren cd52ef315c Added Hex methods 2015-03-18 11:44:17 +01:00
obscuren ff55c6f5ba Merge branch 'develop' into conversion
Conflicts:
	common/types.go
2015-03-17 13:09:22 +01:00
obscuren 843db4978e updated blockpool 2015-03-16 23:10:26 +01:00
obscuren 91b0b14845 converted vm 2015-03-16 18:42:18 +01:00
obscuren e620bde405 conversion state 2015-03-16 17:09:08 +01:00
obscuren 76f215b0fe Getters shouldn't need to be pointer receiver 2015-03-16 16:44:27 +01:00
obscuren d338650089 compilable trie (tests fail) 2015-03-16 16:28:16 +01:00
obscuren 20b7162a62 Added functions to Hash & Address
* Set, SetString, SetBytes
* StringTo*, BytesTo*
2015-03-16 13:23:06 +01:00
obscuren dc864ee3a5 Added ToString methods 2015-03-16 12:20:17 +01:00
obscuren 3cf51d5479 tmp 2015-03-16 12:03:52 +01:00
obscuren f486c0ae56 new type + additional methods 2015-03-16 11:59:52 +01:00
obscuren b523441361 Moved ethutil => common 2015-03-16 11:27:38 +01:00