Commit graph

57 commits

Author SHA1 Message Date
MarcoFalke fafc9d5af4
test: Fix intermittent issue in wallet_bumpfee 2020-08-24 13:49:28 +02:00
MarcoFalke fa347b2f25
test: Select at least the fee in wallet_bumpfee to avoid negative amounts 2020-08-24 13:44:07 +02:00
Samuel Dobson 8a85377cd0
Merge #18654: rpc: separate bumpfee's psbt creation function into psbtbumpfee
79d6332e9e moveonly: Fix indentation in bumpfee RPC (Andrew Chow)
431071c28a Hide bumpfee's psbt creation behavior behind -deprecatedrpc (Andrew Chow)
4638224f64 Add psbtbumpfee RPC (Andrew Chow)

Pull request description:

  Adds a new RPC `psbtbumpfee` which always creates a psbt. `bumpfee` will then only be able to create and broadcast fee bumping transactions instead of changing its behavior based on `IsWalletSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)`.

  Split from #18627

ACKs for top commit:
  Sjors:
    re-utACK 79d6332
  meshcollider:
    utACK 79d6332e9e
  fjahr:
    Code review ACK 79d6332e9e

Tree-SHA512: 1c92c4b4461bb30e78be3ee73165f624398ef33996ce36043b61a8931be667030d0fca12fd0b30097b78c56e4e9092c69582b237cbdac51d56f6be23d8c0f1bb
2020-08-13 12:21:11 +12:00
Sebastian Falbesoner dac7a111bd refactor: test: use _ variable for unused loop counters
substitutes "for x in range(N):" by "for _ in range(N):"
indicates to the reader that a block is just repeated N times, and
that the loop counter is not used in the body
2020-08-06 18:39:33 +02:00
Andrew Chow 4638224f64 Add psbtbumpfee RPC 2020-06-25 15:32:11 -04:00
Karl-Johan Alm 05227a3554
tests for bumpfee / estimate_modes
* invalid parameter tests for bumpfee
* add tests for no conf_target explicit estimate_modes
2020-06-24 16:01:38 +09:00
MarcoFalke fa2cce4391
wallet: Remove trailing whitespace from potential translation strings
If the potential translation strings are translated in the future,
trailing whitespace is going to make translation effort harder.
2020-05-01 07:41:32 -04:00
MarcoFalke fa301fec96
test: Fix wallet_bumpfee intermittent error 2020-04-28 11:53:00 -04:00
MarcoFalke 54f812d9d2
Merge #18673: scripted-diff: Sort test includes
fa4632c417 test: Move boost/stdlib includes last (MarcoFalke)
fa488f131f scripted-diff: Bump copyright headers (MarcoFalke)
fac5c37300 scripted-diff: Sort test includes (MarcoFalke)

Pull request description:

  When writing tests, often includes need to be added or removed. Currently the list of includes is not sorted, so developers that write tests and have `clang-format` installed will either have an unrelated change (sorting) included in their commit or they will have to manually undo the sort.

  This pull preempts both issues by just sorting all includes in one commit.

  Please be aware that this is **NOT** a change to policy to enforce clang-format or any other developer guideline or process. Developers are free to use whatever tool they want, see also #18651.

  Edit: Also includes a commit to bump the copyright headers, so that the touched files don't need to be touched again for that.

ACKs for top commit:
  practicalswift:
    ACK fa4632c417
  jonatack:
    ACK fa4632c417, light review and sanity checks with gcc build and clang fuzz build

Tree-SHA512: 130a8d073a379ba556b1e64104d37c46b671425c0aef0ed725fd60156a95e8dc83fb6f0b5330b2f8152cf5daaf3983b4aca5e75812598f2626c39fd12b88b180
2020-04-17 10:12:13 -04:00
MarcoFalke c2e53ff064
Merge #18467: rpc: Improve documentation and return value of settxfee
38677274f9 rpc: settxfee respects -maxtxfee wallet setting (Fabian Jahr)
bda84a08a0 rpc: Add documentation for deactivating settxfee (Fabian Jahr)

