Commit graph

392 commits

Author SHA1 Message Date
Dave Collins
dfbb9446c4 Ensure Win service bits only compile on Windows. 2013-11-25 20:58:18 -06:00
Dave Collins
45732c99fb Allow btcd to run as a Windows service.
This commit modifies btcd to run cleanly as a Windows service.  btcd is
intended to be a long running process that stays synchronized with the
bitcoin block chain and provides chain services to multiple users.  It
follows that a service is the best option on Windows for this
functionality.

A few key points are:

- Supports graceful shutdown via the service stop/shutdown commands
- Integrates cleanly with the Windows event log
- Adds a new /s flag that can be used to install/remove/start/stop the
  service

One outstanding issue is that the application data directory is currently
user specific which means, by default, if you start btcd as a user, the
same data won't be used as when it's running as a service.  This needs to
be resovled.  The most likely approach will be to put all data into the
common appdata directory Windows provides, but it will require some
additional work to deal with permissions properly as user processes can't
write there by default.

Closes #42.
2013-11-25 18:36:11 -06:00
Dave Collins
766aae5a72 Add rolling log file.
This commit modifies the logging to also log all output to a rolling log
file in the btcd home directory under the logs folder.  It uses a maximum
size of 10MB per log file and a max rotation size of 3.  This means the
log files will not exceed 30 megabytes.
2013-11-25 13:40:53 -06:00
Josh Rickmar
7e21226ca6 Update for new btcws.TxMinedNtfn information. 2013-11-25 12:54:23 -05:00
Dave Collins
8e3ede441b Update for recent go-flags API changes. 2013-11-24 12:33:36 -06:00
Josh Rickmar
6f2b96b7e2 Fix help message for listtransactions. 2013-11-22 15:18:23 -05:00
Josh Rickmar
d00ca48475 Print listtransactions replies with go-spew. 2013-11-22 14:20:31 -05:00
Owain G. Ainsworth
f843c141ae in Valid() ensure that na.IP is set. Found by drahn. 2013-11-22 18:48:36 +00:00
Dave Collins
a9bf28af4d Allow the overall log level to be dynamically set.
The code was previously only changing the logging level if it wasn't the
default which is accurate for setting the log level once at startup time,
but it needs to set it unconditionally to allow dynamic updates.
2013-11-22 12:46:44 -06:00
Josh Rickmar
ef47455b05 Add listtransactions support to btcctl.
This is currently using the generic reply formater, and will likely be
switched out for a custom one later.
2013-11-22 13:13:39 -05:00
Dave Collins
daa5310e2f Add support for debuglevel RPC command.
Also include the supported subsystems in the error message if an invalid
subsystem is specified.

Closes #15.
2013-11-22 10:47:29 -06:00
John C. Vernaleo
e930dc55f0 Change a variable name to match btcjson. 2013-11-22 08:50:15 -05:00
Dave Collins
07c656c8b5 Update doc.go with new debug level usage. 2013-11-21 20:01:11 -06:00
Dave Collins
93c1f7d31b Update utilities to use new btclog as well. 2013-11-21 19:03:55 -06:00
Dave Collins
48ab97c271 Allow per-subsystem log levels to be specified.
Now that each subsystem is capable of having its own log level, modify the
-d/--debuglevel flag to allow them to be specified.

Closes #48.
2013-11-21 17:41:45 -06:00
Dave Collins
eb8688df79 Convert btcd to use new btclog package.
Also, make every subsystem within btcd use its own logger instance so each
subsystem can have its own level specified independent of the others.

This is work towards #48.
2013-11-21 17:41:21 -06:00
Owain G. Ainsworth
41d2d36643 Only update p.na on reciept of version message for inbound peers.
Outbound we already have the exact same thing set up, and this should
quieten the race detector. Please note that this does *not* cause
problems with the service flags being wrong. Since by this point we have
already done every thing that would use the service flags from p.na in
addrmanager, and now p.Services is correct..
2013-11-21 19:19:17 +00:00
Marco Peereboom
694fccefa8 typo 2013-11-20 15:55:36 -06:00
John C. Vernaleo
3f37e881dc Remove workaround for certs on go1.1.2.
btcd now requires go1.2.  A note to that effect is in README.md.
2013-11-20 15:34:37 -05:00
Josh Rickmar
0bee8478a9 Fix optional arg handling for importprivkey. 2013-11-20 11:12:00 -05:00
Josh Rickmar
4a290162ee Add dumpprivkey to btcctl. 2013-11-19 22:36:25 -05:00
David Hill
0301690499 Create the home directory if it doesn't exist. 2013-11-19 22:21:50 -05:00
Dave Collins
9643cb6d23 Make golint happy with btcctl. 2013-11-19 20:35:49 -06:00
Dave Collins
b1ed5f75ca Add version to btcctl.
This commit adds version information to btcctl.  The plan is to keep
it in lock step with the btcd version.  It also updates the release script
so the version file is updated automatically with the btcd one.
2013-11-19 20:07:31 -06:00
Dave Collins
9c26f6c4c5 Update doc.go with recent Winows path change. 2013-11-19 18:40:56 -06:00
Dave Collins
0cc756337e Update command line options in doc.go. 2013-11-19 18:16:29 -06:00
Dave Collins
f5a7dcdcbf Default RPC server listener to localhost. 2013-11-19 17:33:36 -06:00
Josh Rickmar
5d13288174 Check auth header for websocket connections. 2013-11-19 18:28:08 -05:00
Dave Collins
9edf7d44fa Ensure generated cert contains 127.0.0.1. 2013-11-19 16:35:00 -06:00
Dave Collins
d18c34a628 Mask the password from btcctl usage. 2013-11-19 16:25:18 -06:00
Dave Collins
02e6d47590 Return error on dir create failure from loadConfig.
Rather than simply exiting on a home directory creation error, return the
error so it exits via the normal path.
2013-11-19 15:56:21 -06:00
David Hill
deb19c2fa3 Bring MarshalECPrivateKey local so < go1.2 works.
Closes #45.
2013-11-19 15:53:31 -06:00
David Hill
35eea401e1 Create the home directory if it doesn't exist. 2013-11-19 16:40:20 -05:00
Dave Collins
c2bec24f51 Improve btcctl config.
This commit improves the configuration for btcctl in several ways:

