Commit graph

593 commits

Author SHA1 Message Date
Josh Rickmar
239e13c0a5 Add createencryptedwallet to wallet request set. 2014-03-18 10:52:43 -05:00
Josh Rickmar
675f967d4a Add createencryptedwallet support to btcctl.
This is a btcwallet extension and will not work when talking to btcd
or bitcoind.
2014-03-18 10:50:38 -05:00
David Hill
ebf5a3e850 add peer to block and tx rejection debug messages.
ok @davecgh
2014-03-17 22:52:55 -04:00
Dave Collins
e5afb5e984 Improve error return from sendrawtransaction.
Rather than simply returning "TX rejected" to the RPC client which
submitted a sendrawtransaction that fails, include the reason the it
failed.
2014-03-17 17:34:25 -05:00
Dave Collins
7a885b3cf6 Reject orphan transactions from sendrawtransaction.
This commit modifies the sendrawtransaction RPC to reject transactions
which are orphans.  This mirrors the behavior of the reference
implementation.
2014-03-17 17:32:30 -05:00
Dave Collins
a87e6fbdea Change rate limit debug messages to trace level. 2014-03-17 00:23:08 -05:00
Dave Collins
93140802ba Improve non-standard tx error message.
This commit removes the word "only" from the non-standard transaction
error message when the number of items on the stack does not match the
number of expected items.

This was suggested by @mbelshe.
2014-03-17 00:19:53 -05:00
Francis Lam
24028ad37f Updated getinfo to return new RelayFee and use btcjson.InfoResult 2014-03-16 13:31:17 -05:00
Dave Collins
3c2a3e9f54 Update install command to also install utilities.
This commit updates the install command under the Installation section in
README.md to include all subdirectories thereby including the utilities
such as addblock and btcctl.
2014-03-15 22:32:45 -05:00
Dave Collins
510a44bdd9 Fix some comment typos. 2014-03-13 08:45:41 -05:00
Dave Collins
b661dd3693 Convert block manager block handler to pure FIFO.
Rather than having a separate query channel for the block manager, use the
same channel so the block handler acts as a pure FIFO queue.  This
prevents possible starvation of query related messages.

ok @owainga
2014-03-12 13:26:06 -05:00
Francis Lam
33af740985 Added missing notificationMsg types to notificationHandler 2014-03-04 21:36:48 -05:00
David Hill
b452acdde2 remove link 2014-03-04 13:00:06 -05:00
David Hill
5549b99e19 mention IRC server 2014-03-04 12:58:59 -05:00
Josh Rickmar
27f3d916ec Do not block removing clients if notification manager quit. 2014-03-04 11:31:44 -05:00
Josh Rickmar
a7d5b365b1 Retain order when processing client notifications.
This change modifies the RPC server's notifiation manager from a
struct with requests, protected by a mutux, to two goroutines.  The
first maintains a queue of all notifications and control requests
(registering/unregistering notifications), while the second reads from
the queue and processes notifications and requests one at a time.

Previously, to prevent slowing down block and mempool processing, each
notification would be handled by spawning a new goroutine.  This lead
to cases where notifications would end up being sent to clients in a
different order than they were created.  Adding a queue keeps the
order of notifications originating from the same goroutine, while also
not slowing down processing while waiting for notifications to be
processed and sent.

ok @davecgh
2014-03-04 11:15:25 -05:00
Owain G. Ainsworth
aff33f1e3c Consistently use the peer stringer to print the peer address.
This provides more information than using the address directly.
2014-03-04 15:47:20 +00:00
Dave Collins
2a42cc134f Lower min transaction relay fee to 1000 satoshi.
This mirrors a recent change in the reference implementation.  Since the
vast majority of the network still uses it and transactions which aren't
considered standard won't be relayed, the rules for standard transactions
need to be kept consistent.

Ideally this should be handled via floating fees, but we're rather limited
until we have miner support and a larger network share so the probability
of a transaction being relayed and confirmed is high.

