Commit graph

229 commits

Author SHA1 Message Date
Dave Collins
66a17f8a47 Return time offset in getinfo RPC.
This was previously hard-coded to zero instead of using the offset
provided by the median time source which takes time samples from the other
connected nodes.
2015-01-24 11:24:53 -06:00
Dave Collins
919109f12c Update btcjson import paths to new location. 2015-01-16 23:58:09 -06:00
Dave Collins
10643379a9 Update btcws import paths to new location. 2015-01-16 23:37:26 -06:00
Dave Collins
a57505b7f0 Update btcscript import paths to new location. 2015-01-16 19:37:00 -06:00
Dave Collins
528622b259 Update btcchain import paths to new location. 2015-01-16 18:47:50 -06:00
Dave Collins
0b7a9074ef Update btcdb import paths to new location. 2015-01-16 18:30:32 -06:00
Dave Collins
44102d752a Update btcec import paths to new location. 2015-01-16 18:06:03 -06:00
Dave Collins
2bd21ead0b Update btcnet import paths to new location. 2015-01-16 17:31:08 -06:00
Dave Collins
54ccb83025 Update btcwire import paths to new location. 2015-01-16 15:13:21 -06:00
Dave Collins
3172e84bb3 Update fastsha256 import paths to new location. 2015-01-16 09:10:29 -06:00
Dave Collins
b732eac0be Update websocket import paths to new location. 2015-01-15 17:20:30 -06:00
Dave Collins
58db4a8b7e Update btcutil import paths to new location. 2015-01-15 10:30:38 -06:00
Dave Collins
a64ffb820a Correct RPC time handling for getblocktemplate.
This commit modifies the getblocktemplate RPC to correctly handle the
curtime field.

Currently, the RPC server will refuse to serve a block template if the
current time is before the minimum allowed time for a block even though
the real generated block template already accounted for it.

This consists of three changes:
- Remove the unnecessary and incorrect check in the RPC invocation for the
  current time against the min required time since it is already handled
  properly by the block template generation.
- Expose the network time source to the RPC work state and use the
  adjusted time for checking against the maximum allowed time instead of
  the current time.
- Set the returned RPC result curtime field to the time of the generated
  block header.

Fixes #209.
2015-01-08 01:41:50 -06:00
Dave Collins
4b727d2035 Ignore error in script disassembly for RPC results.
This commit modifies the creation of RPC results to ignore errors in
script disassembly since they already contain the error string inline and
the RPC results must still be generated regardless.

This was already done in the decodescript RPC, however the same thing was
not being done in the higher level verbose transaction results.  This
applies to both the createrawtransaction and decoderawtransaction RPCs.

Also, since this was the only thing that could error within those
functions, the error returns and caller checking of now non-existent
errors have been removed.

Fixes #210.
2015-01-07 16:23:23 -06:00
Dave Collins
04d47de262 Allow disabling RPC server TLS for localhost only.
This commit introduces a new flag, --notls, which can be used to disable
TLS for the RPC server.  However, the flag can only be used when the RPC
server is bound to localhost interfaces.  This is intended to prevent the
situation where someone decides they want to expose the RPC server to the
web for remote management/access, but forgot they have TLS disabled.
2015-01-02 11:17:23 -06:00
Dave Collins
33546047e3 Use correct error name in handleGetRawTransaction.
This commit corrects the error check from the createTxRawResult call in
handleGetRawTransaction.  It was previously given a different name which
resulted in the wrong error being checked.

Fixes #196.
2014-12-21 21:49:21 -06:00
Josh Rickmar
1d0c09a852 Require TLS 1.2 minimum.
This prevents a downgrade attack to the vulnerable SSLv3.  While here,
go ahead and require at least TLS 1.2 since TLS 1.0 and 1.1 have their
own set of issues and it's only a matter of time before those would
need to be completely avoided as well.

ok @davecgh
2014-12-15 13:53:14 -05:00
Dave Collins
888884a399 Use .haveTransaction in new getmempool RPC code.
The mempool is already locked and the exported version locks it, so the
unexported version is needed.
2014-11-17 15:46:42 -06:00
Dave Collins
1973aa5fd5 A few nitpicks with recent getrawmempool updates.
This commit addresses a few nitpicks in the recent getrawmppol update
which populates the starting and current priority fields.

In particular:

- Move the new calcInputValueAge function before the function which
  invokes it so it is consistent with the rest of the mempool code
- Double space after periods for consistency
- Correct the comments for calcInputValueAge to indiciate that inputs
  which are in the the memory pool count as zero toward the value age
  rather than the incorrect claim that that the overal input value age is
  zero when one of them does
- Rename endingPriority to currentPriority to match the RPC field and its
  actual function
- Make the comment about using zero when input transactions can't be found
  for some reason more accurate since there can be (and frequently is)
  more than one input transaction
