Commit graph

1394 commits

Author SHA1 Message Date
Jonas Schnelli
440f8d3abe fix potential devision by 0 2020-11-12 17:11:18 +01:00
Jon Atack
173b5b5fe0
wallet: update fee rate units, use sat/vB for fee_rate error messages
and BTC/kvB for feeRate error messages.
2020-11-12 11:43:03 +01:00
MarcoFalke
d9f5132736
Merge #20344: wallet: fix scanning progress calculation for single block range
5e146022da wallet: fix scanning progress calculation for single block range (Sebastian Falbesoner)

Pull request description:

  If the blockchain is rescanned for a single block (i.e. start and stop hashes are equal, and with that also the estimated start/stop verification progress values) the progress calculation could lead to a NaN value caused by a division by zero (0.0/0.0), resulting in an invalid JSON result for the `getwalletinfo` RPC.  This PR fixes this behaviour by setting the progress to zero in that special case. Fixes #20297.

  The behaviour can easily be reproduced by continuously running single block rescans in an endless loop, e.g. via
  ```bash
  #!/bin/bash
  while true
  do
      bitcoin-cli rescanblockchain $(bitcoin-cli getblockcount)
  done
  ```

  and at the same time perform some `getwalletinfo` RPCs.

  On the master branch, this leads to frequent invalid responses (tested on mainchain):
  ```
  $ bitcoin-cli getwalletinfo
  error: couldn't parse reply from server
  $ curl --user `cat ~/.bitcoin/.cookie` --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getwalletinfo", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
  {"result":{"walletname":"","walletversion":169900,"format":"bdb","balance":0.00000000,"unconfirmed_balance":0.00000000,"immature_balance":0.00000000,"txcount":0,"keypoololdest":1603677276,"keypoolsize":1000,"hdseedid":"3196e33ecb47c7130e6ca60f2f895f9259860dca","keypoolsize_hd_internal":1000,"paytxfee":0.00000000,"private_keys_enabled":true,"avoid_reuse":false,"scanning":{"duration":0,"progress":},"descriptors":false},"error":null,"id":"curltest"}
  ```
  (note that missing value for "progress" in the JSON result).

  On the PR branch, the behaviour doesn't occur anymore.

ACKs for top commit:
  MarcoFalke:
    review ACK 5e146022da
  promag:
    Core review ACK 5e146022da.

