Commit graph

243 commits

Author SHA1 Message Date
Jeff Garzik e5e9904c1c RPC: add getrawchangeaddress, for raw transaction change destinations 2013-08-28 16:29:52 -04:00
Gavin Andresen a0bb001431 Merge pull request #2886 from gavinandresen/rpctiming
Make RPC password resistant to timing attacks
2013-08-15 18:53:26 -07:00
Gavin Andresen 4323bfeafd Merge pull request #2776 from jgarzik/keypoolsize
RPC: keypoolrefill now permits optional size parameter, to bump keypool
2013-08-14 22:01:22 -07:00
Gavin Andresen 42656ea2e5 Make RPC password resistant to timing attacks
Fixes issue#2838; this is a tweaked version of pull#2845 that
should not leak the length of the password and is more generic,
in case we run into other situations where we need
timing-attack-resistant comparisons.
2013-08-08 19:58:57 +10:00
Gavin Andresen 050d2e953f Remove #define loop from util.h
Replace the loop macro with while (true). The #define caused
problems for Qt.
2013-07-31 14:06:44 +10:00
Jeff Garzik 091aa8dae9 RPC: add getbestblockhash, to return tip of best chain 2013-07-03 11:02:29 -04:00
Jeff Garzik 36bd46f1c4 RPC: keypoolrefill gains optional size parameter 2013-06-25 16:21:42 -04:00
Pieter Wuille ee4949794b Merge pull request #2592 from sipa/dumpwallet
Add dumpwallet and importwallet RPC commands
2013-06-23 12:10:17 -07:00
Jeff Garzik 4be2aba302 Merge pull request #2778 from jgarzik/rpc-verifydb
RPC: add 'verifychain' to verify chain database at runtime
2013-06-22 23:08:13 -07:00
Pieter Wuille 4e534aa9d8 Add dumpwallet and importwallet RPCs
dumpwallet: produce a dump of all keys in a wallet, in a format
compatible with Bitcoin Wallet for Android and Multibit.

importwallet: import such a dump
2013-06-22 17:30:56 +02:00
Jeff Garzik f590653377 RPC: add 'verifychain', to verify chain database at runtime 2013-06-19 11:53:02 -04:00
Mike Hearn 0e4b317555 Introduce a CChainParameters singleton class and regtest mode.
The new class is accessed via the Params() method and holds
most things that vary between main, test and regtest networks.
The regtest mode has two purposes, one is to run the
bitcoind/bitcoinj comparison tool which compares two separate
implementations of the Bitcoin protocol looking for divergence.

The other is that when run, you get a local node which can mine
a single block instantly, which is highly convenient for testing
apps during development as there's no need to wait 10 minutes for
a block on the testnet.
2013-06-19 16:28:52 +02:00
Jeff Garzik 543d70a676 Merge pull request #2747 from luke-jr/getblock_verbose0
Add verbose flag to getblock RPC so it is possible to get hex dumps of blocks
2013-06-10 08:16:39 -07:00
Luke Dashjr 2331952141 RPC: getblock(): Accept 2nd "verbose" parameter, similar to getrawtransaction, but defaulting to 1 for backward compatibility 2013-06-07 17:44:39 +00:00
Philip Kaufmann 3260b4c090 remove GetBoolArg() fDefault parameter defaulting to false
- explicitly set the default of all GetBoolArg() calls
- rework getarg_test.cpp and util_tests.cpp to cover this change
- some indentation fixes
- move macdockiconhandler.h include in bitcoin.cpp to the "our headers"
  section
2013-06-01 12:53:57 +02:00
Jeff Garzik 6bc6d57303 Merge pull request #2716 from laanwj/2013_05_30_getwork
Move pMiningKey init out of StartRPCThreads
2013-05-30 09:15:16 -07:00
Jeff Garzik 9c95a2e836 Merge pull request #2625 from gavinandresen/walletlock_asio
Use boost::asio::deadline_timer for walletpassphrase timeout
2013-05-30 08:01:22 -07:00
Wladimir J. van der Laan d98bf10f23 Move pMiningKey init out of StartRPCThreads
This commit decouples the pMiningKey initialization and shutdown from the RPC
threads.

`getwork` and `getblocktemplate` rely on pMiningKey, and can also be ran
from the debug window in the UI even when the RPC server is not running.

