Commit Graph

140 Commits

Author SHA1 Message Date
Jon Layton 2a63c34936 Merge remote-tracking branch 'btc/master' into upstream-merge 2018-10-16 22:27:53 -05:00
Jon Layton a4e0e39f82 [wallet] Add SIGHASH_FORKID where necessary, allowing raw transaction signing to succeed 2018-10-02 17:13:32 -05:00
Ben Woosley 9c5af58d51
Consolidate redundant implementations of ParseHashStr
This change:
* adds a length check to ParseHashStr, appropriate given its use to populate
  a 256-bit number from a hex str.
* allows the caller to handle the failure, which allows for the more
  appropriate JSONRPCError on failure in prioritisetransaction rpc
2018-09-25 09:14:52 -07:00
practicalswift f34c8c466a Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations. 2018-08-27 18:19:33 +02:00
MarcoFalke ddddce0e46
util: Replace boost::signals2 with std::function 2018-08-24 08:34:38 -04:00
Tim Ruffing 7272fdcfe7 [docs] Reformat -help output for help2man
This commit slightly changes the format of the "Usage" strings in CLI
`-help` messages to meet the expection of the help2man tool, which we
use to generate man pages. On the way, we remove a few calls to
`strprintf()`, which became superficial after commit 32fbfda.
2018-08-04 16:17:13 +02:00
Daniel Kraft 57889e688d bitcoin-tx: Stricter check for valid integers
Just calling atoi to convert strings to integers does not check for
valid integers very thoroughly; in particular, it just ignores
everything starting from the first non-numeral character.  Even a string
like "foo" is fine and silently returns 0.

This meant that bitcoin-tx would not fail if such a string was passed in
various places where an integer is expected (like the locktime or an
input/output index); this means that it would, for instance, silently
accept a typo and interpret it in an unexpected way.

In this change, we use ParseInt64 for parsing strings to integers,
which actually verifies that the full string is valid as number.
New tests in the bitcoin-util-test cover the new error paths.
2018-07-07 14:25:09 +02:00
Andrew Chow ed94c8b556 Replace CombineSignatures with ProduceSignature
Instead of using CombineSignatures to create the final scriptSig or
scriptWitness of an input, use ProduceSignature itself.

To allow for ProduceSignature to place signatures, pubkeys, and scripts
that it does not know about, we pass down the SignatureData to SignStep
which pulls out the information that it needs from the SignatureData.
2018-07-03 17:19:23 -07:00
Andrew Chow 0422beb9bd Make SignatureData able to store signatures and scripts
In addition to having the scriptSig and scriptWitness, have SignatureData
also be able to store just the signatures (pubkeys mapped to sigs) and
scripts (script ids mapped to scripts).

Also have DataFromTransaction be able to extract signatures and scripts
from the scriptSig and scriptWitness of an input to put them in SignatureData.

Adds a new SignatureChecker which takes a SignatureData and puts pubkeys
and signatures into it when it successfully verifies a signature.

Adds a new field in SignatureData which stores whether the SignatureData
was complete. This allows us to also update the scriptSig and
scriptWitness to the final one when updating a SignatureData with another
one.
2018-07-03 17:18:52 -07:00
Ben Woosley abd2678ac1
Drop ParseHashUV in favor of calling ParseHashStr
The one existing call already validates get_str will
pass via checkObject.
2018-06-08 10:53:38 -07:00
Wladimir J. van der Laan f0fd39f376
Merge #13269: refactoring: Drop UpdateTransaction in favor of UpdateInput
6aa33feadb Drop UpdateTransaction in favor of UpdateInput (Ben Woosley)

Pull request description:

  Updating the input explicitly requires the caller to present a mutable
  input, which more clearly communicates the effects and intent of the call
  (and, often, the enclosing loop).

  In most cases, this input is already immediately available and need not be
  looked up.

Tree-SHA512: 8c7914a8b7ae975d8ad0e9d760e3c5da65776a5f79d060b8ffb6b3ff7a32235f71ad705f2185b368d9263742d7796bb562395d22b806d90e8502d8c496011e57
2018-06-05 19:06:16 +02:00
Andrew Chow 4f8704d57f Give an error and exit if there are unknown parameters
If an unknown option is given via either the command line args or
the conf file, throw an error and exit

Update tests for ArgsManager knowing args

Ignore unknown options in the config file for bitcoin-cli

