Commit graph

12115 commits

Author SHA1 Message Date
Ross Nicoll 2515bbcb84 Handle legacy v2 block at #66064 2019-07-13 22:25:22 +00:00
Ross Nicoll 18c23eafe9 Correct PoW calculation logic to use locally calculated difficulty 2019-07-13 22:25:22 +00:00
Ross Nicoll 3f788348e1 Sync changes from Dogecoin 1.10 2019-07-13 22:25:22 +00:00
Ross Nicoll ce564e381a Merge AuxPoW support from Namecore
Changes are as below:

Wrap CBlockHeader::nVersion into a new class (CBlockVersion).  This allows to take care of interpreting the field into a base version, auxpow flag and the chain ID.

Update getauxblock.py for new 'generate' RPC call.

Add 'auxpow' to block JSON.

Accept auxpow as PoW verification.

Add unit tests for auxpow verification.

Add check for memory-layout of CBlockVersion.

Weaken auxpow chain ID checks for the testnet.

Allow Params() to overrule when to check the auxpow chain ID and for legacy blocks.  Use this to disable the checks on testnet.

Introduce CPureBlockHeader.

Split the block header part that is used by auxpow and the "real" block header (that uses auxpow) to resolve the cyclic dependency between the two.

Differentiate between uint256 and arith_uint256.

This change was done upstream, modify the auxpow code.

Add missing lock in auxpow_tests.

Fix REST header check for auxpow headers.

Those can be longer, thus take that into account.  Also perform the check actually on an auxpow header.

Correctly set the coinbase for getauxblock results.

Call IncrementExtraNonce in getauxblock so that the coinbase is actually initialised with the stuff it should be.  (BIP30 block height and COINBASE_FLAGS.)

Implement getauxblock plus regression test.

Turn auxpow test into FIXTURE test.

This allows using of the Params() calls.

Move CMerkleTx code to auxpow.cpp.

Otherwise we get linker errors when building without wallet.

Fix rebase with BIP66.

Update the code to handle BIP66's nVersion=3.

Enforce that auxpow parent blocks have no auxpow block version.

This is for compatibility with namecoind.  See also https://github.com/namecoin/namecoin/pull/199.

Move auxpow-related parameters to Consensus::Params.
2019-07-13 22:25:22 +00:00
Ross Nicoll 54b20fd87a Add Dogecoin difficulty calculations 2019-04-28 19:24:07 +00:00
Ross Nicoll e6719497b7 Correct build and test net seed
* Correct the test case from 100 blocks to 240
* Remove incorrect ", true" in testnet seed configuration
2019-04-28 12:22:13 -07:00
Ross Nicoll 8ef665d5e4 Replace test data with Dogecoin values
Replace test data with Dogecoin equivalents in the folowing tests:

* base58
* bip32
* keys
* miner
* pow
* wallet

Replace RPC and deterministic signatures in unit tests with Dogecoin values. While
conventionally I'd use an alternative implementation for these, as RFC 6979
compliant signature generation isn't terribly common, and there's no reason
to suspect we've modified this code, I'm going to assert that it's good enough
to test that the code doesn't provide different values.

Disabled Bitcoin PoW tests, but left code in place to simplify later merges. These are
replaced by the Dogecoin PoW tests.
2019-04-03 05:16:26 +00:00
Ross Nicoll 9b494d566c Add Dogecoin block subsidy calculations. 2019-04-03 05:16:26 +00:00
Ross Nicoll 6d635e8914 Replace consensus values with Dogecoin equivalents
* Replace chain parameters with Dogecoin values
* Update maximum coins to match Dogecoin
* Disable version 2 block requirement
* Update coinbase maturity to match Dogecoin
2019-04-03 05:16:26 +00:00
coblee 8a3a19471c Litecoin: Fix zeitgeist2 attack thanks to Lolcust and ArtForz. This fixes an issue where a 51% attack can change difficulty at will. Go back the full period unless it's the first retarget after genesis. 2019-04-03 05:16:26 +00:00
Ross Nicoll 76a9aab2f4 Scrypt n=1024 PoW hash
Scrypt n=1024 PoW hash based upon Colin Percival's Tarnsnap (2009)

