Commit graph

3525 commits

Author SHA1 Message Date
Dave Collins
d40cff64b0 Expose a close ntfn channel to all RPC handlers.
This commit modifies the RPC server such that all handlers now receive a
channel which will be notified when a client disconnects.  This
notification can then be used to stop long-running operations early when a
client disconnects.

This capability was already present for websocket clients, but this commit
exposes it to standard HTTP clients as well.
2014-06-27 11:58:47 -05:00
Dave Collins
dc84f95fe9 Name field WorkID to make golint happy. 2014-06-27 00:30:37 -05:00
Dave Collins
84af0d500f Update for SubmitBlockOptions field name change. 2014-06-27 00:27:32 -05:00
Dave Collins
ae51c3e6e0 Update test coverage report. 2014-06-27 00:01:33 -05:00
Dave Collins
a22da99f91 Convert script errors to RuleErrors.
This commit modifies the error return type for errors during script
validation to use the RuleError so they are consistent with the rest of
the errors.  This also helps the calling code differentiate blocks
rejected due to script parsing and validation errors as opposed to
internal issues such as inability to read from the disk.

To accomplish this, two new two new RuleErrors, ErrScriptMalformed and
ErrScriptValidation, have been added.

Also, the errors for script parsing issues and script validation errors
have been improved to include both transaction hashes and indexes involved
in the validation effort.  Previously script parsing issues had almost no
additional information as to which transaction input/outputs the failing
script came from.
2014-06-26 23:47:14 -05:00
Dave Collins
894d5e23aa Unmarshal the SubmitBlock error.
The string needs to be unmarshaled rather than returned directly otherwise
it will have an extra set of quotes plus it's safter to properly unmarshal
it.

Pointed out by @jrick.
2014-06-26 21:47:43 -05:00
Dave Collins
cf3ad14d4d Remove TODO that is complete. 2014-06-26 20:31:32 -05:00
Dave Collins
0f6726b9c3 Add missing import. 2014-06-26 20:24:40 -05:00
Dave Collins
cb67972512 Detect error strings on SumitBlock.
The submitblock RPC returns a string containing an error if it failed for
any reason.  This comment detects a non-null return from submitblock and
converts that string to an error which is returned.
2014-06-26 18:04:01 -05:00
Dave Collins
59731e552b Update addblock for ProcessBlock behavior flags. 2014-06-26 17:42:13 -05:00
Dave Collins
ad275b34a8 Add a new behavior flag to disable the pow check.
This commit adds a new behavior flag, BFNoPoWCheck which allows the caller
to indicate the check which ensures a block hashes to a value less than
required target should not be performed.
2014-06-26 17:25:47 -05:00
Dave Collins
48c6806b24 Update for btcchain ProcessBlock behavior flags.
ok @jrick
2014-06-26 17:18:05 -05:00
Dave Collins
67394ec45d Modify ProcessBlock to accept behavior flags.
This commit change the ProcessBlock function to accept a new type named
BehaviorFlags in place of the current fastAdd parameter.

This has been done to pave the way for adding more control over the checks
that are performed such as avoiding the proof of work checks which will be
in an upcoming commit.  A bitmask was chosen because it will allow the
ProcessBlock API to remain a little more stable since new flag additions
that change the behavior are only likely to be used by new code because
adding flags does not change the existing behavior.

ok @jrick
2014-06-26 17:17:32 -05:00
Dave Collins
7d84d801d7 Make golint happy. 2014-06-26 16:10:10 -05:00
Dave Collins
a9e1b8fb84 Use system CAs when Certificates are not specified.
This commit modifies the TLS setup to only override the RootCAs for the
TLS connection if certificates are specified.  This allows the
Certificates parameter to be ommitted from the connection config to use
the system CAs.
2014-06-25 21:53:00 -05:00
Dave Collins
21872ecdaa Update for recent btcchain ProcessBlock API change.
Now that the ProcessBlock function returns whether or not the block was an
orphan, the code which requests the parent blocks from the peer that sent
them has been moved to directly after the call to it.

This makes the handling more obvious and has allowed removal of the
blockPeer map which was kept so the notification handler could identify
which peer to request the blocks from.

ok @jrick
2014-06-25 17:46:11 -05:00
Dave Collins
415ac4596a Make orphan ntfns to a return val on ProcessBlock.
This commit changes the way that orphan blocks are identified by adding a
new boolean return value on ProcessBlock and removing the notification for
NTOrphanBlock.

This allows the calling code to identify orphan blocks immediately instead
of having to setup a seperate callback handler and implementing some type
of state tracking.  This, in turn, allows cleaner code for handling them.

In addition, the tests have been updated for the new function signature
and also now check that each block is or is not an orphan as expected
which makes the tests more robust.

ok @jrick
2014-06-25 17:46:00 -05:00
David Hill
0ae3676a7d Log when the initial connection has been made. 2014-06-25 12:56:47 -04:00
Dave Collins
0550bbbdc5 Add tests for new RuleError and ErrorCode types. 2014-06-24 19:14:30 -05:00
Dave Collins
6e0aab52df Improve the RuleError type to include error codes.
This commit changes the RuleError type to a struct which consists of an
error code and human-readable description.

From a usage perspective, existing code should not break since type
asserting an error to a RuleError still works in the same manner.  The
difference is the caller can now take that type asserted RuleError and
access the .ErrorCode field on it to programmatically identify the
specific rule that was violated.