2014-11-17 00:31:14 -06:00
Olaoluwa Osuntokun
a49b0d05b3 Add the starting+current priority to getrawmempool. 2014-11-16 23:58:33 -06:00
Dave Collins
c3065d32f4 Make use of the new btcchain MedianTimeSource.
This commit uses the new MedianTimeSource API in btcchain to create a
median time source which is stored in the server and is fed time samples
from all remote nodes that are connected.  It also modifies all call sites
which now require the the time source to pass it in.
2014-10-09 10:44:22 -05:00
Jonathan Gillham
1bbd1e9cba Changed TxIn.PreviousOutpoint to TxIn.PreviousOutPoint after btcwire API change. 2014-10-01 16:34:30 +01:00
ortutay
139d9cb447 Implement verifymessage RPC. 2014-08-22 16:58:02 -07:00
David Hill
e720e398a1 Mark getchaintips RPC command as unimplemented. 2014-08-12 11:33:07 -04:00
Josh Rickmar
790a4f5a6e Return nil for some spent gettxout outputs.
This change modifies the behavior of the gettxout RPC to match the
behavior of the reference client.  If a transaction output is spent by
a mined transaction, the handler will now return nil (JSON null).

While here, avoid indexing some slices multiple times, by creating a
local variable instead.
2014-07-24 15:02:07 -05:00
Olaoluwa Osuntokun
293d71e9c3 Implement gettxout rpc.
Use new error type defined in Roasbeef/btcjson@4dc9db809
2014-07-19 13:01:59 -05:00
Dave Collins
000691dc9e Implement BIP0061 reject handling (pver 70002).
This commit implements reject handling as defined by BIP0061 and bumps the
maximum supported protocol version to 70002 accordingly.

As a part of supporting this a new error type named RuleError has been
introduced which encapsulates and underlying error which could be one of
the existing TxRuleError or btcchain.RuleError types.

This allows a single high level type assertion to be used to determine if
the block or transaction was rejected due to a rule error or due to an
unexpected error.  Meanwhile, an appropriate reject error can be created
from the error by pulling the underlying error out and using it.

Also, a check for minimum protocol version of 209 has been added.

Closes #133.
2014-07-14 12:25:11 -05:00
David Hill
2f0cab1a48 Log accepted blocks via submitblock.
ok @davecgh
2014-07-14 11:08:07 -04:00
Dave Collins
be7923a4ed Update to account for recent btcchain API changes. 2014-07-11 09:57:03 -05:00
Dave Collins
bd7a100ebb Address a few more comments. 2014-07-10 09:43:03 -05:00
Dave Collins
ffe0b09890 Seed random generator in RPC server during init.
Rather than reseeding the PRNG used throughout the RPC server on each
call, do it once during init.

Suggested by @jrick
2014-07-10 09:43:02 -05:00
Dave Collins
180f4ac0a2 Implement some BIP0023 getblocktemplate mutations.
This commit implements a portion of the mutations section of BIP0023.
In particular, it adds the mutable, mintime, maxtime, and noncerange keys
to the returned block template along with indicating support for the time,
transactions/add, prevblock, and coinbase/append mutations.  Also, the
addition of the mintime and maxtime fields imply support for the
time/decrement and time/increment mutations.  Further, if the caller
indicates the coinbasevalue capability, the coinbasetxn field will be
omitted thereby implying support for the coinbase and generation
mutations.

Closes #124.
2014-07-10 09:43:01 -05:00
Dave Collins
21050b4751 Implement BIP0023 getblocktemplate block proposals.
This commit implements block proposals as defined by BIP0023.

This is work towards #124.
2014-07-10 09:43:00 -05:00
Dave Collins
db20f25ff7 Implement BIP0023 basic pool extensions support.
This commit implements the basic pool extension portion of the getblocktemplate
RPC as defined by BIP0023.

This is work towards #124.
2014-07-10 09:42:59 -05:00
Dave Collins
fc5656894d Implement getblocktemplate long poll support.
This commit implements the long polling portion of the getblocktemplate
RPC as defined by BIP0022.  Per the specification, each block template is
returned with a longpollid which can be used in a subsequent
getblocktemplate request to keep the connection open until the server
determines the block template associated with the longpollid should be
replaced with a new one.

This is work towards #124.
2014-07-10 09:42:58 -05:00
Dave Collins
eb7ecdcc22 Implement basic getblocktemplate BIP0022 support.
This commit implements the non-optional and template tweaking support for
the getblocktemplate RPC as defined by BIP0022.  This implementation does
not yet include long polling support.