Pull request description:

  ~~Closes 18315~~

  `settxfee` can be deactivated by passing 0 as the fee. That does not seem to be documented for the user so this PR adds it in the description. The return value of a simple boolean seems also too simplified given the multiple dimensions that this deactivation feature enables. I.e. it does not seem intuitive if the returned boolean shows that the call succeeded or if means that `settxfee` is active. My suggested solution is to change the return value to a JSON object that included the "active" state and the currently set fee rate.

  Examples:
  ```
  $ src/bitcoin-cli settxfee 0.0000000
  {
    "active": false,
    "fee_rate": "0.00000000 BTC/kB"
  }
  $ src/bitcoin-cli settxfee 0.0001
  {
    "active": true,
    "fee_rate": "0.00010000 BTC/kB"
  }
  ```

ACKs for top commit:
  MarcoFalke:
    ACK 38677274f9, seems useful to error out early instead of later #16257 🕍
  jonatack:
    ACK 38677274f9
  meshcollider:
    LGTM, utACK 38677274f9

Tree-SHA512: 642813b5cf6612abb4b6cb63728081a6bd1659d809e0149c8f56060b6da7253fee989b3b202854f3051df3773c966799af30b612648c466b099f00590f356548
2020-04-17 07:55:55 -04:00
MarcoFalke fa488f131f
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
2020-04-16 13:33:09 -04:00
Fabian Jahr 38677274f9
rpc: settxfee respects -maxtxfee wallet setting 2020-04-14 15:52:42 +02:00
Jon Atack b224b4e7bd
test: wallet_bumpfee assertion fixup 2020-04-06 18:37:50 +02:00
Jon Atack 25e03ba1ff
test: relax bumpfee dust_to_fee txsize an extra vbyte
and add explanatory documentation for the reasoning.
2020-04-06 17:07:33 +02:00
Jon Atack e347cfa9a7
rpc: remove deprecated totalFee arg from RPC bumpfee 2020-03-26 17:54:18 +01:00
Jon Atack a6d1ab8caa
test: update bumpfee testing from totalFee to fee_rate 2020-03-22 11:02:54 +01:00
Gregory Sanders f1b4503114 bumpfee test: exit loop at proper time with new fee value being compared 2020-03-10 13:56:52 -04:00
Gregory Sanders 2e4edc68f9 Add some test logging to wallet_bumpfee.py 2020-03-10 13:56:52 -04:00
Gregory Sanders 091a876664 Test watchonly wallet bumpfee with PSBT return
Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
2019-12-18 09:03:36 -05:00
Gregory Sanders 02afb0c550 Fix origfee return for bumpfee with feerate arg 2019-12-01 20:54:16 -05:00
MarcoFalke 422ec33d45
Merge #17322: Fix input size assertion in wallet_bumpfee.py
38516f9078 Fix input size assertion in wallet_bumpfee.py (Gregory Sanders)

Pull request description:

  I was investigating a curious error for https://github.com/bitcoin/bitcoin/pull/17290 and realized that this check should have caught that error earlier in the test.

  The loop is intended to ensure that only a single input exists the entire time until the change output disappears, a single additional bump occurs, then it leaves the loop.

Top commit has no ACKs.

Tree-SHA512: 1d2d6ef535ec2c55f516ee5de11352386ceac6bedaabc6842229a486d9f28d35310ad5f57bfcc1f1e654fc397ecff29ec33256f9b3da897500b7e1635004b63a
2019-11-15 14:02:01 -05:00
Gregory Sanders 38516f9078 Fix input size assertion in wallet_bumpfee.py 2019-11-15 13:58:51 -05:00
Sebastian Falbesoner 8d8e5a79d0 test: use default address type (bech32) for wallet_bumpfee tests
The use of native segwit addresses (pure p2wpkh instead of p2sh-p2wpkh) leads
to smaller transaction sizes, needing adaption of some constants in the
following test cases:
    - test_dust_to_fee(): adaption of dust calculation
          (p2wpkh spend estimate of 67 is taken from src/policy/policy.cpp:GetDustThreshold())
    - test_maxtxfee_fails(): lowering -maxtxfee setting to trigger fail