Solves issue #2706.
2013-05-30 16:41:35 +02:00
Gavin Andresen 36e826cea1 Clean up mining CReserveKey to prevent crash at shutdown
Fixes issue#2687
2013-05-23 14:17:15 -04:00
Gavin Andresen 92f2c1fe0f Use boost::asio::deadline_timer for walletpassphrase timeout
New method in bitcoinrpc:  RunLater, that uses a map of deadline
timers to run a function later.

Behavior of walletpassphrase is changed; before, calling
walletpassphrase again before the lock timeout passed
would result in: Error: Wallet is already unlocked.

You would have to call lockwallet before walletpassphrase.

Now: the last walletpassphrase with correct password
wins, and overrides any previous timeout.

Fixes issue# 1961 which was caused by spawning too many threads.

Test plan:

Start with encrypted wallet, password 'foo'
NOTE:
 python -c 'import time; print("%d"%time.time())'
... will tell you current unix timestamp.

Try:

walletpassphrase foo 600
getinfo
EXPECT: unlocked_until is about 10 minutes in the future

walletpassphrase foo 1
sleep 2
sendtoaddress mun74Bvba3B1PF2YkrF4NsgcJwHXXh12LF 11
EXPECT: Error: Please enter the wallet passphrase with walletpassphrase first.

walletpassphrase foo 600
walletpassphrase foo 0
getinfo
EXPECT: wallet is locked (unlocked_until is 0)

walletpassphrase foo 10
walletpassphrase foo 600
getinfo
EXPECT: wallet is unlocked until 10 minutes in future

walletpassphrase foo 60
walletpassphrase bar 600
EXPECT: Error, incorrect passphrase
getinfo
EXPECT: wallet still scheduled to lock 60 seconds from first (successful) walletpassphrase
2013-05-07 11:47:33 -04:00
Jeff Garzik 9f4976afe2 RPC: strictly require HTTP URI "/"
Previously, JSON-RPC clients accessed URI "/", and the JSON-RPC server
did not care about the URI at all, and would accept any URI as valid.

Change the JSON-RPC server to require URI "/" for all current accesses.

This changes enables the addition of future interfaces at different
URIs, such as pull request #1982 which demonstrates HTTP REST wallet
download.

Or, a future, breaking change in JSON-RPC interface could be introduced
by serving JSON-RPC calls from new URI "/v2/".
2013-05-01 10:41:24 -04:00
Gavin Andresen b31499ec72 Clean up shutdown process 2013-04-03 19:57:53 -04:00
Gavin Andresen 21eb5adadb Port Thread* methods to boost::thread_group 2013-04-03 19:57:13 -04:00
Gavin Andresen 1b43bf0d3a Rename util.h Sleep --> MilliSleep
Two reasons for this change:
1. Need to always use boost::thread's sleep, even on Windows, so the
sleeps can be interrupted (prior code used Windows' built-in Sleep).

2. I always forgot what units the old Sleep took.
2013-04-03 14:04:21 -04:00
Philip Kaufmann 90bd933e6d translation base files update 2013-04-02
- also includes a small change to a string in bitcoinrpc.cpp, which is not
  on Transifex anyway, so is safe to merge
2013-04-02 15:46:40 +02:00
Gavin Andresen 3d9d2d423b Recommend alertnotify 2013-03-21 10:08:21 -04:00
freewil 10ef361169 CRPCCommand.unlocked -> CRPCCommand.threadSafe
unlocked could be confused with wallet encryption
2013-03-07 06:18:55 -05:00
freewil dcf8b8fd9e make vRPCCommands comment match property names 2013-03-07 05:29:18 -05:00
Andrew Poelstra 3913a99087 Enable dumpprivkey in safe mode 2013-02-14 11:55:55 -08:00
Matt Corallo 67a11bd6c5 Add a getaddednodeinfo RPC. 2013-01-27 03:03:04 -05:00
Matt Corallo 72a348fd9a Add addnode RPC command. 2013-01-27 03:03:04 -05:00
Philip Kaufmann 6e65420bd5 make bitcoinrpc.cpp UTF-8 conformant again
- just replaces a character in a comment, which I had problems with when
  opening the file in Qt Creator IDE
2013-01-20 18:50:30 +01:00
Pieter Wuille 5dfbd4ff68 Convert fRescan argument to importprivkey to bool 2012-12-19 12:23:29 +01:00
Gavin Andresen 78504bb04f Merge pull request #1861 from jgarzik/coinlock
Add new RPC "lockunspent", to prevent spending of selected outputs
2012-12-12 09:15:43 -08:00
Philip Kaufmann 5350ea4171 update CClientUIInterface and remove orphan Wx stuff
- fix ThreadSafeMessageBox always displays error icon
- allow to specify MSG_ERROR / MSG_WARNING or MSG_INFORMATION without a
  custom caption / title
- allow to specify CClientUIInterface::ICON_ERROR / ICON_WARNING and
  ICON_INFORMATION (which is default) as message box icon
- remove CClientUIInterface::OK from ThreadSafeMessageBox-calls, as
  the OK button will be set as default, if none is specified
- prepend "Bitcoin - " to used captions
- rename BitcoinGUI::error() -> BitcoinGUI::message() and add function
  documentation
- change all style parameters and enum flags to unsigned
- update code to use that new API

- update Client- and WalletModel to use new BitcoinGUI::message() and
  rename the classes error() method into message()
- include the possibility to supply the wanted icon for messages from
  Client- and WalletModel via "style" parameter
2012-11-26 13:32:31 +01:00
Jeff Garzik fdbb537d26 Add new RPC "lockunspent", to prevent spending of selected outputs
and associated RPC "listlockunspent".

This is a memory-only filter, which is empty when a node restarts.
2012-11-15 21:11:30 -05:00
Jeff Garzik 7e1610d51e RPC: Forbid RPC username == RPC password
Added security measure.
2012-11-15 20:33:42 -05:00
Wladimir J. van der Laan e88f8887b6 Merge pull request #1977 from Diapolo/rem_printf_redef_rpc
remove printf redefinition from bitcoinrpc.cpp
2012-11-10 03:47:11 -08:00
Jeff Garzik 8146591a53 Merge branch 'http-improvements'
The base bits of pull req #1982.
2012-11-09 17:34:25 -05:00
Jeff Garzik fcf234fc08 RPC: HTTP server uses its own ReadHTTPRequestLine()
rather than reusing ReadHTTPStatus() from the client mode.

The following additional HTTP request validations are added, both in line with
existing HTTP client practice:

1) HTTP method must be GET or POST.  Most clients use POST, some
   use GET.  Either way, this continues to work.