This is work towards #124.
2014-07-10 09:42:57 -05:00
Dave Collins
6248dd5e5d Don't return a double pointer.
This commit has no effect on the effective functionality since Go
automatically deferences pointers, but there is no reason to have a
double indirection when returning the reply for getmininginfo.
2014-07-09 01:34:56 -05:00
Josh Rickmar
9e60210f18 Update for untyped btcutil consts.
ok @davecgh
2014-07-08 11:14:46 -05:00
Tomás Senart
2afc5a0af2 Use lighter atomic counters instead of mutexes
Where appropriate, it makes sense to use lighter weight atomic counters
instead of mutexes.
2014-07-07 13:04:39 -05:00
David Hill
2e029b1c3d Add gettxout to btcctl. 2014-07-04 10:50:57 -04:00
Josh Rickmar
5966a5230d Don't log error if getrawtransaction finds no tx.
ok @davecgh
2014-07-03 10:37:37 -05:00
David Hill
6f17ebc8cb Implement validateaddress.
validateaddress will simply return whether the given address is
valid or not.  For the full implementation, one should query
btcwallet instead.
2014-07-02 23:52:34 -04:00
Tomás Senart
cc2c486791 Replace map[a]bool with map[a]struct{}
The later uses no memory storage for values and provides the same
functionality.
2014-07-02 19:06:29 -05:00
Tomás Senart
a0f20007c5 golint -min_confidence=0.3 .
This commits removes a number of golint warnings. There is a class of
warnings which I can't fix due to unsufficient knowledge of the domain
at this point. These are listed here:

addrmanager.go:907:1: comment on exported method AddrManager.Attempt
should be of the form "Attempt ..."
addrmanager.go:1048:1: exported function RFC1918 should have comment or
be unexported
addrmanager.go:1058:1: exported function RFC3849 should have comment or
be unexported
addrmanager.go:1065:1: exported function RFC3927 should have comment or
be unexported
addrmanager.go:1073:1: exported function RFC3964 should have comment or
be unexported
addrmanager.go:1081:1: exported function RFC4193 should have comment or
be unexported
addrmanager.go:1089:1: exported function RFC4380 should have comment or
be unexported
addrmanager.go:1097:1: exported function RFC4843 should have comment or
be unexported
addrmanager.go:1105:1: exported function RFC4862 should have comment or
be unexported
addrmanager.go:1113:1: exported function RFC6052 should have comment or
be unexported
addrmanager.go:1121:1: exported function RFC6145 should have comment or
be unexported
addrmanager.go:1128:1: exported function Tor should have comment or be
unexported
addrmanager.go:1143:1: exported function Local should have comment or be
unexported
addrmanager.go:1228:2: exported const InterfacePrio should have comment
(or a comment on this block) or be unexported
discovery.go:26:2: exported var ErrTorInvalidAddressResponse should have
comment or be unexported
limits/limits_unix.go:19:1: exported function SetLimits should have
comment or be unexported
limits/limits_windows.go:7:1: exported function SetLimits should have
comment or be unexported
util/dropafter/dropafter.go:22:6: exported type ShaHash should have
comment or be unexported
util/dropafter/dropafter.go:38:2: exported const ArgSha should have
comment (or a comment on this block) or be unexported
util/dropafter/dropafter.go:128:5: exported var ErrBadShaPrefix should
have comment or be unexported
util/dropafter/dropafter.go:129:5: exported var ErrBadShaLen should have
comment or be unexported
util/dropafter/dropafter.go:130:5: exported var ErrBadShaChar should
have comment or be unexported
util/showblock/showblock.go:24:6: exported type ShaHash should have
comment or be unexported
util/showblock/showblock.go:46:2: exported const ArgSha should have
comment (or a comment on this block) or be unexported
util/showblock/showblock.go:163:1: exported function DumpBlock should
have comment or be unexported
util/showblock/showblock.go:211:5: exported var ErrBadShaPrefix should
have comment or be unexported
util/showblock/showblock.go:212:5: exported var ErrBadShaLen should have
comment or be unexported
util/showblock/showblock.go:213:5: exported var ErrBadShaChar should
have comment or be unexported
2014-07-02 11:01:56 -05:00
Tomás Senart
84fa553b65 Split imports into logical groups 2014-07-02 15:56:41 +02:00
Dave Collins
767caaa6ae Make hex decoding consistent in RPC handlers.
The hex package requires an even number of characters in hex encoded
strings.  Some of the handlers already prepended a zero if necessary to
make this condition true, however other did not.  This commit extends this
functionality to all handlers and also makes the error return consistent.

ok @jrick
2014-07-01 20:39:31 -05:00
Dave Collins
1db0eb4fec Update for recent btcjson changes.
This commit updates the types to match the recent changes to the btcjson
result types.
2014-06-29 16:37:21 -05:00
Dave Collins
0c9c005c33 Modify NewBlockTemplate to accept nil pay addr.
There are certain cases such as getblocktemplate which allow external
callers to be repsonsible for creating their own coinbase to replace the
generated one.  By allowing the pay address to be nil in such cases, the
need to specify mining addresses via --miningaddr can be avoided thereby
leaving the payment address management up to the caller.
2014-06-27 14:16:08 -05:00
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
48c6806b24 Update for btcchain ProcessBlock behavior flags.
ok @jrick
2014-06-26 17:18:05 -05:00