Commit Graph

4473 Commits

Author SHA1 Message Date
MarcoFalke
fa0758e145
test: Add diamond-shape prioritisetransaction test 2022-03-24 14:33:41 +01:00
MarcoFalke
fa450c18db
test: Rework create_self_transfer_multi
* Add fallback for utxos_to_spend if none are provided
* Refactor a for-loop
2022-03-24 14:33:28 +01:00
MarcoFalke
4a0ab355b3
Merge bitcoin/bitcoin#24626: init: disallow reindex-chainstate when pruning
b2813980b8 init: disallow reindex-chainstate when pruning (Martin Zumsande)

Pull request description:

  The combination of `-reindex-chainstate` and `-prune` currently makes the node stuck in an endless loop:

  - `LoadChainstate()` will wipe the existing chainstate (so we have no genesis block anymore). It won't clean up unusable block files by calling `CleanupBlockRevFiles()` as for full `-reindex`.
  - `ThreadImport()` has [logic](91d12344b1/src/node/blockstorage.cpp (L855)) of reloading Genesis after reindexing. This is what makes full `-reindex` work with `-prune` but it's not executed for `-reindex-chainstate`.
  - Since we still don't have a genesis block, init will wait for it forever in an endless loop ([code](91d12344b1/src/init.cpp (L1630-L1640))).

  Fix this by disallowing `-reindex-chainstate` together with `-prune`. This is discouraged in the help for `-reindex-chainstate` anyway ("When in pruning mode or if blocks on disk might be corrupted, use full -reindex instead.") but wasn't enforced.

  Fixes #24242

ACKs for top commit:
  MarcoFalke:
    cr ACK b2813980b8

Tree-SHA512: 7220842daaf9a4f972d82b13b81fdeac2833bf5e665c5b0f8eaf6a4bcd0725c8e97d19ec956ca4b730065a983475bb3a2732713d338f4caf8666ccbf63d4d988
2022-03-24 14:27:13 +01:00
Martin Zumsande
b2813980b8 init: disallow reindex-chainstate when pruning
This fixes a bug where the node would be stuck in an
endless loop when combining these parameters.
2022-03-24 13:03:40 +01:00
fanquake
26d98d51f2
Merge bitcoin/bitcoin#24574: test: Actually print TSan tracebacks
fa76d8d4d7 test: Actually print TSan tracebacks (MarcoFalke)

Pull request description:

  Commit 5e5138a721 made the TSan logs to be printed before returning an error from the ci script.

  However, it seems that on Cirrus CI, the `--failfast` option will kill not only all python process and bitcoind child process, but also the parent CI bash script, rendering the `trap` inefficient. I believe this bug was introduced in commit 451b96f7d2.

ACKs for top commit:
  fanquake:
    utACK fa76d8d4d7

