Commit graph

180 commits

Author SHA1 Message Date
Jeff Garzik 0e1d3551da RPC: add facility to enable RPCs to run outside cs_main, wallet locks
Use with 'stop' and 'help' RPCs.

This provides a facility to individually evaluate the locking for an RPC, and
potentially make it more parallel.
2012-08-21 12:03:52 -04:00
Jeff Garzik 5f2b41d54d Merge pull request #1693 from jgarzik/rpcwallet
Move code to new modules rpcwallet.cpp, rpcblockchain.cpp
2012-08-21 08:44:21 -07:00
Jeff Garzik c625ae04d2 RPC, cosmetic: move more RPC code to new rpcblockchain.cpp module 2012-08-21 11:03:38 -04:00
Jeff Garzik e3bc569865 RPC, cosmetic: move wallet-related RPCs to new rpcwallet.cpp module 2012-08-21 10:38:57 -04:00
Gregory Maxwell 4a4a0c1196 Merge pull request #1690 from gavinandresen/signrawtx_null
Allow signrawtransaction '...' null null 'hashtype'
2012-08-21 06:40:50 -07:00
Jeff Garzik 7600e7fc39 RPC, cosmetic: Create rpcmining.cpp as new home for mining-related RPC code 2012-08-21 02:21:33 -04:00
Jeff Garzik ddd1ffb4f1 RPC, cosmetic: de-indent getblocktemplate() 2012-08-21 02:06:09 -04:00
Jeff Garzik 79f2525ab6 RPC: split new 'submitblock' out of 'getblocktemplate' 2012-08-21 02:02:06 -04:00
Gavin Andresen cc6dfd1f4b Allow signrawtransaction '...' null null 'hashtype'
Allows the user to pass null as the second or third parameter
to signrawtransaction, in case you need to (for example) fetch
private keys from the wallet but want to specify the hash type.
2012-08-20 17:19:13 -04:00
Luke Dashjr 44427fa833 Merge branch 'gmp_bip_0.6.0' into gmp_bip
Conflicts:
	src/bitcoinrpc.cpp
2012-08-03 01:12:55 +00:00
Luke Dashjr 3390014fd0 Minimal BIP 22 (getblocktemplate) support
- Replaces getmemorypool with new getblocktemplate
- Add missing keys: coinbaseaux, target, mutable, noncerange, sigoplimit, sizelimit, and height
- Accept and send parameter Objects, checking "mode" key if present
- Return rejection reason "rejected" for submit mode
2012-08-03 01:02:51 +00:00
Gregory Maxwell 8ce7915aad Merge pull request #1612 from luke-jr/opti_getblkhash
Optimize JSON-RPC getblockhash
2012-08-01 11:49:26 -07:00
Luke Dashjr 1be064190e Optimize JSON-RPC getblockhash
- If the height is in the first half, start at the genesis block and go up, rather than at the top
- Cache the last lookup and use it as a reference point if it's close to the next request, to make linear lookups always fast
2012-08-01 18:23:30 +00:00
Luke Dashjr 814efd6f1f Bugfix: Fix a variety of misspellings 2012-08-01 17:49:51 +00:00
Gavin Andresen 986a78979e Merge branch 'bugfix_CNBerr' of git://github.com/luke-jr/bitcoin 2012-07-26 13:55:21 -04:00
Gavin Andresen 18871d4785 Give a better error message than 'type mismatch' for complex JSON arguments 2012-07-17 12:02:31 -04:00
Giel van Schijndel 9f46ab62b1 Fix thread names after review
* Fix wrong thread name for wallet *relocking* thread
  - Was named the unlocking thread
 * Use consistent naming

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-07-17 01:50:35 +02:00
Giel van Schijndel 96931d6f78 Give threads a recognisable name to aid in debugging
NOTE: These thread names are visible in gdb when using 'info threads'.
      Additionally both 'top' and 'ps' show these names *unless* told to
      display the command-line instead of task name.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-07-17 01:50:35 +02:00