Tree-SHA512: f0e6aad5a6cd08b36c5fe820fff0ef26663229b39169a4dbe757f3c795a41cf5c69c9dc90efe7515675ae1059307f8971123781a0514d10704123a6f28b125ab
2020-11-11 16:11:01 +01:00
Sebastian Falbesoner
5e146022da wallet: fix scanning progress calculation for single block range
If the blockchain is rescanned for a single block (i.e. start and stop hashes
are equal, and with that also the estimated verification progress) the progress
calculation could lead to a NaN value caused by a division by zero, resulting in
an invalid JSON result for the getwalletinfo RPC.  Fixed by setting the progress
to zero in that special case.

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2020-11-11 13:15:00 +01:00
Andrew Poelstra
240f03f586 Merge cef87f7a48 into merged_master (Bitcoin PR #17290)
This one took a little bit of work. Basically everywhere that Andy's new code
didn't compile, I looked for a similarly shaped line in the pre-PR diff between
Bitcoin and Elements and adjusted it in the same way. Was pretty typical; all
CAmounts become CAmountMaps, etc.

I then spent about 7 hours chasing down a coin selection failure in the blocksign
functional tests, which ultimately turned out to be a Core issue. I added a
stopgap fix (commented, search for "stopgap" in wallet.cpp), and opened the issue
https://github.com/bitcoin/bitcoin/issues/20347

There was also a bug where we were not estimating change output sizes correctly
in case we had massive blinded outputs, which I had to fix to get the functional
tests to pass.
2020-11-10 21:59:56 +00:00
Andrew Poelstra
5c15120d59 Merge b7bc9b8330 into merged_master (Bitcoin PR #17444) 2020-11-09 23:10:13 +00:00
Andrew Poelstra
c1d327d827 Merge 4a3b6f47cd into merged_master (Bitcoin PR #17354) 2020-11-09 23:10:09 +00:00
Andrew Poelstra
cfde15703a Merge 99ab3a72c5 into merged_master (Bitcoin PR #15931) 2020-11-09 23:10:09 +00:00
Andrew Poelstra
9ec912e160 Merge 976cc766c4 into merged_master (Bitcoin PR #17381) 2020-11-09 23:10:08 +00:00
Andrew Poelstra
c3b2f1d8c0 Merge bdda137878 into merged_master (Bitcoin PR #16766) 2020-11-09 21:20:51 +00:00
Andrew Poelstra
84bc0faf8f Merge bbc9e4133c into merged_master (Bitcoin PR #17304) 2020-11-09 21:20:51 +00:00
Andrew Poelstra
751d0ac9f4 Merge 100fa0a62a into merged_master (Bitcoin PR #17300) 2020-11-09 21:20:48 +00:00
Andrew Poelstra
e910b15aa8 Merge 6a97e8a060 into merged_master (Bitcoin PR #17260) (multiple commits)
This is the start of some nontrivial wallet refactoring by achow. See
https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Class-Structure-Changes
for a high-level design.

This PR moves some stuff out of CWallet into a dummy "box" LegacyScriptPubKeyMan
which is (currently) very tightly coulped to CWallet. Because of the coupling there
are currently null-checks that cannot fail, things which assume non-nullness which
will eventually be wrong, and a plethora of currently-equivalent ways to get from
a CWallet to a provider or back.

Our approach is basically to ignore the refactoring; leave the blinding key stuff
in CWallet and have it call into the wallet's provider when we are obtaining the
underlying keys.

Later, probably in a post-rebase PR, we should rethink how we manage blinding keys
to more closely match Core's "all keys go into providers" model.
2020-11-09 21:20:47 +00:00
Andrew Poelstra
fc2108d672 Merge 8a191148db into merged_master (Bitcoin PR #17154) 2020-11-09 21:20:43 +00:00
Andrew Poelstra
42a1dc16a6 Merge a22b62481a into merged_master (Bitcoin PR #17070) 2020-11-09 21:20:43 +00:00
Andrew Poelstra
c08bbefb33 Merge 0d7e8d66c4 into merged_master (Bitcoin PR #17203) 2020-11-09 21:20:42 +00:00
Andrew Poelstra
821f5256a5 Merge 46d6930f8c into merged_master (Bitcoin PR #16659) 2020-11-09 21:20:41 +00:00
Andrew Poelstra
2640e37921 Merge a3af5b5c13 into merged_master (Bitcoin PR #17138) 2020-11-09 21:20:40 +00:00
Andrew Poelstra
0fbbfe35c3 Merge a689c11907 into merged_master (Bitcoin PR #16524) 2020-11-09 21:20:33 +00:00
Andrew Poelstra
ff55bb704c Merge 8d39c636aa into merged_master (Bitcoin PR #16952) 2020-11-09 21:20:32 +00:00
Andrew Poelstra
8fa52e84b0 Merge 8af835a72d into merged_master (Bitcoin PR #16796) 2020-11-09 21:20:23 +00:00
Andrew Poelstra
29e73c226a Merge 5e202382a9 into merged_master (Bitcoin PR #16624) 2020-11-09 21:20:21 +00:00
Andrew Poelstra
0003c1dd27 Merge 6e431296da into merged_master (Bitcoin PR #16745) 2020-11-09 21:20:20 +00:00
Andrew Poelstra
fd1ee6632c Merge e9ef1b2c2e into merged_master (Bitcoin PR #16716) 2020-11-09 21:20:20 +00:00
Andrew Poelstra
6e9332432f Merge a8ecd0dada into merged_master (Bitcoin PR #16753) 2020-11-09 21:20:19 +00:00
Andrew Poelstra
f35b9f02e1 Merge b499d8576f into merged_master (Bitcoin PR #16557) 2020-11-09 21:20:13 +00:00
Andrew Poelstra
c14d13f7fe Merge be0e8b4bff into merged_master (Bitcoin PR #15713) 2020-11-09 21:20:11 +00:00
Andrew Poelstra
62ce823f8f Merge c67ef2938c into merged_master (Elements PR #600)
Also uncommented a bunch of PSBT functional tests (had to add a fee output
to one transaction, update `find_output` to skip CT outputs, and change two
constant checks at the end of the commented-out section).
2020-11-09 21:20:10 +00:00
Andrew Poelstra
fc0be4dda7 Merge 00922b8720 into merged_master (Bitcoin PR #15906) 2020-11-09 21:20:10 +00:00
Andrew Poelstra
b584854f1b Merge 8241b51504 into merged_master (Bitcoin PR #16451) 2020-11-09 21:20:10 +00:00
Andrew Poelstra
cf718f2179 Merge 478fe328a7 into merged_master (Bitcoin PR #16475) 2020-11-09 21:20:09 +00:00
Andrew Poelstra
7b34c1b724 Merge 74ea1f3b0f into merged_master (Bitcoin PR #16399) 2020-11-09 21:20:09 +00:00
Andrew Poelstra
29e9ba5bc9 Merge dfb7fd60f2 into merged_master (Bitcoin PR #16402) 2020-11-09 21:20:08 +00:00
Andrew Poelstra
bf4ccc84dd Merge dbf4f3f86a into merged_master (Bitcoin PR #16301) 2020-11-09 21:20:08 +00:00
Andrew Poelstra
83019c2acd Merge d960d5ca99 into merged_master (Bitcoin PR #16362) 2020-11-09 21:20:08 +00:00
Andrew Poelstra
152198061a Merge 459baa1756 into merged_master (Bitcoin PR #16208) 2020-11-09 21:20:06 +00:00
Wladimir J. van der Laan
1dfe19e284
Merge #20153: wallet: do not import a descriptor with hardened derivations into a watch-only wallet
538be4219a wallet: fix importdescriptor silent fail (Ivan Metlushko)

Pull request description:

  Currently `importdescriptor` command will successfully import a descriptor with hardened derivations into a watch-only wallet while silently failing to expand the descriptor to fill the cache. This leads to a broken wallet state and failure to load such wallet due to missing cache on subsequent restart.

ACKs for top commit:
  laanwj:
    Code review ACK 538be4219a
  achow101:
    ACK 538be4219a
  meshcollider:
    utACK 538be4219a

Tree-SHA512: 4bdd0ab4437d55b3f1a79c3a300a0b186089155c020fe220a73d0cce274de47d90371d88918d39fd795f9fccf8db328f1e322d29a6062f9ce94a1c254398f004
2020-11-09 20:19:00 +01:00
Wladimir J. van der Laan
663fd92b28
Merge #20266: wallet: fix change detection of imported internal descriptors
bd93fc9945 Fix change detection of imported internal descriptors (Andrew Chow)

Pull request description:

  Import internal descriptors were having address book entries added which meant they would be detected as non-change. Fix this and add a test for it.

ACKs for top commit:
  laanwj:
    Code review ACK bd93fc9945
  meshcollider:
    utACK bd93fc9945
  promag:
    Code review ACK bd93fc9945.

Tree-SHA512: 8fa9e364be317627ec171eedffdb505976c0e7f1e55bc7e8cfdffa3aeea5db24d231f55166602cd0e97a5ba621acc871de0a765c75d0c65678f83e93c3b657c5
2020-11-09 15:14:45 +01:00
Andrew Poelstra
a50b652932 Merge 735d6b57e7 into merged_master (Bitcoin PR #16227) 2020-11-09 03:58:21 +00:00
Andrew Poelstra
082a6486a0 Merge 4fcccdac78 into merged_master (Bitcoin PR #16244) 2020-11-09 03:58:21 +00:00
Andrew Poelstra
8a94b6b2cb Merge ff0aad8a40 into merged_master (Bitcoin PR #16361) 2020-11-09 03:58:21 +00:00
Andrew Poelstra
7774f13936 Merge 6c1e45c4c4 into merged_master (Bitcoin PR #16322) 2020-11-09 03:58:21 +00:00
Andrew Poelstra
0065d674a4 Merge 8d1286014c into merged_master (Bitcoin PR #16237)
I'm sorry, this should have been a few commits, but it got away from me
as the scope of this refactoring was not immediately obvious. It essentially
just moves code around so hopefully is not too hard to review. --asp
2020-11-09 03:58:21 +00:00
Andrew Poelstra
15f0fb459f Merge 4882040182 into merged_master (Bitcoin PR #16291) 2020-11-09 03:58:20 +00:00
Andrew Poelstra
f7cb3a9645 Merge f373beebbc into merged_master (Bitcoin PR #16344) 2020-11-09 03:58:19 +00:00
Andrew Poelstra
62a63e4c6b Merge 8c69fae944 into merged_master (Bitcoin PR #15457) 2020-11-09 03:58:19 +00:00
Andrew Poelstra
969b50e413 Merge 1212808762 into merged_master (Bitcoin PR #16257) 2020-11-09 03:58:17 +00:00
Andrew Poelstra
d363ffe5e4 Merge ca80fec973 into merged_master (Bitcoin PR #16286) 2020-11-09 03:58:17 +00:00
Andrew Poelstra
4a70305bf8 Merge 44d8172323 into merged_master (Bitcoin PR #13756)
This PR introduces a `avoid_reuse` flag to the `getnewaddress` `sendtoaddress` `getbalance`
RPCs, which we've also added some asset-specific stuff. Since both changes have default
values they aren't individually breaking, but together they are since some existing
asset-related RPC workflows now require the user to jam a `False` in there to make
the new avoid-reuse stuff go away.
2020-11-06 15:20:16 +00:00
Andrew Poelstra
d4b074ad4b Merge d54d02bfe1 into merged_master (Elements PR #660) 2020-11-06 15:20:14 +00:00