Tree-SHA512: 686f889d38a343882cb62ad6e0c2080196330e7cc7086891a7ff66d9443b455c82ba8d7e4a5cc42daa0513b0ad2743055bfe90e2f6ac88a910ee3b663fabddcd
2022-03-24 11:56:14 +00:00
MarcoFalke
864fb89b2f
Merge bitcoin/bitcoin#24637: test: use MiniWallet for mempool_package_onemore.py
2b6dd4e75b test: use MiniWallet for mempool_package_onemore.py (Sebastian Falbesoner)
eb3c5c4ef2 test: MiniWallet: add helper methods `{send,create}_self_transfer_multi` (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (mempool_package_onemore.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in https://github.com/bitcoin/bitcoin/issues/20078. For this purpose helper methods `MiniWallet.{create,send}_self_transfer_multi` are introduced which serve as a replacement for `chain_transaction`. With this, it should be also quite straight-forward to change the larger related test `mempool_packages.py` to use MiniWallet.

ACKs for top commit:
  MarcoFalke:
    ACK 2b6dd4e75b 💾

Tree-SHA512: 0c97fa0519ca5eaa6df8953a04678aa8a6a66905a82db6ff40042a675d0c0682aee829a48db84e4e7983d8f766875021f0d39d65e12889342610b8861bc29cd5
2022-03-24 12:37:11 +01:00
fanquake
8234cdaf62
Merge bitcoin/bitcoin#24587: test: use MiniWallet for rpc_createmultisig.py
2726b60a3a test: use MiniWallet for rpc_createmultisig.py (Ayush Sharma)

Pull request description:

  This PR enables one of the non-wallet functional tests (rpc_createmultisig.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in #20078 .

ACKs for top commit:
  danielabrozzoni:
    re-ACK 2726b60a3a

Tree-SHA512: fb0ef22d3f1c161ca5963cb19ce76533ac3941f15102fc0aa2286ef3bec48f219e5934d504b41976f9f295fb6ca582b737e0fea896df4eb964cdaba1b2c91650
2022-03-24 11:11:56 +00:00
fanquake
ce05f838f1
Merge bitcoin/bitcoin#24635: test: Run non-wallet tests only once
fa7a576391 test: Run non-wallet tests only once (MarcoFalke)

Pull request description:

  I don't see why non-wallet tests should run for two wallet configs, even though they never use a wallet.

ACKs for top commit:
  achow101:
    ACK fa7a576391

Tree-SHA512: 2a135acf3c3c83a2704ae11f40c72882b23a676828647be1a066653c4d00e4523704f377eb8745c6386829601cc5d643abdce376831c1db91a07e999e1d5e01f
2022-03-23 20:02:23 +00:00
Sebastian Falbesoner
2b6dd4e75b test: use MiniWallet for mempool_package_onemore.py
This test can now be run even with the Bitcoin Core wallet disabled.
2022-03-22 18:44:27 +01:00
Sebastian Falbesoner
eb3c5c4ef2 test: MiniWallet: add helper methods {send,create}_self_transfer_multi 2022-03-22 18:43:51 +01:00
Ayush Sharma
2726b60a3a test: use MiniWallet for rpc_createmultisig.py
This test can now be run even with the Bitcoin Core wallet disabled.
2022-03-22 14:17:51 +05:30
MarcoFalke
b8f498f80d
Merge bitcoin/bitcoin#24535: test: Fix generate calls and comments in feature_segwit
fa8593f898 test: Fix generate calls and comments in feature_segwit (MarcoFalke)

Pull request description:

  There are currently a few incorrect comments: Block `432` is mined "twice" (The second one is actually 433).

  There isn't any need to mine this many blocks anyway, so remove a few calls.

ACKs for top commit:
  theStack:
    Tested ACK fa8593f898

Tree-SHA512: b034077b85e6c978a80aa4de493797b4ae451d686cfb3e4fe40f37a38f41f7cb886f8e00a1c245a284be3502164b17414097fcb0bef66d155a1c1db5cfbe9e8f
2022-03-22 09:10:55 +01:00
MarcoFalke
fa7a576391
test: Run non-wallet tests only once 2022-03-22 08:11:46 +01:00
MarcoFalke
e3206c9445
Merge bitcoin/bitcoin#24605: test: Use MiniWallet in feature_coinstatsindex
fa48ea3067 Use MiniWallet in feature_coinstatsindex (MarcoFalke)
fab61437f6 test: Refactor MiniWallet get_utxo helper (MarcoFalke)

Pull request description:

  Allows the test to be run even without a wallet compiled

ACKs for top commit:
  josibake:
    ACK fa48ea3067
  ayush933:
    tACK  fa48ea3 . The test runs successfully with the wallet disabled.
  willcl-ark:
    tACK fa48ea3067 both with and without wallet compiled in.

Tree-SHA512: e04e04ea0f236c062d6be68909ece2770130ce1d5343823893073d95aebc6eedb1ad1dc5bc41e5b0cb0bf2cd9018bb1d668f0e7f5f1101ed4e0b007ed6b00f69
2022-03-22 07:56:29 +01:00
MarcoFalke
fa8593f898
test: Fix generate calls and comments in feature_segwit 2022-03-18 16:23:43 +01:00
MarcoFalke
fa48ea3067
Use MiniWallet in feature_coinstatsindex 2022-03-17 20:49:10 +01:00
MarcoFalke
fab61437f6
test: Refactor MiniWallet get_utxo helper 2022-03-17 20:48:43 +01:00
DrahtBot
d6b24e14d2 test: Fix intermittent failure in feature_segwit 2022-03-16 19:56:31 +01:00
MarcoFalke
fa76d8d4d7
test: Actually print TSan tracebacks 2022-03-15 19:16:35 +01:00
MarcoFalke
7b83c7d609
Merge bitcoin/bitcoin#24510: test: check for importprunedfunds RPC errors
7573789925 test: check for importprunedfunds RPC errors (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the following errors of the `importprunedfunds` RPC:
  7003b6ab24/src/wallet/rpc/backup.cpp (L320-L322)
  7003b6ab24/src/wallet/rpc/backup.cpp (L332-L334)
  7003b6ab24/src/wallet/rpc/backup.cpp (L338-L340)
  7003b6ab24/src/wallet/rpc/backup.cpp (L343-L345)

ACKs for top commit:
  MarcoFalke:
    review ACK 7573789925

Tree-SHA512: b054520d102e5940bdeed2456ca644e91afb187d169b751b1262ce34480e4e9fbe1616ab184a78777c184350dced23508c3d367ed5825cab78bb5ad687fd7dac
2022-03-15 16:04:17 +01:00
MarcoFalke
e0881aa5f0
Merge bitcoin/bitcoin#24505: wallet: Add a deprecation warning for newly created legacy wallets
61152183ab wallet: Add a deprecation warning for newly created legacy wallets (Andrew Chow)

Pull request description:

  As we slowly deprecate legacy wallets, we need to warn users that are making new legacy wallets that their wallet type is going to be unsupported in the future.

ACKs for top commit:
  jonatack:
    ACK 61152183ab
  S3RK:
    reACK 61152183ab
  theStack:
    ACK 61152183ab

Tree-SHA512: e89bfb8168869542498958f0c9a2ab302dfd43287f8a49e7d9e09f60438a567bb8b7219a4e569797ee819b30b624f532fcc0b70c6aa0edcb392a301b8ce8b541
2022-03-14 08:37:46 +01:00
MarcoFalke
e04720ec33
Merge bitcoin/bitcoin#24528: rpc: rename getdeploymentinfo status-next to status_next
5d7c69b887 rpc: rename getdeploymentinfo status-next to status_next (Jon Atack)

Pull request description:

  Rename the `status-next` field to `status_next` in getdeploymentinfo before the RPC is released in v23.

  Before
  ```
  Result:
  {                                       (json object)
    "hash" : "str",                       (string) requested block hash (or tip)
    "height" : n,                         (numeric) requested block height (or tip)
    "deployments" : {                     (json object)
      "xxxx" : {                          (json object) name of the deployment
        "type" : "str",                   (string) one of "buried", "bip9"
        "height" : n,                     (numeric, optional) height of the first block which the rules are or will be enforced (only for "buried" type, or "bip9" type with "active" status)
        "active" : true|false,            (boolean) true if the rules are enforced for the mempool and the next block
        "bip9" : {                        (json object, optional) status of bip9 softforks (only for "bip9" type)
          "bit" : n,                      (numeric, optional) the bit (0-28) in the block version field used to signal this softfork (only for "started" and "locked_in" status)
          "start_time" : xxx,             (numeric) the minimum median time past of a block at which the bit gains its meaning
          "timeout" : xxx,                (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in
          "min_activation_height" : n,    (numeric) minimum height of blocks for which the rules may be enforced
          "status" : "str",               (string) status of deployment at specified block (one of "defined", "started", "locked_in", "active", "failed")
          "since" : n,                    (numeric) height of the first block to which the status applies
          "status-next" : "str",          (string) status of deployment at the next block
          "statistics" : {                (json object, optional) numeric statistics about signalling for a softfork (only for "started" and "locked_in" status)
            "period" : n,                 (numeric) the length in blocks of the signalling period
            "threshold" : n,              (numeric, optional) the number of blocks with the version bit set required to activate the feature (only for "started" status)
            "elapsed" : n,                (numeric) the number of blocks elapsed since the beginning of the current period
            "count" : n,                  (numeric) the number of blocks with the version bit set in the current period
            "possible" : true|false       (boolean, optional) returns false if there are not enough blocks left in this period to pass activation threshold (only for "started" status)
          },
          "signalling" : "str"            (string) indicates blocks that signalled with a # and blocks that did not with a -
        }
      }
    }
  }
  ```
  After
  ```
  Result:
  {                                       (json object)
    "hash" : "str",                       (string) requested block hash (or tip)
    "height" : n,                         (numeric) requested block height (or tip)
    "deployments" : {                     (json object)
      "xxxx" : {                          (json object) name of the deployment
        "type" : "str",                   (string) one of "buried", "bip9"
        "height" : n,                     (numeric, optional) height of the first block which the rules are or will be enforced (only for "buried" type, or "bip9" type with "active" status)
        "active" : true|false,            (boolean) true if the rules are enforced for the mempool and the next block
        "bip9" : {                        (json object, optional) status of bip9 softforks (only for "bip9" type)
          "bit" : n,                      (numeric, optional) the bit (0-28) in the block version field used to signal this softfork (only for "started" and "locked_in" status)
          "start_time" : xxx,             (numeric) the minimum median time past of a block at which the bit gains its meaning
          "timeout" : xxx,                (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in
          "min_activation_height" : n,    (numeric) minimum height of blocks for which the rules may be enforced
          "status" : "str",               (string) status of deployment at specified block (one of "defined", "started", "locked_in", "active", "failed")
          "since" : n,                    (numeric) height of the first block to which the status applies
          "status_next" : "str",          (string) status of deployment at the next block
          "statistics" : {                (json object, optional) numeric statistics about signalling for a softfork (only for "started" and "locked_in" status)
            "period" : n,                 (numeric) the length in blocks of the signalling period
            "threshold" : n,              (numeric, optional) the number of blocks with the version bit set required to activate the feature (only for "started" status)
            "elapsed" : n,                (numeric) the number of blocks elapsed since the beginning of the current period
            "count" : n,                  (numeric) the number of blocks with the version bit set in the current period
            "possible" : true|false       (boolean, optional) returns false if there are not enough blocks left in this period to pass activation threshold (only for "started" status)
          },
          "signalling" : "str"            (string) indicates blocks that signalled with a # and blocks that did not with a -
        }
      }
    }
  }
  ```

Top commit has no ACKs.

Tree-SHA512: 4facfd7af3cfb7b6f5495758c4387602802f5e39d9270b162d17350a7f954eab0b74d895f17f0d8dfbc7814d36db7cff56d08c42728432885ea6f4e37aea4aa8
2022-03-13 10:23:20 +01:00
Sebastian Falbesoner
aab552fa30 test: use MiniWallet for feature_maxuploadtarget.py
This test can now be run even with the Bitcoin Core wallet disabled.
2022-03-11 16:14:48 +01:00
fanquake
23e8c702bc
Merge bitcoin/bitcoin#24421: miner: always assume we can build witness blocks
40e871d9b4 [miner] always assume we can create witness blocks (glozow)

Pull request description:

  Given the low possibility of a reorg reverting the segwit soft fork, there is no longer a need to check whether segwit is active to see if it's okay to add to the block template (see also #23512, #21009, etc). `TestBlockValidity()` is also run on the block template at the end of `CreateNewBlock()`, so any invalid block would be caught there.

ACKs for top commit:
  gruve-p:
    ACK 40e871d9b4
  jnewbery:
    utACK 40e871d9b4, although I disagree about changing the test for segwit transaction in mempool before activagtion, instead of just removing it: https://github.com/bitcoin/bitcoin/pull/24421#discussion_r822933721.
  achow101:
    ACK 40e871d9b4
  theStack:
    Code-review ACK 40e871d9b4

Tree-SHA512: bf4860bf2bed8339622d05228d11d60286edb0c32a9a3c434b8d154913c07ea56e50649f4af7009c2a1c6a58a81d2299ab43b41a6f16dee7d08cc89cc1603019
2022-03-11 15:00:38 +00:00
Jon Atack
5d7c69b887
rpc: rename getdeploymentinfo status-next to status_next 2022-03-11 10:21:48 +01:00
Andrew Chow
61152183ab wallet: Add a deprecation warning for newly created legacy wallets 2022-03-10 07:32:02 -05:00
Sebastian Falbesoner
7573789925 test: check for importprunedfunds RPC errors 2022-03-09 16:16:07 +01:00
MarcoFalke
aa83bbb1fe
Merge bitcoin/bitcoin#24490: tests: Ensure sorted/multi_a descriptors always generate different addrs
db27ac9354 tests: Ensure sorted/multi_a descriptors always generate different addrs (Andrew Chow)

Pull request description:

  Sometimes the multi_a and sortedmulti_a descriptors will produce some of the same addresses in the tests. This causes the wallets to start generating addresses at a different index as they detect that one of the addresses is used. This subsequently causes a test failure.

  To avoid this problem, use descriptors that will produce unique addresses by putting one of the multi_a in a different branch.

ACKs for top commit:
  ajtowns:
    ACK db27ac9354
  theStack:
    Tested ACK db27ac9354

Tree-SHA512: 0f57822bf4c7c79da304f092d7d43d6118e78a087cbeb0766fbbf634dc27911ae723d5d41350884d3b63a24d3b3817944f7e5fa534afb849161dd008a1e4a62f
2022-03-09 11:33:03 +01:00
Andrew Chow
9d22dbe2e1
Merge bitcoin/bitcoin#24198: wallet, rpc: add wtxid in WalletTxToJSON
7abd8b21ba doc: include wtxid in TransactionDescriptionString (brunoerg)
2d596bce6f doc: add wtxid info in release-notes (brunoerg)
a5b66738f1 test: add wtxid in expected_fields for wallet_basic (brunoerg)
e8c659a297 wallet: add wtxid in WalletTxToJSON (brunoerg)
7482b6f895 wallet: add GetWitnessHash() (brunoerg)

Pull request description:

  This PR add `wtxid` in `WalletTxToJSON` which allows to return this field in `listsinceblock`, `listtransactions` and `gettransaction` (RPCs).

ACKs for top commit:
  achow101:
    re-ACK 7abd8b21ba
  w0xlt:
    crACK 7abd8b2
  luke-jr:
    re-utACK 7abd8b21ba

Tree-SHA512: f86f2dbb5e38e7b19932006121802f47b759d31bdbffe3263d1db464f6a3a30fddd68416f886a44f6d3a9fd570f7bd4f8d999737ad95c189e7ae5e8ec1ffbdaa
2022-03-08 14:32:10 -05:00
MarcoFalke
b07fdd7f9e
Merge bitcoin/bitcoin#24312: addrman: Log too low compat value
fa097d074b addrman: Log too low compat value (MarcoFalke)

Pull request description:

  Before this patch, when writing a negative `lowest_compatible` value, it would be read as a positive value. For example `-32` will be read as `224`. There is generally nothing wrong with that. Though, similarly there shouldn't be anything wrong with refusing to read a negative value. I find the code after this patch more logical than before. Also, this allows dropping a file-wide sanitizer suppression.

  In practice none of this should ever happen. Bitcoin Core would never write a negative `lowest_compatible` in normal operation, unless the file storage is later corrupted by external influence.

ACKs for top commit:
  mzumsande:
    re-ACK fa097d074b

Tree-SHA512: 9aae7b8fe666f52f667f149667025e0160cef1a793cc4d392e36608f65c2bee8096da429235118f40a3368f327aabe30f3732ae78c5874648ea6f423f2687b65
2022-03-08 16:48:22 +01:00
Sebastian Falbesoner
31846b006d test: refactor: use random.sample for choosing random keys in wallet_taproot.py 2022-03-07 18:40:17 +01:00
Andrew Chow
db27ac9354 tests: Ensure sorted/multi_a descriptors always generate different addrs
Sometimes the multi_a and sortedmulti_a descriptors will produce some of
the same addresses in the tests. This causes the wallets to start
generating addresses at a different index as they detect that one of
the addresses is used. This subsequently causes a test failure.

To avoid this problem, use descriptors that will produce unique
addresses by putting one of the multi_a in a different branch.
2022-03-07 06:06:16 -05:00
Andrew Chow
bada9636d7
Merge bitcoin/bitcoin#24043: Add (sorted)multi_a descriptor for k-of-n multisig inside tr
4828d53ecc Add (sorted)multi_a descriptors to doc/descriptors.md (Pieter Wuille)
b5f33ac1f8 Simplify wallet_taproot.py functional test (Pieter Wuille)
eb0667ea96 Add tests for (sorted)multi_a derivation/signing (Pieter Wuille)
c17c6aa08d Add signing support for (sorted)multi_a scripts (Pieter Wuille)
3eed6fca57 Add multi_a descriptor inference (Pieter Wuille)
79728c4a3d Add (sorted)multi_a descriptor and script derivation (Pieter Wuille)
25e95f9ff8 Merge/generalize IsValidMultisigKeyCount/GetMultisigKeyCount (Pieter Wuille)

Pull request description:

  This adds a new `multi_a(k,key_1,key_2,...,key_n)` (and corresponding `sortedmulti_a`) descriptor for k-of-n policies inside `tr()`. Semantically it is very similar to the existing `multi()` descriptor, but with the following changes:
  * The corresponding script is `<key1> OP_CHECKSIG <key2> OP_CHECKSIGADD <key3> OP_CHECKSIGADD ... <key_n> OP_CHECKSIGADD <k> OP_NUMEQUAL`, rather than the traditional `OP_CHECKMULTISIG`-based script, making it usable inside the `tr()` descriptor.
  * The keys can optionally be specified in x-only notation.
  * Both the number of keys and the threshold can be as high as 999; this is the limit due to the consensus stacksize=1000 limit

  I expect that this functionality will later be replaced with a miniscript-based implementation, but I don't think it's necessary to wait for that.

  Limitations:
  * The wallet code will for not estimate witness size incorrectly for script path spends, which may result in a (dramatic) fee underpayment with large multi_a scripts.
  * The multi_a script construction is (slightly) suboptimal for n-of-n (where a `<key1> OP_CHECKSIGVERIFY ... <key_n-1> OP_CHECKSIGVERIFY <key_n> OP_CHECKSIG` would be better). Such a construction is not included here.

ACKs for top commit:
  achow101:
    ACK 4828d53ecc
  gruve-p:
    ACK 4828d53ecc
  sanket1729:
    code review ACK 4828d53ecc
  darosior:
    Code review ACK 4828d53ecc

Tree-SHA512: 5dcd434b79585f0ff830f7d501d27df5e346f5749f47a3109ec309ebf2cbbad0e1da541eec654026d911ab67fd7cf7793fab0f765628d68d81b96ef2a4d234ce
2022-03-04 07:28:23 -05:00
Vasil Dimov
7d64ea4a01
net: only assume all local addresses if listening on any
If `-bind=` is provided then we would bind only to a particular address
and should not add all the other addresses of the machine to the list of
local addresses.

Fixes https://github.com/bitcoin/bitcoin/issues/20184 (case 4.)
2022-03-02 15:42:40 +01:00
Vasil Dimov
0cfc0cd322
net: fix GetListenPort() to derive the proper port
`GetListenPort()` uses a simple logic: "if `-port=P` is given, then we
must be listening on `P`, otherwise we must be listening on `8333`".
This is however not true if `-bind=` has been provided with `:port` part
or if `-whitebind=` has been provided. Thus, extend `GetListenPort()` to
return the port from `-bind=` or `-whitebind=`, if any.

Fixes https://github.com/bitcoin/bitcoin/issues/20184 (cases 1. 2. 3. 5.)
2022-03-02 15:42:37 +01:00
Vasil Dimov
3cb9d9c861
net: make CaptureMessage() mockable
Rename `CaptureMessage()` to `CaptureMessageToFile()` and introduce a
`std::function` variable called `CaptureMessage` whose value can be
changed by unit tests, should they need to inspect message contents.
2022-03-02 15:40:36 +01:00
laanwj
267917f563
Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places
c4d76c6faa tests: Tests for inactive HD chains (Andrew Chow)
8077862c5e wallet: Refactor TopUp to be able to top up inactive chains too (Andrew Chow)
70134eb34f wallet: Properly set hd chain counters when loading (Andrew Chow)
961b9e4e40 wallet: Parse hdKeypath if key_origin is not available (Andrew Chow)
0652ee73ec Add size check on meta.key_origin.path (Rob Fielding)

Pull request description:

  Currently inactive HD chains are only derived from at the time a key in that chain is found to have been used. However, at that time, the wallet may not be able to derive keys (e.g. it is locked). Currently we would just move on and not derive any new keys, however this could result in missing funds.

  This PR resolves this problem by adding memory only variables to `CHDChain` which track the highest known index. `TopUp` is modified to always try to top up the inactive HD chains, and this process will use the new variables to determine how much to top up. In this way, after an encrypted wallet is unlocked, the inactive HD chains will be topped up and hopefully funds will not be missed.

  Note that because these variables are not persisted to disk (because `CHDChain`s for inactive HD chains are not written to disk), if an encrypted wallet is not unlocked in the same session as a key from an inactive chain is found to be used, then it will not be topped up later unless more keys are found.

  Additionally, wallets which do not have upgraded key metadata will not derive any keys from inactive HD chains. This is resolved by using the derivation path string in `CKeyMetadata.hdKeypath` to determine what indexes to derive.

ACKs for top commit:
  laanwj:
    Code review ACK c4d76c6faa

Tree-SHA512: b2b572ad7f1b1b2847edece09f7583543d63997e18ae32764e5a27ad608dd64b9bdb2d84ea27137894e986a8e82f047a3dba9c8015b74f5f179961911f0c4095
2022-03-02 09:35:07 +01:00
laanwj
848b11615b
Merge bitcoin/bitcoin#22834: net: respect -onlynet= when making outbound connections
0eea83a85e scripted-diff: rename `proxyType` to `Proxy` (Vasil Dimov)
e53a8505db net: respect -onlynet= when making outbound connections (Vasil Dimov)

Pull request description:

  Do not make outbound connections to hosts which belong to a network
  which is restricted by `-onlynet`.

  This applies to hosts that are automatically chosen to connect to and to
  anchors.

  This does not apply to hosts given to `-connect`, `-addnode`,
  `addnode` RPC, dns seeds, `-seednode`.

  Fixes https://github.com/bitcoin/bitcoin/issues/13378
  Fixes https://github.com/bitcoin/bitcoin/issues/22647
  Supersedes https://github.com/bitcoin/bitcoin/pull/22651

ACKs for top commit:
  naumenkogs:
    utACK 0eea83a85e
  prayank23:
    reACK 0eea83a85e
  jonatack:
    ACK 0eea83a85e code review, rebased to master, debug built, and did some manual testing with various config options on signet

Tree-SHA512: 37d68b449dd6d2715843fc84d85f48fa2508be40ea105a7f4a28443b318d0b6bd39e3b2ca2a6186f2913836adf08d91038a8b142928e1282130f39ac81aa741b
2022-03-01 18:32:01 +01:00
laanwj
159f89c118
Merge bitcoin/bitcoin#24365: wallet: Don't generate keys for wallets with private keys disabled during upgradewallet
c7376cc8d7 tests: Test upgrading wallet with privkeys disabled (Andrew Chow)
3d985d4f43 wallet: Don't generate keys when privkeys disabled when upgrading (Andrew Chow)

Pull request description:

  When we're upgrading a wallet, we shouldn't be trying to generate new keys for wallets where private keys are disabled.

  Fixes #23610

ACKs for top commit:
  laanwj:
    Code review ACK c7376cc8d7
  benthecarman:
    tACK c7376cc8d7 this fixed the issue for me

Tree-SHA512: fa07cf37df9196ff98671bb1ce5c9aa0bab46495066b4dab796d7e8e5d5c7adb414ff56adae4fd3e15658a610995bd19a9e1edb00c46144b0df635c5b343f3a6
2022-02-28 13:15:11 +01:00
MarcoFalke
c7da61dcc3
Merge bitcoin/bitcoin#24403: Avoid implicit-integer-sign-change in VerifyLoadedChainstate
fa7991601c Fixup style of VerifyDB (MarcoFalke)
fa462ea787 Avoid implicit-integer-sign-change in VerifyLoadedChainstate (MarcoFalke)

Pull request description:

  This happens when checking all blocks (`-1`).

  To test:

  ```
  ./configure CC=clang CXX=clang++ --with-sanitizers=undefined,integer
  make
  UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./test/functional/rpc_blockchain.py

ACKs for top commit:
  theStack:
    Code-review ACK fa7991601c
  brunoerg:
    crACK fa7991601c

Tree-SHA512: bcbe6becf2fbedd21bbde83a544122e79465937346802039532143b2e4165784905a8852c0ccb088b964874df5e5550931fdde3629cbcee3ae237f2f63c43a8e
2022-02-28 12:33:32 +01:00
MarcoFalke
fa097d074b
addrman: Log too low compat value
Also remove uint8_t{} casts from values that are already of the same
type.
2022-02-25 14:16:32 +01:00
MarcoFalke
aaaa4dbab4
Avoid implicit-integer-sign-change in bech32.cpp 2022-02-25 09:43:54 +01:00
MarcoFalke
fae6b26758
test: Remove no longer needed suppressions 2022-02-25 09:41:05 +01:00
MarcoFalke
b00b60ed4f
Merge bitcoin/bitcoin#24201: p2p: Avoid InitError when downgrading peers.dat
d41ed32153 p2p: Avoid InitError when downgrading peers.dat (junderw)

Pull request description:

  fixes #24188 (also see https://github.com/bitcoin/bitcoin/pull/22762#issuecomment-951063826)
  When downgrading, a peers.dat with a future version that has a minimum
  required version larger than the downgraded Bitcoin Core version would cause an InitError.

  This commit changes this behavior to overwrite the existing peers.dat with
  a new empty one.

ACKs for top commit:
  prayank23:
    reACK d41ed32153
  kallewoof:
    reACK d41ed32153

Tree-SHA512: c8e625fe36ce0b1aab6c8ef7241c8954038bb856f2de27bdc4814dc9a60e51be28815c7d77d0f96eace49687a0cea02deb713978bbd3a5add742f50a675f2a40
2022-02-25 08:45:11 +01:00
junderw
d41ed32153
p2p: Avoid InitError when downgrading peers.dat
fixes #24188
When downgrading, a peers.dat with a future version that has a minimum
required version larger than the downgraded version would cause an InitError.

This commit changes this behavior to overwrite the existing peers.dat with
a new empty one, while creating a backup in peers.dat.bak.
2022-02-25 09:53:10 +09:00
MarcoFalke
f1ce67f09f
Merge bitcoin/bitcoin#19013: test: add v0.20.1, v0.21.0 and v22.0 to backwards compatibility test
24cec4b5c0 test: Fix intermittent test failure in feature_backwards_compatibility (MarcoFalke)
d8b705f1ca test: previous releases: add v22.0 (Sjors Provoost)
40849eebd9 test: bump sandbox argument minimum version (Sjors Provoost)
8a57a06a50 test: previous releases: add v0.21.0 (Sjors Provoost)
8cba75f5fd test: v0.20.1 backwards compatibility (Sjors Provoost)
0e4b695b6a test: backwards compatibility: misc fixes (Sjors Provoost)
76557cbe4c test: Remove i686 from test/get_previous_releases.py (MarcoFalke)

Pull request description:

  This also simplifies the tests a bit.

ACKs for top commit:
  ryanofsky:
    Code review ACK 24cec4b5c0. Only change since last review is rebasing and adding comment and whitelist args.

Tree-SHA512: 85a603ddd70fd8f0180d00fb84eb2ad2f92d6199b7d3f7c1abd660bfba53f869faf40f1a4183a8ce15dbd496ee3132d879c1258651c9d443ece69e5fe328bd26
2022-02-24 17:42:28 +01:00
laanwj
358fe779cb
Merge bitcoin/bitcoin#24381: test: Run symlink regression tests on Windows
fad7ddf9e3 test: Run symlink regression tests on Windows (MarcoFalke)

Pull request description:

  Seems odd to add tests, but not run them on the platform that needs them most.

ACKs for top commit:
  laanwj:
    Code review ACK fad7ddf9e3
  ryanofsky:
    Code review ACK fad7ddf9e3, just removing new test. Would be nice if the test could be added later, of course.

Tree-SHA512: 64b235967a38c2eb90657e8d7a0447bcc8ce81d1b75a275b6c48bd42efd9ea7e7939257e484f297ee84598def3738eaeb289561aeba1dd6a99b258d389995139
2022-02-23 15:48:55 +01:00
fanquake
f9b522e50d
Merge bitcoin/bitcoin#24426: test: Fix intermittent Tsan issue
fa7e1471c0 test: Fix intermittent Tsan issue (MarcoFalke)

Pull request description:

  Fix https://cirrus-ci.com/task/5176769937408000?logs=ci#L5161

  ```
  WARNING: ThreadSanitizer: data race (pid=22965)
    Write of size 8 at 0x7f74d5e21f50 by main thread:
      #0 std::__1::ios_base::precision(long) /usr/lib/llvm-13/bin/../include/c++/v1/ios:513:18 (test_bitcoin+0x1a8366)
      #1 boost::io::ios_base_all_saver::restore() /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/io/ios_state.hpp:341:17 (test_bitcoin+0x1a8366)
      #2 boost::unit_test::unit_test_log_t::operator<<(boost::unit_test::log::begin const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_log.ipp:336:55 (test_bitcoin+0x1a8366)
      #3 boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, unsigned long, ...) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/test_tools.ipp:359:19 (test_bitcoin+0x1b3b9b)
      #4 txindex_tests::txindex_initial_sync::test_method() src/test/txindex_tests.cpp:31:5 (test_bitcoin+0x78aebc)
      #5 txindex_tests::txindex_initial_sync_invoker() src/test/txindex_tests.cpp:16:1 (test_bitcoin+0x78a384)
      #6 boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:117:11 (test_bitcoin+0x2bf30d)
      #7 boost::function0<void>::operator()() const /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x224027)
      #8 boost::detail::forward::operator()() /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1368:32 (test_bitcoin+0x224027)
      #9 boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:137:18 (test_bitcoin+0x224027)
      #10 boost::function0<int>::operator()() const /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x1ac66c)
      #11 int boost::detail::do_invoke<boost::shared_ptr<boost::detail::translator_holder_base>, boost::function<int ()> >(boost::shared_ptr<boost::detail::translator_holder_base> const&, boost::function<int ()> const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:290:30 (test_bitcoin+0x1ac66c)
      #12 boost::execution_monitor::catch_signals(boost::function<int ()> const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:879:16 (test_bitcoin+0x1ac66c)
      #13 boost::execution_monitor::execute(boost::function<int ()> const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1277:16 (test_bitcoin+0x1ac980)
      #14 boost::execution_monitor::vexecute(boost::function<void ()> const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1377:5 (test_bitcoin+0x1a7f9b)
      #15 boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_monitor.ipp:49:9 (test_bitcoin+0x1a7f9b)
      #16 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:823:44 (test_bitcoin+0x1e0d5c)
      #17 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:792:58 (test_bitcoin+0x1e14a6)
      #18 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:792:58 (test_bitcoin+0x1e14a6)
      #19 boost::unit_test::framework::run(unsigned long, bool) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:1696:29 (test_bitcoin+0x1a6bfb)
      #20 boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_main.ipp:248:9 (test_bitcoin+0x1c4ed6)
      #21 main /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_main.ipp:304:12 (test_bitcoin+0x1c5506)
    Previous write of size 8 at 0x7f74d5e21f50 by thread T4:
      [failed to restore the stack]
    Location is global 'std::__1::cout' of size 160 at 0x7f74d5e21f30 (libc++.so.1+0x0000000cdf50)
    Thread T4 'b-txindex' (tid=22989, running) created by main thread at:
      #0 pthread_create <null> (test_bitcoin+0x1184cd)
      #1 std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) /usr/lib/llvm-13/bin/../include/c++/v1/__threading_support:514:10 (test_bitcoin+0xa23f1b)
      #2 std::__1:🧵:thread<void (*)(char const*, std::__1::function<void ()>), char const*, BaseIndex::Start(CChainState&)::$_0, void>(void (*&&)(char const*, std::__1::function<void ()>), char const*&&, BaseIndex::Start(CChainState&)::$_0&&) /usr/lib/llvm-13/bin/../include/c++/v1/thread:307:16 (test_bitcoin+0xa23f1b)
      #3 BaseIndex::Start(CChainState&) src/index/base.cpp:363:21 (test_bitcoin+0xa23f1b)
      #4 txindex_tests::txindex_initial_sync::test_method() src/test/txindex_tests.cpp:31:5 (test_bitcoin+0x78adfa)
      #5 txindex_tests::txindex_initial_sync_invoker() src/test/txindex_tests.cpp:16:1 (test_bitcoin+0x78a384)
      #6 boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:117:11 (test_bitcoin+0x2bf30d)
      #7 boost::function0<void>::operator()() const /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x224027)
      #8 boost::detail::forward::operator()() /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1368:32 (test_bitcoin+0x224027)
      #9 boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:137:18 (test_bitcoin+0x224027)
      #10 boost::function0<int>::operator()() const /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x1ac66c)
      #11 int boost::detail::do_invoke<boost::shared_ptr<boost::detail::translator_holder_base>, boost::function<int ()> >(boost::shared_ptr<boost::detail::translator_holder_base> const&, boost::function<int ()> const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:290:30 (test_bitcoin+0x1ac66c)
      #12 boost::execution_monitor::catch_signals(boost::function<int ()> const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:879:16 (test_bitcoin+0x1ac66c)
      #13 boost::execution_monitor::execute(boost::function<int ()> const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1277:16 (test_bitcoin+0x1ac980)
      #14 boost::execution_monitor::vexecute(boost::function<void ()> const&) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1377:5 (test_bitcoin+0x1a7f9b)
      #15 boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_monitor.ipp:49:9 (test_bitcoin+0x1a7f9b)
      #16 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:823:44 (test_bitcoin+0x1e0d5c)
      #17 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:792:58 (test_bitcoin+0x1e14a6)
      #18 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:792:58 (test_bitcoin+0x1e14a6)
      #19 boost::unit_test::framework::run(unsigned long, bool) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:1696:29 (test_bitcoin+0x1a6bfb)
      #20 boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_main.ipp:248:9 (test_bitcoin+0x1c4ed6)
      #21 main /tmp/cirrus-ci-build/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_main.ipp:304:12 (test_bitcoin+0x1c5506)
  SUMMARY: ThreadSanitizer: data race /usr/lib/llvm-13/bin/../include/c++/v1/ios:513:18 in std::__1::ios_base::precision(long)
  ==================
  Exit status: 2

ACKs for top commit:
  fanquake:
    CI ignored ACK fa7e1471c0

Tree-SHA512: 5194e026410b96ad3c8addeecce0a55ee0271c3cfac9fa0715345b1a50d59925549cee0a3e415e5837ae6d2f214a7b622c73cfc7fdf41d5e55c24fb87fddb9d1
2022-02-23 11:48:49 +00:00
glozow
40e871d9b4 [miner] always assume we can create witness blocks
Given the low possibility of a reorg reverting the segwit soft fork,
there is no need to check whether segwit is active here. Also,
TestBlockValidity is run on the block template after it has been
created.
2022-02-23 10:55:05 +00:00
MarcoFalke
3c565302aa
Merge bitcoin/bitcoin#24409: Always output license/copyright info with -version
5a89bed410 contrib: address gen-manpages feedback from #24263 (fanquake)
2618fb8d15 Output license info when binaries are passed -version (fanquake)
4c3e3c5746 refactor: shift CopyrightHolders() and LicenseInfo() to clientversion.cpp (fanquake)

Pull request description:

  Addresses a review comment from #24263, and addresses the [comment](https://github.com/bitcoin/bitcoin/pull/24263#issuecomment-1030582925) where it was pointed out that we are inconsistent with emitting  our copyright. After this change, the copyright is always emitted with `-version`, rather than `-help`, i.e:
  ```bash
  bitcoind -version

  Bitcoin Core version v22.99.0-fc1f355913f6-dirty
  Copyright (C) 2009-2022 The Bitcoin Core developers

  Please contribute if you find Bitcoin Core useful. Visit
  <https://bitcoincore.org/> for further information about the software.
  The source code is available from <https://github.com/bitcoin/bitcoin>.

  This is experimental software.
  Distributed under the MIT software license, see the accompanying file COPYING
  or <https://opensource.org/licenses/MIT>
  ```

  The info is also added to binaries other than `bitcoind`/`bitcoin-qt`. This change also prevents duplicate copyright info appearing in the `bitcoind` man page.

ACKs for top commit:
  laanwj:
    Tested ACK 5a89bed410

Tree-SHA512: 0ac2a1adf9e9de0c3206f35837008e3f93eaf15b193736203d71609273f0887cca20b8a90972cb9f941ebd62b330d61a0cbb5fb1b7a7f2dbc715ed8a0c1569d9
2022-02-23 09:39:42 +01:00