Closes #100.

ok @owainga
2014-03-04 09:40:57 -06:00
David Hill
cbb5c5b424 recieve -> receive 2014-03-02 13:28:29 -05:00
Dave Collins
d2bfd3d98b Alphabetize subsystem loggers.
This commit simply alphabetizes the subsystem logger variables, map, and
use switch so the order in the code is consistent with the sorted output
displayed when using --debuglevel.
2014-03-01 16:08:21 -06:00
Dave Collins
91e563edaa Add IP address to a few more peer error messages.
This commit adds the peer IP to a few more error messages as originally
noted by #102.
2014-02-28 10:59:35 -06:00
Dave Collins
ce2f68a982 Fix typo on previous commit.
The peer and error were reversed for the regression test error message
case.

Spotted by @dajohi.
2014-02-28 10:55:25 -06:00
Dave Collins
29b790b9c8 Add IP address to peer error messages.
Closes #102.
2014-02-28 10:48:50 -06:00
Dave Collins
178e60a66e Update sample conf regarding debuglevel subsystems.
The debuglevel parameter has accepted subsystems in additional to an
overall level for quite some time, but the sample config file was not
updated to reflect that.

This commit updates the sample config file accordingly.
2014-02-28 09:54:34 -06:00
Dave Collins
f01459c30e Update for recent btcutil Addr interface changes. 2014-02-26 14:06:48 -06:00
Dave Collins
8c7c1e84a3 Use mtx to control disconnect of websocket client.
This commit changes the websocket client code to use a mutex for
disconnect since it's theoretically possible a non-blocking select on the
quit channel could fall through from two different goroutines thus causing
a second call to close.

ok @jrick.
2014-02-25 12:50:32 -06:00
Josh Rickmar
0c6d7bbeae Improve websocket transaction notifications.
This change improves the mechanism by which btcd notifies a websocket
client of transaction relating to watched address and unspent outputs
in the following ways:

1. The old processedtx notification has been replaced with the new
   recvtx notification.  This notification, rather than parsing out
   details used by wallet clients, sends the serialized transaction
   (as hexadecimal) and any block details (if mined) if any transaction
   output sends to one of the websocket client's watched addresses.

2. The old txspent notification has been replaced with the new
   redeemingtx notification.  This notification, rather than parsing
   out details used by wallet clients, sends the serialized transaction
   (as hexadecimal) and any block details (if mined) if any transaction
   input spends a watched output.

3. When processing notifications for transaction outputs, if any output
   spends to a client's watched address, a corresponding spent request
   is automatically registered.

4. Transaction notifications originating from mempool now include both
   transaction inputs and outputs, rather than only processing

5. When processing notifications for transaction inputs, a client's
   output spent request is only removed if the transaction being
   processed has also been mined into a block.  In combination with the
   4th change, this results in two redeemingtx notifications for
   transactions which first appear in mempool and are subsequently mined
   into a block.
2014-02-24 13:17:57 -05:00
Josh Rickmar
a3ccc25e5a Return errors for any sendrawtransaction rejection.
This changes the implementation of the sendrawtransaction RPC handler
to match bitcoind behavior by always returning a rejection error for
any error processing or accepting the tx by the mempool.  Previously,
if the tx was rejected for a rule error rather than an actual failure,
a client would still receive the tx sha as a result with no error.
2014-02-21 09:03:04 -05:00
Dave Collins
40cdacde23 Prepare for release 0.7.0. 2014-02-20 15:51:40 -06:00
Dave Collins
264c89099f Make non-canoncial data pushes non-standard.
This commit makes use of the new btcscript.HasCanonicalPushes to enforce
canonical data pushes for transactions that are considered standard.