ok @jrick
2014-06-24 19:14:24 -05:00
Josh Rickmar
35d555d541 Do not log warning for filtered block inv types.
ok @davecgh
2014-06-24 18:44:28 -05:00
Josh Rickmar
d2d518a8e4 btcctl: Add lockunspent support.
ok @davecgh
2014-06-24 18:36:05 -05:00
Josh Rickmar
00874b6ec2 Unmarshal correct lockunspent outpoints parameter. 2014-06-23 16:51:21 -05:00
Dave Collins
5f444ce000 Wait for conection to peer before mining with CPU. 2014-06-19 09:44:12 -05:00
Josh Rickmar
22b6af1400 Fix unmarshaling of HTTP POST responses.
If connecting to a bitcoin RPC server as an HTTP POST client, full
response objects rather than just the raw result bytes were being
passed to the specific result unmarshalers, causing unmarshal errors
for the incorrect JSON types.  To fix this, first unmarshal the
response body into a rawResponse, and pass only the raw result bytes
(or an error) to the specific handlers.

This was reported by nskelsey on IRC.

ok @davecgh
2014-06-18 10:21:18 -05:00
Dave Collins
370899e1fc Change RawTxInput.Vout to uint32 as well.
This was missed by the previous commit.
2014-06-16 15:49:40 -05:00
Josh Rickmar
6dc257b8c8 Notify websocket clients of finished rescans.
ok @davecgh
2014-06-16 14:48:52 -05:00
Josh Rickmar
385201f9da Update test coverage report. 2014-06-16 14:47:11 -05:00
Josh Rickmar
160113d612 Add rescanfinished notification. 2014-06-16 14:46:25 -05:00
Josh Rickmar
aceaed82c5 Add support for new rescanfinished notification.
ok @davecgh
2014-06-16 14:45:47 -05:00
Dave Collins
289efbdea9 Update for recent btcjson API changes. 2014-06-16 14:44:36 -05:00
Dave Collins
b585d4e3a0 Make params which reference txout indices uint32.
This reasons for this change follow:

- All instances of the same key should be consistent amongst the commands
  and returns
- Output indices can't be negative, so rather than adding more code to
  check for a negative after unmarshal, just allow the unmarshal to weed
  out negatives

ok @jcvernaleo
2014-06-16 14:44:04 -05:00
Dave Collins
1997d73c65 Alphabetize result type declarations. 2014-06-13 17:06:41 -05:00
David Hill
7d228846bd sync tx_valid.json test data. 2014-06-13 11:34:47 -04:00
Josh Rickmar
6d79aa5ff1 Test panic for converting invalid sha strings.
ok @davecgh
2014-06-13 09:49:08 -05:00
Josh Rickmar
4bbcede9e0 Add tests for network registration.
While here, fix a bug found through testing.  Register will now return
ErrDuplicateNet if the caller attempts to register any of the standard
network parameters provided by this package.

ok @davecgh
2014-06-13 09:49:02 -05:00
Dave Collins
7448f9555c Make golint happier. 2014-06-12 23:00:03 -05:00
Dave Collins
67d570e660 Correct a few cases of address encoding.
There are certain RPCs where an address should be sent as the raw string
instead of the encoded bitcoin address since the RPC handler on the other
end expects "keys" instead of Bitcoin addresses.

For example, the multisignature RPCs addmultisigaddress and createmultisig
can work with pubkeys (compressed, uncompressed, or hybrid) as well as
Bitcoin addresses.

The original issue which prompted these changes was report by Paul Snow on
IRC.
2014-06-12 22:55:30 -05:00
Dave Collins
41dce5796d Update to coveralls.io for test coverage reporting.
Also add a test coverage badge to the README.md.
2014-06-12 18:44:34 -05:00
Dave Collins
acda2044a0 Add godoc reference badge to README.md. 2014-06-12 18:40:44 -05:00
Dave Collins
3cbba55822 Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2014-06-12 18:37:35 -05:00
Dave Collins
0f23236f43 Make subsidy halving interval for simnet 210000.
This value matches testnet and mainnet and makes more sense because it
allows way more coins to be generated which is useful during simulation
testing.

NOTE: this will invalidate existing simnet chains, but since they
are only intended to be short lived for the duration of a simulation test,
this is a non-issue.
2014-06-12 18:20:51 -05:00
Dave Collins
c71988f668 Add comments for prefixes the encoding IDs map to. 2014-06-12 18:14:46 -05:00
GeertJohan
a3091847b3 Fix adding wrong HashAddrID to pubKeyHashAddrIDs 2014-06-13 01:00:59 +02:00
John C. Vernaleo
6a69acef21 Fix typo. 2014-06-12 15:41:57 -04:00
John C. Vernaleo
cd3d832551 Switch pingtime and pingwait to float64.
Needed to match bitcoin-core and btcjson.

ok @davec
2014-06-12 15:39:20 -04:00
John C. Vernaleo
3d7749fcea Change PingTime and PingWait to float64.
This is to match bitcoin-core.  Caught by Skelsey.

Closes #24
2014-06-12 15:36:57 -04:00
Dave Collins
ac5cc1d64e Use default genproclimit of -1 on setgenerate RPC.
The correct default for the genproclimit on the setgenerate RPC is -1.

ok @jcvernaleo.
2014-06-12 14:23:38 -05:00
David Hill
e9211bd01a Fix log message. 2014-06-12 14:04:05 -04:00
Josh Rickmar
28c0a3c8c7 Modify doco and example for btcwallet ws endpoint. 2014-06-12 13:00:42 -05:00