2019-10-22 16:38:48 +02:00
Wladimir J. van der Laan fecc1be231
Merge #16884: wallet: Change default address type to bech32
71d4eddf42 Add release note for bech32 by default in wallet (Gregory Sanders)
b34f0180e3 Revert "gui: Generate bech32 addresses by default (take 2, fixup)" (Gregory Sanders)
f50785ab56 Change default address type to bech32 (Gregory Sanders)

Pull request description:

ACKs for top commit:
  MarcoFalke:
    re-ACK 71d4eddf42 (only change is restore mimick behavior)
  laanwj:
    ACK 71d4eddf42

Tree-SHA512: 3c49a1b51c49f3a762ad08985167ca1b89b0177ae20ab6d5883f1f74dde7a155921c1b855a842199bbf32f563c56b33f8b603bc842637bdcb121001023d454b6
2019-10-02 17:46:01 +02:00
Wladimir J. van der Laan 8afa602f30
Merge #16727: wallet: Explicit feerate for bumpfee
c812aba394 test bumpfee fee_rate argument (ezegom)
9f25de3d9e rpc bumpfee check fee_rate argument (ezegom)
88e5f997df rpc bumpfee: add fee_rate argument (ezegom)
1a4c791cf4 rpc bumpfee: move feerate estimation logic into separate method (ezegom)

Pull request description:

  Taking over for https://github.com/bitcoin/bitcoin/pull/16492 which seems to have gone inactive.

  Only minor commit cleanups, rebase, and some help text fixes on top of previous PR. Renamed `feeRate` to `fee_rate` to reflect updated guidelines.

ACKs for top commit:
  Sjors:
    Code review ACK c812aba
  laanwj:
    ACK c812aba394

Tree-SHA512: 5f7f51bd780a573ccef1ccd72b0faf3e5d143f6551060a667560c5163f7d9480e17e73775d1d7bcac0463f3b6b4328f0cff7b27e39483bddc42a530f4583ce30
2019-10-02 15:55:19 +02:00
ezegom c812aba394 test bumpfee fee_rate argument 2019-09-30 09:31:53 -04:00
Gregory Sanders f50785ab56 Change default address type to bech32 2019-09-26 16:23:32 -04:00
MarcoFalke fa3b9ee8b2
scripted-diff: test: Replace connect_nodes_bi with connect_nodes
-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended -e 's/connect_nodes_bi\(self.nodes,\s*(.),\s*/connect_nodes(self.nodes[\1], /g' $(git grep -l connect_nodes_bi)
sed -i --regexp-extended -e 's/connect_nodes_bi(,| )/connect_nodes\1/g'                                  $(git grep -l connect_nodes_bi)
-END VERIFY SCRIPT-
2019-09-17 13:08:21 -04:00
Gregory Sanders a92d9ce8cf deprecate totalFee argument in bumpfee RPC call 2019-07-26 14:09:03 -04:00
João Barbosa 5c1b9714cb wallet: Fix -maxtxfee check by moving it to CWallet::CreateTransaction 2019-07-02 16:13:39 +01:00
Wladimir J. van der Laan 6c21a801f3
Merge #15538: wallet_bumpfee.py: Make sure coin selection produces change
276972cb95 wallet_bumpfee.py: Make sure coin selection produces change (Gregory Sanders)

Pull request description:

  I was hitting the case where change-less transactions were being made.

ACKs for top commit:
  ryanofsky:
    utACK 276972cb95

Tree-SHA512: e2b7a50363daddd3ee749cacfc9d3d685a6c0c7e3e48118bb60131d205bf83ea06cdd66b69dfa3bd4dbb3bbf2b5b673d7225171486ae72fc762e5dabe2c01ef5
2019-07-02 14:49:26 +02:00
MarcoFalke fa52eb55c9
test: Remove True argument to CBlock::serialize
Unnamed arguments are confusing as to what they mean without looking up
the function signature.