A canonical data push is one where the fewest number of bytes possible to
encode the size of the data being pushed is used.  This includes using the
small integer opcodes for single byte data that can be represented
directly.
2014-02-20 01:25:29 -06:00
Owain G. Ainsworth
cb1f3cf48c Rate limit free-to-relay transactions.
Closes #40

ok @davecgh
2014-02-19 22:39:02 +00:00
Dave Collins
28929ff429 Increase block prio size and max standard tx size.
This commit increases the block priority size to 50000 and the max
standard tx size to 100k.  This matches relatively recent changes in the
reference implementation.  The max block size was also increased to
750000, but since btcd does not currently create blocks, there is no
constant for it.  That constant will likely be added as a part of the
getwork implementation since it requires block creation.

Closes #71.
2014-02-19 12:28:13 -06:00
Dave Collins
8ac86f1053 Allow notifications to work for all address types.
Previously the websocket notifications for addresses were limited to
pay-to-pubkey-hash only.  This commit removes that restriction so
all btcutil.Address types are supported.  This includes pay-to-pubkey,
pay-to-pubkey-hash, and pay-to-script-hash.
2014-02-19 09:47:17 -06:00
Dave Collins
7162a11995 Remove tracking requests from websocket client too.
When a spent notification and address notification is removed, the
tracking entry in the client which is used to track what to remove on
shutdown needs to be removed as well.
2014-02-19 09:14:11 -06:00
Dave Collins
7d35bc9460 Add --rpcmaxwebsockets option with default of 25.
This commit adds a new configuration option, --rpcmaxwebsockets, to limit the
number of max RPC websocket clients that are served concurrently.
2014-02-19 00:53:14 -06:00
Dave Collins
54203d7db0 Rework and improve websocket notification system.
This commit refactors the entire websocket client code to resolve several
issues with the previous implementation.  Note that this commit does not
change the public API for websockets.  It only consists of internal
improvements.

The following is the major issues which have been addressed:
- A slow websocket client could impede notifications to all clients
- Long-running operations such as rescans would block all other requests
  until it had completed
- The above two points taken together could lead to apparant hangs since
  the client doing the rescan would eventually run out of channel buffer
  and block the entire group of clients until the rescan completed
- Disconnecting a websocket during certain operations could lead to a hang
- Stopping the rpc server with operations under way could lead to a hang
- There were no limits to the number of websocket clients that could
  connect

The following is a summary of the major changes:

- The websocket code has been split into two entities: a
  connection/notification manager and a websocket client
- The new connection/notification manager acts as the entry point from
  the rest of the subsystems to feed data which potentially needs to
  notify clients
- Each websocket client now has its own instance of the new websocket
  client type which controls its own lifecycle
- The data flow has been completely redesigned to closely resemble the
  peer data flow
- Each websocket now has its own long-lived goroutines for input, output,
  and queuing of notifications
- Notifications use the new notification queue goroutine along with
  queueing to ensure they dont't block on stalled or slow peers
- There is a new infrastructure for asynchronously executing long-running
  commands such as a rescan while still allowing the faster operations to
  continue to be serviced by the same client
- Since long-running operations now run asynchronously, they have been
  limited to one at a time
- Added a limit of 10 websocket clients.  This is hard coded for now, but
  will be made configurable in the future

Taken together these changes make the code far easier to reason about and
update as well solve the aforementioned issues.

Further optimizations to improve performance are possible in regards to
the way the connection/notification manager works, however this commit
already contains a ton of changes, so they are being left for another
time.
2014-02-19 00:53:05 -06:00
Dave Collins
97e0149dc3 Include IP address in RPC auth failure log message. 2014-02-19 00:30:18 -06:00
Dave Collins
9a15453806 Make room for longer options in doc.go.
Also, fix a few missing equals signs while here.
2014-02-18 21:00:06 -06:00
Dave Collins
a293212581 Add --rpcmaxclients option with default of 10.
This commit adds a new configuration option, --rpcmaxclients, to limit the
number of max standard RPC clients that are served concurrently.  Note
that this value does not apply to websocket connections.  A future commit
will add support for limiting those separately.

