aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
AgeCommit message (Collapse)Author
2019-11-26Add OutputType and CPubKey parameters to KeepDestinationAndrew Chow
These need to be added so that LearnRelatedScripts can be called from within KeepDestination later.
2019-11-26Rename Keep/ReturnKey to Keep/ReturnDestination and remove the wrapperAndrew Chow
There is no reason to have Keep/ReturnDestination to be a wrapper for Keep/ReturnKey. Instead just make them the same function.
2019-11-22Key pool: Move CanGetAddresses callAndrew Chow
Call LegacyScriptPubKeyMan::CanGetAddresses directly instead of calling CWallet::CanGetAddresses to only query the relevant key manager This is a minor change in behavior: call now only happens if a new key needs to be reserved, since if a key is already reserved it might fail unnecessarily. This change also serves as a sanity check https://github.com/bitcoin/bitcoin/pull/16341#discussion_r331238394
2019-11-23Merge #17447: wallet: Make -walletdir network onlySamuel Dobson
3c2c439dcd8797019ac6d6614775d5c20ee41c36 wallet: Make -walletdir network only (João Barbosa) Pull request description: With this PR `bitcoind -regtest` doesn't run if bitcoin.conf has ``` walletdir=/mnt/mydisk/wallets ``` But works with ``` [regtest] walletdir=/mnt/mydisk/wallets ``` Doesn't change mainnet behavior. Closes #15630. ACKs for top commit: ryanofsky: ACK 3c2c439dcd8797019ac6d6614775d5c20ee41c36 MarcoFalke: ACK 3c2c439dcd8797019ac6d6614775d5c20ee41c36 🍈 meshcollider: Tested ACK 3c2c439dcd8797019ac6d6614775d5c20ee41c36 Tree-SHA512: 8ab3b2db5f3f9cab78b36baaf490c80f7330372cfd8f73fe6536c8fb4c6e55e09f62296feb70617075838b3bcd7101abebbef3b228b6c3dbd42ce8c7a5c372d9
2019-11-23Merge #17553: wallet: Remove out of date comments for ↵Samuel Dobson
CalculateMaximumSignedTxSize 6a2e6b0600077e5903400dc74bc8b0c26592fde6 Remove out of date comments for CalculateMaximumSignedTxSize (Gregory Sanders) Pull request description: These paths can be hit for probably a number of reasons, and ISMINE spendability is not a requirement to call it. For example: During watch-only transaction creation, previous transaction in wallet, pubkey imported, but not the witnessscript associated with the prevout. In this case I think no/minimal comment is better than specific and soon to be out of date. ACKs for top commit: achow101: ACK 6a2e6b0600077e5903400dc74bc8b0c26592fde6 darosior: ACK 6a2e6b0600077e5903400dc74bc8b0c26592fde6 Tree-SHA512: ad4c26fd2409eb5aed19d67c19cb5479d226bd11e9298630309c4344f6562ace2e10c2850ebe22770331d71e91320a606e79619b9fe52dd478ce1f589a740122
2019-11-23Merge #17237: wallet: LearnRelatedScripts only if KeepDestinationSamuel Dobson
3958295bc8a3787b66b0269190218a3764088f79 wallet: LearnRelatedScripts only if KeepDestination (João Barbosa) 55295fba4cbff36e9a8c3fed9c38e82ebe3c48b7 wallet: Lock address type in ReserveDestination (João Barbosa) Pull request description: Only mutates the wallet if the reserved key is kept. First commit is a refactor that makes the address type a class member. The second commit moves `LearnRelatedScripts` from `GetReservedDestination` to `KeepDestination` to avoid an unnecessary call to `AddCScript` - which in turn prevents multiple entries of the same script in the wallet DB. ACKs for top commit: achow101: Re-ACK 3958295bc8a3787b66b0269190218a3764088f79 Sjors: ACK 3958295bc8a3787b66b0269190218a3764088f79 ryanofsky: Code review ACK 3958295bc8a3787b66b0269190218a3764088f79. I like this change. The new behavior makes more sense, and the change makes the code clearer, since the current LearnRelatedScripts call is hard to understand and explain. (Personally, I'd like it if this PR were merged before #17373 or that PR was rebased on top of this one so it would be less confusing.) meshcollider: utACK 3958295bc8a3787b66b0269190218a3764088f79 Tree-SHA512: 49a5f4b022b28042ad37ea309b28378a3983cb904e234a25795b5a360356652e0f8e60f15e3e64d85094ea63af9be01812d90ccfc08ca4f1dd927fdd8566e33f
2019-11-23Merge #16944: gui: create PSBT with watch-only walletSamuel Dobson
c6dd565c8820aa8a98b190621e10c6e2821a9ecc [gui] watch-only wallet: copy PSBT to clipboard (Sjors Provoost) 39465d545d521e66bb3accfa788aa94bffaf47eb [wallet] add fillPSBT to interface (Sjors Provoost) 848f88920853724511387ca0b7ef652fa14ced71 [gui] send: include watch-only (Sjors Provoost) 40537f090907f81ba885edb7dff1558382976912 [wallet] ListCoins: include watch-only for wallets without private keys (Sjors Provoost) Pull request description: For wallets with `WALLET_FLAG_DISABLE_PRIVATE_KEYS` this makes the watch-only balance available on the send screen (including coin selection). Instead of sending a transaction it generates a PSBT. The user can take this PSBT and process it with [HWI](https://github.com/bitcoin-core/HWI) or put it an SD card for hardware wallets that support that. The PSBT is copied to the clipboard. This was the easiest approach; we can add a dialog later to display it, as well as an option to save to disk. ACKs for top commit: instagibbs: test and code review ACK https://github.com/bitcoin/bitcoin/pull/16944/commits/c6dd565c8820aa8a98b190621e10c6e2821a9ecc meshcollider: re-ACK c6dd565c8820aa8a98b190621e10c6e2821a9ecc Tree-SHA512: ebc3da0737e33b255ed926191b84569aedb6097d14868662bd5dce726ce3048e86e9a31eba987b10dffe1482b35c21ae1cd595c2caa4634bc4cf78a826a83852
2019-11-23Merge #17371: Refactor: Require scriptPubKey to get wallet SigningProviderSamuel Dobson
d0dab897afaac0a18aa47d3ce673a4a43a69178a Refactor: Require scriptPubKey to get wallet SigningProvider (Andrew Chow) 4b0c718f8f48c678cbe4575e9a9cf9e62a30f0da Accumulate result UniValue in SignTransaction (Andrew Chow) Pull request description: Easier to review ignoring whitespace: git log -p -n1 -w This commit does not change behavior. It passes new CScript arguments to signing functions, but the arguments aren't currently used. Split from #17261 ACKs for top commit: instagibbs: utACK https://github.com/bitcoin/bitcoin/pull/17371/commits/d0dab897afaac0a18aa47d3ce673a4a43a69178a ryanofsky: Code review ACK d0dab897afaac0a18aa47d3ce673a4a43a69178a. Thanks for the SignTransaction update. No other changes since last review Sjors: Code review ACK d0dab897afaac0a18aa47d3ce673a4a43a69178a promag: Code review ACK d0dab897afaac0a18aa47d3ce673a4a43a69178a. meshcollider: Code review ACK d0dab897afaac0a18aa47d3ce673a4a43a69178a Tree-SHA512: c3f52df20fd9d6b3b5aa65562cf5f7dce7b7f44c148b0f988f8b578fce2a28e9b7bf010f5f04bb5bf60f5272b2899f1dbbfb8aee81579c21c9cba559d1d2bb70
2019-11-23Merge #17290: Enable BnB coin selection for preset inputs and subtract fee ↵Samuel Dobson
from outputs b007efdf1910db1d38671d6435d2f379bbf847d2 Allow BnB when subtract fee from outputs (Andrew Chow) db15e71e79b24601853703bebd1c92f4b523fd5f Use BnB when preset inputs are selected (Andrew Chow) Pull request description: Currently we explicitly disable BnB when there are preset inputs selected or when the subtract fee from outputs option is enabled. This PR enables BnB for both cases. Kind of an alternative to #17246 (implements the subtract fee from outputs part of it) and borrows a test from there too. ACKs for top commit: instagibbs: reACK https://github.com/bitcoin/bitcoin/pull/17290/commits/b007efdf1910db1d38671d6435d2f379bbf847d2 Sjors: re-ACK b007efdf1910db1d38671d6435d2f379bbf847d2 Tree-SHA512: 933276b09b2fa2ab43db7f0b98762f06f6f5fa8606195f96aca9fa1cb71ae4ee7156028dd482b1cada82ddd0996a9daf12ea5c152589fdf192cd96cbc51e99df
2019-11-21Remove out of date comments for CalculateMaximumSignedTxSizeGregory Sanders
2019-11-20Merge #17444: wallet: Avoid showing GUI popups on RPC errors (take 2)MarcoFalke
faffa7f0dcc9971cb20534816eccdf75bebc853a wallet: Avoid showing GUI popups on RPC errors (take 2) (MarcoFalke) Pull request description: Commit 8b0d82bb428de9e7f1da7c61574e7a8376a62d43 claims "This commit does not change behavior." However, it re-introduced the bug I tried to fix in #17070 ACKs for top commit: ryanofsky: Code review ACK faffa7f0dcc9971cb20534816eccdf75bebc853a Tree-SHA512: 99987f80c76414dca40c7d76b2fe4ea853debbe3c49e7acdeab2596c726a2935c468f4484d49212e65ecc9c8b0d861c0c2b83c1ddfc07670540699199dbfecb0
2019-11-20Allow BnB when subtract fee from outputsAndrew Chow
2019-11-20Use BnB when preset inputs are selectedAndrew Chow
2019-11-18Refactor: Require scriptPubKey to get wallet SigningProviderAndrew Chow
Easier to review ignoring whitespace: git log -p -n1 -w This commit does not change behavior. It passes new CScript arguments to signing functions, but the arguments aren't currently used.
2019-11-18Accumulate result UniValue in SignTransactionAndrew Chow
SignTransaction will be called multiple times in the future. Pass it a result UniValue so that it can accumulate the results of multiple SignTransaction passes.
2019-11-13[wallet] ListCoins: include watch-only for wallets without private keysSjors Provoost
This makes them available in GUI coin selection.
2019-11-12wallet: Make -walletdir network onlyJoão Barbosa
2019-11-11rpc: Expose block height of wallet transactionsJoão Barbosa
2019-11-11wallet: Avoid showing GUI popups on RPC errors (take 2)MarcoFalke
2019-11-08scripted-diff: Change `BCLog::DB` to `BCLog::WALLETDB`Wladimir J. van der Laan
-BEGIN VERIFY SCRIPT- git grep -l "BCLog::DB" src | xargs sed -i "s/BCLog::DB/BCLog::WALLETDB/g" sed -i "s/DB =/WALLETDB =/g" src/logging.h -END VERIFY SCRIPT-
2019-11-08Merge #17405: wallet: Remove unused boost::this_thread::interruption_pointfanquake
fad1de66a29bf6bd348a932150dad7d472feb3d0 wallet: Remove unused boost::this_thread::interruption_point (MarcoFalke) Pull request description: `BerkeleyEnvironment::Open` is only called from the main thread (init) or an http rpc thread, neither of which can be interrupted, so remove the useless interruption point. `BerkeleyEnvironment{}` is only used in tests, which run in a single process/thread, so remove the useless interruption point. ACKs for top commit: laanwj: ACK fad1de66a29bf6bd348a932150dad7d472feb3d0 fanquake: ACK fad1de66a29bf6bd348a932150dad7d472feb3d0 Tree-SHA512: dacd8398e966e4a6ce5cf7d3ed821c9c267eff40b14c0635085441647cdb72d1642807f89355419f1710f814c7963e35a10d102d0b985c7198261dfc736256f8
2019-11-08Merge #17354: wallet: Tidy CWallet::SetUsedDestinationStatefanquake
0b75a7f0680d16a41043864a897470324917b1e8 wallet: Reuse existing batch in CWallet::SetUsedDestinationState (João Barbosa) 01f45dd00eb032a19d142026e4d019944192da19 wallet: Avoid recursive lock in CWallet::SetUsedDestinationState (João Barbosa) Pull request description: This PR makes 2 distinct changes around `CWallet::SetUsedDestinationState`: - 1st the recursive lock is removed and now it requires the lock to be held; - 2nd change is to support, in the best case, just a wallet database flush when transaction is added to the wallet. ACKs for top commit: achow101: ACK 0b75a7f0680d16a41043864a897470324917b1e8 MarcoFalke: ACK 0b75a7f0680d16a41043864a897470324917b1e8 ryanofsky: Code review ACK 0b75a7f0680d16a41043864a897470324917b1e8. Code changes looks fine but PR description should be updated to say what benefits of the change are. I might have missed something, but I didn't see a place where multiple batches were used previously and a single batch was used now. So the main benefit of this change appears to be removing a recursive lock? And maybe moving toward a consistent convention for passing batch instances? Tree-SHA512: abcf23a5850d29990668db20d6f624cca3e89629cc9ed003e0d05cde1b58ab2ff365034f156684ad13e55764b54c6c0c2bc7d5f96b8af7dc5e45a3be955d6b15
2019-11-08Merge #15931: Remove GetDepthInMainChain dependency on locked chain interfaceSamuel Dobson
36b68de5b2938722911db900ca299f7008780d01 Remove getBlockDepth method from Chain::interface (Antoine Riard) b66c429c56c85fa16c309be0b2bca9c25fdd3e1a Remove locked_chain from GetDepthInMainChain and its callers (Antoine Riard) 0ff03871add000f8b4d8f82aeb168eed2fc9dc5f Use CWallet::m_last_block_processed_height in GetDepthInMainChain (Antoine Riard) f77b1de16feee097a88e99d2ecdd4d84beb4f915 Only return early from BlockUntilSyncedToCurrentChain if current tip is exact match (Antoine Riard) 769ff05e48fb53d4b62c59060424a0fea71d0aab Refactor some importprunedfunds checks with guard clause (Antoine Riard) 5971d3848e09abf571e5308185275296127efca4 Add block_height field in struct Confirmation (Antoine Riard) 9700fcb47feca9d78e005b8d18b41148c8f6b25f Replace CWalletTx::SetConf by Confirmation initialization list (Antoine Riard) 5aacc3eff15b9b5bdc951f1e274f00d581f63bce Add m_last_block_processed_height field in CWallet (Antoine Riard) 10b4729e33f76092bd8cfa06d1a5e0a066436f76 Pass block height in Chain::BlockConnected/Chain::BlockDisconnected (Antoine Riard) Pull request description: Work starter to remove Chain::Lock interface by adding m_last_block_processed_height in CWallet and m_block_height in CMerkleTx to avoid GetDepthInMainChain having to keep a lock . Once this one done, it should ease work to wipe out more cs_main locks from wallet code. I think it's ready for a first round of review before to get further. - `BlockUntilSyncedToCurrent` : restrain isPotentialTip to isTip because we want to be sure that wallet see BlockDisconnected callbacks if its height differs from the Chain one. It means during a reorg, an RPC could return before the BlockDisconnected callback had been triggered. This could cause a tx that had been included in the disconnected block to be displayed as confirmed, for example. ~~- `AbandonTransaction` : in case of conflicted tx (nIndex = -1), we set its m_block_height to the one of conflicting blocks, but if this height is superior to CWallet::m_last_block_processed_height, that means tx isn't conflicted anymore so we return 0 as tx is again unconfirmed~~ After #16624, we instead rely on Confirmation. ~~- `AddToWalletIfInvolvingMe`: in case of block disconnected, transactions are added to mempool again, so we need to replace old txn in `mapWallet` with a height set to zero so we remove check on block_hash.IsNull~~ Already done in #16624 ACKs for top commit: jnewbery: @jkczyz you've ACKed an intermediate commit (github annoyingly orders commits in date order, not commit order). Did you mean to ACK the final commit in this branch (36b68de5b2938722911db900ca299f7008780d01). jkczyz: > @jkczyz you've ACKed an intermediate commit (github annoyingly orders commits in date order, not commit order). Did you mean to ACK the final commit in this branch ([36b68de](https://github.com/bitcoin/bitcoin/commit/36b68de5b2938722911db900ca299f7008780d01)). meshcollider: utACK 36b68de5b2938722911db900ca299f7008780d01 ryanofsky: Code review ACK 36b68de5b2938722911db900ca299f7008780d01. Changes since last review: new jkczyz refactor importprunedfunds commit, changed BlockUntilSyncedToCurrentChainChanges commit title and description, changed Confirmation struct field order and line-wrapped comment jnewbery: utACK 36b68de5b2938722911db900ca299f7008780d01 promag: Code review ACK 36b68de5b2938722911db900ca299f7008780d01. Tree-SHA512: 08b89a0bcc39f67c82a6cb6aee195e6a11697770c788ba737b90986b4893f44e90d1ab9ef87239ea3766508b7e24ea882b7199df41173ab27a3d000328c14644
2019-11-07wallet: Remove unused boost::this_thread::interruption_pointMarcoFalke
2019-11-07Merge #17384: test: Create new test libraryMarcoFalke
fa4c6fa9b1139791f45f1495d662c1c7cd2f7ed6 doc: Add documentation for new test/lib (MarcoFalke) faec28252cf4f8e754c689a7a44fd421f631db50 scripted-diff: test: Move setup_common to test library (MarcoFalke) Pull request description: Sorry for clickbait, this is only a move-only scripted-diff commit and one documentation commit. Longer term, someone who knows something about build systems can make this an actual library. Motivation for this is that each module gets compiled for each target that includes it. For example, setup_common is compiled 27 times (for the fuzz suite) and another 3 times for the other tests (bench, unit test, gui) ACKs for top commit: practicalswift: ACK fa4c6fa9b1139791f45f1495d662c1c7cd2f7ed6 -- diff looks correct and Travis is happy jonatack: ACK fa4c6fa9b1139791f45f1495d662c1c7cd2f7ed6 with the reserve that the commit messages (and PR description) contain the motivation for this change. Built, ran tests, light code review. ryanofsky: Code review ACK fa4c6fa9b1139791f45f1495d662c1c7cd2f7ed6. I didn't realize `lib` was actually name of existing directory, not a new name. But in any case this looks good and nice to have one scripted diff instead of two. Tree-SHA512: 2e176df90c60578276e4a6dc83ff57ff59d8e666ecf30c5ceacb8c326725da91baa4cac3dfa7a2e1605f58122a3e3e27e4938ff33e3a0ce7ea53afffebbf57a4
2019-11-06Remove getBlockDepth method from Chain::interfaceAntoine Riard
Pass conflicting height in CWallet::MarkConflicted
2019-11-06Remove locked_chain from GetDepthInMainChain and its callersAntoine Riard
We don't remove yet Chain locks as we need to preserve lock order with CWallet one until swapping at once to avoid deadlock failures (spotted by --enable-debug)
2019-11-06Use CWallet::m_last_block_processed_height in GetDepthInMainChainAntoine Riard
Avoid to lock chain to query state thanks to tracking last block height in CWallet.
2019-11-06Only return early from BlockUntilSyncedToCurrentChain if current tipAntoine Riard
is exact match In the next commit, we start using BlockConnected/BlockDisconnected callbacks to establish tx depth, rather than querying the chain directly. Currently, BlockUntilSyncedToCurrentChain will return early if the best block processed by the wallet is a descendant of the node'tip. That means that in the case of a re-org, it won't wait for the BlockDisconnected callbacks that have been enqueued during the re-org but have not yet been triggered in the wallet. Change BlockUntilSyncedToCurrentChain to only return early if the wallet's m_last_block_processed matches the tip exactly. This ensures that there are no BlockDisconnected or BlockConnected callbacks in-flight.
2019-11-06Refactor some importprunedfunds checks with guard clauseAntoine Riard
Credit to jkczyz
2019-11-06Add block_height field in struct ConfirmationAntoine Riard
At wallet loading, we rely on chain state querying to retrieve height of txn, to do so we ensure that lock order is respected between cs_main and cs_wallet. If wallet loaded is the wallet-tool one, all wallet txn will show up with a height of zero. It doesn't matter as confirmation height is not used by wallet-tool. Reorder arguments and document Confirmation calls to avoid ambiguity. Fixes nits left from #16624
2019-11-06scripted-diff: test: Move setup_common to test libraryMarcoFalke
-BEGIN VERIFY SCRIPT- # Move files for f in $(git ls-files src/test/lib/); do git mv $f src/test/util/; done git mv src/test/setup_common.cpp src/test/util/ git mv src/test/setup_common.h src/test/util/ # Replace Windows paths sed -i -e 's|\\setup_common|\\util\\setup_common|g' $(git grep -l '\\setup_common') sed -i -e 's|src\\test\\lib\\|src\\test\\util\\|g' build_msvc/test_bitcoin/test_bitcoin.vcxproj # Everything else sed -i -e 's|/setup_common|/util/setup_common|g' $(git grep -l 'setup_common') sed -i -e 's|test/lib/|test/util/|g' $(git grep -l 'test/lib/') # Fix include guard sed -i -e 's|BITCOIN_TEST_SETUP_COMMON_H|BITCOIN_TEST_UTIL_SETUP_COMMON_H|g' ./src/test/util/setup_common.h sed -i -e 's|BITCOIN_TEST_LIB_|BITCOIN_TEST_UTIL_|g' $(git grep -l 'BITCOIN_TEST_LIB_') -END VERIFY SCRIPT-
2019-11-06Replace CWalletTx::SetConf by Confirmation initialization listAntoine Riard
2019-11-06Merge #17381: LegacyScriptPubKeyMan code cleanupsWladimir J. van der Laan
05b224a175065aee4d6d9c471722bc4503f01fdf Add missing SetupGeneration error handling in EncryptWallet (Russell Yanofsky) bfd826a675445801adec86a469040f3ceb8172ee Clean up nested scope in GetReservedDestination (Russell Yanofsky) 491a599b37f3e3a648e52aebed677ca11b0615e2 Get rid of confusing LegacyScriptPubKeyMan::TopUpKeyPool method (Russell Yanofsky) 4a0abf694ee10cf186f25a67ca35c3fce0c10874 Pass CTxDestination to ScriptPubKeyMan::GetMetadata (Russell Yanofsky) b07b07cd8779355ba1dd16e7eb4af42e0ae1c587 Add EnsureLegacyScriptPubKeyMan and use in rpcwallet.cpp (Russell Yanofsky) Pull request description: This PR implements suggested code cleanups from #17300 and #17304 review comments ACKs for top commit: Sjors: re-ACK 05b224a laanwj: Code review ACK 05b224a175065aee4d6d9c471722bc4503f01fdf Tree-SHA512: 12fd86637088515b744c028e0501c5d21a9cf9ee9c9cfd70e9cb65d44611ea5643abd5f6f101105caa5aff015d74de606f074f08af7dae8429f929d21288ab45
2019-11-05Merge #16540: test: Add ASSERT_DEBUG_LOG to unit test frameworkMarcoFalke
fa2c44c3ccc3e7a54e2afc862addd555d5a6e51b test: Add ASSERT_DEBUG_LOG to unit test framework (MarcoFalke) fa1936f57bbf5aebb1f8fc18701441d79219d443 logging: Add member for arbitrary print callbacks (MarcoFalke) Pull request description: Similar to `assert_debug_log` in the functional test framework Top commit has no ACKs. Tree-SHA512: aa9eaeca386b61d806867c04a33275f6eb4624fa5bf50f2928d16c83f5634bac96bcac46f9e8eda3b00b4251c5f12d7b01d6ffd84ba8e05c09eeec810cc31251
2019-11-05Add m_last_block_processed_height field in CWalletAntoine Riard
At BlockConnected/BlockDisconnected, we rely on height of block itself to know current height of wallet
2019-11-05Pass block height in Chain::BlockConnected/Chain::BlockDisconnectedAntoine Riard
To do so we update CValidationInterface::BlockDisconnect to take a CBlockIndex pointing to the block being disconnected. This new parameter will be use in the following commit to establish wallet height.
2019-11-05Add missing SetupGeneration error handling in EncryptWalletRussell Yanofsky
Suggested https://github.com/bitcoin/bitcoin/pull/17304#discussion_r341286026 by me
2019-11-05Clean up nested scope in GetReservedDestinationRussell Yanofsky
Suggested https://github.com/bitcoin/bitcoin/pull/17304#discussion_r341194391 by Gregory Sanders <gsanders87@gmail.com> Reason for keeping the `return true` `return false` verbosity is that more code will be added after the ReserveKeyFromKeyPool() call before returning.
2019-11-05Get rid of confusing LegacyScriptPubKeyMan::TopUpKeyPool methodRussell Yanofsky
Previous discussion https://github.com/bitcoin/bitcoin/pull/17304#discussion_r340307903
2019-11-05Pass CTxDestination to ScriptPubKeyMan::GetMetadataRussell Yanofsky
Pass CTxDestination instead of more ambiguous uint160 hash value. This is more type safe and more efficient since it avoids doing map lookups that will always fail and were not done previously before a18edd7b383d667b15b6d4b87aa3a055a9fa5051 from https://github.com/bitcoin/bitcoin/pull/17304 Change suggested by Andrew Chow <achow101-github@achow101.com> in https://github.com/bitcoin/bitcoin/pull/17304#discussion_r340345745 and https://github.com/bitcoin/bitcoin/pull/17381#issuecomment-549994944
2019-11-05Add EnsureLegacyScriptPubKeyMan and use in rpcwallet.cppRussell Yanofsky
This also fixes unused variable warnings in rpcdump.cpp
2019-11-05Merge #16766: wallet: Make IsTrusted scan parents recursivelySamuel Dobson
4671fc3d9e669da8b8781f0cbefee43cb9acd527 Expand on wallet_balance.py comment from https://github.com/bitcoin/bitcoin/pull/16766\#issuecomment-527563982 (Jeremy Rubin) 91f3073f08aff395dd813296bf99fd8ccc81bb27 Update release notes to mention changes to IsTrusted and impact on wallet (Jeremy Rubin) 8f174ef112199aa4e98d756039855cc561687c2e Systematize style of IsTrusted single line if (Jeremy Rubin) b49dcbedf79613f0e0f61bfd742ed265213ed280 update variable naming conventions for IsTrusted (Jeremy Rubin) 5ffe0d144923f365cb1c2fad181eca15d1668692 Update comment in test/functional/wallet_balance.py (Jeremy Rubin) a550c58267f50c59c2eea1d46edaa5019a8ad5d8 Update wallet_balance.py test to reflect new behavior (Jeremy Rubin) 5dd7da4ccd1354f09e2d00bab29288db0d5665d0 Reuse trustedParents in looped calls to IsTrusted (Jeremy Rubin) 595f09d6de7f1b94428cdd1310777aa6a4c584e5 Cache tx Trust per-call to avoid DoS (Jeremy Rubin) dce032ce294fe0d531770f540b1de00dc1d13f4b Make IsTrusted scan parents recursively (Jeremy Rubin) Pull request description: This slightly modifies the behavior of IsTrusted to recursively check the parents of a transaction. Otherwise, it's possible that a parent is not IsTrusted but a child is. If a parent is not trusted, then a child should not be either. This recursive scan can be a little expensive, so ~it might be beneficial to have a way of caching IsTrusted state, but this is a little complex because various conditions can change between calls to IsTrusted (e.g., re-org).~ I added a cache which works per call/across calls, but does not store the results semi-permanently. Which reduces DoS risk of this change. There is no risk of untrusted parents causing a resource exploitation, as we immediately return once that is detected. This is a change that came up as a bug-fix esque change while working on OP_SECURETHEBAG. You can see the branch where this change is important here: https://github.com/bitcoin/bitcoin/compare/master...JeremyRubin:stb-with-rpc?expand=1. Essentially, without this change, we can be tricked into accepting an OP_SECURETHEBAG output because we don't properly check the parents. As this was a change which, on its own, was not dependent on OP_SECURETHEBAG, I broke it out as I felt the change stands on its own by fixing a long standing wallet bug. The test wallet_balance.py has been corrected to meet the new behavior. The below comment, reproduced, explains what the issue is and the edge cases that can arise before this change. # Before `test_balance()`, we have had two nodes with a balance of 50 # each and then we: # # 1) Sent 40 from node A to node B with fee 0.01 # 2) Sent 60 from node B to node A with fee 0.01 # # Then we check the balances: # # 1) As is # 2) With transaction 2 from above with 2x the fee # # Prior to #16766, in this situation, the node would immediately report # a balance of 30 on node B as unconfirmed and trusted. # # After #16766, we show that balance as unconfirmed. # # The balance is indeed "trusted" and "confirmed" insofar as removing # the mempool transactions would return at least that much money. But # the algorithm after #16766 marks it as unconfirmed because the 'taint' # tracking of transaction trust for summing balances doesn't consider # which inputs belong to a user. In this case, the change output in # question could be "destroyed" by replace the 1st transaction above. # # The post #16766 behavior is correct; we shouldn't be treating those # funds as confirmed. If you want to rely on that specific UTXO existing # which has given you that balance, you cannot, as a third party # spending the other input would destroy that unconfirmed. # # For example, if the test transactions were: # # 1) Sent 40 from node A to node B with fee 0.01 # 2) Sent 10 from node B to node A with fee 0.01 # # Then our node would report a confirmed balance of 40 + 50 - 10 = 80 # BTC, which is more than would be available if transaction 1 were # replaced. The release notes have been updated to note the new behavior. ACKs for top commit: ariard: Code Review ACK 4671fc3, maybe extend DoS protection in a follow-up PR. fjahr: Code review ACK 4671fc3d9e669da8b8781f0cbefee43cb9acd527 ryanofsky: Code review ACK 4671fc3d9e669da8b8781f0cbefee43cb9acd527. Changes since last review: 2 new commits adding suggested release note and python test comment, also a clean rebase with no changes to the earlier commits. The PR description is more comprehensive now, too. Looks good! promag: Code review ACK 4671fc3d9e669da8b8781f0cbefee43cb9acd527. Tree-SHA512: 6b183ff425304fef49724290053514cb2770f4a2350dcb83660ef24af5c54f7c4c2c345b0f62bba60eb2d2f70625ee61a7fab76a7f491bb5a84be5c4cc86b92f
2019-11-05Merge #17258: Fix issue with conflicted mempool tx in listsinceblockSamuel Dobson
436ad436434b94982bcb7dc1d13a21949263ef73 Fix issue with conflicted mempool tx in listsinceblock (Adam Jonas) Pull request description: Closes #8752 by bringing back abandoned #10470. This now checks that returned transactions are not conflicting with any transactions that are filtered out by the given blockhash and add a functional test to prevent this in the future. For more context, #8757 was closed in favor of #10470. ACKs for top commit: instagibbs: utACK https://github.com/bitcoin/bitcoin/pull/17258/commits/436ad436434b94982bcb7dc1d13a21949263ef73 kallewoof: utACK 436ad436434b94982bcb7dc1d13a21949263ef73 jonatack: I'm not qualifed to give an ACK here but 436ad436434b94982bcb7dc1d13a21949263ef73 appears reasonable. Built/ran tests/verified that this test fails without the change in rpcwallet.cpp: Tree-SHA512: 63d75cd3d3f19fc84dc38899b200c96179b82b24db263cd0116ee5b715265be647157855c2e35912d2fbc49c7b37db9375d6aab0ac672f0f09bece8431de5ea9
2019-11-04Merge #17318: replace asserts in RPC code with CHECK_NONFATAL and add linterMarcoFalke
c98bd13e675fbf5641ed64d551b63aaf55a1a8e9 replace asserts in RPC code with CHECK_NONFATAL and add linter (Adam Jonas) Pull request description: - Replace instances of assert in /rpc files and rpcwallet with CHECK_NONFATAL(condition) - Add a linter to prevent future usage of assert being used in RPC code ref https://github.com/bitcoin/bitcoin/pull/17192 ACKs for top commit: practicalswift: ACK c98bd13e675fbf5641ed64d551b63aaf55a1a8e9 -- diff looks correct Tree-SHA512: a16036b6bbcca73a5334665f66e17e1756377d582317568291da1d727fc9cf8c84bac9d9bd099534e1be315345336e5f7b66b93793135155f320dc5862a2d875
2019-11-04wallet: LearnRelatedScripts only if KeepDestinationJoão Barbosa
2019-11-04wallet: Lock address type in ReserveDestinationJoão Barbosa
2019-11-04test: Add ASSERT_DEBUG_LOG to unit test frameworkMarcoFalke
2019-11-02wallet: Reuse existing batch in CWallet::SetUsedDestinationStateJoão Barbosa
2019-11-02wallet: Avoid recursive lock in CWallet::SetUsedDestinationStateJoão Barbosa