Since segwit is active by default in regtest, and all blocks are
serialized with witness (#15664, c459c5f), remove the argument
`with_witness=True` from all calls to `CBlock::serialize` and
`BlockTransactions::serialize`.

This diff has been created with a script, but is better reviewed without
a scripted diff.

sed -i --regexp-extended -e 's/block(_?[2a-z]*)\.serialize\([a-z_]*=?True/block\1.serialize(/g' $(git grep -l serialize ./test)
2019-05-08 10:06:21 -04:00
MeshCollider 4f4ef3138b
Merge #15557: Enhance bumpfee to include inputs when targeting a feerate
184f8785f wallet_bumpfee.py: add test for change key preservation (Gregory Sanders)
d08becff8 add functional tests for feerate bumpfee with adding inputs (Gregory Sanders)
0ea47ba7b generalize bumpfee to add inputs when needed (Gregory Sanders)

Pull request description:

  When targeting a feerate using `bumpfee`, call a new function that directly uses `CWallet::CreateTransaction` and coin control to get the desired result. This allows us to get a superset of previous behavior, with an arbitrary RBF bump of a transaction provided it passes the preconditional checks and spare confirmed utxos are available.

  Note(s):
  0) The coin selection will use knapsack solver for the residual selection.
  1) This functionality, just like knapsack coin selection in general, will hoover up negative-value inputs when given the chance.
  2) Newly added inputs must be confirmed due to current Core policy. See error: `replacement-adds-unconfirmed`
  3) Supporting this with `totalFee` is difficult since the "minimum total fee" option in `CreateTransaction` logic was (rightly)taken out in #10390 .

ACKs for commit 184f87:
  jnewbery:
    utACK 184f8785f7

