aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/scriptpubkeyman.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* | Implement SetType in DescriptorScriptPubKeyManAndrew Chow2020-04-231-1/+5
| |
* | Introduce DescriptorScriptPubKeyMan as a dummy classAndrew Chow2020-04-231-0/+110
| |
* | Introduce SetType function to tell ScriptPubKeyMans the type and ↵Andrew Chow2020-04-231-0/+2
| | | | | | | | internal-ness of it
* | Merge #17219: wallet: allow transaction without change if keypool is emptySamuel Dobson2020-04-181-1/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 92bcd70808b9cac56b184903aa6d37baf9641b37 [wallet] allow transaction without change if keypool is empty (Sjors Provoost) 709f8685ac37510aa145ac259753583c82280038 [wallet] CreateTransaction: simplify change address check (Sjors Provoost) 5efc25f9638866941028454cfa9bae27f1519cb4 [wallet] translate "Keypool ran out" message (Sjors Provoost) Pull request description: Extracted from #16944 First this PR simplifies the check when generating a change address, by dropping `CanGetAddresses` and just letting `reservedest.GetReservedDestination` do this check. Second, when the keypool is empty, instead of immediately giving up, we create a dummy change address and pass that to coin selection. If we didn't need the change address (e.g. when spending the entire balance), then it's all good. If we did need a change address, we throw the original error. ACKs for top commit: fjahr: Code review ACK 92bcd70808b9cac56b184903aa6d37baf9641b37 jonasschnelli: utACK 92bcd70808b9cac56b184903aa6d37baf9641b37 achow101: ACK 92bcd70808b9cac56b184903aa6d37baf9641b37 meshcollider: Code review ACK 92bcd70808b9cac56b184903aa6d37baf9641b37 Tree-SHA512: 07b8c8251f57061c58a85ebf0359be63583c23bac7a2c4cefdc14820c0cdebcc90a2bb218e5ede0db11d1e204cda149e056dfd18614642070b3d56efe2735006
| * | [wallet] translate "Keypool ran out" messageSjors Provoost2020-02-041-1/+1
| |/
* | scripted-diff: Bump copyright headersMarcoFalke2020-04-161-1/+1
| | | | | | | | | | | | -BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
* | Replace std::to_string with locale-independent alternativeBen Woosley2020-03-141-2/+3
| |
* | Replace GetSigningProvider with GetSolvingProviderAndrew Chow2020-03-091-1/+1
| | | | | | | | | | | | Not all ScriptPubKeyMans will be able to provide private keys, but pubkeys and scripts should be. So only provide public-only SigningProviders, i.e. ones that can help with Solving.
* | Move direct calls to MessageSign into new SignMessage functions in CWallet ↵Andrew Chow2020-03-091-0/+14
| | | | | | | | | | | | | | and ScriptPubKeyMan Instead of getting a SigningProvider and then going to MessageSign, have ScriptPubKeyMan handle the message signing internally.
* | Move key and script filling and signing from CWallet::FillPSBT to ↵Andrew Chow2020-03-091-0/+42
| | | | | | | | | | | | | | | | ScriptPubKeyMan::FillPSBT Instead of fetching a SigningProvider from ScriptPubKeyMan in order to fill and sign the keys and scripts for a PSBT, just pass that PSBT to a new FillPSBT function that does all that for us.
* | Add SignTransaction function to ScriptPubKeyMan and LegacyScriptPubKeyManAndrew Chow2020-03-081-0/+6
| |
* | wallet/spkm: make GetOldestKeyPoolTime() constKarl-Johan Alm2020-03-021-1/+1
| | | | | | | | The method checks the oldest key time for key pools and returns the oldest. It does no modifications.
* | wallet: make CanGetAddresses() constKarl-Johan Alm2020-03-021-1/+1
| | | | | | | | CWallet::CanGetAddresses() is used to check whether the wallet has available or is able to produce keys for addresses. It uses the ScriptPubKeyMan::CanGetAddresses(), which in turn uses the const KeypoolCountExternalKeys() method, all which do counting and no modifications.
* | wallet: make KeypoolCountExternalKeys() constKarl-Johan Alm2020-03-021-1/+1
| | | | | | | | This method returns the sum of the key pool sizes. It does no modification.
* | wallet: make CanGenerateKeys() constKarl-Johan Alm2020-03-021-1/+1
| | | | | | | | This method simply checks if HD is or can be enabled and does not require mutability.
* | wallet: Improve LegacyScriptPubKeyMan::CanProvide script recognitionRussell Yanofsky2020-02-121-8/+16
|/ | | | | | | | | | | | | | | | | | | | Make LegacyScriptPubKeyMan::CanProvide method able to recognize p2sh scripts when the redeem script is present in the mapScripts map without the p2sh script also having to be added to the mapScripts map. This restores behavior prior to https://github.com/bitcoin/bitcoin/pull/17261, which I think broke backwards compatibility with old wallet files by no longer treating addresses created by `addmultisigaddress` calls before #17261 as solvable. The reason why tests didn't fail with the CanProvide implementation in #17261 is because of a workaround added in 4a7e43e8460127a40a7895519587399feff3b682 "Store p2sh scripts in AddAndGetDestinationForScript", which masked the problem for new `addmultisigaddress` RPC calls without fixing it for multisig addresses already created in old wallet files. This change adds a lot of comments and allows reverting commit 4a7e43e8460127a40a7895519587399feff3b682 "Store p2sh scripts in AddAndGetDestinationForScript", so the AddAndGetDestinationForScript() function, CanProvide() method, and mapScripts map should all be more comprehensible
* Refactor: Replace SigningProvider pointers with unique_ptrsAndrew Chow2020-01-231-2/+2
| | | | | | | Needed for future ScriptPubKeyMans which may need to create SigningProviders dynamically and thus a normal pointer is not enough This commit does not change behavior.
* Refactor: Copy CWallet signals and print function to LegacyScriptPubKeyManAndrew Chow2020-01-231-10/+0
| | | | This commit does not change behavior.
* Box the wallet: Add multiple keyman maps and loopsAndrew Chow2020-01-231-0/+33
| | | | | | | Add wallet logic for dealing with multiple ScriptPubKeyMan instances. This doesn't change current behavior because there is still only a single LegacyScriptPubKeyMan. But in the future the new logic will be used to support descriptor wallets.
* HD Split: Avoid redundant upgradesAndrew Chow2020-01-231-1/+1
| | | | | | This avoids repeaded upgrades when support for more multiple keyman references is added in the next commit: https://github.com/bitcoin/bitcoin/pull/16341#discussion_r322370108
* Locking: Lock cs_KeyStore instead of cs_wallet in legacy keymanAndrew Chow2020-01-231-34/+34
| | | | This commit only affects locking behavior and doesn't have other changes.
* Merge #17537: wallet: Cleanup and move opportunistic and superfluous TopUp()sfanquake2019-12-171-3/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6e77a7b65cda1b46ce42f0c99ca91562255aeb28 keypool: Add comment about TopUp and when to use it (Andrew Chow) ea50e34b287e0da0806c1116bb55ade730e8ff6c keypool: Move opportunistic TopUps from LegacyScriptPubKeyMan to CWallet and ReserveDestination (Andrew Chow) bb2c8ce23c9d7ba8d0e5538243e07218443c85b4 keypool: Remove superfluous topup from CWallet::GetNewChangeDestination (Andrew Chow) Pull request description: * The `TopUp()` in `CWallet::GetNewChangeDestination` is unnecessary as currently m_spk_man calls TopUp further down the call stack inside LegacyScriptPubKeyMan::ReserveKeyFromKeyPool (called by LegacyScriptPubKeyMan::GetReservedDestination). This also lets us prepare for future changes with multiple ScriptPubKeyMans in the wallet. * An opportunistic `TopUp()` is moved from `LegacyScriptPubKeyMan::GetNewDestination` to `CWallet::GetNewDestination`. * Another opportunistic `TopUp()` is moved from `LegacyScriptPubKeyMan::ReserveKeyFromKeyPool` Moving opportunistic TopUps ensures that ScriptPubKeyMans will always be topped up before requesting Destinations from them as we cannot always rely on future ScriptPubKeyMan implementaions topping up internally. See also: https://github.com/bitcoin/bitcoin/pull/17373#discussion_r348598174 ACKs for top commit: instagibbs: utACK https://github.com/bitcoin/bitcoin/pull/17537/commits/6e77a7b65cda1b46ce42f0c99ca91562255aeb28 only change is slight elaboration on comment ryanofsky: Code review ACK 6e77a7b65cda1b46ce42f0c99ca91562255aeb28. Only the comment changed since my previous review. Tree-SHA512: bdfc8d303842c3fb7c3d40af7abfa6d9dac4ef71a24922bb92229674ee89bfe3113ebb46d3903ac48ef99f0a7d6eaac33282495844f2b31f91b8df55084c421f
| * keypool: Move opportunistic TopUps from LegacyScriptPubKeyMan to CWallet and ↵Andrew Chow2019-11-221-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ReserveDestination An opportunistic TopUp is moved from LegacyScriptPubKeyMan::GetNewDestination to CWallet::GetNewDestination. Another opportunistic TopUp is moved from LegacyScriptPubKeyMan::ReserveKeyFromKeyPool (called by LegacyScriptPubKeyMan::GetReservedDestination) to ReserveDestination::GetReservedDestination. Moving opportunistic TopUps ensures that ScriptPubKeyMans will always be topped up before requesting Destinations from them as we cannot always rely on future ScriptPubKeyMan implementaions topping up internally. As such, it is also unnecessary to keep the TopUp calls in the LegacyScriptPubKeyMan functions so they are moved. This does not change behavior as TopUp calls are moved up the call stack.
* | Replace LegacyScriptPubKeyMan::IsCrypted with ↵Andrew Chow2019-12-061-7/+6
| | | | | | | | LegacyScriptPubKeyMan::HasEncryptionKeys
* | Remove SetCrypted() and fUseCrypto; Change IsCrypted()'s implementationAndrew Chow2019-12-061-10/+4
| | | | | | | | | | | | | | Removes SetCrypted() and fUseCrypto as we don't need them anymore. SetCrypted calls in LegacyScriptPubKeyMan are replaced with mapKeys.empty() IsCrypted() is changed to just call HasEncryptionKeys()
* | Rename EncryptKeys to Encrypt and pass in the encrypted batch to useAndrew Chow2019-12-061-4/+13
| |
* | Clear mapKeys before encryptingAndrew Chow2019-12-061-2/+3
| | | | | | | | | | Does not change behavior. Needed to make AddCryptedKeyInner() work with SetCrypted() being gone.
* | Move fDecryptionThoroughlyChecked from CWallet to LegacyScriptPubKeyManAndrew Chow2019-12-061-2/+1
| |
* | Move Unlock implementation to LegacyScriptPubKeyManAndrew Chow2019-12-061-4/+2
| | | | | | | | | | CWallet::Unlock is changed to call ScriptPubKeyMan::CheckDecryptionKey and the original implementation of Unlock is renamed to CheckDecryptionKey.
* | Replace LegacyScriptPubKeyMan::vMasterKey with GetDecryptionKey()Andrew Chow2019-12-061-3/+2
| |
* | Key pool: Fix omitted pre-split count in GetKeyPoolSizeAndrew Chow2019-12-021-1/+1
| | | | | | | | This is a bugfix: https://github.com/bitcoin/bitcoin/pull/16341#discussion_r330669214
* | Key pool: Change ReturnDestination interface to take address instead of keyAndrew Chow2019-12-021-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | In order for ScriptPubKeyMan to be generic and work with future ScriptPubKeyMans, ScriptPubKeyMan::ReturnDestination is changed to take a CTxDestination instead of a CPubKey. Since LegacyScriptPubKeyMan still deals with keys internally, a new map m_reserved_key_to_index is added in order to track the keypool indexes that have been reserved. The CPubKey argument of KeepDestination is also removed so that it is more generic. Instead of taking a CPubKey or a CTxDestination, we just use the nIndex given to find the pubkey.
* | Key pool: Move LearnRelated and GetDestination callsAndrew Chow2019-12-021-1/+3
| | | | | | | | | | | | | | | | Addresses are determined by LegacyScriptPubKeyMan::GetReservedDestination instead of ReserveDestination::GetReservedDestination as other ScriptPubKeyMan implementations may construct addresses differently This does not change behavior.
* | Add OutputType and CPubKey parameters to KeepDestinationAndrew Chow2019-11-261-4/+4
| | | | | | | | | | These need to be added so that LearnRelatedScripts can be called from within KeepDestination later.
* | Rename Keep/ReturnKey to Keep/ReturnDestination and remove the wrapperAndrew Chow2019-11-261-13/+3
| | | | | | | | | | There is no reason to have Keep/ReturnDestination to be a wrapper for Keep/ReturnKey. Instead just make them the same function.
* | Key pool: Move CanGetAddresses callAndrew Chow2019-11-221-0/+4
|/ | | | | | | | | | | 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
* Clean up nested scope in GetReservedDestinationRussell Yanofsky2019-11-051-4/+2
| | | | | | | | Suggested https://github.com/bitcoin/bitcoin/pull/17304#discussion_r341194391 by Gregory Sanders <[email protected]> Reason for keeping the `return true` `return false` verbosity is that more code will be added after the ReserveKeyFromKeyPool() call before returning.
* Get rid of confusing LegacyScriptPubKeyMan::TopUpKeyPool methodRussell Yanofsky2019-11-051-11/+6
| | | | Previous discussion https://github.com/bitcoin/bitcoin/pull/17304#discussion_r340307903
* Pass CTxDestination to ScriptPubKeyMan::GetMetadataRussell Yanofsky2019-11-051-8/+14
| | | | | | | | | | | | 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 <[email protected]> in https://github.com/bitcoin/bitcoin/pull/17304#discussion_r340345745 and https://github.com/bitcoin/bitcoin/pull/17381#issuecomment-549994944
* Refactor: Move nTimeFirstKey accesses out of CWalletAndrew Chow2019-11-011-0/+6
| | | | This commit does not change behavior.
* Refactor: Move GetKeypoolSize code out of CWalletAndrew Chow2019-11-011-0/+6
| | | | This commit does not change behavior.
* Refactor: Move RewriteDB code out of CWalletAndrew Chow2019-11-011-0/+11
| | | | This commit does not change behavior.
* Refactor: Move SetupGeneration code out of CWalletAndrew Chow2019-11-011-0/+13
| | | | This commit does not change behavior.
* Refactor: Move HavePrivateKeys code out of CWallet::CreateWalletFromFileAndrew Chow2019-11-011-0/+6
| | | | This commit does not change behavior.
* Refactor: Move Upgrade code out of CWallet::CreateWalletFromFileAndrew Chow2019-11-011-0/+35
| | | | This commit does not change behavior.
* Refactor: Move MarkUnusedAddresses code out of CWallet::AddToWalletIfInvolvingMeAndrew Chow2019-11-011-0/+17
| | | | This commit does not change behavior.
* Refactor: Move GetMetadata code out of getaddressinfoAndrew Chow2019-11-011-0/+15
| | | | | | | | Easier to review ignoring whitespace: git log -p -n1 -w This commit does not change behavior.
* Refactor: Move LoadKey LegacyScriptPubKeyMan method definitionAndrew Chow2019-11-011-0/+5
| | | | This commit does not change behavior.
* Refactor: Move SetAddressBookWithDB call out of ↵Andrew Chow2019-11-011-6/+1
| | | | | | LegacyScriptPubKeyMan::ImportScriptPubKeys This commit does not change behavior.
* refactor: Replace UnsetWalletFlagWithDB with UnsetBlankWalletFlag in ↵Andrew Chow2019-11-011-4/+4
| | | | | | | | | | ScriptPubKeyMan ScriptPubKeyMan is only using UnsetWalletFlagWithDB to unset the blank wallet flag. Just make that it's own function and not expose the flag writing directly. This does not change behavior.