Commit graph

5515 commits

Author SHA1 Message Date
Cozz Lovan 292623adf5 Subtract fee from amount
Fixes #2724 and #1570.

Adds the
automatically-subtract-the-fee-from-the-amount-and-send-whats-left
feature to the GUI and RPC (sendtoaddress,sendmany).
2015-03-13 11:04:18 +01:00
Wladimir J. van der Laan 7077fe6dd4
Merge pull request #5884
e96c518 BUGFIX: Stack around the variable 'rv' was corrupted (fsb4000)
2015-03-12 18:16:24 +01:00
fsb4000 e96c5184e7 BUGFIX: Stack around the variable 'rv' was corrupted 2015-03-12 22:17:22 +06:00
Alex Morcos a9af415887 fix InvalidateBlock to repopulate setBlockIndexCandidates 2015-03-12 10:15:33 -04:00
Jonas Schnelli 50c72f23ad [Move Only] Move wallet related things to src/wallet/
could once be renamed from /src/wallet to /src/legacywallet.
2015-03-12 14:13:02 +01:00
Wladimir J. van der Laan dd4ffcec0e
Merge pull request #5859
9519a9a Add correct bool combiner for net signals (Pieter Wuille)
2015-03-12 11:14:03 +01:00
Wladimir J. van der Laan 92fd887fd4 tests: add a BasicTestingSetup and apply to all tests
Make sure that chainparams and logging is properly initialized. Doing
this for every test may be overkill, but this initialization is so
simple that that does not matter.

This should fix the travis issues.
2015-03-12 09:45:22 +01:00
Jonas Schnelli 89e70e931d [QT] fix OSX dock icon window reopening
fixes #5878
2015-03-12 00:16:23 +01:00
Wladimir J. van der Laan e564e63ef0
Merge pull request #5871
3aa0130 test: remove fSkipProofOfWork (Wladimir J. van der Laan)
59bd89f test: Remove UNITTEST params (Wladimir J. van der Laan)
2015-03-11 15:13:05 +01:00
dexX7 317e66c741
Initialization: set Boost path locale in main thread
The path locale is lazy initialized and to avoid deinitialization errors
in multithreading environments, it is set explicitly by the main thread.
2015-03-11 14:33:29 +01:00
Wladimir J. van der Laan d734d87b28
Merge pull request #5749
f754707 Fix - bitcoin-qt usage message (Luca Venturini)
1fdb9fa Help messages correctly formatted (79 chars) (Luca Venturini)
2015-03-11 10:20:59 +01:00
Wladimir J. van der Laan 45b7dc2c25
Merge pull request #5864
bb6acff fix possible block db breakage during re-index (Cory Fields)
2015-03-11 08:33:52 +01:00
Luca Venturini f75470794b Fix - bitcoin-qt usage message
. Closes the bug from commit e179eb3d9b
("bitcoin-qt -help" did not show any message)
. Move all the options in init.cpp (there were already some
options related to bitcoin-qt)
2015-03-10 22:07:17 -07:00
Luca Venturini 1fdb9fa3f9 Help messages correctly formatted (79 chars)
Help messages are formatted programmatically with FormatParagraph
in order not to break existing strings in Transifex.

The new format works even if the translation of the strings
modifies the lenght of the message.

Sqashed 6 commits in a single one.
Help messages correctly formatted for SVGA text mode (132 chars)

Help messages are formatted programmatically with FormatParagraph
in order not to break existing strings in Transifex.

The new format should work even if the translation of the strings
modifies the lenght of the message.

Fix - syntax error

Correct formatting for 79 chars

Correctly based on C++ functions

Removed spare spaces from option strings

Fix - syntax error
2015-03-10 22:07:17 -07:00
Cory Fields bb6acff079 fix possible block db breakage during re-index
When re-indexing, there are a few cases where garbage data may be skipped in
the block files. In these cases, the indices are correctly written to the index
db, however the pointer to the next position for writing in the current block
file is calculated by adding the sizes of the valid blocks found.

As a result, when the re-index is finished, the index db is correct for all
existing blocks, but the next block will be written to an incorrect offset,
likely overwriting existing blocks.