Closes #68.
2014-02-18 20:46:41 -06:00
Dave Collins
66e93f5163 Switch over to new btcjson.GetRawMempoolResult.
Rather than using a type specifically in btcd for the getrawmempool, this
commit, along with a recent commit to btcjson, changes the code over to
use the type from btcjson.  This is more consistent with other RPC results
and provides a few extra benefits such as the ability for btcjson to
automatically unmarshal the results into a concrete type with proper field
types as opposed to a generic interface.
2014-02-16 14:00:40 -06:00
Dave Collins
41da7ae606 Switch over to new btcjson.GetPeerInfoResult.
Rather than using a type specifically in btcd for the getpeerinfo, this
commit, along with a recent commit to btcjson, changes the code over to
use the type from btcjson.  This is more consistent with other RPC results
and provides a few extra benefits such as the ability for btcjson to
automatically unmarshal the results into a concrete type with proper field
types as opposed to a generic interface.
2014-02-16 13:45:48 -06:00
Dave Collins
8ebbee1f05 Always include syncnode field in getpeerinfo RPC.
Recent commits to the reference implementation have changed the syncnode
field to be present in the getpeerinfo RPC even when it is false.  This
commit changes btcd to match.
2014-02-16 12:41:35 -06:00
Dave Collins
3a195b9100 Remove duplicate PEER prefix from peer logging.
These were left over from the switch to the logging subsystems which
include the prefix as a part of the subsystem.
2014-02-14 12:45:33 -06:00
Francis Lam
9306270a84 Fixed wsContext locking problems in NewBlockNotifyCheckTxIn
The wsContext was being locked twice when NewBlockNotifyCheckTxIn is
called.  Fixed by changing handlers to assume lock is acquired and
renamed methods to not be exported.
2014-02-13 16:13:58 -05:00
David Hill
12242ee589 Add a requirements section to the README 2014-02-13 12:39:17 -05:00
Dave Collins
e5a1c6e5ac Use mutexes for byte counts to fix i386/arm panic.
This commit changes the server byte counters over to use a mutex instead
of the atomic package.  The atomic.AddUint64 function requires the struct
fields to be 64-bit aligned on 32-bit platforms.  The byte counts are
fields in the server struct and are not 64-bit aligned.  While it would be
possible to arrange the fields to be aligned through various means, it
would make the code too fragile for my tastes.  I prefer code that doesn't
depend on platform specific alignment.

Fixes #96.
2014-02-13 09:58:19 -06:00
Dave Collins
f9922c7305 Add --logdir option to specify logging directory.
This commit adds a new option, --logdir, which works in the same fashion
as the --datadir option.  Consequently, the logging directory is name
"namespaced" by the network as well.  This resolves the issue where two
btcd instances running (one for mainnet and one for testnet) would
overwrite each other's log files by default.

It also provides the user with a method to change the logging location to
non-default locations if they prefer.  For example, it enables multiple
btcd instances on the same network to specify unique logging directories
(even though running multiple btcd instances on the same network is not
the most sane configuration).

Closes #95.
2014-02-12 15:56:05 -06:00
Owain G. Ainsworth
e20a3e9f2c Copy netaddresses in AddressCache instead of referencing them.
While harmless, this prevents the race detector complaining when these
are then used. Closes #94
2014-02-12 15:33:52 +00:00
Owain G. Ainsworth
33082445c5 Add signmessage support to btcctl 2014-02-12 15:30:05 +00:00
Francis Lam
4431fd9c0d Added checking for closed connections in websocket handler helpers
Since the websocket handlers run in their own separate goroutines, it's
possible that they execute after the websocket connection has been
closed and cleaned up.  This commit add the necessary checks to ensure
stale data isn't added to notification lists and that requests to closed
connections are ignored.

This closes #92.
2014-02-11 22:39:11 -05:00