Commit graph

3531 commits

Author SHA1 Message Date
Dave Collins
627aeb5e9c Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-23 11:43:10 -06:00
Dave Collins
4f4afedf39 Use the new btcec Signature.Serialize API.
This commit modifies the code to use the new btcec Signature.Serialize API
instead of the internal sigDER which has now been removed.  This closes #3.

ok @owainga
2013-12-23 11:35:14 -06:00
Dave Collins
bb6b277706 Add tests for new Signature.Serialize function.
This is part of the resolution for issue btcscript/#3.
2013-12-23 11:31:26 -06:00
Dave Collins
2067215193 Expose a new Serialize function on Signature type.
This commit exposes a new function named Serialize on the Signature type
which can be used to obtain a DER encoded signature.  Previously this
function was named sigDer and was part of btcscript, but as @donovanhide
pointed out in issue btcscript/#3, it really should have been part of this
package.

ok @owainga
2013-12-23 11:31:08 -06:00
Dave Collins
85ac6b06f7 Make NewFieldVal only avilable to the test package.
Since the function was only exported for use by the test package (and was
commented as such), just move it into the internal_test.go file so it is
only available when the tests run.
2013-12-20 19:19:02 -06:00
Dave Collins
ac7e4de201 Add field and point addition/multiplicaiton tests.
This commit adds 100% test coverage for the new code.  This brings the
overall btcec coverage up to 99.76%.
2013-12-20 15:09:58 -06:00
Dave Collins
9be5c5cbd9 Significantly optimize signature verification.
This commit essentially rewrites all of the primitives needed to perform
the arithmetic for ECDSA signature verification of secp256k1 signatures to
significantly speed it up.  Benchmarking has shown signature verification
is roughly 10 times faster with this commit over the previous.

In particular, it introduces a new field value which is used to perform the
modular field arithmetic using fixed-precision operations specifically
tailored for the secp256k1 prime.  The field also takes advantage of
special properties of the prime for significantly faster modular reduction
than is available through generic methods.

In addition, the curve point addition and doubling have been optimized
minimize the number of field multiplications in favor field squarings
since they are quite a bit faster.  They routines also now look for
certain assumptions such as z values of 1 or equivalent z values which
can be used to further reduce the number of multiplicaitons needed when
possible.

Note there are still quite a few more optimizations that could be done
such as using precomputation for ScalarBaseMult, making use of the
secp256k1 endomorphism, and using windowed NAF, however this work already
offers significant performance improvements.

For example, testing 10000 random signature verifications resulted in:
New btcec took 15.9821565s
Old btcec took 2m34.1016716s

Closes conformal/btcd#26.
2013-12-20 15:07:15 -06:00
Dave Collins
cc9aadf041 Don't use headers first when checkpoints disabled.
Headers first relies on having valid checkpoints, so if checkpoints are
disabled, it needs to be disabled as well.
2013-12-20 14:01:25 -06:00
Owain G. Ainsworth
2c81f61616 Also drain the inv channel as well as the message channel on peer quit.
Shold prevent a deadlock where we exit but server/blockmaanger is
waiting on our inv channel.

Closes #62
2013-12-17 15:51:37 +00:00
Owain G. Ainsworth
d72255bce3 gofmt 2013-12-17 14:02:35 +00:00
Owain G. Ainsworth
8310661c29 Parse out ports from externalip strings if present.
If not, continue to use the default. Should fix a problem reported by
Justus Ranvier on github.