Modified by Artforz, coblee, pooler, wtogami, Nikolay Belikov, Adrian Gallagher, Ross Nicoll
2019-04-03 05:16:26 +00:00
Wladimir J. van der Laan c6e4a1fca5
Merge #14889: [0.17] Backport #14424 (Stop requiring imported pubkey to sign non-PKH schemes)
89a9a9d938 Stop requiring imported pubkey to sign non-PKH schemes (Pieter Wuille)

Pull request description:

  Github-Pull: #14424
  Rebased-From: 2f6b466aeb

Tree-SHA512: 1ea10dee66626f04918f197cd7c4949a836fa49c8f676f276b2328f8d79389059db7b30fc04d4c4bf8209f6a8d21f3ea49a017ddc7623eca6b7e6efc2fe0d749
2018-12-07 00:10:06 +01:00
Pieter Wuille 89a9a9d938 Stop requiring imported pubkey to sign non-PKH schemes
Github-Pull: #14424
Rebased-From: 2f6b466aeb
2018-12-07 10:30:22 +13:00
MarcoFalke abae8aeff1
Merge #14880: 0.17: Backport #14453
dcb032dcdf qa: Ensure wallet unload during walletpassphrase timeout (João Barbosa)
75b5d8c4ea rpc: Fix wallet unload during walletpassphrase timeout (João Barbosa)

Pull request description:

  Backport #14453 to 0.17

Tree-SHA512: fce0adccbb07b6635bb773a71beb4a9b814bceb77bbe7bbc5bcb7d151aabb1148c791622f58c990afe202012ca1971cd466cb536fc6f37e22cdc58738720b593
2018-12-06 13:07:25 -05:00
João Barbosa 75b5d8c4ea rpc: Fix wallet unload during walletpassphrase timeout
Github-Pull: #14453
Rebased-From: 321decf
2018-12-05 23:14:10 +00:00
Gregory Sanders 7a590d8390 fix converttopsbt permitsigdata arg, add basic test
Github-Pull: #14356
Rebased-From: 88a79cb436
2018-12-05 17:38:57 -05:00
Glenn Willen db445d4e5a Refactor PSBTInput signing to enforce invariant
Refactor the process of PSBTInput signing to enforce the invariant that
a PSBTInput always has _either_ a witness_utxo or a non_witness_utxo,
never both.

This simplifies the logic of SignPSBTInput slightly, since it no longer
has to deal with the "both" case. When calling it, we now give it, in
order of preference: (1) whichever of the utxo fields was already
present in the PSBT we received, or (2) if neither, the
non_witness_utxo field, which is just a copy of the input transaction,
which we get from the wallet.

SignPSBTInput no longer has to remove one of the two fields; instead, it
will check if we have a witness signature, and if so, it will replace
the non_witness_utxo with the witness_utxo (which is smaller, as it is
just a copy of the output being spent.)

Add PSBTInput::IsSane checks in two more places, which checks for
both utxo fields being present; we will now give an RPC error early on
if we are supplied such a malformed PSBT to fill in.