Fix tests and bitcoin-cli to match actual options used
2018-05-30 11:27:50 -04:00
Wladimir J. van der Laan 3d4fa83587 Stop translating command line options
Many options are extremely technical, and refer internals, making it
difficult to translate usefully. This came up in discussion of e.g.
 #10949. If a message is not understood by translators (which are
typically end-users, not developers) they'll either translate it
literally, making it harder to understand instead of easier, with the
added drawback of the user no longer being able to google it.

Also the translation was only working for bitcoin-qt as with
the console programs, there is no translation backend. So it was
injecting never-used translation messages for bitcoin-cli, -tx.

For these reasons, stop translating options help completely. This should
not affect the output **in any way** except for bitcoin-qt when a
non-English language is configured in the locale.

This implements #10962.
2018-05-30 14:23:35 +02:00
Wladimir J. van der Laan 3c2a41a9fc
Merge #13011: Cache witness hash in CTransaction
fac1223a56 Cache witness hash in CTransaction (MarcoFalke)
faab55fbb1 Make CMutableTransaction constructor explicit (MarcoFalke)

Pull request description:

  This speeds up:
  * compactblocks (v2)
  * ATMP
  * validation and miner (via `BlockWitnessMerkleRoot`)
  * sigcache (see also unrelated #13204)
  * rpc and rest (nice, but irrelevant)

  This presumably slows down rescan, which uses a `CTransaction` and its `GetHash`, but never uses the `GetWitnessHash`. The slow down is proportional to the number of witness transactions in the rescan window. I.e. early in the chain there should be no measurable slow down. Later in the chain, there should be a slow down, but acceptable given the speedups in the modules mentioned above.

Tree-SHA512: 443e86acfcceb5af2163e68840c581d44159af3fd1fce266cab3504b29fcd74c50812b69a00d41582e7e1c5ea292f420ce5e892cdfab691da9c24ed1c44536c7
2018-05-23 19:26:18 +02:00
Ben Woosley 6aa33feadb
Drop UpdateTransaction in favor of UpdateInput
Updating the input explicitly requires the caller to present a mutable
input, which more clearly communicates the effects and intent of the method.

In most cases, this input is already immediately available and need not be
looked up.
2018-05-18 11:08:13 -07:00
Andrew Chow 4d4185a4f0 Make gArgs aware of the arguments
gArgs knows what the available arguments are and their help. Getting
the help message is moved to gArgs and HelpMessage() is removed
2018-05-09 12:21:05 -04:00
MarcoFalke faab55fbb1
Make CMutableTransaction constructor explicit
Silently converting to a CMutableTransaction will drop all caches
and should thus be done explicitly
2018-05-04 17:40:52 -04:00
Wladimir J. van der Laan e625548e7c
Merge #12950: bitcoin-tx: Flatten for loop over one element
fa72f34 bitcoin-tx: Remove unused for loop (MarcoFalke)

Pull request description:

  This flattens out a for loop and gets rid of the then unused vector `txVariants`.

Tree-SHA512: 68081b313d846ce235a97a642c9d0097c3641350e819d6254001f332b053e41fa63ce49faca68120f5aaf5d5f4bfda104662eae781e2956d76a8915770344045
2018-04-13 17:15:15 +02:00
MarcoFalke fa72f34c64
bitcoin-tx: Remove unused for loop 2018-04-11 14:12:40 -04:00
Pieter Wuille 190b8d2dcf Make BaseSignatureCreator a pure interface 2018-04-10 09:29:17 -07:00
Anthony Towns 11b6b5b86e Move ChainNameFromCommandLine into ArgsManager and rename to GetChainName 2018-04-06 04:46:02 +10:00
Wladimir J. van der Laan bd59c4395c
Merge #12859: Bugfix: Include <memory> for std::unique_ptr
a5bca13 Bugfix: Include <memory> for std::unique_ptr (Luke Dashjr)

Pull request description:

  Not sure why all these includes were missing, but it's breaking builds for some users:

  https://bugs.gentoo.org/show_bug.cgi?id=652142

  (Added to all files with a reference to `std::unique_ptr`)

Tree-SHA512: 8a2c67513ca07b9bb52c34e8a20b15e56f8af2530310d9ee9b0a69694dd05e02e7a3683f14101a2685d457672b56addec591a0bb83900a0eb8e2a43d43200509
2018-04-05 09:31:53 +02:00
Ben Woosley b386970d07
[moveonly] Extract HelpRequested to dry up the help options testing
This ensures consistency across interfaces and makes the version handling more clear.
2018-04-02 15:42:06 -07:00
Luke Dashjr a5bca13095 Bugfix: Include <memory> for std::unique_ptr 2018-04-02 18:31:52 +00:00
Wladimir J. van der Laan ae5bcc7abb
Merge #10694: Remove redundant code in MutateTxSign(CMutableTransaction&, const std::string&)
b1149ee4c Remove redundant code in MutateTxSign(CMutableTransaction&, const std::string&) (practicalswift)

Pull request description:

  Remove redundant code in `MutateTxSign(CMutableTransaction&, const std::string&)`.

Tree-SHA512: 0f0aba4def18b9a4ca73f2bd676881bc05d852d1d34b564416b2b979056263e5471c5d8ce743af44ef6bce11d77b74d18151c983b735cdf47c36f6591ab4b3fb
2018-03-13 16:59:50 +01:00
Pieter Wuille 119b0f85e2 Split key_io (address/key encodings) off from base58 2018-02-19 18:55:21 -08:00
Pieter Wuille 32e69fa0df Replace CBitcoinSecret with {Encode,Decode}Secret 2018-02-19 18:55:20 -08:00
murrayn d3e467520f Properly alphabetize output of CLI --help option. 2018-02-01 23:19:41 -08:00
practicalswift b1149ee4c3 Remove redundant code in MutateTxSign(CMutableTransaction&, const std::string&) 2018-01-29 09:09:39 +01:00
Alin Rus a73aab7cd8 Use the character based overload for std::string::find.
std::string::find has a character based overload as can be seen here
(4th oveload): http://www.cplusplus.com/reference/string/string/find/

Use that instead of constantly allocating temporary strings.
2018-01-11 21:40:51 +01:00
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
MeshCollider 1a445343f6 scripted-diff: Replace #include "" with #include <> (ryanofsky)
-BEGIN VERIFY SCRIPT-
for f in \
  src/*.cpp \
  src/*.h \
  src/bench/*.cpp \
  src/bench/*.h \
  src/compat/*.cpp \
  src/compat/*.h \
  src/consensus/*.cpp \
  src/consensus/*.h \
  src/crypto/*.cpp \
  src/crypto/*.h \
  src/crypto/ctaes/*.h \
  src/policy/*.cpp \
  src/policy/*.h \
  src/primitives/*.cpp \
  src/primitives/*.h \
  src/qt/*.cpp \
  src/qt/*.h \
  src/qt/test/*.cpp \
  src/qt/test/*.h \
  src/rpc/*.cpp \
  src/rpc/*.h \
  src/script/*.cpp \
  src/script/*.h \
  src/support/*.cpp \
  src/support/*.h \
  src/support/allocators/*.h \
  src/test/*.cpp \
  src/test/*.h \
  src/wallet/*.cpp \
  src/wallet/*.h \
  src/wallet/test/*.cpp \
  src/wallet/test/*.h \
  src/zmq/*.cpp \
  src/zmq/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-
2017-11-16 08:23:01 +13:00
Matt Corallo a6f33ea77d Sanity-check script sizes in bitcoin-tx 2017-10-24 14:11:52 -04:00
Wladimir J. van der Laan 470c730e3f
Merge #10898: Fix invalid checks (NULL checks after dereference, redundant checks, etc.)
76fed83 Avoid NULL pointer dereference when _walletModel is NULL (which is valid) (practicalswift)
4971a9a Use two boolean literals instead of re-using variable (practicalswift)
b5fb339 Remove duplicate uriParts.size() > 0 check (practicalswift)
7466991 Remove redundant check (!ecc is always true) (practicalswift)
55224af Remove redundant NULL checks after new (practicalswift)

Pull request description:

  Contains:
  * Remove redundant `NULL` checks after throwing `new`
  * Remove redundant check (`!ecc` is always true)
  * Remove duplicate `uriParts.size() > 0` check
  * Use two boolean literals instead of re-using variable

Tree-SHA512: 30e9af8a9d5c8184836f8267b492aeb4e26eca171a3be08f634b3f39b3055b9fa9f06623f6c69b294ca13bf99743f7645cfac2b25e014ff74687bd085a997895
2017-10-12 23:55:50 +02:00
practicalswift 7466991670 Remove redundant check (!ecc is always true) 2017-10-02 15:47:43 +02:00
Matt Corallo 28d4542a0a Disallow uncompressed pubkeys in bitcoin-tx [multisig] output adds 2017-09-20 23:29:59 -04:00
Pieter Wuille 5c8ff0d448 Introduce wrappers around CBitcoinAddress
This patch removes the need for the intermediary Base58 type
CBitcoinAddress, by providing {Encode,Decode,IsValid}Destination
function that directly operate on the conversion between strings
and CTxDestination.
2017-09-06 13:07:45 -07:00
Marko Bencun bb81e17355 scripted-diff: stop using the gArgs wrappers
They were temporary additions to ease the transition.

-BEGIN VERIFY SCRIPT-
find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g'
-END VERIFY SCRIPT-
2017-08-14 17:02:10 +02:00
practicalswift 90d4d89230 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-
2017-08-07 07:36:37 +02:00
Gregory Maxwell 3babbcb487 Remove confusing MAX_BLOCK_BASE_SIZE.
Some people keep thinking that MAX_BLOCK_BASE_SIZE is a separate
 size limit from the weight limit when it fact it is superfluous,
 and used in early tests before the witness data has been
 validated or just to compute worst case sizes.  The size checks
 that use it would not behave any differently consensus wise
 if they were eliminated completely.

Its correct value is not independently settable but is a function
 of the weight limit and weight formula.

This patch just eliminates it and uses the scale factor as
 required to compute the worse case constants.

It also moves the weight factor out of primitives into consensus,
 which is a more logical place for it.
2017-07-14 19:24:17 +00:00
Matt Corallo 73c942ecd3 Use "replaceable" instead of "rbfoptin" in bitcoin-tx.
To be consistent with RPC naming
2017-07-05 18:11:22 -04:00
Pieter Wuille d636f3943d
Merge #10536: Remove unreachable or otherwise redundant code
4265bf351 Remove unreachable or otherwise redundant code (practicalswift)

Tree-SHA512: bc9666ab5d20c936d78c50c0361405aca9edd116602aa9bcd71a79a904b647ac9eca0651d1a9d530189a6ac1c4e235bfc69ec1a68f7e36cc14d6848ac2206b7b
2017-06-20 16:16:38 -07:00
Pieter Wuille 1ad3d4e126
Merge #10502: scripted-diff: Remove BOOST_FOREACH, Q_FOREACH and PAIRTYPE
1238f13cf scripted-diff: Remove PAIRTYPE (Jorge Timón)
18dc3c396 scripted-diff: Remove Q_FOREACH (Jorge Timón)
7c00c2672 scripted-diff: Fully remove BOOST_FOREACH (Jorge Timón)
a5410ac5e Small preparations for Q_FOREACH, PAIRTYPE and #include <boost/foreach.hpp> removal (Jorge Timón)

Tree-SHA512: d3ab4a173366402e7dcef31608977b757d4aa07abbbad2ee1bcbcfa311e994a4552f24e5a55272cb22c2dcf89a4b0495e02e9d9aceae4b08c0bab668f20e324c
2017-06-13 18:05:58 -07:00
practicalswift 4265bf351a Remove unreachable or otherwise redundant code 2017-06-12 15:01:46 +02:00
Wladimir J. van der Laan 29f80cd230
Merge #10545: Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of
3fb81a8 Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of (practicalswift)

Tree-SHA512: 63a9ac9ec5799472943dce1cd92a4b14e7f1fe12758a5fc4b1efceaf2c85a4ba71dad5ccc50813527f18b192e7714c076e2478ecd6ca0d452b24e88416f872f7
2017-06-08 20:26:40 +02:00
practicalswift 3fb81a8480 Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of 2017-06-06 21:29:16 +02:00
Luke Dashjr 23b0fe34f5 bitcoin-tx: rbfoptin: Avoid touching nSequence if the value is already opting in 2017-06-05 23:14:34 +00:00
Luke Dashjr b005bf21a7 Introduce MAX_BIP125_RBF_SEQUENCE constant 2017-06-05 23:14:34 +00:00
Jonas Schnelli 575cde4605 [bitcoin-tx] add rbfoptin command 2017-06-05 23:13:24 +00:00
Jorge Timón 7c00c26726
scripted-diff: Fully remove BOOST_FOREACH
-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
2017-06-05 20:10:50 +02:00