Commit graph

595 commits

Author SHA1 Message Date
Dave Collins
e0fab228a4 Correct getrawtransaction RPC handling and cleanup.
The getrawtransaction RPC call should return a hex-encoded string of the
transaction when verbose is false instead of a TxRawResult object with the
Hex field set to be compatible with the Sathoshi client.  This commit,
along with a recent commit to btcjson corrects this.

Also, while here, do a bit of cleanup, finish a TODO to check for an
invalid hash, and optimize the handling of non-verbose slightly.
2013-12-26 23:30:57 -06:00
Dave Collins
af3609d861 Factor out common message to hex in RPC server. 2013-12-26 22:53:44 -06:00
Dave Collins
8477ef569a Update btcctl getblock for recent changes.
This commit allows btcctl to accept the optional verbosity parameters on
getblock.
2013-12-26 11:19:32 -06:00
Dave Collins
67b5c2fb7e Correct getblock RPC handling and optimize.
The getblock RPC call should return a hex-encoded string of the block when
verbose is false instead of a BlockResult object with a Hex field set to
be compatible with the Sathoshi client.  This commit, along with a recent
commit to btcjson corrects this.

Also, while here, move code which only applies to verbose mode after the
call which handles the non-verbose logic.  This saves a few cycles since
the non-verbose logic doesn't need the extra information.
2013-12-26 11:13:31 -06:00
Dave Collins
ca4cf29e49 Add a new function to btcctl for JSON display.
This commit adds a new function to btcctl that shows the results as
properly indented JSON instead of relying on spew and changes all of the
commands that used spew to the new function.  The output of btcctl
should be more user-facing than developer-facing.
2013-12-25 23:18:16 -06:00
Dave Collins
23ff70d682 Add gethashespersec command to btcctl. 2013-12-25 19:13:14 -06:00
Dave Collins
195ada0979 Add newline to previous print change. 2013-12-25 17:47:56 -06:00
Dave Collins
6be128a843 Display float values with btcctl with %f.
This commit modifies btcctl to show float values with %f instead of the
default %v.  This means the values will show similar to 1180923195.260000
instead of 1.18092319526e+09 (scientific notation).
2013-12-25 17:47:12 -06:00
Dave Collins
dc200d002e Correct getrawmempool verbose fee field.
The fee field of the getrawmempool RPC JSON response should be in Bitcoins
instead of Satoshi.  This commit corrects that issue.

Also, add a couple of comments and fix a comment typo while here.
2013-12-25 12:33:12 -06:00
Dave Collins
edf8f2f224 Use curHeight in mempool transaction add.
Since there is already a variable for the current block height in addition
to the next block height, use the existing curHeight variable instead
doing nextBlockHeight-1 in mempool add.
2013-12-25 12:15:59 -06:00
Dave Collins
4c184ead54 Use consistent wrapping for externalip config opt. 2013-12-24 17:01:32 -06:00
Dave Collins
17a9b41bef Cleanup peer.go.
This commit does some housekeeping on peer.go to make the code more
consistent, correct a few comments, and add new comments to explain the
peer data flow.  A couple of examples are variables not using the standard
Go style (camelCase) and comments that don't match the style of other
comments.
2013-12-24 14:05:28 -06:00
Owain G. Ainsworth
d3a7f15a87 Alter the way peers queue outbound messages somewhat.
Instead of one thread that queues and writes, we move to a two queue
model. The queueHandler muxes all the sources of outgoung packets and
drips them to the actual sender. This is done so that a large send
doesnt' allow the channels to fillup and cause blockmanager and server
to block, which delays other peers.

Most messages we handle as is. However, for getdata we do some manual
limiting and pipelining, we queue up three and then we load the next
into memory, not sending it until the otherp ackets have been sent. We
may want to change this later to queue the packet *then* wait so that we
don't completely drain the pipe.

A few misc tweaks to avoid deadlocking by ensuring the all channels will
always drain. mostly this relates to ensuring that we know no more data
will be coming before we drain the channel, and not queueing after we
are marked to disconnect.

Discussed heavily with drahn@ and davec@.
2013-12-23 23:51:52 +00: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
Josh Rickmar
e4fa45ff08 Better logging for rescans. 2013-12-16 09:09:28 -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
Owain G. Ainsworth
95563691cd go fmt. 2013-12-11 00:41:03 +00: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
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
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
Dave Collins
6995910df5 Add support for TravisCI. 2013-12-08 20:35:56 -06:00
Dave Collins
7654eb1eb5 Cast SatoshiPerBitcoin const for createTxRawResult. 2013-12-08 20:21:23 -06:00
Francis Lam
22b61f634a Updated createTxRawResult to use btcutil.SatoshiPerBitcoin 2013-12-08 18:47:39 -05:00
Francis Lam
dd10de9e8b Fix handleGetBlock/handleGetRawTransaction to return btcjson.Error
Wrap *.BtcEncode errors into btcjson.Error when failing to encode wire
bytes to buffer
2013-12-08 18:43:47 -05:00
Francis Lam
762fc2c11c Fixed up GetRawTransaction and updated GetBlock to handle verbose
Updated handleGetRawTransaction to populate all the fields required to
match bitcoind.  It still doesn't handle MULTISIG addresses correctly.

Changed handleGetBlock to implement new optional verbose (default true)
flag and also added a verboseTx flag to return TxRawDefault instead of
Txid.  When verbose=false, GetBlock returns hex-encoded wire bytes for
the block.
2013-12-08 14:57:14 -05:00
Josh Rickmar
305be0c29f Correctly set vout for getrawtransaction.
The vout field (as part of the getrawtransaction JSON reply) should be
set to the input's previous outpoint's index, not the current input
index.

Found by flam and reported on IRC. Thanks!
2013-12-06 17:34:18 -05:00
Josh Rickmar
bbb10dc387 Make authentication check time-constant. 2013-12-05 13:21:51 -05:00
Dave Collins
786409d06e Update README.md now that Go 1.2 has been released. 2013-12-02 09:49:43 -06:00
Josh Rickmar
f22164b261 Search each txout for payment to a wallet address.
This switches a break to a continue if a txout does not include a
pay-to-pubkey-hash script type.  btcwallet only supports
pay-to-pubkey-hash at the moment, and this fixes an issue where a tx
may have an different type of output, as well as pay-to-pubkey-hash,
which may be ignored by the wallet notification code.

Found by dhill.
2013-12-02 10:35:25 -05:00
Josh Rickmar
aea23ddff3 Send nil when rescan is finished.
I previously fixed the duplicate send (before seeing GH issue #54),
but forgot that btcwallet expects a nil reply when rescan has
finished.  This adds the final reply back, but replies with nil.

Fixes #54.
2013-12-02 10:24:22 -05:00
Josh Rickmar
41ecc9f835 Do not duplicate sending final rescan tx. 2013-12-02 10:11:00 -05:00
David Hill
9e57a6c5be add --notls option to disable connecting with TLS
ok oga@
2013-11-26 20:13:31 -05:00