Commit graph

3614 commits

Author SHA1 Message Date
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
Josh Rickmar
8d9b8fcf82 Make importprivkey rescan optarg default to true. 2013-11-19 15:26:47 -05: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
Marco Peereboom
6ad853019a use fastsha256 2013-11-19 09:26:22 -06:00
Marco Peereboom
aa3cdbe7b1 use fastsha256 2013-11-19 09:22: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
Owain G. Ainsworth
e43c79c74d add TlsRpcCommand and TlsRawRpcCommand.
These act the same as the !tls versions of this code but they take a PEM
encoded certificate chain to be used to verify certificates (ca verified
certs could use /etc/ssl/certs.pem) and a parameter to skip cert
verification and will use https internally.
2013-11-19 14:46:17 +00:00
Josh Rickmar
5ec4aaff09 Add importprivkey support to btcctl. 2013-11-18 14:51:31 -05:00
John C. Vernaleo
606262514b Improve error messages.
Attempt to determine if error when sending a command is due to auth
issue and give more useful error in that case.
2013-11-18 13:23:05 -05:00
Dave Collins
5bf879dcfc Minor cleanup of some documentation and comments. 2013-11-18 10:38:24 -06:00
Josh Rickmar
9dbf75029f ReScan -> Rescan 2013-11-18 09:13:02 -05: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
Dave Collins
166f8c9ae5 Don't relay resurrected transactions.
This commit modifies the transaction memory pool handling so that it does
not relay resurrected transactions.  The other peers on the network will
also be reorganizing to the same block, so they already know about them.
2013-11-15 09:52:47 -06:00
Dave Collins
9fb17c3a6d Improve usage display a little.
This commit makes use of the new default-mask go-flags option in
conjunction with delaying the usage display until after the config file is
parsed.  This has a couple of nice properties such as showing the actual
values that will be used as loaded from the specific config file instead
of the defaults specified in btcd itself, and also allows any config file
parsing errors to be shown prior to displaying the usage.
2013-11-14 20:38:27 -06:00
Dave Collins
50388bcf66 Add more mempool standard checks.
This commit adds a few more checks to restrict what transactions are
allowed into the transaction memory pool and therefore are candidates
to be mined and relayed.

In particular, the following changes were made to what is considered
standard:

- nulldata scripts are now supported and considered standard
- multi-signature transaction are now checked to ensure they only have a
  max of 3 pubkeys and the number of signatures doesn't exceed the number
  of pubkeys
- the number of inputs to a signature script must now match the expected
  number of inputs for the script type (includes support for additional
  pay-to-script-hash inputs)
- the number of inputs pushed onto the stack by a redeeming sig script
  must match the number of inputs consumed by the referenced pk script
- there can now only be a max of one nulldata output per transaction
2013-11-14 17:40:12 -06:00
Dave Collins
d4c5b3d04d Add tests for new nulldata standard script type. 2013-11-14 16:20:11 -06:00
Dave Collins
cfc2a4cc76 Add support for nulldata standard scripts.
This commit adds the new standard script type for empty, but data carrying
and provably prunable transaction scripts.

Closes #2.

ok @owainga
2013-11-14 16:20:02 -06:00
Dave Collins
c33bd15df2 Add a new func CalcMultiSigStats.
This commit adds a new function to extract the number of pulic keys and
number of signatures from a multi-signature script.

ok @owainga
2013-11-14 16:18:11 -06:00
Dave Collins
8550b11685 Fix missing comma. 2013-11-14 14:43:40 -06:00
Dave Collins
80e8c589d8 Bring back nonstand script class stringer test. 2013-11-14 14:42:44 -06:00
Dave Collins
e2770d3691 Go fmt. 2013-11-14 14:39:57 -06:00
Dave Collins
e3eca752da Allow verbose param on btcctl getrawtransaction. 2013-11-14 12:19:20 -06:00
Dave Collins
1ca389aa3d Go fmt. 2013-11-14 11:13:58 -06:00
Dave Collins
c3a3fbcabf Don't bother parsing listeners if disabled. 2013-11-13 21:16:49 -06:00
Dave Collins
3902a71bee Minor cleanup. 2013-11-13 21:12:41 -06:00
Dave Collins
ac375df71f Use the passed addresses in parseListeners.
Also, check the return error on parseListeners to catch invalid IP
addresses.
2013-11-13 21:02:34 -06:00
Dave Collins
50484c5841 Update sample config file with recent changes.
This commit updates the sample config file to add the new listen option
and update the semantics regarding the combination of --proxy and --tor
flags.
2013-11-13 20:20:32 -06:00
Dave Collins
7b86bec825 Comment new parseLiteners function. 2013-11-13 19:43:36 -06:00
Owain G. Ainsworth
6116a6cb02 Support --listen.
This allows the provision of address/port pairs to be listened on instead
of just providing the port. e.g.:
btcd --listen 1.2.3.4:4321 --listen 127.0.0.01 --listen [::1]:5432

When --proxy and --connect are used, we disable listening *unless* any --listen
arguments have been provided, when we will listen on those addresses as
requested.

Initial code by davec, integration by myself.

Closes #33

allow listens to fail, but warn. error if all failed

fmt
2013-11-14 01:15:47 +00:00
Dave Collins
3108b94401 Add 0.3.3 deps to deps.txt. 2013-11-13 10:53:57 -06:00
Dave Collins
58fdcec6e2 Prepare for release 0.3.3. 2013-11-13 10:52:14 -06:00
Owain G. Ainsworth
d20f958c92 Make parameters to VerifyChainCmd int32.
One is a blockheight (int32 pretty much by protocol definition, it
breaks at 1e8 in a long time) and the other is between 0 and 5.
2013-11-12 20:54:08 -06:00
Dave Collins
2300b35731 Add checkpoint at block height 267300. 2013-11-12 20:11:55 -06:00
Owain G. Ainsworth
31a97d5c09 look up tx in mempool first for getrawtransaction
Closes #26
2013-11-12 22:57:27 +00:00
Owain G. Ainsworth
bb276b53aa Add support for the verifychain command.
So far we only do level 0 and level 1 checks (precense and basic
sanity). The checks done at higher levels in bitcoind are closely
coupled with their database layout.

arguably Closes #13
2013-11-12 22:57:26 +00:00
John C. Vernaleo
94e74e7cc7 Increase test coverage for Cmd. 2013-11-12 16:33:58 -05:00