Also add a check to FillPSBT, to avoid touching any input that is
already signed. (This is now redundant, since we should no longer
potentially harm an already-signed input, but it's harmless.)

fixes #14473

Github-Pull: #14588
2018-12-03 10:37:08 -08:00
Glenn Willen ad94165db9 Simplify arguments to SignPSBTInput
Remove redundant arguments to SignPSBTInput -- since it needs several
bits of the PartiallySignedTransaction, pass in a reference instead of
doing it piecemeal. This saves us having to pass in both a PSBTInput and
its index, as well as having to pass in the CTransaction. Also avoid
redundantly passing the sighash_type, which is contained in the
PSBTInput already.

Github-Pull: #14588
Rebased-From: 0f5bda2bd9
2018-12-03 10:36:37 -08:00
Glenn Willen 39ece4fc28 Add bool PSBTInputSigned
Refactor out a "PSBTInputSigned" function to check if a PSBT is signed,
for use in subsequent commits.

Also improve a related comment.

GitHub-Pull: #14588
Rebased-From: 53e6fffb8f
2018-12-03 10:36:08 -08:00
Glenn Willen 70ee1f8709 New PartiallySignedTransaction constructor from CTransction
New constructor that creates a PartiallySignedTransaction from a
CTransaction, automatically sizing the inputs and outputs vectors for
convenience.

Github-Pull: #14588
Rebased-From: 65166d4cf8
2018-12-03 10:35:34 -08:00
Glenn Willen a9eab081d5 Remove redundant txConst parameter to FillPSBT
Github-Pull: #14588
Rebased-From: 4f3f5cb4b1
2018-12-03 10:34:57 -08:00
Glenn Willen cfdd6b2f6c More concise conversion of CDataStream to string
Use .str() instead of .data() and .size() when converting CDataStream to
a string. Uses std::string, avoiding conversion to a C string.

Github-Pull: #14588
Rebased-From: fe5d22bc67
2018-12-03 10:34:20 -08:00
Andrew Chow a3fe125490 check that a separator is found for psbt inputs, outputs, and global map
Github-Pull: #14377
Rebased-From: 4fb3388db9
2018-12-03 10:32:58 -08:00
MarcoFalke 3362a95be3
Merge #14196: [0.17][psbt] always drop the unnecessary utxo and convert non-witness utxo to witness when necessary
fcefc6851a Convert non-witness UTXOs to witness if witness sig created (Andrew Chow)
fcdea8ad2a Drop the unnecessary UTXO based on the UTXOs present, not on earlier wallet things (Andrew Chow)

Pull request description:

  When we sign an input in a psbt that has a non-witness utxo but a witness signature is produced, we will now replace the non-witness utxo with the corresponding witness utxo. Furthermore, we should make sure that the correct UTXO type is used based on what UTXOs are there, not based on earlier wallet behavior.

  Note that this is PR'd to the 0.17 branch because the code here no longer exists in master.

Tree-SHA512: 882e9e4e9b77d6ac1743c35c0d59023aad6f4f19193398f97f2c6b81f6627d74e5220b1d674a0edba1ff2fc2a7f61afbf838d3faf0a964fccd3dee97c631aa47
2018-12-01 12:31:14 -05:00
Gregory Sanders 2a5cc40dc4 CreateTransaction: Assume minimum p2sh-p2wpkh spend size for unknown change 2018-11-30 11:08:41 -05:00
Gregory Sanders 53dcf2b407 Remove stale comment in CalculateMaximumSignedInputSize 2018-11-30 11:08:35 -05:00
practicalswift 79358817e5
Add SAFE_CHARS[SAFE_CHARS_URI]: Chars allowed in URIs (RFC 3986)
Github-Pull: #14618
Rebased-From: ab8c6f24d2
2018-11-29 18:34:58 +08:00
practicalswift 9666dbaf09
rpc: Make HTTP RPC debug logging more informative
Github-Pull: #14618
Rebased-From: 991248649b
2018-11-29 18:34:15 +08:00
Kaz Wesley b90157891a
add test demonstrating addrLocal UB
Github-Pull: #14728
Rebased-From: 8ebbef0169
2018-11-29 18:32:48 +08:00
Kaz Wesley 6f04264bbb
fix uninitialized read when stringifying an addrLocal
Reachable from either place where SetIP is used when our best-guess
addrLocal for a peer is IPv4, but the peer tells us it's reaching us at
an IPv6 address.

In that case, SetIP turns an IPv4 address into an IPv6 address without
setting the scopeId, which is subsequently read in GetSockAddr during
CNetAddr::ToStringIP and passed to getnameinfo. Fix by ensuring every
constructor initializes the scopeId field with something.

Github-Pull: #14728
Rebased-From: b7b36decaf
2018-11-29 18:32:05 +08:00
Gregory Sanders 5782fdcd8c
Throw error if CPubKey is invalid during PSBT keypath serialization
Github-Pull: #14690
Rebased-From: 4e4de10f69
2018-11-29 11:51:47 +08:00
Luke Dashjr de5e48a461
Bugfix: RPC: Add address_type named param for createmultisig
Github-Pull: #14596
Rebased-From: d8bf1071cf
2018-11-29 11:50:17 +08:00
Eric Scrivner fb9ad043f8 Fix listreceivedbyaddress not taking address as a string
Fixes #14173. Add the patch in #14173 and include a regression test.

Github-Pull: #14417
Rebased-From: d4d70eda33
2018-11-28 15:35:05 -05:00
practicalswift 91fa15aaeb wallet: Avoid potential use of unitialized value bnb_used in CWallet::CreateTransaction(...)
Github-Pull: #13546
Rebased-From: a23a7f60aa
2018-11-28 15:35:05 -05:00
Kaz Wesley 2f9fd29321 disallow oversized CBlockHeaderAndShortTxIDs
Otherwise we'd reply with a bogus BlockTransactionsRequest trying to
request indexes with overflowed deltas.

Github-Pull: #14685
Rebased-From: b08af10fb2
2018-11-28 15:35:05 -05:00
Kaz Wesley 5331ad0506 fix a deserialization overflow edge case
A specially-constructed BlockTransactionsRequest can overflow in
deserialization in a way that is currently harmless.

Github-Pull: #14685
Rebased-From: 6bed4b374d
2018-11-28 15:35:05 -05:00
Kaz Wesley 94065024c7 add a test demonstrating an overflow in a deserialization edge case
Also add a test that the highest legal index is accepted.

Github-Pull: #14685
Rebased-From: 051faf7e9d
2018-11-28 15:35:05 -05:00
gustavonalle bb90695551 [wallet] Ensure wallet is unlocked before signing
Github-Pull: #14310
Rebased-From: db15805668
2018-11-28 15:35:05 -05:00
Wladimir J. van der Laan 5150accdd2
Merge #14441: [wallet] Backport(0.17): Restore ability to list incoming transactions by label
89306ab0df [wallet] Restore ability to list incoming transactions by label (Russell Yanofsky)

Pull request description:

  Backport of PR #14411 to v0.17.

  This change partially reverts #13075 and #14023.

  Fixes #14382

Tree-SHA512: 1f8300e1a79e826cd706561265b8788deef505fa510be1a76ed9a62e5fca37cf6a741423ac0e5de2a36d6e8b9f25f141885455aacacbbf6474814e6eae406a27
2018-11-10 12:45:44 +01:00
Tim Ruffing 0242b5afa4
qt: Revert "Force TLS1.0+ for SSL connections"
This reverts commit 15e26a6a9a, whose
purpose was to tweak the Qt configuration to force TLS, i.e., to
disable SSLv3, in Qt versions >= 5.5. However, the default behavior
of Qt >= 5.4 is to disable SSLv3 anyway [1], so the configuration
tweak is redundant.

With Qt 5.11.2, the configuration tweak is not only redundant but in
fact provokes a deadlock (#14359) due to Qt 5.11.2 being incompatible
with OpenSSL 1.1.1 [2]. Since the deadlock occurs at the early startup
stage of bitcoin-qt, it renders bitcoin-qt entirely non-functional
when compiled against OpenSSL 1.1.1 and Qt 5.11.2 (and possible future
combinations of OpenSSL and Qt versions).

This commit fixes #14359 by removing the redundant code.

[1] https://code.qt.io/cgit/qt/qtbase.git/commit/?id=3fd2d9eff8c1f948306ee5fbfe364ccded1c4b84
[2] https://bugreports.qt.io/browse/QTBUG-70956

Github-Pull: #14403
Rebased-From: 7d173c4cd1
Tree-SHA512: 71a34b13202c834c5ca73bcb9b70efff26c34e1aac3b954f098620b62c2be53a8e319929c4764a5b5cc5d0dd163ff70f4eb3a4f1f608363b7d23d1b16b25ddc7
2018-11-06 09:03:28 +01:00
MarcoFalke 76dd5257f9
Merge #14566: 0.17: qa backports
9461f98c53 Disable wallet and address book Qt tests on macOS minimal platform (Russell Yanofsky)
703a24418c descriptors.md: Refer to descriptors as describing instead of matching (Russell Yanofsky)
5f51fd6d59 doc/descriptors.md tweaks (Russell Yanofsky)
29899ecd36 Import CInv from correct module (Chun Kuan Lee)
f7adb32e38 qa: Run all tests even if wallet is not compiled (MarcoFalke)
86fadee990 qa: Premine to deterministic address with -disablewallet (MarcoFalke)
8bc1badada Test rpc_help.py failed: Check whether ZMQ is enabled or not. (Kvaciral)
24d796a6cc test: Add tests for RPC help (João Barbosa)
168efeaca6 qa: Use named args in some tests (MarcoFalke)
73e538cf6a scripted-diff: Use named arguments in feature_block (MarcoFalke)
96dc936862 scripted-diff: Pass node into p2p_segwit acceptance tests (MarcoFalke)
7ff32a6b98 qa: Add some actual witness in rpc_rawtransaction (MarcoFalke)
b72fbabe17 [qa] Use correct python index slices in example test (Suhas Daftuar)
06544faff0 qa: Add TestNode::assert_debug_log (MarcoFalke)

Pull request description:

  Just the test and doc changes from #14328 to prevent that one from piling up.

Tree-SHA512: 51c1e66d346cbf51bc67b2f365448620dd9992ba4ef70592c5eb489cd50a047dab8179c86db2cafe161d8b2aa04498cc760fb5deb7eef49b39272911c74227a9
2018-10-28 06:44:08 -04:00
Russell Yanofsky 9461f98c53 Disable wallet and address book Qt tests on macOS minimal platform
macOS Qt minimal platform is frequently broken, and these are currently failing
with Qt 5.11.1.

The tests do pass when run on the full cocoa platform
(with `test_bitcoin-qt -platform cocoa`).

Github-Pull: #14011
Rebased-From: a3197c5294
2018-10-24 22:03:20 -04:00
Sjors Provoost f7dbcaa72f
[doc] getblocktemplate: use SegWit in example 2018-10-18 15:06:31 +07:00
Russell Yanofsky 89306ab0df [wallet] Restore ability to list incoming transactions by label
Backport of PR 14411 to v0.17.

This change partially reverts #13075 and #14023.

Fixes #14382
2018-10-10 16:34:50 +09:00
Suhas Daftuar 833180f538 Fix crash bug with duplicate inputs within a transaction
Introduced by #9049
2018-09-17 16:14:31 -04:00
Andrew Chow fcefc6851a Convert non-witness UTXOs to witness if witness sig created
If a witness signature was created when a non-witness UTXO is used,
convert the non-witness UTXO to a witness one.
2018-09-11 00:11:00 -04:00
Andrew Chow fcdea8ad2a Drop the unnecessary UTXO based on the UTXOs present, not on earlier wallet things
Instead of dropping the unnecessary UTXO based on whether the wallet did something,
do it based on whether two UTXOs are there.
2018-09-11 00:09:57 -04:00
Pieter Wuille 465a583f9d
Replace duplcate reference with reference to reference doc
Github-Pull: #14096
Rebased-From: 2b5d6f8df2
Tree-SHA512: 79af808c581ebb17d60aab8322b1debcc4182480b84eaedcbfac1e67c8b543c61df22789095742d67d732dba35e7e5fad77912385b695f89fb0f44f75db11560
2018-09-06 14:52:00 +02:00
Pieter Wuille eece974d0a
Adjust TODO link
Github-Pull: #14096
Rebased-From: 89709db7a2
Tree-SHA512: 0bf74e1179bee6e616d8fd2c125411ef30611d9aa3b32412025615a793abbc629a7b6d89a89ef05b11ac3541cc869c0caebba2d00942fdd6ab8d2e98d9b9caca
2018-09-06 14:51:59 +02:00
Wladimir J. van der Laan 83aafd5b32
util: Report parse errors in configuration file
Report errors while parsing the configuration file, instead of silently
ignoring them.

    $ src/bitcoind -regtest
    Error reading configuration file: parse error on line 22: nodebuglogfile, if you intended to specify a negated option, use nodebuglogfile=1 instead
    $ src/bitcoind -regtest
    Error reading configuration file: parse error on line 22: sdafsdfafs
    $ src/bitcoind -regtest
    Error reading configuration file: parse error on line 24: -nodebuglogfile=1, options in the configuration file must be specified without leading -

Github-Pull: #14105
Rebased-From: a66c0f78a9
Tree-SHA512: 2b6be1ab643623e6ef9b53354820147a6c5d2baae3795ffe428fc60d8563ec00a68a379aee4029380f80f892abe23763afb1c75c32b60a13bffe7b82496bf2bb
2018-09-06 13:54:01 +02:00