I think it is important we maintain some reasoning that an Input script
is actually a script signature, but in the end, these names are more
coherent and understandable when reasoning with our code. So I think
its OK we break tradition with bitcoind.
Undefined is treated as zero if it ever gets to this point anyway, so no
value is added by having this default param here.
A test fixture to verify this behaviour is added.
Taken from browserify-buffer.
Also adds a few more tests to assert this is working correctly from both
read and write perspectives.
The assertion in for writePushDataInt in the 32 bit case was
unnecessary as that is handled by buffer.writeUInt32LE anyway.
To save on us building a hash map with which to check the inputs,
instead I just ensure that the order of the inputs is the same as it is
in the serialized transaction.
All the `invalid2` tests have been removed as they were not invalid
base58check. They were actually valid in some cases.
They will be re-integrated in more specific bitcoin core tests in
relation to Address/ECKey respectively.
By removing Address.Error, we remove a code smell.
This part of the code base was also not under any form of test.
Test data and tests have therefore been added verifying its behaviour in
both Wallet and Address tests.
This also adds tests for all other ECDSA serialize/parsing functions.
The k, r, s and D values were sourced from test vectors on
https://bitcointalk.org/index.php?topic=285142.40 .
The compact signatures (aka, i values) were generated from bitcoinjslib, but they
are straight forward anyway.
An ECKey is a composition of a private key (D), a public key (Q) and its
compression flag.
These functions gave the impression of serialization of this
composition, when really they only serialized `D`.
They have therefore been removed in favour of always using a sane
serialization format (WIF) that matches the needed behaviour.
If a user needs the previous functionality, simply use `privKey.D.*`
instead of `privKey.*`, as BigInteger supports `*Buffer/*Hex` functions
as expected.
The use of fixtures allows for more behavioural driven tests and simpler
addition of more test cases in future.
However, as ECPubKey is just a wrapper around other strenuously tested
modules, the test data is currently limited to testing a subset of the
total wrapper.
This should probably be done better by using mocked out modules instead.