Jeff Garzik 698b9f3095 bitcoinrpc.cpp: Removed outdated comment
Fixes #1373
2012-07-05 18:18:15 -04:00
Gavin Andresen dab9fa7f91 Use unsigned ints to fix signed/unsigned warnings 2012-07-05 13:26:27 -04:00
Gavin Andresen a2709fad7f Implement raw transaction RPC calls
Implement listunspent / getrawtransaction / createrawtransaction /
signrawtransaction, to support creation and
signing-on-multiple-device multisignature transactions.
2012-07-05 12:50:09 -04:00
Gavin Andresen 899d373b3c RPCTypeCheck method to make type-checking JSON Arrays easier. 2012-07-05 12:42:25 -04:00
Gavin Andresen 9a6ab7f142 Rework gettransaction / getblock RPC calls
This PULL reworks new (post-0.6.*) features of the
gettransaction/getblock RPC calls as follows:

It removes the 'decompositions' object argument from getblock,
replacing it just a list of transaction hashes; equivalent
(I believe) of passing the {"tx":"hash"} decomposition.

It replaces the 'decompositions' object argument of
gettransaction with a boolean flag; if true, returns
the same stuff that the {"script":"obj"} decomposition
would return (txins/txouts as hex, disassembled, and bitcoin
addresses).

It adds a "rawtx" field to the output of gettransaction,
that is the entire transaction serialized and hex-encoded.

It removes the "size" field from gettransaction, since the size
is trivial to compute from the "rawtx" field (either take the
length after hex-decoding, or just compute it as hex-length/2).
2012-07-05 12:42:25 -04:00
Jeff Garzik 613389019e RPC: add support for JSON-RPC 2.0-style request batching
If the top-level object is an array, it is assumed to be an array of
JSON-RPC requests.  An array is returned, containing one response (error or
not) per request, in the order submitted.

In a slight change in semantics, batched requests -always- return
an HTTP 200 OK status, even ones full of invalid or incorrect requests.
2012-07-03 22:53:57 -04:00
Jeff Garzik c6494d82fa RPC: break out high level JSON-RPC req/resp into their own functions
This prepares for JSON-RPC 2.0 batches.
2012-07-03 22:53:30 -04:00
Jeff Garzik 1006f0707e RPC: add 'getpeerinfo', returning easy-to-retrieve per-CNode data 2012-06-29 17:24:53 -04:00
Jeff Garzik 70ab73a008 Create new rpcnet module, and move 'getconnectioncount' RPC to it 2012-06-28 23:18:38 -04:00
Matt Corallo 460d878613 Fix build error. 2012-06-28 19:31:22 +02:00
Matt Corallo 4e97a9d9eb Lock vnThreadsRunning[THREAD_RPCHANDLER]. 2012-06-28 18:34:11 +02:00
Matt Corallo 7cf3d2ccb9 Use a rpc-specific queue to tell asio connections to shutdown. 2012-06-28 18:32:32 +02:00
Matt Corallo 18c4beb05b Revert "*Always* send a shutdown signal to enable custom shutdown actions"
This reverts commit 896899e0d6.
2012-06-28 15:52:45 +02:00
Giel van Schijndel ad25804feb Cancel outstanding listen ops for RPC when shutting down
Use Boost's signal2 slot tracking mechanism to cancel any (still open)
listening sockets when receiving a shutdown signal.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-06-24 15:12:15 +02:00
Giel van Schijndel 415a87ef36 Merge branch 'master' into async-ipv6-rpc 2012-06-24 12:34:15 +02:00
Jeff Garzik 25d5c19522 RPC: add 'getrawmempool', listing all transaction ids in memory pool 2012-06-22 11:43:34 -04:00
Giel van Schijndel 896899e0d6 *Always* send a shutdown signal to enable custom shutdown actions
NOTE: This is required to be sure that we can properly shut down the RPC
      thread.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-06-17 21:50:49 +02:00