2) HTTP URI must start with "/" character.
   Normal URI is "/" (a 1-char string), so this is fine.
2012-11-04 17:16:46 -05:00
Jeff Garzik 2306dc4b76 RPC, cosmetic: push down ReadHTTPStatus() calls into ReadHTTP() callers
ReadHTTPStatus() is currently overloaded:  In client mode, it properly parses
and receives an HTTP status line.  In server mode, it incorrectly parses the
HTTP request line as an HTTP status line.

This server mode bug has never mattered, because the RPC server never
cared about the URI (path) provided in the HTTP request.  That will change in
the future, so go ahead and begin fixing the problem.

This patch is cosmetic, and should result in NO behavior changes.

Further renames:
ReadHTTPHeader -> ReadHTTPHeaders
ReadHTTP -> ReadHTTPMessage
2012-11-04 16:06:38 -05:00
Pieter Wuille 92467073ad Remove -detachdb and stop's detach argument.
As the only BDB database left is the wallet, and it is always
detached.

Also remove IsChainFile() predicate and related chainfile-specific
logic.
2012-11-04 12:59:06 +01:00
Philip Kaufmann ed552cfae0 remove printf redefinition from bitcoinrpc.cpp
- as the redefiniton of printf happens in util.h, which is included in
  bitcoinrpc.cpp, we don't need another redefinition
2012-11-04 11:24:54 +01:00
Gavin Andresen 34226be7a8 New createmultisig rpc command
This is to support the signrawtransaction API call; given the public
keys involved in a multisig transaction, this gives back the redeemScript
needed to sign it.
2012-10-29 13:34:35 -04:00
Pieter Wuille beeb57610c Add gettxout and gettxoutsetinfo RPCs 2012-10-20 23:08:57 +02:00
Philip Kaufmann 95e625d235 fix wrong (signed/unsigned) printf format specifier in bitcoinrpc.cpp
- also includes the required bitcoinstrings.cpp update
2012-10-05 23:31:58 +02:00
Wladimir J. van der Laan 285746d3db Add constants for HTTP status codes 2012-10-04 15:49:15 +02:00
Wladimir J. van der Laan 738835d7b8 Document RPC error codes
Replace all "magic values" in RPCError(...) by constants.
2012-10-04 15:49:15 +02:00
Philip Kaufmann d210f4f5b8 fix -Wformat warnings all over the source 2012-10-01 19:45:42 +02:00
Pieter Wuille 2e3ffb2d82 Remove stack randomization 2012-09-28 21:53:28 +02:00