Rather than using the sum of all valid blocks to determine the next write
position, use the end of the last block written to the file. Don't assume that
the current block is the last one in the file, since they may be read
out-of-order.
2015-03-10 13:59:46 -04:00
Wladimir J. van der Laan 3aa0130b96 test: remove fSkipProofOfWork
Not used, and REGTEST already allows creating blocks at
the lowerst possible difficulty.
2015-03-09 16:09:54 +01:00
Wladimir J. van der Laan 59bd89f116 test: Remove UNITTEST params
UNITTEST parameter are not used by any current tests, and the model
(modifyable parameters) is inconvenient when unit-testing. As
they are stored in a global structure eevery test
would have to (re)set up its own parameters.

For consistency it is also better to test with MAIN parameters.
2015-03-09 16:06:14 +01:00
Wladimir J. van der Laan 8cbe1f4f58
tests: change main and wallet tests to BOOST_FIXTURE_TEST_SUITE
Avoid this travis error:

    test_bitcoin: chainparams.cpp:330: const CChainParams& Params():
    Assertion `pCurrentParams' failed.
    unknown location(0): fatal error in "subsidy_limit_test": signal:
    SIGABRT (application abort requested)
    test/allocator_tests.cpp(116): last checkpoint
2015-03-09 15:04:59 +01:00
Wladimir J. van der Laan cdae53e456
Merge pull request #5852
51598b2 Reinitialize state in between individual unit tests. (Pieter Wuille)
2015-03-09 12:51:07 +01:00
Wladimir J. van der Laan c1b723c30a
Merge pull request #5442
dca799e Ignore getaddr messages on Outbound connections. (Ivan Pustogarov)
2015-03-09 12:24:53 +01:00
Philip Kaufmann 8517e9709e [Qt] rework setNumBlocks to have blockDate as parameter
- reduces some functional overhead and simplifies the code
2015-03-09 10:58:17 +01:00
Wladimir J. van der Laan 513e025239
Merge pull request #5858
9bbb880 [Qt] fix a issue where "command line options"-action overwrite "Preference"-action (on OSX) (Jonas Schnelli)
2015-03-09 10:45:12 +01:00
Wladimir J. van der Laan d26f0b263c
Merge pull request #5793
6cb4a52 [Qt, Linux] honor current network when creating autostart link (Philip Kaufmann)
9673c35 [Qt, Win] honor current network when creating autostart link (Philip Kaufmann)
2015-03-09 09:55:49 +01:00
Pieter Wuille 2f10aa0fa1
Merge pull request #5151
eec3713 make CMessageHeader a dumb storage class (Cory Fields)
2015-03-07 05:38:34 -08:00
Wladimir J. van der Laan a0ae79d775 Replace CBlockHeader::GetHash with call to SerializeHash
Removes variability between LE and BE.
As suggested by @sipa.
2015-03-06 17:21:59 +01:00
Wladimir J. van der Laan 62b30f09ac Add serialize float/double tests 2015-03-06 17:21:59 +01:00
Wladimir J. van der Laan 9f4fac98c4 src/txmempool.cpp: make numEntries a uint32_t
Don't ever serialize a size_t or long, their sizes are platform
dependent.
2015-03-06 17:21:59 +01:00
Wladimir J. van der Laan f4e6487219 src/arith_256.cpp: bigendian compatibility 2015-03-06 17:21:59 +01:00
Wladimir J. van der Laan aac3205375 src/netbase.h: Fix endian in CNetAddr serialization
We've chosen to htons/ntohs explicitly on reading and writing
(I do not know why). But as READWRITE already does an endian swap
on big endian, this means the port number gets switched around,
which was what we were trying to avoid in the first place. So
to make this compatible, serialize it as FLATDATA.
2015-03-06 17:21:58 +01:00
Wladimir J. van der Laan 01f9c3449a src/serialize.h: base serialization level endianness neutrality
Serialization type-safety and endianness compatibility.
2015-03-06 17:21:58 +01:00
Wladimir J. van der Laan 4e853aa163 src/script/script.h: endian compatibility for PUSHDATA sizes 2015-03-06 17:21:58 +01:00
Wladimir J. van der Laan 4f92773f92 src/primitives/transaction.h: endian compatibility in serialization 2015-03-06 17:21:58 +01:00
Wladimir J. van der Laan 81aeb28436 src/primitives/block.cpp: endian compatibility in GetHash 2015-03-06 17:21:58 +01:00
Wladimir J. van der Laan dec84cae2a src/net.cpp: endian compatibility in EndMessage 2015-03-06 17:21:58 +01:00
Wladimir J. van der Laan 556814ec4e src/main.cpp: endian compatibility in packet checksum check 2015-03-06 17:21:55 +01:00
Luke Dashjr 721cb557aa GUI: Display label rather than address on popups 2015-03-06 15:07:43 +00:00
Wladimir J. van der Laan 3ca5852dc2 src/hash.cpp: endian compatibility 2015-03-06 15:54:53 +01:00
Wladimir J. van der Laan 4414f5ffe1 build: Endian compatibility
- Detect endian instead of stopping configure on big-endian
- Add `byteswap.h` and `endian.h` header for compatibility with
  Windows and other operating systems that don't come with them
- Update `crypto/common.h` functions to use compat
  endian header
2015-03-06 15:54:53 +01:00
Wladimir J. van der Laan 51377c2dbe
Merge pull request #5843
ba04c4a Limit message sizes before transfer (Pieter Wuille)
2015-03-06 15:31:31 +01:00
Wladimir J. van der Laan ee9f2bfa7b
Merge pull request #5813
34e5015 Add unit tests for next difficulty calculations (Ross Nicoll)
2015-03-06 15:27:00 +01:00
Pieter Wuille ba04c4a780 Limit message sizes before transfer
This introduces a fixed limit for the size of p2p messages, and enforces it
before download.
2015-03-06 04:03:17 -08:00
Pieter Wuille 9519a9a420 Add correct bool combiner for net signals 2015-03-06 03:45:26 -08:00
Jonas Schnelli 9bbb880be4 [Qt] fix a issue where "command line options"-action overwrite "Preference"-action (on OSX)
- fixes #5800
2015-03-06 09:33:23 +01:00
Rob Van Mieghem 84a05b843b
QT: remove unused parameter 2015-03-05 12:20:49 -05:00
Wladimir J. van der Laan 215475aa00
Merge pull request #5830
6f1274c qt: Don't save geometry for options and about/help window (Wladimir J. van der Laan)
2015-03-05 14:42:20 +01:00
Cozz Lovan 90a43c1e93 [Qt] Code-movement-only: Format confirmation message in sendcoinsdialog 2015-03-05 13:25:12 +01:00
Pieter Wuille 51598b2631 Reinitialize state in between individual unit tests.
This changes the TestingSetup fixture to be per-unit-test rather than global.
Most tests don't need it, so it's only invoked in a few.
2015-03-03 09:01:46 -08:00
Wladimir J. van der Laan 3dfcdf46c2
Merge pull request #5775
deda3e1 [Qt] remove unused getNumBlocksAtStartup() from ClientModel (Philip Kaufmann)
47ee8cf [Qt] use qint64 in BitcoinGUI::setNumBlocks (Philip Kaufmann)
2015-03-03 16:57:30 +01:00
Wladimir J. van der Laan f8e68f7bfb
Merge pull request #5819
d23b0a2 depends: always use static qt5 for linux (Cory Fields)
3448b13 build: fix typo in configure help (Cory Fields)
c95ac83 gitian: fix x86_64 build with static libstdc++ (Cory Fields)
0671516 build: change reduce exports/static libstdc++ options for gitian and travis (Cory Fields)
aa36730 build: remove libstdc++ backwards-compat (Cory Fields)
3ee028f build: disable reduced exports by default (Cory Fields)
2015-03-03 16:27:50 +01:00
Pieter Wuille 86eb461c5b
Merge pull request #5839
16a58a8 keys: remove libsecp256k1 verification until it's actually supported (Cory Fields)
2015-03-03 04:08:15 -08:00
Cory Fields 16a58a8644 keys: remove libsecp256k1 verification until it's actually supported
This was added a while ago for testing purposes, but was never intended to be
used. Remove it until upstream libsecp256k1 decides that verification is
stable/ready.
2015-03-02 11:31:43 -05:00
Pieter Wuille 10a3ff07f5
Merge pull request #5832
9abbeea Remove obsolete pubsub method definitions (Pieter Wuille)
2015-03-01 03:13:09 -08:00
Luke Dashjr e96028c78e GUI: Clarify terminology; use "Label" heading for labels row, and "Node/Service" rather than [IP] "Address" 2015-02-26 20:56:42 +00:00
Wladimir J. van der Laan db4a1d598c
Merge pull request #5694
25cf6f3 minor rework of SendMoney in rpcwallet (Philip Kaufmann)
2015-02-26 17:20:29 +01:00
Wladimir J. van der Laan 59310f1c02
Merge pull request #5820
85da07a Better fingerprinting protection for non-main-chain getdatas. (Pieter Wuille)
2015-02-26 17:13:13 +01:00
Pieter Wuille 9abbeeabd7 Remove obsolete pubsub method definitions 2015-02-26 05:30:59 -08:00
Wladimir J. van der Laan 482783b341
Merge pull request #5801
de5403f [GUI] Move fee dialog minimise button away from "Transaction Fee" (Michael Ford)
2015-02-26 11:26:32 +01:00
Wladimir J. van der Laan 6f1274c8c9
qt: Don't save geometry for options and about/help window
These dialogs will be something that people occasionally open, not keep
open during their session, so just popping it up in a sensible place
is good enough. Remembering only creates potential issues, like spawning
it outside the current screen area.

On Ubuntu this causes the dialogs to be positioned in the
middle of the main dialog, so I didn't add code for that. YMMV.

Inspired by github pull #5777 by @L-Cranston-Shadow
2015-02-26 10:23:42 +01:00
Cory Fields eec37136fd make CMessageHeader a dumb storage class
It shouldn't know or care about bitcoind's chain param selection
2015-02-25 18:44:49 -05:00
21E14 32eaf8a3de WIN32 Seed Cleanup: Move nLastPerfmon behind win32 ifdef.
Code to avoid calling Perfmon too often is only needed when perfmon is actually going to get called.
This is not intended to make any functional difference in the addition of entropy to the random pool.
2015-02-25 18:37:06 -05:00
Pieter Wuille 85da07a5a0 Better fingerprinting protection for non-main-chain getdatas.
With headers-first we can compare against the best header timestamp, rather
than using checkpoints which require code updates to maintain.
2015-02-24 04:35:13 -08:00
Cory Fields aa3673064c build: remove libstdc++ backwards-compat
Backwards-compatibility for libstdc++ is not limited to straightforward abi
changes. Symbol visibility also needs to be taken into consideration, and
that really can't be addressed simply.

Instead, just static-link libstdc++ for backwards-compat.
2015-02-23 17:56:15 -05:00
Ross Nicoll 34e5015cd2
Add unit tests for next difficulty calculations
Split GetNextWorkRequired() into two functions to allow the difficulty calculations to
be tested without requiring a full blockchain.
Add unit tests to cover basic difficulty calculation, plus each of the min/max actual
time, and maximum difficulty target conditions.
2015-02-21 13:14:19 +00:00
Michael Ford de5403f878 [GUI] Move fee dialog minimise button away from "Transaction Fee"
Its original placement was causing confusion among some users.
2015-02-21 09:11:33 +08:00
Wladimir J. van der Laan a026a56c4e
Merge #5706: fix crash: RPC \
e5d9d77 fix crash: createmultisig and addmultisigaddress (fsb4000)
2015-02-20 09:51:38 +01:00
Wladimir J. van der Laan 07f4386b38
Merge #5689: openssl: abstract out OPENSSL_cleanse
1630219 openssl: abstract out OPENSSL_cleanse (Cory Fields)
2015-02-19 12:09:26 +01:00
Philip Kaufmann 6cb4a52535 [Qt, Linux] honor current network when creating autostart link 2015-02-19 12:08:47 +01:00
Philip Kaufmann 9673c35daf [Qt, Win] honor current network when creating autostart link
- creates a "Bitcoin (testnet).lnk" when on testnet or a "Bitcoin
  (regtest).lnk, when on regtest
- fixes #5778
2015-02-19 12:06:49 +01:00
Wladimir J. van der Laan 47a79bb880
Merge #5366: No longer check osx compatibility in RenameThread
850c570 No longer check osx compatibility in RenameThread (Michael Ford)
2015-02-18 17:36:39 +01:00
Wladimir J. van der Laan 8d0418720c
Merge #5799: Rename Interval() to DifficultyAdjustmentInterval()
e5ece05 Rename Interval() to DifficultyAdjustmentInterval() (Shaul Kfir)
2015-02-18 17:29:28 +01:00
Wladimir J. van der Laan e3a3cd7a28
Merge #5784: Fix usage of NegateSignatureS in script_tests
78c6bed Add test for DER-encoding edge case (Suhas Daftuar)
6f50dbd Fix NegateSignatureS to not duplicate last byte of S (Suhas Daftuar)
2015-02-18 09:52:59 +01:00
Shaul Kfir e5ece053da Rename Interval() to DifficultyAdjustmentInterval() 2015-02-17 08:46:51 -05:00
Pieter Wuille 175d86e633
Merge #5710: Add more information to errors in ReadBlockFromDisk
f5791c6 Add more information to errors in ReadBlockFromDisk (Wladimir J. van der Laan)
2015-02-16 11:58:35 -08:00
Cory Fields 1630219d90 openssl: abstract out OPENSSL_cleanse
This makes it easier for us to replace it if desired, since it's now only in
one spot. Also, it avoids the openssl include from allocators.h, which
essentially forced openssl to be included from every compilation unit.
2015-02-15 11:34:02 -05:00
Suhas Daftuar 78c6bedb9c Add test for DER-encoding edge case
The fix to NegateSignatureS caused a test which had been failing
in IsValidSignatureEncoding to then fail in IsLowDERSignature.
Add new test so the original check remains exercised.
2015-02-10 13:25:41 -05:00
Suhas Daftuar 6f50dbd2fd Fix NegateSignatureS to not duplicate last byte of S
NegateSignatureS is called with a signature without a hashtype, so
do not save the last byte and append it after S negation.

Updates the two tests which were affected by this bug.
2015-02-10 13:23:57 -05:00
Wladimir J. van der Laan d48ce48093
Merge #5548: [REST] add /rest/chaininfos
2c0f901 [REST] rest/chaininfos add documentation (Jonas Schnelli)
59582c8 [REST] add /rest/chaininfos (Jonas Schnelli)
2015-02-10 12:08:07 +01:00
Wladimir J. van der Laan a9565863e0
Merge #5629: [Qt] prevent amount overflow problem with payment requests
a651668 [Qt] prevent amount overflow problem with payment requests (Philip Kaufmann)
2015-02-09 13:50:56 +01:00
Wladimir J. van der Laan 183ca292bd
Merge #5699: Split logic to undo txin's off DisconnectBlock.
eb1c2cd Split logic to undo txin's off DisconnectBlock. (Daniel Kraft)
2015-02-09 13:22:35 +01:00
Wladimir J. van der Laan beff11a3a1
Merge #5679: Get rid of DetectShutdownThread
28ee7e8 Get rid of DetectShutdownThread (Wladimir J. van der Laan)
2015-02-09 12:57:09 +01:00
Wladimir J. van der Laan 7225577f6b
Merge pull request #5739
f4b2078 Replace difficulty readjustment blocks with Interval() (Shaul Kfir)
2015-02-09 12:48:38 +01:00
Wladimir J. van der Laan 0f44672437
Merge pull request #5753
d67a642 [Qt] add bitcoin logo to about screen (Jonas Schnelli)
2015-02-09 11:34:01 +01:00
Philip Kaufmann deda3e156d [Qt] remove unused getNumBlocksAtStartup() from ClientModel 2015-02-09 11:28:03 +01:00
Philip Kaufmann 47ee8cf091 [Qt] use qint64 in BitcoinGUI::setNumBlocks
- as QDateTime.secsTo() returns a qint64 also store in a qint64 and not in
  an integer
2015-02-09 11:21:26 +01:00
Gregory Maxwell 28d4cff0ed Sanitize command strings before logging them.
Normally bitcoin core does not display any network originated strings without
 sanitizing or hex encoding.  This wasn't done for strcommand in many places.

This could be used to play havoc with a terminal displaying the logs,
 especially with printtoconsole in use.

Thanks to Evil-Knievel for reporting this issue.
2015-02-08 19:58:59 +00:00
Ivan Pustogarov dca799e1db Ignore getaddr messages on Outbound connections.
The only time when a client sends a "getaddr" message is when he
esatblishes an Outbound connection (see ProcessMessage() in
src/main.cpp).  Another bitcoin client is expected to receive a
"getaddr" message only on Inbound connection. Ignoring "gettaddr"
requests on Outbound connections can resolve potential privacy issues
(and as was said such request normally do not happen anyway).
2015-02-06 22:03:42 +01:00
Wladimir J. van der Laan fb6140b54b
Merge pull request #5721
cf008ac Acquire CCheckQueue's lock to avoid race condition (Suhas Daftuar)
2015-02-06 16:51:39 +01:00
Wladimir J. van der Laan f5791c6ae3 Add more information to errors in ReadBlockFromDisk
A lot of times, disk corruption problems appear here.
To facilitate debugging and troubleshooting, add position information
to the error messages.
2015-02-05 14:21:25 +01:00
Jonas Schnelli d67a642392 [Qt] add bitcoin logo to about screen 2015-02-04 20:52:18 +01:00
Jonas Schnelli 17115d0a34 fix getblocktemplate lock issue
getblocktemplate didn't have a wallet lock before #5711 and IMO there is no need for LEAVE/ENTER critical section.
2015-02-04 16:34:34 +01:00
Philip Kaufmann 25cf6f3d41 minor rework of SendMoney in rpcwallet
- rework the function to not log errors but use throw JSONRPCError
- remove a check for IsLocked() that is done in sendtoaddress and
  sendfrom RPC calls already
- cache GetBalance() return value, because it's possibly used twice
2015-02-04 15:11:54 +01:00
Wladimir J. van der Laan 93b7544501
Merge pull request #5319
35f7227 Clean up wallet encryption code. (Daniel Kraft)
2015-02-04 13:56:57 +01:00
Philip Kaufmann a6516686dc [Qt] prevent amount overflow problem with payment requests
Bitcoin amounts are stored as uint64 in the protobuf messages (see
paymentrequest.proto), but CAmount is defined as int64_t. Because
of that we need to verify that single and accumulated amounts are
in a valid range and no variable overflow has happened.

- fixes #5624 (#5622)

Thanks @SergioDemianLerner for reporting that issue and also supplying us
with a possible solution.

- add static verifyAmount() function to PaymentServer and move the logging
  on error into the function
- also add a unit test to paymentservertests.cpp
2015-02-04 13:47:32 +01:00
Wladimir J. van der Laan 31dedb463b
Merge pull request #5509
7f991e3 c++11: These look like user-defined literals. (Cory Fields)
5a6155c c++11: don't forward-declare types used in maps (Cory Fields)
3447cf8 c++11: MOVEONLY: break circular dependency in wallet (Cory Fields)
bbacd88 c++11: MOVEONLY: move function definitions out of the header (Cory Fields)
a2b04dd build: fix newer boost build with c++11 (Cory Fields)
2015-02-04 13:06:16 +01:00
Wladimir J. van der Laan 87ecfb0f96
Merge pull request #5711
5ebe095 Trim RPC command table (Wladimir J. van der Laan)
4401b2d Removed main.h dependency from rpcserver.cpp (Eric Lombrozo)
2015-02-04 10:23:09 +01:00
Cory Fields 7f991e364e c++11: These look like user-defined literals.
Add a space to keep the compiler happy
2015-02-03 23:31:00 -05:00
Cory Fields 5a6155ccfa c++11: don't forward-declare types used in maps 2015-02-03 23:30:59 -05:00
Cory Fields 3447cf87e2 c++11: MOVEONLY: break circular dependency in wallet
c++11 (libc++'s stdlib implementation anyway) doesn't allow for map types to be
forward-declared. for example:

class foo;
std::map<int, foo> bar; // error, foo has not been defined.
class foo{};

Since CWallet and CWalletTx are inter-dependent, but only std::map<*,CWalletTx>
is used, forward-declare CWallet instead and define CWalletTx first.

Despite the mangled git diff, this change only amounts to moving ~320 lines in
a single chunk.
2015-02-03 23:30:59 -05:00
Cory Fields bbacd88204 c++11: MOVEONLY: move function definitions out of the header
These need to be moved out of the header in order to resolve a circular
dependency between CWallet and CTxWallet. See next commit.
2015-02-03 22:41:33 -05:00
Cory Fields a2b04ddfe6 build: fix newer boost build with c++11 2015-02-03 22:41:01 -05:00