Commit graph

4018 commits

Author SHA1 Message Date
fanquake
3457054c61
Merge #20346: script: modify security-check.py to use "==" instead of "is" for literal comparison
b6121edf70 swapped "is" for "==" in literal comparison (Tyler Chambers)

Pull request description:

  In Python 3.8+ literal comparisons using "is" instead of "==" produce a SyntaxWarning [source](https://docs.python.org/3.8/whatsnew/3.8.html#changes-in-python-behavior).

  I checked the entire devtools directory, this seems to be the only occurrence.

  This is a small fix, but removes the SyntaxWarning.
  Fixes: #20338

ACKs for top commit:
  hebasto:
    re-ACK b6121edf70, only squashed since my [previous](https://github.com/bitcoin/bitcoin/pull/20346#pullrequestreview-525934568) review.
  practicalswift:
    re-ACK b6121edf70: patch still looks correct
  theStack:
    utACK b6121edf70

Tree-SHA512: 82a43495d6552fbaa3b02b58f0930b049d27aa937fe44b47714e3c059f844cc494de20674557371cbccf24fb8873ecb7376fb965ae326847eed2b855ed2d59c6
2020-11-17 13:57:40 +08:00
Wladimir J. van der Laan
c48e788246
Merge #18836: wallet: upgradewallet fixes and additional tests
5f9c0b6360 wallet: Remove -upgradewallet from dummywallet (MarcoFalke)
a314271f08 test: Remove unused wallet.dat (MarcoFalke)
bf7635963c tests: Test specific upgradewallet scenarios and that upgrades work (Andrew Chow)
4b418a9dec test: Add test_framework/bdb.py module for inspecting bdb files (Andrew Chow)
092fc43485 tests: Add a sha256sum_file function to util (Andrew Chow)
0bd995aa19 wallet: upgrade the CHDChain version number when upgrading to split hd (Andrew Chow)
8e32e1c41c wallet: remove nWalletMaxVersion (Andrew Chow)
bd7398cc62 wallet: have ScriptPubKeyMan::Upgrade check against the new version (Andrew Chow)
5f720544f3 wallet: Add GetClosestWalletFeature function (Andrew Chow)
842ae3842d wallet: Add utility method for CanSupportFeature (Andrew Chow)

Pull request description:

  This PR cleans up the wallet upgrade mechanism a bit, fixes some probably bugs, and adds more test cases.

  The `nWalletMaxVersion` member variable has been removed as it made `CanSupportFeature` unintuitive and was causing a couple of bugs. The reason this was introduced originally was to allow a wallet upgrade to only occur when the new feature is first used. While this makes sense for the old `-upgradewallet` option, for an RPC, this does not quite make sense. It's more intuitive for an upgrade to occur if possible if the `upgradewallet` RPC is used as that's an explicit request to upgrade a particular wallet to a newer version. `nWalletMaxVersion` was only relevant for upgrades to `FEATURE_WALLETCRYPT` and `FEATURE_COMPRPUBKEY` both of which are incredibly old features. So for such wallets, the behavior of `upgradewallet` will be that the feature is enabled immediately without the wallet needing to be encrypted at that time (note that `FEATURE_WALLETCRYPT` indicates support for encryption, not that the wallet is encrypted) or for a new key to be generated.

  `CanSupportFeature` would previously indicate whether we could upgrade to `nWalletMaxVersion` not just whether the current wallet version supported a feature. While this property was being used to determine whether we should upgrade to HD and HD chain split, it was also causing a few bugs. Determining whether we should upgrade to HD or HD chain split is resolved by passing into `ScriptPubKeyMan::Upgrade` the version we are upgrading to and checking against that. By removing `nWalletMaxVersion` we also fix a bug where you could upgrade to HD chain split without the pre-split keypool.

  `nWalletMaxVersion` was also the version that was being reported by `getwalletinfo` which meant that the version reported was not always consistent across restarts as it depended on whether `upgradewallet` was used. Additionally to make the wallet versions consistent with actually supported versions, instead of just setting the wallet version to whatever is given to `upgradewallet`, we normalize the version number to the closest supported version number. For example, if given 150000, we would store and report 139900.

  Another bug where CHDChain was not being upgraded to the version supporting HD chain split is also fixed by this PR.

  Lastly several more tests have been added. Some refactoring to the test was made to make these tests easier. These tests check specific upgrading scenarios, such as from non-HD (version 60000) to HD to pre-split keypool. Although not specifically related to `upgradewallet`, `UpgradeKeyMetadata` is now being tested too.

  Part of the new tests is checking that the wallet files are identical before and after failed upgrades. To facilitate this, a utility function `sha256sum_file` has been added. Another part of the tests is to examine the wallet file itself to ensure that the records in the wallet.dat file have been correctly modified. So a new `bdb.py` module has been added to deserialize the BDB db of the wallet.dat file. This format isn't explicitly documented anywhere, but the code and comments in BDB's source code in file `dbinc/db_page.h` describe it. This module just dumps all of the fields into a dict.

ACKs for top commit:
  MarcoFalke:
    approach ACK 5f9c0b6360
  laanwj:
    Code review ACK 5f9c0b6360
  jonatack:
    ACK 5f9c0b6360, approach seems fine, code review, only skimmed the test changes but they look well done, rebased on current master, debug built and verified the `wallet_upgradewallet.py` test runs green both before and after running `test/get_previous_releases.py -b v0.19.1 v0.18.1 v0.17.2 v0.16.3 v0.15.2`

Tree-SHA512: 7c4ebf420850d596a586cb6dd7f2ef39c6477847d12d105fcd362abb07f2a8aa4f7afc5bfd36cbc8b8c72fcdd1de8d2d3f16ad8e8ba736b6f4f31f133fe5feba
2020-11-16 11:03:25 +01:00
Andrew Poelstra
6f123becd3 Merge 1d1f8bbf57 into merged_master (Bitcoin PR #16115) 2020-11-14 19:07:24 +00:00
Andrew Poelstra
4c7d6ec20e Merge 3b69310beb into merged_master (Bitcoin PR #17984) 2020-11-14 18:40:28 +00:00
Andrew Poelstra
7500590938 Merge 7fcaa8291c into merged_master (Bitcoin PR #18009) 2020-11-14 18:13:04 +00:00
Andrew Poelstra
91e195d7cd Merge 2d6e76af24 into merged_master (Bitcoin PR #17261)
Moved GetOnlinePakKey to the scriptpubkey manager; the other blinding
stuff remains in the CWallet. At some point after the rebase we should
consider whether there's a better separation to be had between the PAK
related stuff now that we have wallet boxes.
2020-11-14 17:16:10 +00:00
Andrew Poelstra
68d0a25901 Merge 1326092e6c into merged_master (Bitcoin PR #17156)
This fixes a segfault I introduced in 981df590811 (#17371) a couple hundred PRs
ago, where we might out-of-bounds access the vout arrray of a non_witness_utxo
transaction in a PSBT.

This logic should probably be refactored after the rebase -- we sift through
the non_witness_utxos to find a scriptpubkey, which we use to get a wallet
provider, so we can pass this to SignPSBTInput, which then repeats the same
logic (for its own reasons, and without the segfault bug)....and we aren't
even calling SignPSBTInput for signing reasons! It has something to do with
blinding.
2020-11-14 16:52:12 +00:00
Andrew Poelstra
17a72c9c14 Merge c26b05c2b7 into merged_master (Bitcoin PR #17770) 2020-11-14 16:52:11 +00:00
Andrew Poelstra
6f1d11cd82 Merge daae6403d8 into merged_master (Bitcoin PR #17777) 2020-11-14 16:52:09 +00:00
Andrew Poelstra
1b7df1d514 Merge 95ca6aeec7 into merged_master (Bitcoin PR #17691) 2020-11-14 16:52:08 +00:00
Andrew Poelstra
b5dd54f5cd Merge ec9b964cc9 into merged_master (Bitcoin PR #17541) 2020-11-14 16:52:08 +00:00
Andrew Poelstra
d308abd052 Merge 4e8b564df0 into merged_master (Bitcoin PR #17931) 2020-11-14 16:52:07 +00:00
Andrew Poelstra
8bbbb28dae Merge ac61ec9da6 into merged_master (Bitcoin PR #17843) 2020-11-14 16:52:07 +00:00
Andrew Poelstra
7c53615bb6 Merge af05bd9e1e into merged_master (Bitcoin PR #17891) 2020-11-14 16:52:07 +00:00
Andrew Poelstra
eb8d73022f Merge f8c69677a1 into merged_master (Bitcoin PR #17893) 2020-11-14 16:52:06 +00:00
Andrew Poelstra
bf82cc6a32 Merge e7f8450357 into merged_master (Bitcoin PR #16688) 2020-11-14 16:52:06 +00:00
Andrew Poelstra
32b9383743 Merge 295211e668 into merged_master (Bitcoin PR #17445) 2020-11-14 16:52:05 +00:00
Andrew Poelstra
75726e3bc3 Merge 40a495a38a into merged_master (Bitcoin PR #16975) 2020-11-14 16:52:05 +00:00
Andrew Poelstra
74d2e8da1b Merge 7ea3b85ecf into merged_master (Bitcoin PR #17578) 2020-11-14 16:52:04 +00:00
Andrew Poelstra
c0f55c006c Merge 45f151913e into merged_master (Bitcoin PR #16373) 2020-11-14 16:52:04 +00:00
Andrew Poelstra
4f611f400d Merge bcb4cdcca3 into merged_master (Bitcoin PR #17621) 2020-11-14 16:52:04 +00:00
Andrew Poelstra
a936f8e538 Merge 816464198c into merged_master (Bitcoin PR #17851) 2020-11-14 16:52:03 +00:00
Andrew Poelstra
c4e2622681 Merge 3f8dbcd655 into merged_master (Bitcoin PR #16658) 2020-11-14 16:52:03 +00:00
Andrew Poelstra
009bc2fdfb Merge 99813a9745 into merged_master (Bitcoin PR #17829) 2020-11-14 16:52:02 +00:00
Andrew Poelstra
021eccb56e Merge 6cb80a068d into merged_master (Bitcoin PR #17806) 2020-11-14 16:52:01 +00:00
Andrew Poelstra
6b5ef039c0 Merge 03dfa36641 into merged_master (Bitcoin PR #17229) 2020-11-14 16:52:00 +00:00
Andrew Poelstra
c6c5243a64 Merge 806a2c602c into merged_master (Bitcoin PR #17071) 2020-11-14 16:51:59 +00:00
Andrew Poelstra
37b9b15143 Merge a595011f5a into merged_master (Bitcoin PR #17728) 2020-11-14 16:51:59 +00:00
Andrew Poelstra
7776084b8f Merge 988fe5b1ad into merged_master (Bitcoin PR #12763) 2020-11-14 16:51:58 +00:00
Andrew Poelstra
7187ea2de7 Merge 3f1966ead6 into merged_master (Bitcoin PR #17705) 2020-11-14 16:51:57 +00:00
Andrew Poelstra
f3ec9fa522 Merge 7da9e3a817 into merged_master (Bitcoin PR #17050) 2020-11-14 16:51:57 +00:00
Andrew Poelstra
c9585d0fde Merge 3d6752779f into merged_master (Bitcoin PR #17633) 2020-11-14 16:51:56 +00:00
Andrew Poelstra
9709d02c23 Merge fae94785d9 into merged_master (Bitcoin PR #17524)
lol converting the psbt test vector to a pset one was pretty brutal. Conversion to
hex using rust-bitcoin and then manual hex-editing in vim.
2020-11-14 16:51:56 +00:00
Andrew Poelstra
0f9ee77fe1 Merge 1189b6acab into merged_master (Bitcoin PR #17109) 2020-11-14 16:51:56 +00:00
Andrew Poelstra
f68c3ea229 Merge 347dd76ec8 into merged_master (Bitcoin PR #17093) 2020-11-14 16:51:56 +00:00
Andrew Poelstra
11487538e9 Merge df2b743759 into merged_master (Bitcoin PR #17675) 2020-11-14 16:51:55 +00:00
Andrew Poelstra
c59a715d27 Merge cb11324a63 into merged_master (Bitcoin PR #17051) 2020-11-14 16:51:53 +00:00
Andrew Poelstra
96822eee94 Merge 910a4301b1 into merged_master (Bitcoin PR #17522) 2020-11-14 16:51:53 +00:00
Andrew Poelstra
0c0b496469 Merge 5aee0e2163 into merged_master (Bitcoin PR #17650) 2020-11-14 16:51:53 +00:00
Andrew Poelstra
c7bf5baf96 Merge 526e802d69 into merged_master (Elements PR #755)
This Elements PR includes components of Core PR #17211, which since the
refactors to use effective value landed, no longer provides the right
error message when a user provides an unowned input from a wallet tx.
See https://github.com/bitcoin/bitcoin/pull/17211#pullrequestreview-528389011

This breaks a functional test which was included in this PR, but which
conveniently has been changed in the current version of the Core PR. I
fixed the behavior (commented, in SelectCoins) rather than updating the
test to the most recent version.
2020-11-14 16:51:53 +00:00
Andrew Poelstra
5a48ca16e3 Merge fee01bb053 into merged_master (Bitcoin PR #17517) 2020-11-14 16:51:52 +00:00
Andrew Poelstra
fd78a12518 Merge 2949ea924f into merged_master (Elements PR #751) 2020-11-14 16:51:52 +00:00
Andrew Poelstra
c3c860b38a Merge 69ca6cdd66 into merged_master (Bitcoin PR #17599) 2020-11-14 16:51:51 +00:00
Andrew Poelstra
05bbc1a822 Merge 2b6575d989 into merged_master (Bitcoin PR #17643) 2020-11-14 16:51:51 +00:00
Andrew Poelstra
27de4bdecf Merge 19698ac6bc into merged_master (Bitcoin PR #17568) 2020-11-14 16:51:51 +00:00
Andrew Poelstra
b4d7d9d503 Merge 1f59885d27 into merged_master (Bitcoin PR #17361) 2020-11-14 16:51:50 +00:00
Andrew Poelstra
6a5fc1dd58 Merge d8a66626d6 into merged_master (Bitcoin PR #17283) 2020-11-14 16:51:50 +00:00
Andrew Poelstra
cc2097087c Merge dd1478870c into merged_master (Elements PR #791) 2020-11-14 16:51:50 +00:00
Andrew Poelstra
569c46ca22 Merge 6d00035cae into merged_master (Elements PR #778) 2020-11-14 16:51:50 +00:00
Andrew Poelstra
7a8b5877f2 Merge 9cbd87d8ee into merged_master (Bitcoin PR #17518) 2020-11-14 16:51:48 +00:00