Giel van Schijndel 07368a9e3c Merge branch 'master' into async-ipv6-rpc
Conflicts:
	src/bitcoinrpc.cpp

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-06-17 14:30:37 +02:00
Philip Kaufmann 9247134eab introduce a new StartShutdown() function, which starts a thread with Shutdown() if no GUI is used and calls uiInterface.QueueShutdown() if a GUI is used / all direct uiInterface.QueueShutdown() calls are replaced with Shutdown() - this ensures a clean GUI shutdown, even when catching a SIGTERM and allows the BitcoinGUI destructor to get called (which fixes a tray-icon issue and keeps the tray-icon until Bitcoin-Qt exits) 2012-06-12 07:21:03 +02:00
Gavin Andresen 46e06b875d Merge branch 'netopt' of https://github.com/sipa/bitcoin 2012-06-04 14:15:19 -04:00
Gavin Andresen 98474d3d6f Use ConvertTo to simplify sendmany/addmultisigaddress argument handling 2012-05-31 16:09:31 -04:00
Gavin Andresen ea7582bb41 Make sendrawtx return txid to be consistent with other send methods. 2012-05-31 16:05:07 -04:00
Pieter Wuille 587f929c64 Rework network config settings 2012-05-31 18:12:35 +02:00
Giel van Schijndel fbf9df2ea3 Use the QueueShutdown signal to stop accepting new RPC connections
Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-05-25 07:27:25 +02:00
Giel van Schijndel 7cc2ceae09 Allow all addresses on the loopback subnet (127.0.0.0/8) not just 127.0.0.1
Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-05-25 07:27:24 +02:00
Giel van Schijndel a0780ba08a Generalise RPC connection handling code to allow more listening sockets
Using this modification it should be relatively easy to, at a later
time, listen on multiple addresses (even Unix domain sockets should be
possible).

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-05-25 07:27:24 +02:00
Giel van Schijndel 43b6dafa6e Allow clients on the IPv6 loopback as well
Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-05-25 07:27:24 +02:00
Giel van Schijndel c1ecab818c Add dual IPv4/IPv6 stack support to the RPC server
The RPC server now listens for, and handles, incoming connections on
both IPv4 as well as IPv6.

If available (and usable) it uses a dual IPv4/IPv6 socket on systems
that support it (e.g. Linux and BSDs) and falls back to separate
IPv4/IPv6 sockets on systems that don't (e.g. Windows).

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-05-25 07:27:24 +02:00
Giel van Schijndel 914dc01222 Use asynchronous I/O to handle RPC requests
This allows more flexibility in the RPC code, e.g. making it easier to
handle multiple simultaneous connections later on.

Currently asynchronous I/O is only used to listen for and accept
incoming connections.  Asynchronous reading/writing is more involved.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-05-25 07:27:24 +02:00
Pieter Wuille 1025440184 Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
This introduces internal types:
* CKeyID: reference (hash160) of a key
* CScriptID: reference (hash160) of a script
* CTxDestination: a boost::variant of the former two

CBitcoinAddress is retrofitted to be a Base58 encoding of a
CTxDestination. This allows all internal code to only use the
internal types, and only have RPC and GUI depend on the base58 code.

Furthermore, the header dependencies are a lot saner now. base58.h is
at the top (right below rpc and gui) instead of at the bottom. For the
rest: wallet -> script -> keystore -> key. Only keystore still requires
a forward declaration of CScript. Solving that would require splitting
script into two layers.
2012-05-24 20:26:19 +02:00
Pieter Wuille fd61d6f506 Encapsulate public keys in CPubKey 2012-05-24 19:58:12 +02:00
Jeff Garzik 976c08b68a JSON-RPC: Add 'sendrawtx' op, for sending pre-built TX's to network 2012-05-23 16:21:25 -04:00