aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
AgeCommit message (Collapse)Author
2021-06-12Merge bitcoin/bitcoin#22156: Allow tr() import only when Taproot is activeW. J. van der Laan
fbf485c9b2bf1d056bfea77345a15cf56a9cd786 Allow tr() import only when Taproot is active (Andrew Chow) Pull request description: To avoid issues around fund loss, only allow descriptor wallets to import `tr()` descriptors after taproot has activated. ACKs for top commit: sipa: utACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786 fjahr: Code review ACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786 laanwj: Code review ACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786 prayank23: utACK https://github.com/bitcoin/bitcoin/pull/22156/commits/fbf485c9b2bf1d056bfea77345a15cf56a9cd786 Tree-SHA512: 83c43376515eea523dbc89bc5a0fde53e54aec492e49a40c2a33d80fc94aac459e232ae07b024b4bd75b58078c8d090bc7a2d69541c5d3d4834d2f4cfc9c8208
2021-06-12Merge bitcoin/bitcoin#22214: refactor: Rearrange fillPSBT argumentsfanquake
f47e8028391fbcf44fe1dbf3539f42e4185590fd Rearrange fillPSBT arguments (Russell Yanofsky) Pull request description: Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list). --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR #10102. ACKs for top commit: achow101: ACK f47e8028391fbcf44fe1dbf3539f42e4185590fd theStack: Code-review ACK f47e8028391fbcf44fe1dbf3539f42e4185590fd Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
2021-06-10Allow tr() import only when Taproot is activeAndrew Chow
To avoid issues around fund loss, only allow descriptor wallets to import tr() descriptors after taproot has activated.
2021-06-10scripted-diff: wallet/test: Use existing chainmanCarl Dong
-BEGIN VERIFY SCRIPT- git ls-files -- src/wallet/test \ | xargs sed -i -E \ -e 's@g_chainman\.m_blockman@m_node.chainman->m_blockman@g' \ -e 's@([^:])(Chain(state|)Active)@\1::\2@g' \ -e 's@::Chain(state|)Active\(\)@m_node.chainman->ActiveChain\1()@g' -END VERIFY SCRIPT-
2021-06-10Rearrange fillPSBT argumentsRussell Yanofsky
Move fillPSBT input-output argument before output-only arguments. This is a temporary workaround which can go away with improvements to libmultiprocess code generator. Currently code generator figures out order of input-output parameters by looking at input list, but it would make more sense for it to take order from output list, so input-only parameters still have to be first but there is more flexibility for the other parameters.
2021-06-09Merge bitcoin/bitcoin#22173: wallet: Do not load external signers wallets ↵Samuel Dobson
when unsupported e60cd26ad46559770ad84d2959c9a1742ae8b7a6 Do not load external signers wallets when unsupported (Andrew Chow) Pull request description: When external signer support is not compiled, do not load external signer wallets. Alternative to #22168. ACKs for top commit: promag: Tested ACK e60cd26ad46559770ad84d2959c9a1742ae8b7a6. meshcollider: Code review ACK e60cd26ad46559770ad84d2959c9a1742ae8b7a6 Tree-SHA512: aed2d0038f448c2f89c6b48f412b106e63c9ed20e748e69aae21fb58c33fc7e4fa73375a52372c73788669eb2b968a8da6b022c65658fa4484f5bbcf205b1b15
2021-06-09Merge bitcoin/bitcoin#21944: wallet: Fix issues when `walletdir` is root ↵Samuel Dobson
directory d44a261acff40c1c8727d3cc0106bde65a6416d0 Fix issues when `walletdir` is root directory (unknown) Pull request description: + Remove one character less from wallet path + After testing lot of random strings with special chars in `wallet_name`, I found that the issue was not related to special characters in the name. Reviewing PR https://github.com/bitcoin/bitcoin/pull/21907 helped me resolve the issue. **Real issue**: If the path mentioned in `walletdir` is a root directory, first character of the wallet name or path is removed **Solution**: `if` statement to check `walletdir` is a root directory Fixes: https://github.com/bitcoin/bitcoin/issues/21510 https://github.com/bitcoin/bitcoin/issues/21501 Related PR: https://github.com/bitcoin/bitcoin/pull/20080 Consider the wallet directories `w1` and `w2` saved in `D:\`. Run `bitcoind.exe -walletdir=D:\`, Results for `bitcoin-cli.exe listwalletdir`: Before this PR: ``` { "wallets": [ { "name": "1" }, { "name": "2" } ] } ``` After this PR: ``` "wallets": [ { "name": "w1" }, { "name": "w2" } ] } ``` ACKs for top commit: ryanofsky: Code review ACK d44a261acff40c1c8727d3cc0106bde65a6416d0 meshcollider: utACK d44a261acff40c1c8727d3cc0106bde65a6416d0 Tree-SHA512: b09b00f727407e3771c8694861dae1bfd29d97a0d51ddcb5d9c0111dc618b3fff2f75829cbb4361c54457ee564e94fcefd9e2928262a1c918a2b6bbad724eb55
2021-06-09Merge bitcoin/bitcoin#22008: wallet: Cleanup and refactor ↵Samuel Dobson
CreateTransactionInternal 96c2c9520e80ee4fed92f0e1ab859d59fcbdb110 scripted-diff: Rename SelectCoinsMinConf to AttemptSelection (Andrew Chow) b583f73354c617ede9145f9738f13cedf1c13e08 Move vin filling to before final fee setting (Andrew Chow) d39cac0547c960df0a890e89f43b458147b4b07a Set m_subtract_fee_outputs during recipients vector loop (Andrew Chow) 364e0698a543a19e81ae407cc523970e6ed924e8 Move variable initializations to where they are used (Andrew Chow) 32ab430651594ed3d10a6ed75f19de5197f0e9b0 Move recipients vector checks to beginning of CreateTransaction (Andrew Chow) cd1d6d3324a841087f6d5da723394e8d7df07ec7 Rename nSubtractFeeFromAmount in CreateTransaction (Andrew Chow) dac21c793f8fbb4d5debc55ac97c406c7c93ff48 Rename nValue and nValueToSelect (Andrew Chow) d2aee3bbc765a1f02e4ceadb2fa5928ac524f1a7 Remove extraneous scope in CreateTransactionInternal (Andrew Chow) b2995963b5d0b9bca503b0cc69c747f4cedec1e4 Move cs_wallet lock in CreateTransactionInternal to top of function (Andrew Chow) Pull request description: #17331 did some refactors and cleanup of `CreateTransactionInternal` to make it easier to understand, however it is still a bit convoluted even though it doesn't have to be. This PR does additional cleanup and refactoring to `CreateTransactionInternal` so that it is easier to understand. Some unnecessary code was removed, some variables moved around to where they matter, and several indents removed. ACKs for top commit: glozow: reACK 96c2c95 ryanofsky: Code review ACK 96c2c9520e80ee4fed92f0e1ab859d59fcbdb110 also acked previously (was reverted). meshcollider: re-utACK 96c2c9520e80ee4fed92f0e1ab859d59fcbdb110 Tree-SHA512: 3dba67ed436968a07bfd82d435d566ad74e116c6e50ac9baed7144a46ad5c0f630b1ba59d91e8e8972ac2af559d7c0576f0560f09684d2ab20fad6689902866f
2021-06-09Merge bitcoin-core/gui#4: UI external signer support (e.g. hardware wallet)Samuel Dobson
1c4b456e1a0ccf0397d652f8c18201c3224c5c21 gui: send using external signer (Sjors Provoost) 24815c6309431cb0797defaf7add1150bcf4b567 gui: wallet creation detects external signer (Sjors Provoost) 3f845ea2994f53e29abeb3fa158c35f1ee56e7e8 node: add externalSigners to interface (Sjors Provoost) 62ac119f919ae1160ed67af796f24b78025fa8e3 gui: display address on external signer (Sjors Provoost) 450cb40a344605dda3bcc39495c35869580b9fc2 wallet: add displayAddress to interface (Sjors Provoost) eef8d6452962cd4a8956d9ad268164715365b9ab gui: create wallet with external signer (Sjors Provoost) 6cdbc83e9341d1552faee4ccd8c190babc63e8d1 gui: add external signer path to options dialog (Sjors Provoost) Pull request description: Big picture overview in [this gist](https://gist.github.com/Sjors/29d06728c685e6182828c1ce9b74483d). This PR adds GUI support for external signers, based on the since merged bitcoin/bitcoin#16546 (RPC). The UX isn't amazing - especially the blocking calls - but it works. First we adds a GUI setting for the signer script (e.g. path to HWI): <img width="625" alt="Schermafbeelding 2019-08-05 om 19 32 59" src="https://user-images.githubusercontent.com/10217/62483415-e1ff1680-b7b7-11e9-97ca-8d2ce54ca1cb.png"> Then we add an external signer checkbox to the wallet creation dialog: <img width="374" alt="Schermafbeelding 2019-11-07 om 19 17 23" src="https://user-images.githubusercontent.com/10217/68416387-b57ee000-0194-11ea-9730-127d60273008.png"> It's checked by default if HWI detects a device. It also grabs the name. It then creates a fresh wallet and imports the keys. You can verify an address on the device (blocking...): <img width="673" alt="Schermafbeelding 2019-08-05 om 19 29 22" src="https://user-images.githubusercontent.com/10217/62483560-43bf8080-b7b8-11e9-9902-8a036116dc4b.png"> Sending, including coin selection, Just Works(tm) as long the device is present. ~External signer support is enabled by default when the GUI is configured and Boost::Process is present.~ External signer support remains disabled by default, see https://github.com/bitcoin/bitcoin/pull/21935. ACKs for top commit: achow101: Code Review ACK 1c4b456e1a0ccf0397d652f8c18201c3224c5c21 hebasto: ACK 1c4b456e1a0ccf0397d652f8c18201c3224c5c21, tested on Linux Mint 20.1 (Qt 5.12.8) with HWW `2.0.2-rc.1`. promag: Tested ACK 1c4b456e1a0ccf0397d652f8c18201c3224c5c21 but rebased with e033ca1379, with HWI 2.0.2, with Nano S and Nano X. meshcollider: re-code-review ACK 1c4b456e1a0ccf0397d652f8c18201c3224c5c21 Tree-SHA512: 3503113c5c69d40adb6ce364d8e7cae23ce82d032a00474ba9aeb6202eb70f496ef4a6bf2e623e5171e524ad31ade7941a4e0e89539c64518aaec74f4562d86b
2021-06-06Do not load external signers wallets when unsupportedAndrew Chow
When external signer support is not compiled, do not load external signer wallets.
2021-06-03Merge bitcoin/bitcoin#22051: Basic Taproot derivation support for descriptorsW. J. van der Laan
2667366aaa69447a9de4d819669d254a5ebd4d4b tests: check derivation of P2TR (Pieter Wuille) 7cedafc5412857404e9a6c3450b100cb8ee4081a Add tr() descriptor (derivation only, no signing) (Pieter Wuille) 90fcac365e1616779b40a69736428435df75fdf2 Add TaprootBuilder class (Pieter Wuille) 5f6cc8daa83700d1c949d968a5cf0d935be337b7 Add XOnlyPubKey::CreateTapTweak (Pieter Wuille) 2fbfb1becb3c0c109cd7c30b245b51da22039932 Make consensus checking of tweaks in pubkey.* Taproot-specific (Pieter Wuille) a4bf84039c00b196b87f969acf6369d72c56ab46 Separate WitnessV1Taproot variant in CTxDestination (Pieter Wuille) 41839bdb89b3777ece2318877b9c7921ecca2472 Avoid dependence on CTxDestination index order (Pieter Wuille) 31df02a07091dbd5e0b315c8e5695e808f3a5505 Change Solver() output for WITNESS_V1_TAPROOT (Pieter Wuille) 4b1cc08f9f94a1e6e1ecba6b97f99b73fb513872 Make XOnlyPubKey act like byte container (Pieter Wuille) Pull request description: This is a subset of #21365, to aide review. This adds support `tr(KEY)` or `tr(KEY,SCRIPT)` or `tr(KEY,{{S1,{{S2,S3},...}},...})` descriptors, describing Taproot outputs with specified internal key, and optionally any number of scripts, in nested groups of 2 inside `{`/`}` if there are more than one. While it permits importing `tr(KEY)`, anything beyond that is just laying foundations for more features later. Missing: * Signing support (see #21365) * Support for more interesting scripts inside the tree (only `pk(KEY)` is supported for now). In particular, a multisig policy based on the new `OP_CHECKSIGADD` opcode would be very useful. * Inferring `tr()` descriptors from outputs (given sufficient information). * `getaddressinfo` support. * MuSig support. Standardizing that is still an ongoing effort, and is generally kind of useless without corresponding PSBT support. * Convenient ways of constructing descriptors without spendable internal key (especially ones that arent't trivially recognizable as such). ACKs for top commit: Sjors: utACK 2667366 (based on https://github.com/bitcoin/bitcoin/pull/21365#issuecomment-846945215 review, plus the new functional test) achow101: Code Review ACK 2667366aaa69447a9de4d819669d254a5ebd4d4b lsilva01: Tested ACK https://github.com/bitcoin/bitcoin/pull/22051/commits/2667366aaa69447a9de4d819669d254a5ebd4d4b meshcollider: utACK 2667366aaa69447a9de4d819669d254a5ebd4d4b Tree-SHA512: 61046fef22c561228338cb178422f0b782ef6587ec8208d3ce2bd07afcff29a664b54b35c6b01226eb70b6540b43f6dd245043d09aa6cb6db1381b6042667e75
2021-06-03Merge bitcoin/bitcoin#21353: interfaces: Stop exposing wallet destdata to guiW. J. van der Laan
f5ba424cd44619d9b9be88b8593d69a7ba96db26 wallet: Add IsAddressUsed / SetAddressUsed methods (Russell Yanofsky) 62252c95e5aa55f33a5ef22292d5d8161fcb892a interfaces: Stop exposing wallet destdata to gui (Russell Yanofsky) 985430d9b2e183c1f59a34472e413a8d00a7e6da test: Add gui test for wallet receive requests (Russell Yanofsky) Pull request description: Stop giving GUI access to destdata rows in database. Replace with narrow API just for saving and reading receive request information. This simplifies code and should prevent the GUI from interfering with other destdata like address-used status. It also adds some more GUI test coverage. There are no changes in behavior. ACKs for top commit: jarolrod: tACK f5ba424cd44619d9b9be88b8593d69a7ba96db26 laanwj: Code review ACK f5ba424cd44619d9b9be88b8593d69a7ba96db26 Tree-SHA512: 5423df4786e537a59013cb5bfb9e1bc29a7ca4b8835360c00cc2165a59f925fdc355907a4ceb8bca0285bb4946ba235bffa7645537a951ad03fd3b4cee17b6b0
2021-06-01Fix issues when `walletdir` is root directoryunknown
+ Remove one character less from wallet path if root directory
2021-05-31refactor: Switch serialize to uint8_t (1/n)MarcoFalke
2021-05-30scripted-diff: Rename SelectCoinsMinConf to AttemptSelectionAndrew Chow
SelectCoinsMinConf is a bit of a misnomer now since it really just does all of the coin selection given some parameters. So rename this to something less annoying to say and makes a bit more sense. -BEGIN VERIFY SCRIPT- sed -i 's/SelectCoinsMinConf/AttemptSelection/g' $(git grep -l SelectCoinsMinConf ./src) -END VERIFY SCRIPT-
2021-05-30Move vin filling to before final fee settingAndrew Chow
It's unnecessary to fill in the vin with dummy inputs, calculate the fee, then fill in the vin with the actual inputs. Just fill the vin with the actual inputs the first time.
2021-05-30Set m_subtract_fee_outputs during recipients vector loopAndrew Chow
Instead of setting this afterwards based on the results from the loop, just do it inside of the loop itself. Fixed some styling nearby
2021-05-30Move variable initializations to where they are usedAndrew Chow
- txNew nLockTime setting to txNew init - FeeCalc to the fee estimation fetching - setCoins to prior to SelectCoins - nBytes to CalculateMaximumSignedTxSize call - tx_sizes to CalculateMaximumSignedTxSize call - coin_selection_params.m_avoid_partial_spends to params init
2021-05-30Move recipients vector checks to beginning of CreateTransactionAndrew Chow
Ensuring that the recipients vector is not empty and that the amounts are non-negative can be done in CreateTransaction rather than CreateTransactionInternal. Additionally, these checks should happen as soon as possible, so they are done at the beginning of CreateTransaction.
2021-05-30Rename nSubtractFeeFromAmount in CreateTransactionAndrew Chow
Renamed to outputs_to_subtract_fee_from for clarity.
2021-05-30Rename nValue and nValueToSelectAndrew Chow
nValue is the sum of the intended recipient amounts, so name it that for clarity. nValueToSelect is the coin selection target value, so name it selection_target for clarity.
2021-05-30Remove extraneous scope in CreateTransactionInternalAndrew Chow
These brackets were restricting a scope for no apparent reason. Remove them and dedent.
2021-05-30Move cs_wallet lock in CreateTransactionInternal to top of functionAndrew Chow
It isn't necessary to not lock parts of this function. Just lock the whole thing and get rid of an indent.
2021-05-30Merge bitcoin/bitcoin#21207: MOVEONLY: CWallet transaction code out of ↵Samuel Dobson
wallet.cpp/.h c7bd5842e467c4fc286399379572bbdec6b26a4f MOVEONLY: CWallet transaction code out of wallet.cpp/.h (Russell Yanofsky) Pull request description: This commit just moves function without making any changes. It can be reviewed with `git log -p -n1 --color-moved=dimmed_zebra` Motivation for this change is to make `wallet.cpp/h` less monolithic and start to make wallet transaction state tracking comprehensible so bugs in https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Transaction-Conflict-Tracking can be fixed safely without introducing new problems. This moves wallet classes and methods that deal with transactions out of `wallet.cpp/.h` into better organized files: - `transaction.cpp/.h` - CWalletTx and CMerkleTx class definitions - `receive.cpp/.h` - functions checking received transactions and computing balances - `spend.cpp/.h` - functions creating transactions and finding spendable coins After #20773, when loading is separated from syncing it will also be possible to move more `wallet.cpp/.h` functions to: - `sync.cpp/.h` - functions handling chain notifications and rescanning This commit arranges `receive.cpp` and `spend.cpp` functions in dependency order so it's possible to skim `receive.cpp` and get an idea of how computing balances works, and skim `spend.cpp` and get an idea of how transactions are created, without having to jump all over `wallet.cpp` where functions are not in order and there is a lot of unrelated code. Followup commit "refactor: Detach wallet transaction methods" in https://github.com/bitcoin/bitcoin/pull/21206 follows up this PR and tweaks function names and arguments to reflect new locations. The two commits are split into separate PRs because this commit is more work to maintain and less work to review, while the other commit is less work to maintain and more work to review, so hopefully this commit can be merged earlier. ACKs for top commit: Sjors: re-utACK c7bd5842e467c4fc286399379572bbdec6b26a4f fjahr: utACK c7bd5842e467c4fc286399379572bbdec6b26a4f promag: Code review ACK c7bd5842e467c4fc286399379572bbdec6b26a4f, verified move only claim. meshcollider: Dimmed-zebra-check and functional test run ACK c7bd5842e467c4fc286399379572bbdec6b26a4f Tree-SHA512: 4981de6911cb1196774db375494355cc9af59b52456129c002d264a77cd9ed6175f8ecbb6b2f492a59a4d5a0def21a39d96fa79c9f4d99be0992985f553be32f
2021-05-27gui: display address on external signerSjors Provoost
2021-05-27wallet: add displayAddress to interfaceSjors Provoost
2021-05-27scripted-diff: Fix ellipsis after pr20773Hennadii Stepanov
-BEGIN VERIFY SCRIPT- sed -i 's|_("Loading wallet...")|_("Loading wallet…")|' src/wallet/*.cpp -END VERIFY SCRIPT-
2021-05-26MOVEONLY: CWallet transaction code out of wallet.cpp/.hRussell Yanofsky
This commit just moves functions without making any changes. It can be reviewed with `git log -p -n1 --color-moved=dimmed_zebra` Motivation for this change is to make wallet.cpp/h less monolithic and start to make wallet transaction state tracking comprehensible so bugs in https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Transaction-Conflict-Tracking can be fixed safely without introducing new problems. This commit moves wallet classes and methods that deal with transactions out of wallet.cpp/.h into better organized files: - transaction.cpp/.h - CWalletTx and CMerkleTx class definitions - receive.cpp/.h - functions checking received transactions and computing balances - spend.cpp/.h - functions creating transactions and finding spendable coins After #20773, when loading is separated from syncing it will also be possible to move more wallet.cpp/.h functions to: - sync.cpp/.h - functions handling chain notifications and rescanning This commit arranges receive.cpp and spend.cpp functions in dependency order so it's possible to skim receive.cpp and get an idea of how computing balances works, and skim spend.cpp and get an idea of how transactions are created, without having to jump all over wallet.cpp where functions are not in order and there is a lot of unrelated code. Followup commit "refactor: Detach wallet transaction methods" in https://github.com/bitcoin/bitcoin/pull/21206 follows up this PR and tweaks function names and arguments to reflect new locations. The two commits are split into separate PRs because this commit is more work to maintain and less work to review, while the other commit is less work to maintain and more work to review, so hopefully this commit can be merged earlier.
2021-05-26Merge bitcoin/bitcoin#18418: wallet: Increase OUTPUT_GROUP_MAX_ENTRIES to 100fanquake
e6fe1c37d0a2f8037996dd80619d6c23ec028729 rpc: Improve avoidpartialspends and avoid_reuse documentation (Fabian Jahr) 8f073076b102b77897e5a025ae555baae3d1f671 wallet: Increase OUTPUT_GROUP_MAX_ENTRIES to 100 (Fabian Jahr) Pull request description: Follow-up to #17824. This increases OUTPUT_GROUP_MAX_ENTRIES to 100 which means that OutputGroups will now be up to 100 outputs large, up from previously 10. The main motivation for this change is that during the PR review club on #17824 [several participants signaled](https://bitcoincore.reviews/17824.html#l-339) that 100 might be a better value here. I think fees should be manageable for users but more importantly, users should know what they can expect when using the wallet with this configuration, so I also tried to clarify the documentation on `-avoidpartialspends` and `avoid_reuse` a bit. If there are other additional ways how or docs where users can be made aware of the potential consequences of using these parameters, please let me know. Another small upside is that [there seem to be a high number of batching transactions with 100 and 200 inputs](https://miro.medium.com/max/3628/1*sZ5eaBSbsJsHx-J9iztq2g.png)([source](https://medium.com/@hasufly/an-analysis-of-batching-in-bitcoin-9bdf81a394e0)) giving these transactions a bit of a larger anonymity set, although that is probably a very weak argument. ACKs for top commit: jnewbery: ACK e6fe1c37d0 Xekyo: retACK e6fe1c37d0a2f8037996dd80619d6c23ec028729 rajarshimaitra: tACK `e6fe1c3` achow101: ACK e6fe1c37d0a2f8037996dd80619d6c23ec028729 glozow: code review ACK https://github.com/bitcoin/bitcoin/pull/18418/commits/e6fe1c37d0a2f8037996dd80619d6c23ec028729 Tree-SHA512: 79685c58bafa64ed8303b0ecd616fce50fc9a2b758aa79833e4ad9f15760e09ab60c007bc16ab4cbc4222e644cfd154f1fa494b0f3a5d86faede7af33a6f2826
2021-05-26Replace size/weight estimate tuple with struct for named fieldsGregory Sanders
2021-05-26Merge bitcoin/bitcoin#17331: Use effective values throughout coin selectionSamuel Dobson
51a3ac242c92e69b59df26f8f9e287b31e5c3b0f Have OutputGroup determine the value to use (Andrew Chow) 6d6d2784759878ef0c4ac128d12aac68add1edca Change SelectCoins_test to actually test SelectCoins (Andrew Chow) 9d3bd74ab4430532d6e53eef8cf77ad999044b14 Remove CreateTransaction while loop and some related variables (Andrew Chow) 6f0d5189af4c881fe8b97a0c28ce1ffa33480715 Remove use_bnb and bnb_used (Andrew Chow) de26eb0e1fa2b6f03c58ba104d00f7a8ffead39c Do both BnB and Knapsack coin selection in SelectCoinsMinConf (Andrew Chow) 01dc8ebda50a382d45d3d169b2c3f3965869dcae Have KnapsackSolver actually use effective values (Andrew Chow) bf26e018de33216d6f0ed0d6ff822b93536f7cc1 Roll static tx fees into nValueToSelect instead of having it be separate (Andrew Chow) cc3f14b27c06b7a0da1472f5c7100c3f0b76fd98 Move output reductions for fee to after coin selection (Andrew Chow) d97d25d95006725e705635530b27643363d6b2a4 Make cost_of_change part of CoinSelectionParams (Andrew Chow) af5867c89688b06173b295b7c32a42845ea455da Move some calculations to common code in SelectCoinsMinConf (Andrew Chow) 1bf4a62cb61bd4b91d9cd4e379fea2b914786342 scripted-diff: rename some variables (Andrew Chow) Pull request description: Changes `KnapsackSolver` to use effective values instead of just the nominal txout value. Since fees are taken into account during the selection itself, we finally get rid of the `CreateTransaction` loop as well as a few other things that only were only necessary because of that loop. This should not change coin selection behavior at all (except maybe remove weird edge cases that were caused by the loop). In order to keep behavior the same, `KnapsackSolver` will select outputs with a negative effective value (as it did before). ACKs for top commit: ryanofsky: Code review ACK 51a3ac242c92e69b59df26f8f9e287b31e5c3b0f. Looks good to go! instagibbs: review ACK https://github.com/bitcoin/bitcoin/pull/17331/commits/51a3ac242c92e69b59df26f8f9e287b31e5c3b0f meshcollider: re-light-utACK 51a3ac242c92e69b59df26f8f9e287b31e5c3b0f Tree-SHA512: 372c27e00edcd5dbf85177421ba88f20bfdaf1791b6e3dc022c44876ecc379403e2375ed69e71c512c49e6af87641001ff385c4b25ab93684b3a08a53bf3824e
2021-05-25Merge bitcoin/bitcoin#22021: rpc: bumpfee/psbtbumpfee fixes and updatesMarcoFalke
4f504f826bcbb1a4aa4701e87cb68da4ca05b857 rpc: fix code comment for bumpfee/psbtbumpfee output (Jon Atack) 5cb7ac23fb97a0cbc75b7eef0951da0e0bc5292b rpc: fix docs for bumpfee psbt update (Jon Atack) Pull request description: Follow-up to #21544 and #20891 for the `bumpfee_helper` used for RPCs bumpfee and psbtbumpfee: - "psbt" field is only returned in psbtbumpfee and not bumpfee - bumpfee raises if private keys are disabled, so the txid help "Only returned when wallet private keys are enabled." no longer makes sense; remove it - add missing space in RPC examples ("Bump the fee, get the new transaction'stxid") - update txid/psbt code comments ACKs for top commit: klementtan: ACK [`4f504f8`](https://github.com/bitcoin/bitcoin/pull/22021/commits/4f504f826bcbb1a4aa4701e87cb68da4ca05b857) Tree-SHA512: 194faf8af52383eb8ac5cd22825265931bcde135dac79d8ecc4f84f698070da9b9373c00eef8623961881bb293157c7c9a0d71d1bcccf481ae3605a2d1444ed8
2021-05-24Separate WitnessV1Taproot variant in CTxDestinationPieter Wuille
2021-05-24scripted-diff: Replace `GetDataDir()` calls with `gArgs.GetDataDirNet()` callsKiminuo
-BEGIN VERIFY SCRIPT- git ls-files -- 'src' ':(exclude)src/util/system.h' ':(exclude)src/util/system.cpp' | xargs sed -i 's/GetDataDir()/gArgs.GetDataDirNet()/g'; -END VERIFY SCRIPT-
2021-05-22rpc: fix code comment for bumpfee/psbtbumpfee outputJon Atack
2021-05-22rpc: fix docs for bumpfee psbt updateJon Atack
- "psbt" field is only returned in psbtbumpfee and not bumpfee - bumpfee raises if privkeys are disabled, so drop "Only returned when wallet private keys are enabled." - add missing space in RPC example
2021-05-20Merge bitcoin/bitcoin#21913: rpc: RPCHelpMan fixesMarcoFalke
6e2eb0d63b42288c11a65d585d487108643888d0 rpc/wallet: use OMITTED_NAMED_ARG instead of Default(VNULL) (Karl-Johan Alm) 4983f4cba44c4ffaa4972fdede7cf6fcf8caec00 rpc/createwallet: omitted named arguments (Karl-Johan Alm) dc4db23b30b4bc7884bb28630b2b24edd81c1799 rpc: address:amount dictionaries are OBJ_USER_KEYS (Karl-Johan Alm) c8cf0a3d513b8c892f1ae16b8c0cda184064a07b rpc/getpeerinfo: bytesrecv_per_msg is a dynamic dictionary (Karl-Johan Alm) eb4fb7e507b583bd4ae8d1e3747f41616c782ded rpc/gettxoutsetinfo: hash_or_height is a named argument (Karl-Johan Alm) Pull request description: This is a follow-up to #21897, and I believe covers the remaining cases, at least that I could find. Edited to remove unrelated information about a side project. ACKs for top commit: laanwj: Documentation diff ACK 6e2eb0d63b42288c11a65d585d487108643888d0 promag: Code review ACK 6e2eb0d63b42288c11a65d585d487108643888d0. Tree-SHA512: d26f6e074e13d64bbca2a114a0adc7f905d47d238c4e9bc49f70ca0b775afbebf9879fc3794ab29dc316a6dbd00ba8cbeb01197e236ee4ab2e9854db25f23f04
2021-05-19Have OutputGroup determine the value to useAndrew Chow
Instead of hijacking the effective_feerate to use the correct value during coin selection, have OutputGroup be aware of whether we are subtracting the fee from the outputs and provide the correct value to use for selection. To do this, OutputGroup now takes CoinSelectionParams and has a new function GetSelectionAmount().
2021-05-19Change SelectCoins_test to actually test SelectCoinsAndrew Chow
This was originally modified to use SelectCoinsMinConf in order to test both BnB and Knapsack at the same time. But since SelectCoins does both now, this is no longer necessary and we can revert back to actually testing SelectCoins.
2021-05-19Remove CreateTransaction while loop and some related variablesAndrew Chow
Remove the CreateTransaction while loop. Removes variables that were only needed because of that loop. Also renames a few variables and moves their declarations to where they are used. Some subtractFeeFromOutputs handling is moved to after coin selection in order to reduce their amounts once the fee is known. If subtracting the fee reduces the change to dust, we will also now remove the change output
2021-05-19Remove use_bnb and bnb_usedAndrew Chow
These booleans are no longer needed
2021-05-19Do both BnB and Knapsack coin selection in SelectCoinsMinConfAndrew Chow
Instead of switching which algorithm to use based on use_bnb, just run both in SelectCoinsMinConf. If BnB fails, do Knapsack.
2021-05-19Have KnapsackSolver actually use effective valuesAndrew Chow
Although the CreateTransaction loop currently remains, it should be largely unused. KnapsackSolver will now account for transaction fees when doing its selection. In the previous commit, SelectCoinsMinConf was refactored to have some calculations become shared for KnapsackSolver and SelectCoinsBnB. In this commit, KnapsackSolver will now use the not_input_fees and effective_feerate so that it include the fee for non-input things (excluding a change output) so that the algorithm will select enough to cover those fees. This is necessary for selecting on effective values. Additionally, the OutputGroups created for KnapsackSolver will actually have their effective values calculated and set, and KnapsackSolver will do its selection on those effective values. Lastly, SelectCoins is modified to use the same value for preselected inputs for BnB and KnapsackSolver. While it will still use the real value when subtracting the fee from outputs, this behavior will be the same regardless of the algo used for selecting additional inputs.
2021-05-19Roll static tx fees into nValueToSelect instead of having it be separateAndrew Chow
The fees for transaction overhead and recipient outputs are now included in nTargetValue instead of being a separate parameter. For the coin selection algorithms, it doesn't matter that these are separate as in either case, the algorithm needs to select enough to cover these fees. Note that setting nValueToSelect is changed as it now includes not_input_fees. Without the change to how nValueToSelect is increased for KnapsackSolver, this would result in overpaying fees. The change to increase by the difference between nFeeRet and not_input_fees allows this to have the same behavior as previously. Additionally, because we assume that KnapsackSolver will always find a solution that requires change (we assume that BnB always finds a non-change solution), we also include the fee for the change output in KnapsackSolver's target. As part of this, we also use the changeless nFeeRet when iterating for KnapsackSolver. This is because we include the change fee when doing KnapsackSolver, so nFeeRet on further iterations won't include the change fee.
2021-05-19Move output reductions for fee to after coin selectionAndrew Chow
Simplifies CreateTransactionInternal without changing behavior. Removes the pick_new_inputs variable by moving the subtract fee from amount implementation to later in the loop to where it is possible to calculate the fee for the transaction. This allows the fee to be subtracted from the outputs within a single iteration, instead of calculating the fee in the first iteration, and subtracting the fee in the second. This also removes another scenario where a second iteration of the loop finds a smaller input set (and thus smaller fees than the first iteration) with no change and so a third iteration of the loop is done in order to make a change output that contains the excess fees. To handle these cases, we always create a change output which contains the difference between selected input values and the recipient amounts. Once the transaction fee is calculated, the change output is reduced (in the normal case) or the recipient amounts are reduced (in the subtract fee from amount case). All of this is done in a single iteration of the loop.
2021-05-19Merge bitcoin/bitcoin#20773: refactor: split CWallet::CreateW. J. van der Laan
489ebb7b34c403a3ce78ff6fb271f8e6ecb47304 wallet: make chain optional for CWallet::Create (Ivan Metlushko) d73ae939649f3b30e52b5a2cccd7fafd1ab36766 CWallet::Create move chain init message up into calling code (Ivan Metlushko) 44c430ffac940e1d1dd7f5939a495470bc694489 refactor: Add CWallet:::AttachChain method (Russell Yanofsky) e2a47ce08528dfb39c0340145c6977f6afd587f6 refactor: move first run detection to client code (Ivan Metlushko) Pull request description: This is a followup for https://github.com/bitcoin/bitcoin/pull/20365#discussion_r522265003 First part of a refactoring with overall goal to simplify `CWallet` and de-duplicate code with `wallettool` **Rationale**: split `CWallet::Create` and create `CWallet::AttachChain`. `CWallet::AttachChain` takes chain as first parameter on purpose. In future I suggest we can remove `chain` from `CWallet` constructor. The second commit is based on be164f9cf89b123f03b926aa980996919924ee64 from #15719 (thanks ryanofsky) cc ryanofsky achow101 ACKs for top commit: ryanofsky: Code review ACK 489ebb7b34c403a3ce78ff6fb271f8e6ecb47304. Only changes since last review were adding a const variable declaration, and implementing suggestion not to move feerate option checks to AttachChain. Thanks for updates and fast responses! Tree-SHA512: 00235abfe1b00874c56c449adcab8a36582424abb9ba27440bf750af8f3f217b68c11ca74eb30f78a2109ad1d9009315480effc78345e16a3074a1b5d8128721
2021-05-19wallet: make chain optional for CWallet::CreateIvan Metlushko
2021-05-19CWallet::Create move chain init message up into calling codeIvan Metlushko
2021-05-19refactor: Add CWallet:::AttachChain methodRussell Yanofsky
This commit does not change behavior, it just moves code from CWallet::CreateWalletFromFile to CWallet:::AttachChain so it can be updated in the next commit. This commit is most easily reviewed with "git diff -w --color-moved=dimmed_zebra" or by diffing CWallet:::AttachChain against the previous code with an external diff tool.
2021-05-19refactor: move first run detection to client codeIvan Metlushko