Closes #38 (again)
2013-12-16 20:48:23 +00:00
Owain G. Ainsworth
7b304515d6 fix getrawtransaction verbose to be bool. 2013-12-16 18:14:51 +00:00
Owain G. Ainsworth
8aaad1e97b Add support for verbose in getrawmempool.
Closes #55.
2013-12-16 18:14:50 +00:00
Owain G. Ainsworth
4cb318ac02 Handle optional verbose parameter to getrawmempool.
This does remove the `nicer' type handle for getrawmempool for now since
it is no longer so simple.

ok jcv.
2013-12-16 18:01:45 +00:00
Josh Rickmar
e4fa45ff08 Better logging for rescans. 2013-12-16 09:09:28 -05:00
Josh Rickmar
2be94151a3 Add positive tests for commands.
Fixes #3.
2013-12-13 12:30:23 -05:00
Josh Rickmar
2731634dda Implement notifications that actually follow the JSON-RPC spec.
This changes notifications to JSON-RPC Requests, rather than
Responses, that also satisify the btcjson.Cmd interface and are
registered with btcjson's parser.  This prevents issues where JSON-RPC
Response IDs clash due to a client using the same ID as what an old
notification used.

As this changes the API, and thus, requires notification handlers to
be modified, the remaining missing notifications used by btcwallet
have been implemented.  Applications parsing these notifications, such
as btcgui, can now use a common handler function signature for all
notifications.

Test coverage for all notifications has been added (excluding testing
for badly-marshaled notifications with wrong numbers of parameters, or
wrong types).

Fixes #2.
2013-12-13 10:59:09 -05:00
Dave Collins
011025dc0d Fix regtest mode with new headers-first approach.
The regression test does not work properly with the new headers-first
download approach, so force the old inv-based block download for
regression test mode.
2013-12-12 18:10:06 -06:00
Dale Rahn
7b406dcb0f Implement a fast path for the Initial Block Download.
It is not necessary to do all of the transaction validation on
blocks if they have been confirmed to be in the block chain leading
up to the final checkpoint in a given blockschain.

This algorithm fetches block headers from the peer, then once it has
established the full blockchain connection, it requests blocks.
Any blocks before the final checkpoint pass true for fastAdd on
btcchain operation, which causes it to do less valiation on the block.
2013-12-12 17:24:05 -05:00
Dave Collins
c34ab6a95e Remove sqlite3 import from addblock.
The sqlite3 db backend is deprecated, so this is no longer needed.  Also,
since sqlite3 is a cgo binding it doesn't cross compile nicely.
2013-12-12 13:37:46 -06:00
Dave Collins
bbc3c1cf7e Prepare for release 0.4.0. 2013-12-12 13:27:06 -06:00
Dale Rahn
992d11830c Implement a fast path for the Initial Block Download.
It is not necessary to do all of the transaction validation on
blocks if they have been confirmed to be in the block chain leading
up to the final checkpoint in a given blockschain.

This algorithm fetches block headers from the peer, then once it has
established the full blockchain connection, it requests blocks.
Any blocks before the final checkpoint pass true for fastAdd on
btcchain operation, which causes it to do less valiation on the block.
2013-12-12 07:54:48 -05:00
John C. Vernaleo
1f52db626d Update test coverage. 2013-12-11 13:43:18 -05:00
John C. Vernaleo
4d0cbb776b Make id omitemtpy to match spec better. 2013-12-11 13:42:29 -05:00
Josh Rickmar
630d38b1b9 Add README. 2013-12-11 12:16:04 -05:00
Dave Collins
472c998c0d Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-10 19:17:59 -06:00
Dave Collins
b23acb632a Add support for TravisCI. 2013-12-10 19:10:53 -06:00
Owain G. Ainsworth
95563691cd go fmt. 2013-12-11 00:41:03 +00:00
Dave Collins
c0c167cc15 Remove logging bits from script_test.go.
The allows the tests to run without showing warning for malformed bits
(which are intentionally malformed for testing purposes).  Also, the
tests would not compile since the new btclog backend was switched out.
This commit resolves that.
2013-12-10 18:31:21 -06:00
Dave Collins
18576ab105 Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-10 18:01:11 -06:00
Dave Collins
621f9006bf Correct tests for recent getblock updates. 2013-12-10 17:13:42 -06:00
Owain G. Ainsworth
7df65008be Run interrupt handlers in lifo order. 2013-12-10 22:40:26 +00:00
Owain G. Ainsworth
2a554c43b0 Shutdown server fully on ctrl-c
since we don't wait for peers, this largely just waits for the server procs
themselves to die. Unless the entire server is wedged (which is what kill -9 is
for) this should always shut down fairly swiftly.

This should mean we sync addrmanager and disestablish upnp correctly on
interrupt.

Discussed with davec.
2013-12-10 22:40:17 +00:00
Owain G. Ainsworth
f8e88df237 Add basic support for UPnP.
This code borrows and fixes up a chunk of code to handle upnp from
Taipei-Torrent (https://github.com/jackpal/Taipei-Torrent), under
current versions of go none of the xml parsing was working correctly.
This fixes that and also refactors the SOAP code to be a little nicer by
stripping off the soap containers. It is still rather rough but seems to
correctly redirect ports and advertise the correct address.

Upnp is not run by default. --upnp will enable it, but it will still not
run if we are not listening or if --externalip is in use.

Closes #51
2013-12-10 22:39:54 +00:00
Dave Collins
8a132ffde8 Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-10 16:30:47 -06:00
Dave Collins
e5a09bdfaa Configure TravisCI to pull pkgs needed for tests. 2013-12-10 16:13:08 -06:00
Dave Collins
55331de532 Configure TravisCI to pull pkgs needed for tests. 2013-12-10 16:10:14 -06:00
Josh Rickmar
dda0cce06f Add getaddressbalance extension. 2013-12-10 16:14:35 -05:00
Owain G. Ainsworth
1145fb57ed handle .onion addresses in deserialising addrmanager.
Use the generic function that already handles this.
2013-12-10 19:39:48 +00:00
Owain G. Ainsworth
8968f7dd74 Add support for --externalip.
Closes #38
2013-12-10 19:39:47 +00:00
Owain G. Ainsworth
d2d899d157 pushVersionMessage: fix you/me address generation
The you address is the one we already set up fo the user, so either waht
we connected to (this will work with tor, etc), or the ip the user
connect to us from otherwise. We must however check to see if it is the address
of the proxy and strip it.

The me addesss, we use the same address selection for local addresses as
always

This should mean that we pass our tor address out in the version message
and thus the peers should add us to their addressmanager.
2013-12-10 19:39:47 +00:00
Owain G. Ainsworth
f93203b91e Initial basic support for selection of external ip address.
This implements only the bare bones of external ip address selection
using very similar algorithms and selection methods to bitcoind. Every
address we bind to, and if we bind to the wildcard, every listening
address is recorded, and one for the appropriate address type of the
peer is selected.

Support for fetching addresses via upnp, external services, or via the
command line are not yet implemented.

Closes #35
2013-12-10 19:39:47 +00:00
Owain G. Ainsworth
1e836d26f4 Handle tor and dns-name addresses.
Perform the requisite processing on .onion addresses to turn them into the tor
reserved ipv6 region (the same as bitcoind and onioncat). Furthermore,
when printing an ip address, reverse the conversion so we print it
nicely.  base32 as standard is uppercase, but tor and bitcoind seem to
use lowercase so we  first must for we force .onion addrs to uppercase
(and to lowercase on the reverse).

As a side effect we now should handle dns names on the command line (via tor if
required) and add them to the addressmanger as necessary.
2013-12-10 19:39:46 +00:00
Owain G. Ainsworth
d2dd40aae2 fix tor range. add :: to make sure it is parsed as v6. 2013-12-10 19:39:46 +00:00
Owain G. Ainsworth
a3d783e9e8 set up p.na before preparing our reply version message.
Means we can use that instead of generating another (next commit).
2013-12-10 19:39:46 +00:00
Dave Collins
c8e88d383e Correct issue with pushing address messages.
The code to send an address messages in batches was previously clearing
all addresses from the existing message after queueing it to be sent.
Since the message is a pointer, this means it was removing the addresses
from the same message which might not have already been sent yet (from
another goroutine) which led to a race.

This commit modifies the code to create a new address message for each
batch as intended.

Fixes #58.
2013-12-10 09:13:16 -06:00
Dave Collins
977d47641f Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-09 05:41:54 -06:00
Dave Collins
decc1e8c69 Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-09 04:44:34 -06:00
David Hill
9e44506fdc Have TravisCI build against both latest release and tip 2013-12-08 22:11:54 -05:00
Dave Collins
f1c807231d Add TravisCI build status badge to README.md. 2013-12-08 20:44:06 -06:00