- Add the ability to specify a config file
- Add a default entry to the rpc cert to point to the location
  it will likely be in the btcd home directory
- Move the config bits into a separate file for easier maintenance
2013-11-19 14:53:22 -06:00
Dave Collins
04a2f66d64 Allow go-flags to generate help entry in btcctl. 2013-11-19 13:44:52 -06:00
Dave Collins
c3fab78e2c Use consistent case in TLS logging. 2013-11-19 11:42:56 -06:00
Dave Collins
5cd4c8265c Add subsystem to RPC cert generation log messages. 2013-11-19 11:41:31 -06:00
Dave Collins
9a853fdf90 Use single cert/key for RPC by default.
Also, while here, set the default RPC cert/key in the initial config
struct so the default will show when displaying the usage.
2013-11-19 11:38:46 -06:00
David Hill
6fcc1c9d1b Add localhost to DNSNames in generated certificate. 2013-11-19 12:02:40 -05:00
Dave Collins
e433439308 Make RPC section of sample-btcd.conf consistent. 2013-11-19 11:01:23 -06:00
Dave Collins
22600c7c67 Correct a couple of usage inconsistencies.
- Remove periods from --rpccert/--rpckey since none of the other options use
  them
- Make it a little more clear that the --listen and --rpclisten options can be
  used multiple times by changing the summary to start with "Add an ..."
  which also matches the --addpeer style
2013-11-19 10:39:38 -06:00
Owain G. Ainsworth
5d3fcc660e Handle tor addresses in addrmanager.
Both GroupKey and Tor() needed amending for tor addresses, filling in some
TODOs.

Closes #36.
Closes #37
2013-11-19 14:51:41 +00:00
Owain G. Ainsworth
75e577c82e RPC TLS Support.
All rpc sockets now listen using TLS by default, and this can not be
turned off. The keys (defauling to the datadirectory) may be provided by
--rpccert and --rpckey. If the keys do not exist we will generate a new
self-signed keypair with some sane defaults (hostname and all current
interface addresses).

Additionally add tls capability to btcctl so that it can still be used.
The certificate to use for verify can be provided on the commandline or
verification can be turned off (this leaves you susceptible to MITM
attacks)

Initial code from dhill (rpc tls support) and jrick (key generation),
cleanup, debugging and polishing from me.
2013-11-19 14:50:31 +00:00
Owain G. Ainsworth
5da5dfe1c4 Add --rpclisten that behaves frighteningly similar to --listen.
Except it works for the rpcserver instead of the main server.

Closes #34
2013-11-19 14:48:58 +00:00
Josh Rickmar
5ec4aaff09 Add importprivkey support to btcctl. 2013-11-18 14:51:31 -05:00
Dave Collins
5bf879dcfc Minor cleanup of some documentation and comments. 2013-11-18 10:38:24 -06:00
Dave Collins
37d3d83ed3 Improve mempool handling.
- Lock the mempool when removing transactions during a notification as
  intended
- When generating the inventory vectors to serve on a mempool request,
  recheck the memory pool for each hash since it's possible another thread
  could have removed an entry after the initial query for available
  hashes
- When a block is connected, remove any transactions which are now double
  spends as a result of the newly connected transactions
2013-11-15 16:23:27 -06:00
David Hill
7b7d4e8555 fix typo - now addresses show up in getrawtransaction 2013-11-15 16:12:08 -05:00
Dave Collins
6b8c10d1fb Don't load default config file in regtest mode.
The regression test mode is special and therefore most likely will not
want to use the same settings that are in the configuration file.  The -C
option can still be used to specify a config file in regression test mode
if desired.
2013-11-15 14:43:36 -06:00
Dave Collins
527a08eb14 Convert chain RuleError to TxRuleError in mempool.
When a transaction is being checked for acceptance into the transation
memory pool, it makes use of a chain function to ensure the invariant rules
for what transactions are allowed into a block are not violated.  That
function returns a btcchain.RuleError if rules are violated.  However,
since this code path is tailored to free-standing transactions, the error
needs to be converted to a TxRuleError so the caller can properly detect
the transaction as a rejected transaction instead of treating it like an
real error.
2013-11-15 11:59:32 -06:00