Tree-SHA512: fb6542bdfb2c6010e328ec475cf9dcbff4eb2b1a1b27f78010214534908987a5635797196fa05edddffcbcf2987335872dc644a99261886d5cbb34a8f262ad3e
2019-04-15 08:39:50 +12:00
Gregory Sanders 184f8785f7 wallet_bumpfee.py: add test for change key preservation 2019-04-11 07:21:49 -04:00
Gregory Sanders d08becff85 add functional tests for feerate bumpfee with adding inputs 2019-04-11 07:21:49 -04:00
MarcoFalke fafe5f0d09
test: Remove unused imports 2019-04-09 12:10:35 -04:00
MarcoFalke fa16a09215
scripted-diff: use self.sync_* methods
-BEGIN VERIFY SCRIPT-
sed -i -e 's/sync_blocks(self.nodes)/self.sync_blocks()/g'     $(git grep -l 'sync_blocks(self.nodes)'   ./test/functional/*.py)
sed -i -e 's/sync_mempools(self.nodes)/self.sync_mempools()/g' $(git grep -l 'sync_mempools(self.nodes)' ./test/functional/*.py)

sed -i -e 's/  sync_blocks(/  self.sync_blocks(/g'     $(git grep -l sync_blocks   ./test/functional/*.py)
sed -i -e 's/  sync_mempools(/  self.sync_mempools(/g' $(git grep -l sync_mempools ./test/functional/*.py)
-END VERIFY SCRIPT-
2019-04-09 12:09:53 -04:00
MarcoFalke faf77f9b90
test: Pass self to test_simple_bumpfee_succeeds
Needed for a future scripted diff
2019-04-09 12:09:36 -04:00
Gregory Sanders 276972cb95 wallet_bumpfee.py: Make sure coin selection produces change 2019-03-05 11:13:36 -05:00
MarcoFalke faa7cdf764
scripted-diff: Update copyright in ./test
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./test/
-END VERIFY SCRIPT-
2019-03-02 10:58:35 -05:00
MarcoFalke fa6bf21f5e
scripted-diff: test: Use py3.5 bytes::hex() method
-BEGIN VERIFY SCRIPT-
sed -i -e "s/def bytes_to_hex_str/def b_2_x/g" $(git grep -l bytes_to_hex_str)

export RE_B_0="[^()]*"                          # match no bracket
export RE_B_1="${RE_B_0}\(${RE_B_0}\)${RE_B_0}" # match exactly one ()
export RE_B_2="${RE_B_0}\(${RE_B_1}\)${RE_B_0}" # match wrapped (())

export RE_M="(b2x|bytes_to_hex_str)\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\)"

sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g"      $(git grep -l -E '(b2x|bytes_to_hex_str)')

sed -i --regexp-extended -e "/  +bytes_to_hex_str( as b2x)?,/d"    $(git grep -l bytes_to_hex_str)
sed -i --regexp-extended -e "s/ +bytes_to_hex_str( as b2x)?,//g"   $(git grep -l bytes_to_hex_str)
sed -i --regexp-extended -e "s/, bytes_to_hex_str( as b2x)?//g"    $(git grep -l bytes_to_hex_str)

export RE_M="(binascii\.)?hexlify\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\).decode\(${RE_B_0}\)"

sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g" $(git grep -l hexlify -- ':(exclude)share')

sed -i --regexp-extended -e  "/from binascii import hexlify$/d" $(git grep -l hexlify -- ':(exclude)share')
sed -i --regexp-extended -e "s/(from binascii import) .*hexlify/\1 unhexlify/g" $(git grep -l hexlify -- ':(exclude)share')

sed -i -e 's/ignore-names "/ignore-names "b_2_x,/g' ./test/lint/lint-python-dead-code.sh
-END VERIFY SCRIPT-
2019-03-02 10:40:12 -05:00
John Newbery 82f2fa03a5 [test] Remove deprecated addwitnessaddress from wallet_bumpfee.py 2018-09-23 08:51:57 -04:00
John Newbery 67d7d67cf3 [test] Fix flake8 warnings in tests
Fix all flake8 warnings in tests that are about to be updated
to remove addwitnessaddress
2018-09-23 08:50:47 -04:00
Wladimir J. van der Laan f09bc7ec98
Merge #12493: [wallet] Reopen CDBEnv after encryption instead of shutting down
c1dde3a949 No longer shutdown after encrypting the wallet (Andrew Chow)
d7637c5a3f After encrypting the wallet, reload the database environment (Andrew Chow)
5d296ac810 Add function to close all Db's and reload the databae environment (Andrew Chow)
a769461d5e Move BerkeleyEnvironment deletion from internal method to callsite (Andrew Chow)

Pull request description:

  This is the replacement for #11678 which implements @ryanofsky's [suggestion](https://github.com/bitcoin/bitcoin/pull/11678#pullrequestreview-76464511).

  Shutting down the software was to prevent the BDB environment from writing unencrypted private keys to disk in the database log files, as was noted [here](https://bitcointalk.org/index.php?topic=51474.msg616068#msg616068). This PR replaces the shutdown behavior with a CDBEnv flush, close, and reopen which achieves the same effect: everything is cleanly flushed and closed, the log files are removed, and then the environment reopened to continue normal operation.

  To ensure that no unencrypted private keys are in the log files after encrypting the wallet, I wrote [this script](https://gist.github.com/achow101/7f7143e6c3d3fdc034d3470e72823e9d) to pull private keys from the original wallet file and searches for these keys in the log files (note that you will have to change your file paths to make it work on your own machine).

  As for concerns about private keys being written to slack space or being kept in memory, these behaviors no longer exist after the original wallet encryption PR and the shutting down solution from 2011.

  cc @ryanofsky

Tree-SHA512: 34b894283b0677a873d06dee46dff8424dec85a2973009ac9b84bcf3d22d05f227c494168c395219d9aee3178e420cf70d4b3eeacc9785aa86b6015d25758e75
2018-09-14 10:43:35 +02:00
MarcoFalke fac9539836
qa: Run all tests even if wallet is not compiled 2018-09-10 17:53:21 -04:00
João Barbosa 317f2cb3f4 test: Check RPC settxfee errors 2018-08-21 10:52:40 +10:00
practicalswift 68400d8b96 tests: Use explicit imports 2018-08-13 14:13:39 +02:00
Andrew Chow c1dde3a949 No longer shutdown after encrypting the wallet
Since the database environment is flushed, closed, and reopened during
EncryptWallet, there is no need to shut down the software anymore.
2018-08-09 11:28:33 -07:00
DrahtBot eb7daf4d60 Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
MarcoFalke fa7a6cf1b3
policy: Treat segwit as always active 2018-05-29 16:49:52 -04:00